[dpdk-dev,4/8] net/i40e: set TC strict priority mode

Message ID 1487906675-54260-5-git-send-email-wenzhuo.lu@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Wenzhuo Lu Feb. 24, 2017, 3:24 a.m. UTC
  Set some TCs to strict priority mode.
It's a global setting on a physical port.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
 doc/guides/nics/i40e.rst                  |  10 +++
 doc/guides/rel_notes/release_17_05.rst    |   7 ++
 drivers/net/i40e/i40e_ethdev.c            | 119 ++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.h            |   1 +
 drivers/net/i40e/rte_pmd_i40e.h           |  15 ++++
 drivers/net/i40e/rte_pmd_i40e_version.map |   1 +
 6 files changed, 153 insertions(+)
  

Comments

Jingjing Wu March 24, 2017, 5:19 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wenzhuo Lu
> Sent: Friday, February 24, 2017 11:25 AM
> To: dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Subject: [dpdk-dev] [PATCH 4/8] net/i40e: set TC strict priority mode
> 
> Set some TCs to strict priority mode.
> It's a global setting on a physical port.
> 
> Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> ---
>  doc/guides/nics/i40e.rst                  |  10 +++
>  doc/guides/rel_notes/release_17_05.rst    |   7 ++
>  drivers/net/i40e/i40e_ethdev.c            | 119
> ++++++++++++++++++++++++++++++
>  drivers/net/i40e/i40e_ethdev.h            |   1 +
>  drivers/net/i40e/rte_pmd_i40e.h           |  15 ++++
>  drivers/net/i40e/rte_pmd_i40e_version.map |   1 +
>  6 files changed, 153 insertions(+)
> 
> diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst index
> 260287e..361d9d9 100644
> --- a/doc/guides/nics/i40e.rst
> +++ b/doc/guides/nics/i40e.rst
> @@ -478,3 +478,13 @@ enabled. If so, return failure.
>  When enabling per TC max bandwidth, SW will check if per VF max bandwidth
> is enabled. If so, disable per VF max bandwidth and continue with per TC max
> bandwidth setting.
> +
> +TC TX scheduling mode setting
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +There're 2 TX scheduling modes for TCs, round robin and strict priority mode.
> +If a TC is set to strict priority mode, it can consume unlimited bandwidth.
> +It means if APP has set the max bandwidth for that TC, it comes to no
> +effect.
> +It's suggested to set the strict priority mode for a TC that is latency
> +sensitive but no consuming much bandwidth.
> diff --git a/doc/guides/rel_notes/release_17_05.rst
> b/doc/guides/rel_notes/release_17_05.rst
> index d31435c..99811a2 100644
> --- a/doc/guides/rel_notes/release_17_05.rst
> +++ b/doc/guides/rel_notes/release_17_05.rst
> @@ -55,6 +55,13 @@ New Features
>    i40e HW supports to set the max bandwidth for a TC on a VF. Enable this
>    capability.
> 
> +* **Added TC strict priority mode setting on i40e.**
> +
> +  There're 2 TX scheduling modes supported for TCs by i40e HW, round
> + ribon mode  and strict priority mode. By default it's round robin
> + mode. Enable the  capability to change the TX scheduling mode for a
> + TC. It's a global setting  on a physical port.
> +
>  Resolved Issues


> +	if (!veb->strict_prio_tc)
> +		ret = i40e_aq_config_switch_comp_ets(
> +			hw, veb->uplink_seid,
> +			&ets_data, i40e_aqc_opc_enable_switching_comp_ets,
> +			NULL);

How about to check the tc_map when the first time to set strict_prio_tc?
  
Wenzhuo Lu March 24, 2017, 7:07 a.m. UTC | #2
Hi Jingjing,

