ethdev: add DCB support
authorIntel <intel.com>
Wed, 19 Dec 2012 23:00:00 +0000 (00:00 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Thu, 25 Jul 2013 13:23:28 +0000 (15:23 +0200)
Signed-off-by: Intel
12 files changed:
examples/exception_path/main.c
examples/ipv4_frag/main.c
examples/ipv4_multicast/main.c
examples/l2fwd/main.c
examples/l3fwd-vf/main.c
examples/l3fwd/main.c
examples/link_status_interrupt/main.c
examples/load_balancer/init.c
examples/multi_process/symmetric_mp/main.c
examples/vmdq_dcb/main.c
lib/librte_ether/rte_ethdev.c
lib/librte_ether/rte_ethdev.h

index f1f52d9..646065c 100644 (file)
@@ -148,6 +148,7 @@ static const struct rte_eth_conf port_conf = {
                .hw_strip_crc = 0,      /* CRC stripped by hardware */
        },
        .txmode = {
+               .mq_mode = ETH_DCB_NONE,
        },
 };
 
index 5983986..a790d93 100644 (file)
@@ -167,6 +167,7 @@ static const struct rte_eth_conf port_conf = {
                .hw_strip_crc   = 0, /**< CRC stripped by hardware */
        },
        .txmode = {
+               .mq_mode = ETH_DCB_NONE,
        },
 };
 
index 0ae8c3c..356bb64 100644 (file)
@@ -176,6 +176,7 @@ static const struct rte_eth_conf port_conf = {
                .hw_strip_crc   = 0, /**< CRC stripped by hardware */
        },
        .txmode = {
+               .mq_mode = ETH_DCB_NONE,
        },
 };
 
index 6731a14..5ed37b8 100644 (file)
@@ -151,6 +151,7 @@ static const struct rte_eth_conf port_conf = {
                .hw_strip_crc   = 0, /**< CRC stripped by hardware */
        },
        .txmode = {
+               .mq_mode = ETH_DCB_NONE,
        },
 };
 
index ead3cb8..e3a999a 100644 (file)
@@ -197,6 +197,7 @@ static struct rte_eth_conf port_conf = {
                },
        },
        .txmode = {
+               .mq_mode = ETH_DCB_NONE,
        },
 };
 
index 4d579c1..6ca4ab2 100644 (file)
@@ -198,6 +198,7 @@ static struct rte_eth_conf port_conf = {
                },
        },
        .txmode = {
+               .mq_mode = ETH_DCB_NONE,
        },
 };
 
index 5f0fad6..b6a4622 100644 (file)
@@ -151,6 +151,7 @@ static const struct rte_eth_conf port_conf = {
                .hw_strip_crc   = 0, /**< CRC stripped by hardware */
        },
        .txmode = {
+               .mq_mode = ETH_DCB_NONE,
        },
        .intr_conf = {
                .lsc = 1, /**< lsc interrupt feature enabled */
index f95e5ef..ea4f6f4 100644 (file)
@@ -91,6 +91,7 @@ static struct rte_eth_conf port_conf = {
                },
        },
        .txmode = {
+               .mq_mode = ETH_DCB_NONE,
        },
 };
 
index afbb3a4..bfd253b 100644 (file)
@@ -273,6 +273,7 @@ smp_port_init(uint8_t port, struct rte_mempool *mbuf_pool, uint16_t num_queues)
                                },
                        },
                        .txmode = {
+                               .mq_mode = ETH_DCB_NONE,
                        }
        };
        const uint16_t rx_rings = num_queues, tx_rings = num_queues;
