src/dpdk/drivers/net/hinic/hinic_pmd_ethdev.c
static int hinic_dev_configure(struct rte_eth_dev *dev)
{
	struct hinic_nic_dev *nic_dev;
	struct hinic_nic_io *nic_io;
	int err;

	nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
	nic_io = nic_dev->hwdev->nic_io;

	nic_dev->num_sq =  dev->data->nb_tx_queues;
	nic_dev->num_rq = dev->data->nb_rx_queues;

	nic_io->num_sqs =  dev->data->nb_tx_queues;
	nic_io->num_rqs = dev->data->nb_rx_queues;

	/* queue pair is max_num(sq, rq) */
	nic_dev->num_qps = (nic_dev->num_sq > nic_dev->num_rq) ?
			nic_dev->num_sq : nic_dev->num_rq;
	nic_io->num_qps = nic_dev->num_qps;

	if (nic_dev->num_qps > nic_io->max_qps) {
		PMD_DRV_LOG(ERR,
			"Queue number out of range, get queue_num:%d, max_queue_num:%d",
			nic_dev->num_qps, nic_io->max_qps);
		return -EINVAL;
	}

	if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
		dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;

	/* mtu size is 256~9600 */
	if (dev->data->dev_conf.rxmode.max_rx_pkt_len < HINIC_MIN_FRAME_SIZE ||
	    dev->data->dev_conf.rxmode.max_rx_pkt_len >
	    HINIC_MAX_JUMBO_FRAME_SIZE) {
		PMD_DRV_LOG(ERR,
			"Max rx pkt len out of range, get max_rx_pkt_len:%d, "
			"expect between %d and %d",
			dev->data->dev_conf.rxmode.max_rx_pkt_len,
			HINIC_MIN_FRAME_SIZE, HINIC_MAX_JUMBO_FRAME_SIZE);
		return -EINVAL;
	}

	nic_dev->mtu_size =
		HINIC_PKTLEN_TO_MTU(dev->data->dev_conf.rxmode.max_rx_pkt_len);

	/* rss template */
	err = hinic_config_mq_mode(dev, TRUE);
	if (err) {
		PMD_DRV_LOG(ERR, "Config multi-queue failed");
		return err;
	}

	/* init vlan offoad */
	err = hinic_vlan_offload_set(dev,
				ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK);
	if (err) {
		PMD_DRV_LOG(ERR, "Initialize vlan filter and strip failed");
		(void)hinic_config_mq_mode(dev, FALSE);
		return err;
	}

	/* clear fdir filter flag in function table */
	hinic_free_fdir_filter(nic_dev);

	return HINIC_OK;
}
/**
 * Ethernet device configuration.
 *
 * Prepare the driver for a given number of TX and RX queues, mtu size
 * and configure RSS.
 *
 * @param dev
 *   Pointer to Ethernet device structure.
 *
 * @return
 *   0 on success, negative error value otherwise.
 */
Ethernet device configuration.
Prepare the driver for a given number of TX and RX queues, mtu size
and configure RSS.

@param dev
Pointer to Ethernet device structure.