> -----Original Message-----
> From: Wu, Jingjing
> Sent: Friday, March 24, 2017 1:20 PM
> To: Lu, Wenzhuo; dev@dpdk.org
> Cc: Lu, Wenzhuo
> Subject: RE: [dpdk-dev] [PATCH 4/8] net/i40e: set TC strict priority mode
> 
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wenzhuo Lu
> > Sent: Friday, February 24, 2017 11:25 AM
> > To: dev@dpdk.org
> > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> > Subject: [dpdk-dev] [PATCH 4/8] net/i40e: set TC strict priority mode
> >
> > Set some TCs to strict priority mode.
> > It's a global setting on a physical port.
> >
> > Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> > ---
> >  doc/guides/nics/i40e.rst                  |  10 +++
> >  doc/guides/rel_notes/release_17_05.rst    |   7 ++
> >  drivers/net/i40e/i40e_ethdev.c            | 119
> > ++++++++++++++++++++++++++++++
> >  drivers/net/i40e/i40e_ethdev.h            |   1 +
> >  drivers/net/i40e/rte_pmd_i40e.h           |  15 ++++
> >  drivers/net/i40e/rte_pmd_i40e_version.map |   1 +
> >  6 files changed, 153 insertions(+)
> >
> > diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst index
> > 260287e..361d9d9 100644
> > --- a/doc/guides/nics/i40e.rst
> > +++ b/doc/guides/nics/i40e.rst
> > @@ -478,3 +478,13 @@ enabled. If so, return failure.
> >  When enabling per TC max bandwidth, SW will check if per VF max
> > bandwidth is enabled. If so, disable per VF max bandwidth and continue
> > with per TC max bandwidth setting.
> > +
> > +TC TX scheduling mode setting
> > +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > +
> > +There're 2 TX scheduling modes for TCs, round robin and strict priority
> mode.
> > +If a TC is set to strict priority mode, it can consume unlimited bandwidth.
> > +It means if APP has set the max bandwidth for that TC, it comes to no
> > +effect.
> > +It's suggested to set the strict priority mode for a TC that is
> > +latency sensitive but no consuming much bandwidth.
> > diff --git a/doc/guides/rel_notes/release_17_05.rst
> > b/doc/guides/rel_notes/release_17_05.rst
> > index d31435c..99811a2 100644
> > --- a/doc/guides/rel_notes/release_17_05.rst
> > +++ b/doc/guides/rel_notes/release_17_05.rst
> > @@ -55,6 +55,13 @@ New Features
> >    i40e HW supports to set the max bandwidth for a TC on a VF. Enable this
> >    capability.
> >
> > +* **Added TC strict priority mode setting on i40e.**
> > +
> > +  There're 2 TX scheduling modes supported for TCs by i40e HW, round
> > + ribon mode  and strict priority mode. By default it's round robin
> > + mode. Enable the  capability to change the TX scheduling mode for a
> > + TC. It's a global setting  on a physical port.
> > +
> >  Resolved Issues
> 
> 
> > +	if (!veb->strict_prio_tc)
> > +		ret = i40e_aq_config_switch_comp_ets(
> > +			hw, veb->uplink_seid,
> > +			&ets_data,
> i40e_aqc_opc_enable_switching_comp_ets,
> > +			NULL);
> 
> How about to check the tc_map when the first time to set strict_prio_tc?
Thanks for the comment. I didn't consider that before.
But I checked my patch, in the previous code, I've checked if tc_map is equal to strict_prio_tc. So if it's the first time to set strict_prio_tc, tc_map cannot be 0. Lucky :)
  
