* [dpdk-dev] [PATCH 1/2] net/ixgbe: allocate TC bandwidth
2017-04-01 1:18 [dpdk-dev] [PATCH 0/2] enable TC bandwidth allocation on ixgbe Wenzhuo Lu
@ 2017-04-01 1:18 ` Wenzhuo Lu
2017-04-01 1:18 ` [dpdk-dev] [PATCH 2/2] app/testpmd: add CLI to set TC min bandwidth Wenzhuo Lu
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Wenzhuo Lu @ 2017-04-01 1:18 UTC (permalink / raw)
To: dev; +Cc: Bernard Iremonger, Wenzhuo Lu
From: Bernard Iremonger <bernard.iremonger@intel.com>
Ixgbe supports to set the relative bandwidth for the TCs.
It's a global setting for the PF and all the VFs of a
physical port.
This feature provide the API to set the bandwidth.
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
drivers/net/ixgbe/ixgbe_ethdev.c | 78 +++++++++++++++++++++++++++++
drivers/net/ixgbe/ixgbe_ethdev.h | 9 ++++
drivers/net/ixgbe/ixgbe_rxtx.c | 12 +++--
drivers/net/ixgbe/rte_pmd_ixgbe.h | 23 +++++++++
drivers/net/ixgbe/rte_pmd_ixgbe_version.map | 6 +++
5 files changed, 124 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 7169007..9c6ee5d 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1137,6 +1137,8 @@ struct rte_ixgbe_xstats_name_off {
IXGBE_DEV_PRIVATE_TO_DCB_CFG(eth_dev->data->dev_private);
struct ixgbe_filter_info *filter_info =
IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
+ struct ixgbe_bw_conf *bw_conf =
+ IXGBE_DEV_PRIVATE_TO_BW_CONF(eth_dev->data->dev_private);
uint32_t ctrl_ext;
uint16_t csum;
int diag, i;
@@ -1348,6 +1350,9 @@ struct rte_ixgbe_xstats_name_off {
TAILQ_INIT(&filter_l2_tunnel_list);
TAILQ_INIT(&ixgbe_flow_list);
+ /* initialize bandwidth configuration info */
+ memset(bw_conf, 0, sizeof(struct ixgbe_bw_conf));
+
return 0;
}
@@ -8682,6 +8687,79 @@ int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)
return 0;
}
+int
+rte_pmd_ixgbe_set_tc_bw_alloc(uint8_t port,
+ uint8_t tc_num,
+ uint8_t *bw_weight)
+{
+ struct rte_eth_dev *dev;
+ struct ixgbe_dcb_config *dcb_config;
+ struct ixgbe_dcb_tc_config *tc;
+ struct rte_eth_conf *eth_conf;
+ struct ixgbe_bw_conf *bw_conf;
+ uint8_t i;
+ uint8_t nb_tcs;
+ uint16_t sum;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+ dev = &rte_eth_devices[port];
+
+ if (!is_device_supported(dev, &rte_ixgbe_pmd))
+ return -ENOTSUP;
+
+ if (tc_num > IXGBE_DCB_MAX_TRAFFIC_CLASS) {
+ PMD_DRV_LOG(ERR, "TCs should be no more than %d.",
+ IXGBE_DCB_MAX_TRAFFIC_CLASS);
+ return -EINVAL;
+ }
+
+ dcb_config = IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
+ bw_conf = IXGBE_DEV_PRIVATE_TO_BW_CONF(dev->data->dev_private);
+ eth_conf = &dev->data->dev_conf;
+
+ if (eth_conf->txmode.mq_mode == ETH_MQ_TX_DCB) {
+ nb_tcs = eth_conf->tx_adv_conf.dcb_tx_conf.nb_tcs;
+ } else if (eth_conf->txmode.mq_mode == ETH_MQ_TX_VMDQ_DCB) {
+ if (eth_conf->tx_adv_conf.vmdq_dcb_tx_conf.nb_queue_pools ==
+ ETH_32_POOLS)
+ nb_tcs = ETH_4_TCS;
+ else
+ nb_tcs = ETH_8_TCS;
+ } else {
+ nb_tcs = 1;
+ }
+
+ if (nb_tcs != tc_num) {
+ PMD_DRV_LOG(ERR,
+ "Weight should be set for all %d enabled TCs.",
+ nb_tcs);
+ return -EINVAL;
+ }
+
+ sum = 0;
+ for (i = 0; i < nb_tcs; i++)
+ sum += bw_weight[i];
+ if (sum != 100) {
+ PMD_DRV_LOG(ERR,
+ "The summary of the TC weight should be 100.");
+ return -EINVAL;
+ }
+
+ for (i = 0; i < nb_tcs; i++) {
+ tc = &dcb_config->tc_config[i];
+ tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent = bw_weight[i];
+ }
+ for (; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
+ tc = &dcb_config->tc_config[i];
+ tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent = 0;
+ }
+
+ bw_conf->tc_num = nb_tcs;
+
+ return 0;
+}
+
RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd.pci_drv);
RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe, pci_id_ixgbe_map);
RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe, "* igb_uio | uio_pci_generic | vfio");
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 680d5d9..5133649 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -416,6 +416,11 @@ struct ixgbe_macsec_stats {
uint64_t in_pkts_notusingsa;
};
+/* The configuration of bandwidth */
+struct ixgbe_bw_conf {
+ uint8_t tc_num; /* Number of TCs. */
+};
+
/*
* Structure to store private data for each driver instance (for each port).
*/
@@ -437,6 +442,7 @@ struct ixgbe_adapter {
#endif /* RTE_NIC_BYPASS */
struct ixgbe_filter_info filter;
struct ixgbe_l2_tn_info l2_tn;
+ struct ixgbe_bw_conf bw_conf;
bool rx_bulk_alloc_allowed;
bool rx_vec_allowed;
@@ -490,6 +496,9 @@ struct ixgbe_adapter {
#define IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(adapter) \
(&((struct ixgbe_adapter *)adapter)->l2_tn)
+#define IXGBE_DEV_PRIVATE_TO_BW_CONF(adapter) \
+ (&((struct ixgbe_adapter *)adapter)->bw_conf)
+
/*
* RX/TX function prototypes
*/
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 9294a0d..bb9b6d0 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -3677,6 +3677,8 @@ void __attribute__((cold))
uint32_t max_frame = dev->data->mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
struct ixgbe_hw *hw =
IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct ixgbe_bw_conf *bw_conf =
+ IXGBE_DEV_PRIVATE_TO_BW_CONF(dev->data->dev_private);
switch (dev->data->dev_conf.rxmode.mq_mode) {
case ETH_MQ_RX_VMDQ_DCB:
@@ -3748,8 +3750,9 @@ void __attribute__((cold))
/* Re-configure 4 TCs BW */
for (i = 0; i < nb_tcs; i++) {
tc = &dcb_config->tc_config[i];
- tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent =
- (uint8_t)(100 / nb_tcs);
+ if (bw_conf->tc_num != nb_tcs)
+ tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent =
+ (uint8_t)(100 / nb_tcs);
tc->path[IXGBE_DCB_RX_CONFIG].bwg_percent =
(uint8_t)(100 / nb_tcs);
}
@@ -3762,8 +3765,9 @@ void __attribute__((cold))
/* Re-configure 8 TCs BW */
for (i = 0; i < nb_tcs; i++) {
tc = &dcb_config->tc_config[i];
- tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent =
- (uint8_t)(100 / nb_tcs + (i & 1));
+ if (bw_conf->tc_num != nb_tcs)
+ tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent =
+ (uint8_t)(100 / nb_tcs + (i & 1));
tc->path[IXGBE_DCB_RX_CONFIG].bwg_percent =
(uint8_t)(100 / nb_tcs + (i & 1));
}
diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe.h b/drivers/net/ixgbe/rte_pmd_ixgbe.h
index 4d7b507..626c6db 100644
--- a/drivers/net/ixgbe/rte_pmd_ixgbe.h
+++ b/drivers/net/ixgbe/rte_pmd_ixgbe.h
@@ -391,6 +391,29 @@ int rte_pmd_ixgbe_macsec_select_rxsa(uint8_t port, uint8_t idx, uint8_t an,
int rte_pmd_ixgbe_set_vf_rate_limit(uint8_t port, uint16_t vf, uint16_t tx_rate, uint64_t q_msk);
/**
+ * Set all the TCs' bandwidth weight.
+ *
+ * The bw_weight means the percentage occupied by the TC.
+ * It can be taken as the relative min bandwidth setting.
+ *
+ * @param port
+ * The port identifier of the Ethernet device.
+ * @param tc_num
+ * Number of TCs.
+ * @param bw_weight
+ * An array of relative bandwidth weight for all the TCs.
+ * The summary of the bw_weight should be 100.
+ * @return
+ * - (0) if successful.
+ * - (-ENODEV) if *port* invalid.
+ * - (-EINVAL) if bad parameter.
+ * - (-ENOTSUP) not supported by firmware.
+ */
+int rte_pmd_ixgbe_set_tc_bw_alloc(uint8_t port,
+ uint8_t tc_num,
+ uint8_t *bw_weight);
+
+/**
* Response sent back to ixgbe driver from user app after callback
*/
enum rte_pmd_ixgbe_mb_event_rsp {
diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe_version.map b/drivers/net/ixgbe/rte_pmd_ixgbe_version.map
index a992dfd..168837b 100644
--- a/drivers/net/ixgbe/rte_pmd_ixgbe_version.map
+++ b/drivers/net/ixgbe/rte_pmd_ixgbe_version.map
@@ -31,3 +31,9 @@ DPDK_17.02 {
rte_pmd_ixgbe_set_vf_tx;
rte_pmd_ixgbe_set_vf_vlan_filter;
} DPDK_16.11;
+
+DPDK_17.05 {
+ global:
+
+ rte_pmd_ixgbe_set_tc_bw_alloc;
+} DPDK_17.02;
--
1.9.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH 2/2] app/testpmd: add CLI to set TC min bandwidth
2017-04-01 1:18 [dpdk-dev] [PATCH 0/2] enable TC bandwidth allocation on ixgbe Wenzhuo Lu
2017-04-01 1:18 ` [dpdk-dev] [PATCH 1/2] net/ixgbe: allocate TC bandwidth Wenzhuo Lu
@ 2017-04-01 1:18 ` Wenzhuo Lu
2017-04-03 13:27 ` [dpdk-dev] [PATCH 0/2] enable TC bandwidth allocation on ixgbe Ferruh Yigit
2017-04-04 12:19 ` Ferruh Yigit
3 siblings, 0 replies; 6+ messages in thread
From: Wenzhuo Lu @ 2017-04-01 1:18 UTC (permalink / raw)
To: dev; +Cc: Bernard Iremonger, Wenzhuo Lu
From: Bernard Iremonger <bernard.iremonger@intel.com>
Add a CLI in testpmd to test the TC min bandwidth
setting.
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
app/test-pmd/cmdline.c | 66 +++++++++++++++++++++++++++++
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +++
2 files changed, 73 insertions(+)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index a2d4c00..db9b445 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -327,6 +327,9 @@ static void cmd_help_long_parsed(void *parsed_result,
"set tx strict-link-priority (port_id) (tc_bitmap)\n"
" Set some TCs' strict link priority mode on a physical port.\n\n"
+ "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
+ " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
+
"vlan set filter (on|off) (port_id)\n"
" Set the VLAN filter on a port.\n\n"
@@ -12630,6 +12633,68 @@ struct cmd_vf_tc_bw_result {
},
};
+static void
+cmd_tc_min_bw_parsed(
+ void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+ struct cmd_vf_tc_bw_result *res = parsed_result;
+ struct rte_port *port;
+ uint8_t tc_num;
+ uint8_t bw[16];
+ int ret = -ENOTSUP;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ port = &ports[res->port_id];
+ /** Check if the port is not started **/
+ if (port->port_status != RTE_PORT_STOPPED) {
+ printf("Please stop port %d first\n", res->port_id);
+ return;
+ }
+
+ ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
+ if (ret)
+ return;
+
+#ifdef RTE_LIBRTE_IXGBE_PMD
+ ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
+#endif
+
+ switch (ret) {
+ case 0:
+ break;
+ case -EINVAL:
+ printf("invalid bandwidth\n");
+ break;
+ case -ENODEV:
+ printf("invalid port_id %d\n", res->port_id);
+ break;
+ case -ENOTSUP:
+ printf("function not implemented\n");
+ break;
+ default:
+ printf("programming error: (%s)\n", strerror(-ret));
+ }
+}
+
+cmdline_parse_inst_t cmd_tc_min_bw = {
+ .f = cmd_tc_min_bw_parsed,
+ .data = NULL,
+ .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
+ .tokens = {
+ (void *)&cmd_vf_tc_bw_set,
+ (void *)&cmd_vf_tc_bw_tc,
+ (void *)&cmd_vf_tc_bw_tx,
+ (void *)&cmd_vf_tc_bw_min_bw,
+ (void *)&cmd_vf_tc_bw_port_id,
+ (void *)&cmd_vf_tc_bw_bw_list,
+ NULL,
+ },
+};
+
/* TC max bandwidth setting */
static void
cmd_vf_tc_max_bw_parsed(
@@ -12913,6 +12978,7 @@ struct cmd_vf_tc_bw_result {
(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
(cmdline_parse_inst_t *)&cmd_strict_link_prio,
+ (cmdline_parse_inst_t *)&cmd_tc_min_bw,
NULL,
};
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index de4e8a5..b710f9a 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -914,6 +914,13 @@ Set some TCs' strict link priority mode on a physical port::
testpmd> set tx strict-link-priority (port_id) (tc_bitmap)
+set tc tx min bandwidth
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Set all TCs' TX min relative bandwidth (%) globally for all PF and VFs::
+
+ testpmd> set tc tx min-bandwidth (port_id) (bw1, bw2, ...)
+
set flow_ctrl rx
~~~~~~~~~~~~~~~~
--
1.9.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH 0/2] enable TC bandwidth allocation on ixgbe
2017-04-01 1:18 [dpdk-dev] [PATCH 0/2] enable TC bandwidth allocation on ixgbe Wenzhuo Lu
2017-04-01 1:18 ` [dpdk-dev] [PATCH 1/2] net/ixgbe: allocate TC bandwidth Wenzhuo Lu
2017-04-01 1:18 ` [dpdk-dev] [PATCH 2/2] app/testpmd: add CLI to set TC min bandwidth Wenzhuo Lu
@ 2017-04-03 13:27 ` Ferruh Yigit
2017-04-04 10:32 ` Ferruh Yigit
2017-04-04 12:19 ` Ferruh Yigit
3 siblings, 1 reply; 6+ messages in thread
From: Ferruh Yigit @ 2017-04-03 13:27 UTC (permalink / raw)
To: Wenzhuo Lu, dev
On 4/1/2017 2:18 AM, Wenzhuo Lu wrote:
> Ixgbe supports to set TCs' bandwidth allocation.
> This patch set enables this feature.
>
> Bernard Iremonger (2):
> net/ixgbe: allocate TC bandwidth
> app/testpmd: add CLI to set TC min bandwidth
Hi Wenzhuo,
Can you please rebase the patch on top of latest next-net?
Thanks,
ferruh
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH 0/2] enable TC bandwidth allocation on ixgbe
2017-04-01 1:18 [dpdk-dev] [PATCH 0/2] enable TC bandwidth allocation on ixgbe Wenzhuo Lu
` (2 preceding siblings ...)
2017-04-03 13:27 ` [dpdk-dev] [PATCH 0/2] enable TC bandwidth allocation on ixgbe Ferruh Yigit
@ 2017-04-04 12:19 ` Ferruh Yigit
3 siblings, 0 replies; 6+ messages in thread
From: Ferruh Yigit @ 2017-04-04 12:19 UTC (permalink / raw)
To: Wenzhuo Lu, dev
On 4/1/2017 2:18 AM, Wenzhuo Lu wrote:
> Ixgbe supports to set TCs' bandwidth allocation.
> This patch set enables this feature.
>
> Bernard Iremonger (2):
> net/ixgbe: allocate TC bandwidth
> app/testpmd: add CLI to set TC min bandwidth
Applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread