-.. code-block:: c
-
- const uint16_t vlan_tags[] = {
- 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31
- };
-
- /* pool mac addr template, pool mac addr is like: 52 54 00 12 port# pool# */
- static struct ether_addr pool_addr_template = {
- .addr_bytes = {0x52, 0x54, 0x00, 0x12, 0x00, 0x00}
- };
-
- /* Builds up the correct configuration for vmdq+dcb based on the vlan tags array
- * given above, and the number of traffic classes available for use. */
- static inline int
- get_eth_conf(struct rte_eth_conf *eth_conf)
- {
- struct rte_eth_vmdq_dcb_conf conf;
- struct rte_eth_vmdq_rx_conf vmdq_conf;
- struct rte_eth_dcb_rx_conf dcb_conf;
- struct rte_eth_vmdq_dcb_tx_conf tx_conf;
- uint8_t i;
-
- conf.nb_queue_pools = (enum rte_eth_nb_pools)num_pools;
- vmdq_conf.nb_queue_pools = (enum rte_eth_nb_pools)num_pools;
- tx_conf.nb_queue_pools = (enum rte_eth_nb_pools)num_pools;
- conf.nb_pool_maps = num_pools;
- vmdq_conf.nb_pool_maps = num_pools;
- conf.enable_default_pool = 0;
- vmdq_conf.enable_default_pool = 0;
- conf.default_pool = 0; /* set explicit value, even if not used */
- vmdq_conf.default_pool = 0;
-
- for (i = 0; i < conf.nb_pool_maps; i++) {
- conf.pool_map[i].vlan_id = vlan_tags[i];
- vmdq_conf.pool_map[i].vlan_id = vlan_tags[i];
- conf.pool_map[i].pools = 1UL << i ;
- vmdq_conf.pool_map[i].pools = 1UL << i;
- }
- for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++){
- conf.dcb_tc[i] = i % num_tcs;
- dcb_conf.dcb_tc[i] = i % num_tcs;
- tx_conf.dcb_tc[i] = i % num_tcs;
- }
- dcb_conf.nb_tcs = (enum rte_eth_nb_tcs)num_tcs;
- (void)(rte_memcpy(eth_conf, &vmdq_dcb_conf_default, sizeof(*eth_conf)));
- (void)(rte_memcpy(ð_conf->rx_adv_conf.vmdq_dcb_conf, &conf,
- sizeof(conf)));
- (void)(rte_memcpy(ð_conf->rx_adv_conf.dcb_rx_conf, &dcb_conf,
- sizeof(dcb_conf)));
- (void)(rte_memcpy(ð_conf->rx_adv_conf.vmdq_rx_conf, &vmdq_conf,
- sizeof(vmdq_conf)));
- (void)(rte_memcpy(ð_conf->tx_adv_conf.vmdq_dcb_tx_conf, &tx_conf,
- sizeof(tx_conf)));
- if (rss_enable) {
- eth_conf->rxmode.mq_mode= ETH_MQ_RX_VMDQ_DCB_RSS;
- eth_conf->rx_adv_conf.rss_conf.rss_hf = ETH_RSS_IP |
- ETH_RSS_UDP |
- ETH_RSS_TCP |
- ETH_RSS_SCTP;
- }
- return 0;
- }
-
- ......
-
- /* Set mac for each pool.*/
- for (q = 0; q < num_pools; q++) {
- struct ether_addr mac;
- mac = pool_addr_template;
- mac.addr_bytes[4] = port;
- mac.addr_bytes[5] = q;
- printf("Port %u vmdq pool %u set mac %02x:%02x:%02x:%02x:%02x:%02x\n",
- port, q,
- mac.addr_bytes[0], mac.addr_bytes[1],
- mac.addr_bytes[2], mac.addr_bytes[3],
- mac.addr_bytes[4], mac.addr_bytes[5]);
- retval = rte_eth_dev_mac_addr_add(port, &mac,
- q + vmdq_pool_base);
- if (retval) {
- printf("mac addr add failed at pool %d\n", q);
- return retval;
- }
- }