Jingjing Wu March 24, 2017, 9:34 a.m. UTC | #3
> -----Original Message-----
> From: Lu, Wenzhuo
> Sent: Friday, March 24, 2017 3:07 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>; dev@dpdk.org
> Subject: RE: [dpdk-dev] [PATCH 4/8] net/i40e: set TC strict priority mode
> 
> Hi Jingjing,
> 
> > -----Original Message-----
> > From: Wu, Jingjing
> > Sent: Friday, March 24, 2017 1:20 PM
> > To: Lu, Wenzhuo; dev@dpdk.org
> > Cc: Lu, Wenzhuo
> > Subject: RE: [dpdk-dev] [PATCH 4/8] net/i40e: set TC strict priority
> > mode
> >
> >
> >
> > > -----Original Message-----
> > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wenzhuo Lu
> > > Sent: Friday, February 24, 2017 11:25 AM
> > > To: dev@dpdk.org
> > > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> > > Subject: [dpdk-dev] [PATCH 4/8] net/i40e: set TC strict priority
> > > mode
> > >
> > > Set some TCs to strict priority mode.
> > > It's a global setting on a physical port.
> > >
> > > Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> > > ---
> > >  doc/guides/nics/i40e.rst                  |  10 +++
> > >  doc/guides/rel_notes/release_17_05.rst    |   7 ++
> > >  drivers/net/i40e/i40e_ethdev.c            | 119
> > > ++++++++++++++++++++++++++++++
> > >  drivers/net/i40e/i40e_ethdev.h            |   1 +
> > >  drivers/net/i40e/rte_pmd_i40e.h           |  15 ++++
> > >  drivers/net/i40e/rte_pmd_i40e_version.map |   1 +
> > >  6 files changed, 153 insertions(+)
> > >
> > > diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
> > > index
> > > 260287e..361d9d9 100644
> > > --- a/doc/guides/nics/i40e.rst
> > > +++ b/doc/guides/nics/i40e.rst
> > > @@ -478,3 +478,13 @@ enabled. If so, return failure.
> > >  When enabling per TC max bandwidth, SW will check if per VF max
> > > bandwidth is enabled. If so, disable per VF max bandwidth and
> > > continue with per TC max bandwidth setting.
> > > +
> > > +TC TX scheduling mode setting
> > > +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > +
> > > +There're 2 TX scheduling modes for TCs, round robin and strict
> > > +priority
> > mode.
> > > +If a TC is set to strict priority mode, it can consume unlimited bandwidth.
> > > +It means if APP has set the max bandwidth for that TC, it comes to
> > > +no effect.
> > > +It's suggested to set the strict priority mode for a TC that is
> > > +latency sensitive but no consuming much bandwidth.
> > > diff --git a/doc/guides/rel_notes/release_17_05.rst
> > > b/doc/guides/rel_notes/release_17_05.rst
> > > index d31435c..99811a2 100644
> > > --- a/doc/guides/rel_notes/release_17_05.rst
> > > +++ b/doc/guides/rel_notes/release_17_05.rst
> > > @@ -55,6 +55,13 @@ New Features
> > >    i40e HW supports to set the max bandwidth for a TC on a VF. Enable this
> > >    capability.
> > >
> > > +* **Added TC strict priority mode setting on i40e.**
> > > +
> > > +  There're 2 TX scheduling modes supported for TCs by i40e HW,
> > > + round ribon mode  and strict priority mode. By default it's round
> > > + robin mode. Enable the  capability to change the TX scheduling
> > > + mode for a TC. It's a global setting  on a physical port.
> > > +
> > >  Resolved Issues
> >
> >
> > > +	if (!veb->strict_prio_tc)
> > > +		ret = i40e_aq_config_switch_comp_ets(
> > > +			hw, veb->uplink_seid,
> > > +			&ets_data,
> > i40e_aqc_opc_enable_switching_comp_ets,
> > > +			NULL);
> >
> > How about to check the tc_map when the first time to set strict_prio_tc?
> Thanks for the comment. I didn't consider that before.
> But I checked my patch, in the previous code, I've checked if tc_map is equal to
> strict_prio_tc. So if it's the first time to set strict_prio_tc, tc_map cannot be 0.
> Lucky :)

OK. Then I'm fine to ACK this patch.

Acked-by Jingjing Wu <jingjing.wu@intel.com>
  

Patch

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 260287e..361d9d9 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -478,3 +478,13 @@  enabled. If so, return failure.
 When enabling per TC max bandwidth, SW will check if per VF max bandwidth
 is enabled. If so, disable per VF max bandwidth and continue with per TC max
 bandwidth setting.
+
+TC TX scheduling mode setting
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+There're 2 TX scheduling modes for TCs, round robin and strict priority mode.
+If a TC is set to strict priority mode, it can consume unlimited bandwidth.
+It means if APP has set the max bandwidth for that TC, it comes to no
+effect.
+It's suggested to set the strict priority mode for a TC that is latency
+sensitive but no consuming much bandwidth.
diff --git a/doc/guides/rel_notes/release_17_05.rst b/doc/guides/rel_notes/release_17_05.rst
index d31435c..99811a2 100644
--- a/doc/guides/rel_notes/release_17_05.rst
+++ b/doc/guides/rel_notes/release_17_05.rst
@@ -55,6 +55,13 @@  New Features
   i40e HW supports to set the max bandwidth for a TC on a VF. Enable this
   capability.
 
+* **Added TC strict priority mode setting on i40e.**
+
+  There're 2 TX scheduling modes supported for TCs by i40e HW, round ribon mode
+  and strict priority mode. By default it's round robin mode. Enable the
+  capability to change the TX scheduling mode for a TC. It's a global setting
+  on a physical port.
+
 Resolved Issues
 ---------------
 
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 2df9587..24ad11b 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -11549,3 +11549,122 @@  int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
 
 	return 0;
 }