index 5d3efd2..99d51e0 100644 (file)
@@ -130,6 +130,7 @@ static const struct rte_eth_conf vmdq_dcb_conf_default = {
                .jumbo_frame    = 0, /**< Jumbo Frame Support disabled */
        },
        .txmode = {
+               .mq_mode = ETH_DCB_NONE,
        },
        .rx_adv_conf = {
                /*
index ac22f7a..ab0fa59 100644 (file)
@@ -339,6 +339,66 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
                    return (-EINVAL);
                }
        }
+       if (dev_conf->txmode.mq_mode == ETH_VMDQ_DCB_TX) {
+               const struct rte_eth_vmdq_dcb_tx_conf *conf;
+
+               if (nb_tx_q != ETH_VMDQ_DCB_NUM_QUEUES) {
+                       PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB, nb_tx_q "
+                                       "!= %d\n",
+                                       port_id, ETH_VMDQ_DCB_NUM_QUEUES);
+                       return (-EINVAL);
+               }
+               conf = &(dev_conf->tx_adv_conf.vmdq_dcb_tx_conf);
+               if (! (conf->nb_queue_pools == ETH_16_POOLS ||
+                      conf->nb_queue_pools == ETH_32_POOLS)) {
+                       PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB selected, "
+                                   "nb_queue_pools != %d or nb_queue_pools "
+                                   "!= %d\n",
+                                   port_id, ETH_16_POOLS, ETH_32_POOLS);
+                       return (-EINVAL);
+               }
+       }
+       
+       /* For DCB mode check our configuration before we go further */
+       if (dev_conf->rxmode.mq_mode == ETH_DCB_RX) {
+               const struct rte_eth_dcb_rx_conf *conf;
+
+               if (nb_rx_q != ETH_DCB_NUM_QUEUES) {
+                       PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_rx_q "
+                                       "!= %d\n",
+                                       port_id, ETH_DCB_NUM_QUEUES);
+                       return (-EINVAL);
+               }
+               conf = &(dev_conf->rx_adv_conf.dcb_rx_conf);
+               if (! (conf->nb_tcs == ETH_4_TCS ||
+                      conf->nb_tcs == ETH_8_TCS)) {
+                       PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
+                                   "nb_tcs != %d or nb_tcs "
+                                   "!= %d\n",
+                                   port_id, ETH_4_TCS, ETH_8_TCS);
+                       return (-EINVAL);
+               }
+       }
+
+       if (dev_conf->txmode.mq_mode == ETH_DCB_TX) {
+               const struct rte_eth_dcb_tx_conf *conf;
+
+               if (nb_tx_q != ETH_DCB_NUM_QUEUES) {
+                       PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_tx_q "
+                                       "!= %d\n",
+                                       port_id, ETH_DCB_NUM_QUEUES);
+                       return (-EINVAL);
+               }
+               conf = &(dev_conf->tx_adv_conf.dcb_tx_conf);
+               if (! (conf->nb_tcs == ETH_4_TCS ||
+                      conf->nb_tcs == ETH_8_TCS)) {
+                       PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
+                                   "nb_tcs != %d or nb_tcs "
+                                   "!= %d\n",
+                                   port_id, ETH_4_TCS, ETH_8_TCS);
+                       return (-EINVAL);
+               }
+       }
 
        diag = (*dev->dev_ops->dev_configure)(dev, nb_rx_q, nb_tx_q);
        if (diag != 0) {
index afcd240..9e3ac32 100644 (file)
@@ -240,7 +240,18 @@ struct rte_eth_thresh {
  */
 enum rte_eth_rx_mq_mode {
        ETH_RSS     = 0,     /**< Default to RSS mode */
-       ETH_VMDQ_DCB         /**< Use VMDQ+DCB to route traffic to queues */
+       ETH_VMDQ_DCB,        /**< Use VMDQ+DCB to route traffic to queues */
+       ETH_DCB_RX           /**< For RX side,only DCB is on. */
+};
+
+/**
+ * A set of values to identify what method is to be used to transmit 
+ * packets using multi-TCs.
+ */
+enum rte_eth_tx_mq_mode {
+       ETH_DCB_NONE    = 0,    /**< It is not in DCB mode. */
+       ETH_VMDQ_DCB_TX,        /**< For TX side,both DCB and VT is on. */
+       ETH_DCB_TX              /**< For TX side,only DCB is on. */
 };
 
 /**
@@ -290,6 +301,20 @@ struct rte_eth_rss_conf {
 #define ETH_VMDQ_MAX_VLAN_FILTERS   64 /**< Maximum nb. of VMDQ vlan filters. */
 #define ETH_DCB_NUM_USER_PRIORITIES 8  /**< Maximum nb. of DCB priorities. */
 #define ETH_VMDQ_DCB_NUM_QUEUES     128 /**< Maximum nb. of VMDQ DCB queues. */
+#define ETH_DCB_NUM_QUEUES          128 /**< Maximum nb. of DCB queues. */
+
+/* DCB capability defines */
+#define ETH_DCB_PG_SUPPORT      0x00000001 /**< Priority Group(ETS) support. */
+#define ETH_DCB_PFC_SUPPORT     0x00000002 /**< Priority Flow Control support. */ 
+
+/**
+ * This enum indicates the possible number of traffic classes
+ * in DCB configratioins
+ */
+enum rte_eth_nb_tcs {
+       ETH_4_TCS = 4, /**< 4 TCs with DCB. */
+       ETH_8_TCS = 8  /**< 8 TCs with DCB. */
+};
 
 /**
  * This enum indicates the possible number of queue pools
@@ -300,6 +325,25 @@ enum rte_eth_nb_pools {
        ETH_32_POOLS = 32  /**< 32 pools with DCB. */
 };
 
+/* This structure may be extended in future. */
+struct rte_eth_dcb_rx_conf {
+       enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs */
+       uint8_t dcb_queue[ETH_DCB_NUM_USER_PRIORITIES];
+       /**< Possible DCB queue,4 or 8. */
+};
+struct rte_eth_vmdq_dcb_tx_conf {
+       enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools. */
+       uint8_t dcb_queue[ETH_DCB_NUM_USER_PRIORITIES];
+       /**< Possible DCB queue,4 or 8. */
+};
+struct rte_eth_dcb_tx_conf {
+       enum rte_eth_nb_tcs nb_tcs; /**< possible DCB TCs, 4 or 8 TCs. */
+       uint8_t dcb_queue[ETH_DCB_NUM_USER_PRIORITIES];
+       /**< Possible DCB queue,4 or 8. */
+};
+
 /**
  * A structure used to configure the VMDQ+DCB feature
  * of an Ethernet port.
@@ -326,9 +370,9 @@ struct rte_eth_vmdq_dcb_conf {
 
 /**
  * A structure used to configure the TX features of an Ethernet port.
- * For future extensions.
  */
 struct rte_eth_txmode {
+       enum rte_eth_tx_mq_mode mq_mode; /**< TX multi-queues mode. */
 };
 
 /**
@@ -538,7 +582,18 @@ struct rte_eth_conf {
                struct rte_eth_rss_conf rss_conf; /**< Port RSS configuration */
                struct rte_eth_vmdq_dcb_conf vmdq_dcb_conf;
                /**< Port vmdq+dcb configuration. */
+               struct rte_eth_dcb_rx_conf dcb_rx_conf;
+               /**< Port dcb RX configuration. */
        } rx_adv_conf; /**< Port RX filtering configuration (union). */
+       union {
+               struct rte_eth_vmdq_dcb_tx_conf vmdq_dcb_tx_conf;
+               /**< Port vmdq+dcb TX configuration. */
+               struct rte_eth_dcb_tx_conf dcb_tx_conf;
+               /**< Port dcb TX configuration. */
+       } tx_adv_conf; /**< Port TX DCB configuration (union). */
+       /** Currently,Priority Flow Control(PFC) are supported,if DCB with PFC 
+           is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. */ 
+       uint32_t dcb_capability_en; 
        struct rte_fdir_conf fdir_conf; /**< FDIR configuration. */
        struct rte_intr_conf intr_conf; /**< Interrupt mode configuration. */
 };