@return
0 on success, negative error value otherwise.
Ethernet device configuration . Prepare the driver for a given number of TX and RX queues mtu size and configure RSS . @param dev Pointer to Ethernet device structure . @return 0 on success negative error value otherwise .
static int hinic_dev_configure(struct rte_eth_dev *dev)
{
	struct hinic_nic_dev *nic_dev;
	struct hinic_nic_io *nic_io;
	int err;
	nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
	nic_io = nic_dev->hwdev->nic_io;
	nic_dev->num_sq =  dev->data->nb_tx_queues;
	nic_dev->num_rq = dev->data->nb_rx_queues;
	nic_io->num_sqs =  dev->data->nb_tx_queues;
	nic_io->num_rqs = dev->data->nb_rx_queues;
	nic_dev->num_qps = (nic_dev->num_sq > nic_dev->num_rq) ?
			nic_dev->num_sq : nic_dev->num_rq;
	nic_io->num_qps = nic_dev->num_qps;
	if (nic_dev->num_qps > nic_io->max_qps) {
		PMD_DRV_LOG(ERR,
			"Queue number out of range, get queue_num:%d, max_queue_num:%d",
			nic_dev->num_qps, nic_io->max_qps);
		return -EINVAL;
	}
	if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
		dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
	if (dev->data->dev_conf.rxmode.max_rx_pkt_len < HINIC_MIN_FRAME_SIZE ||
	    dev->data->dev_conf.rxmode.max_rx_pkt_len >
	    HINIC_MAX_JUMBO_FRAME_SIZE) {
		PMD_DRV_LOG(ERR,
			"Max rx pkt len out of range, get max_rx_pkt_len:%d, "
			"expect between %d and %d",
			dev->data->dev_conf.rxmode.max_rx_pkt_len,
			HINIC_MIN_FRAME_SIZE, HINIC_MAX_JUMBO_FRAME_SIZE);
		return -EINVAL;
	}
	nic_dev->mtu_size =
		HINIC_PKTLEN_TO_MTU(dev->data->dev_conf.rxmode.max_rx_pkt_len);
	err = hinic_config_mq_mode(dev, TRUE);
	if (err) {
		PMD_DRV_LOG(ERR, "Config multi-queue failed");
		return err;
	}
	err = hinic_vlan_offload_set(dev,
				ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK);
	if (err) {
		PMD_DRV_LOG(ERR, "Initialize vlan filter and strip failed");
		(void)hinic_config_mq_mode(dev, FALSE);
		return err;
	}
	hinic_free_fdir_filter(nic_dev);
	return HINIC_OK;
}
static int hinic_dev_configure ( struct rte_eth_dev * dev ) { struct hinic_nic_dev * nic_dev ; struct hinic_nic_io * nic_io ; int err ; nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV ( dev ) ; nic_io = nic_dev -> hwdev -> nic_io ; nic_dev -> num_sq = dev -> data -> nb_tx_queues ; nic_dev -> num_rq = dev -> data -> nb_rx_queues ; nic_io -> num_sqs = dev -> data -> nb_tx_queues ; nic_io -> num_rqs = dev -> data -> nb_rx_queues ; nic_dev -> num_qps = ( nic_dev -> num_sq > nic_dev -> num_rq ) ? nic_dev -> num_sq : nic_dev -> num_rq ; nic_io -> num_qps = nic_dev -> num_qps ; if ( nic_dev -> num_qps > nic_io -> max_qps ) { PMD_DRV_LOG ( ERR , " " , nic_dev -> num_qps , nic_io -> max_qps ) ; return - EINVAL ; } if ( dev -> data -> dev_conf . rxmode . mq_mode & ETH_MQ_RX_RSS_FLAG ) dev -> data -> dev_conf . rxmode . offloads |= DEV_RX_OFFLOAD_RSS_HASH ; if ( dev -> data -> dev_conf . rxmode . max_rx_pkt_len < HINIC_MIN_FRAME_SIZE || dev -> data -> dev_conf . rxmode . max_rx_pkt_len > HINIC_MAX_JUMBO_FRAME_SIZE ) { PMD_DRV_LOG ( ERR , " " " " , dev -> data -> dev_conf . rxmode . max_rx_pkt_len , HINIC_MIN_FRAME_SIZE , HINIC_MAX_JUMBO_FRAME_SIZE ) ; return - EINVAL ; } nic_dev -> mtu_size = HINIC_PKTLEN_TO_MTU ( dev -> data -> dev_conf . rxmode . max_rx_pkt_len ) ; err = hinic_config_mq_mode ( dev , TRUE ) ; if ( err ) { PMD_DRV_LOG ( ERR , " " ) ; return err ; } err = hinic_vlan_offload_set ( dev , ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK ) ; if ( err ) { PMD_DRV_LOG ( ERR , " " ) ; ( void ) hinic_config_mq_mode ( dev , FALSE ) ; return err ; } hinic_free_fdir_filter ( nic_dev ) ; return HINIC_OK ; }
Ethernet device configuration.
Ethernet device configuration .
/* queue pair is max_num(sq, rq) */ /* mtu size is 256~9600 */ /* rss template */ /* init vlan offoad */ /* clear fdir filter flag in function table */