+
+int
+rte_pmd_i40e_set_tc_strict_prio(uint8_t port, uint8_t tc_map)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_pf *pf;
+	struct i40e_vsi *vsi;
+	struct i40e_veb *veb;
+	struct i40e_hw *hw;
+	struct i40e_aqc_configure_switching_comp_ets_data ets_data;
+	int i;
+	int ret;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_device_supported(dev, &rte_i40e_pmd))
+		return -ENOTSUP;
+
+	pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+
+	vsi = pf->main_vsi;
+	if (!vsi) {
+		PMD_DRV_LOG(ERR, "Invalid VSI.");
+		return -EINVAL;
+	}
+
+	veb = vsi->veb;
+	if (!veb) {
+		PMD_DRV_LOG(ERR, "Invalid VEB.");
+		return -EINVAL;
+	}
+
+	if ((tc_map & veb->enabled_tc) != tc_map) {
+		PMD_DRV_LOG(ERR,
+			    "TC bitmap isn't the subset of enabled TCs 0x%x.",
+			    veb->enabled_tc);
+		return -EINVAL;
+	}
+
+	if (tc_map == veb->strict_prio_tc) {
+		PMD_DRV_LOG(INFO, "No change for TC bitmap. Nothing to do.");
+		return 0;
+	}
+
+	hw = I40E_VSI_TO_HW(vsi);
+
+	/* Disable DCBx if it's the first time to set strict priority. */
+	if (!veb->strict_prio_tc) {
+		ret = i40e_aq_stop_lldp(hw, true, NULL);
+		if (ret)
+			PMD_DRV_LOG(INFO,
+				    "Failed to disable DCBx as it's already"
+				    " disabled.");
+		else
+			PMD_DRV_LOG(INFO,
+				    "DCBx is disabled according to strict"
+				    " priority setting.");
+	}
+
+	memset(&ets_data, 0, sizeof(ets_data));
+	ets_data.tc_valid_bits = veb->enabled_tc;
+	ets_data.seepage = I40E_AQ_ETS_SEEPAGE_EN_MASK;
+	ets_data.tc_strict_priority_flags = tc_map;
+	/* Get all TCs' bandwidth. */
+	for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
+		if (veb->enabled_tc & BIT_ULL(i)) {
+			/* For rubust, if bandwidth is 0, use 1 instead. */
+			if (veb->bw_info.bw_ets_share_credits[i])
+				ets_data.tc_bw_share_credits[i] =
+					veb->bw_info.bw_ets_share_credits[i];
+			else
+				ets_data.tc_bw_share_credits[i] =
+					I40E_QOS_BW_WEIGHT_MIN;
+		}
+	}
+
+	if (!veb->strict_prio_tc)
+		ret = i40e_aq_config_switch_comp_ets(
+			hw, veb->uplink_seid,
+			&ets_data, i40e_aqc_opc_enable_switching_comp_ets,
+			NULL);
+	else if (tc_map)
+		ret = i40e_aq_config_switch_comp_ets(
+			hw, veb->uplink_seid,
+			&ets_data, i40e_aqc_opc_modify_switching_comp_ets,
+			NULL);
+	else
+		ret = i40e_aq_config_switch_comp_ets(
+			hw, veb->uplink_seid,
+			&ets_data, i40e_aqc_opc_disable_switching_comp_ets,
+			NULL);
+
+	if (ret) {
+		PMD_DRV_LOG(ERR,
+			    "Failed to set TCs' strict priority mode."
+			    " err (%d)", ret);
+		return -EINVAL;
+	}
+
+	veb->strict_prio_tc = tc_map;
+
+	/* Enable DCBx again, if all the TCs' strict priority disabled. */
+	if (!tc_map) {
+		ret = i40e_aq_start_lldp(hw, NULL);
+		if (ret) {
+			PMD_DRV_LOG(ERR,
+				    "Failed to enable DCBx, err(%d).", ret);
+			return -EINVAL;
+		}
+
+		PMD_DRV_LOG(INFO,
+			    "DCBx is enabled again according to strict"
+			    " priority setting.");
+	}
+
+	return ret;
+}
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index f545850..3420699 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -305,6 +305,7 @@  struct i40e_veb {
 	uint16_t stats_idx;
 	struct i40e_eth_stats stats;
 	uint8_t enabled_tc;   /* The traffic class enabled */
+	uint8_t strict_prio_tc; /* bit map of TCs set to strict priority mode */
 	struct i40e_bw_info bw_info; /* VEB bandwidth information */
 };
 
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 08ee2b0..3ca49a4 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -403,4 +403,19 @@  int rte_pmd_i40e_set_vf_tc_max_bw(uint8_t port,
 				  uint8_t tc_no,
 				  uint32_t bw);
 
+/**
+ * Set some TCs to strict priority mode on a physical port.
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param tc_map
+ *    A bit map for the TCs.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) not supported by firmware.
+ */
+int rte_pmd_i40e_set_tc_strict_prio(uint8_t port, uint8_t tc_map);
+
 #endif /* _PMD_I40E_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index bd657ab..488e6b6 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -26,6 +26,7 @@  DPDK_17.02 {
 DPDK_17.05 {
 	global:
 
+	rte_pmd_i40e_set_tc_strict_prio;
 	rte_pmd_i40e_set_vf_max_bw;
 	rte_pmd_i40e_set_vf_tc_bw_alloc;
 	rte_pmd_i40e_set_vf_tc_max_bw;