DPDK patches and discussions
 help / color / mirror / Atom feed
From: Wenzhuo Lu <wenzhuo.lu@intel.com>
To: dev@dpdk.org
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Subject: [dpdk-dev] [PATCH 2/8] net/i40e: allocate VF TC bandwidth from PF
Date: Fri, 24 Feb 2017 11:24:29 +0800	[thread overview]
Message-ID: <1487906675-54260-3-git-send-email-wenzhuo.lu@intel.com> (raw)
In-Reply-To: <1487906675-54260-1-git-send-email-wenzhuo.lu@intel.com>

Allocate all TCs' relative bandwidth (percentage) on
a specific VF.
It can be taken as relative min bandwidth setting.
User can call the API to set VF TC's min bandwidth
from PF.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
 doc/guides/rel_notes/release_17_05.rst    |   5 ++
 drivers/net/i40e/i40e_ethdev.c            | 118 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           |  26 +++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |   1 +
 4 files changed, 150 insertions(+)

diff --git a/doc/guides/rel_notes/release_17_05.rst b/doc/guides/rel_notes/release_17_05.rst
index f41a839..a726138 100644
--- a/doc/guides/rel_notes/release_17_05.rst
+++ b/doc/guides/rel_notes/release_17_05.rst
@@ -45,6 +45,11 @@ New Features
 
   i40e HW supports to set the max bandwidth for a VF. Enable this capability.
 
+* **Added VF TC min bandwidth setting on i40e.**
+
+  i40e HW supports to set the allocated bandwidth for a TC on a VF. Enable this
+  capability.
+
 Resolved Issues
 ---------------
 
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index cb8f1a4..5a46737 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -247,6 +247,10 @@
 #define I40E_QOS_BW_MAX 40000
 /* The bandwidth should be the multiple of 50Mbps. */
 #define I40E_QOS_BW_GRANULARITY 50
+/* The min bandwidth weight is 1. */
+#define I40E_QOS_BW_WEIGHT_MIN 1
+/* The max bandwidth weight is 127. */
+#define I40E_QOS_BW_WEIGHT_MAX 127
 
 static int eth_i40e_dev_init(struct rte_eth_dev *eth_dev);
 static int eth_i40e_dev_uninit(struct rte_eth_dev *eth_dev);
@@ -11313,3 +11317,117 @@ int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
 
 	return 0;
 }
+
+int
+rte_pmd_i40e_set_vf_tc_bw_alloc(uint8_t port, uint16_t vf_id,
+				uint8_t tc_num, uint8_t *bw_weight)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_pf *pf;
+	struct i40e_vsi *vsi;
+	struct i40e_hw *hw;
+	struct i40e_aqc_configure_vsi_tc_bw_data tc_bw;
+	int ret = 0;
+	int i, j;
+	uint16_t sum;
+	bool b_change = false;
+
+	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);
+
+	if (vf_id >= pf->vf_num || !pf->vfs) {
+		PMD_DRV_LOG(ERR, "Invalid VF ID.");
+		return -EINVAL;
+	}
+
+	vsi = pf->vfs[vf_id].vsi;
+	if (!vsi) {
+		PMD_DRV_LOG(ERR, "Invalid VSI.");
+		return -EINVAL;
+	}
+
+	if (tc_num > I40E_MAX_TRAFFIC_CLASS) {
+		PMD_DRV_LOG(ERR, "TCs should be no more than %d.",
+			    I40E_MAX_TRAFFIC_CLASS);
+		return -EINVAL;
+	}
+
+	sum = 0;
+	for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
+		if (vsi->enabled_tc & BIT_ULL(i))
+			sum++;
+	}
+	if (sum != tc_num) {
+		PMD_DRV_LOG(ERR,
+			    "Weight should be set for all %d enabled TCs.",
+			    sum);
+		return -EINVAL;
+	}
+
+	sum = 0;
+	for (i = 0; i < tc_num; i++) {
+		if (!bw_weight[i]) {
+			PMD_DRV_LOG(ERR,
+				    "The weight should be 1 at least.");
+			return -EINVAL;
+		}
+		sum += bw_weight[i];
+	}
+	if (sum != 100) {
+		PMD_DRV_LOG(ERR,
+			    "The summary of the TC weight should be 100.");
+		return -EINVAL;
+	}
+
+	/**
+	 * Create the configuration for all the TCs.
+	 */
+	memset(&tc_bw, 0, sizeof(tc_bw));
+	tc_bw.tc_valid_bits = vsi->enabled_tc;
+	j = 0;
+	for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
+		if (vsi->enabled_tc & BIT_ULL(i)) {
+			if (bw_weight[j] !=
+				vsi->bw_info.bw_ets_share_credits[i])
+				b_change = true;
+
+			tc_bw.tc_bw_credits[i] = bw_weight[j];
+			j++;
+		}
+	}
+
+	/* No change. */
+	if (!b_change) {
+		PMD_DRV_LOG(INFO,
+			    "No change for TC allocated bandwidth."
+			    " Nothing to do.");
+		return 0;
+	}
+
+	hw = I40E_VSI_TO_HW(vsi);
+
+	ret = i40e_aq_config_vsi_tc_bw(hw, vsi->seid, &tc_bw, NULL);
+	if (ret) {
+		PMD_DRV_LOG(ERR,
+			    "Failed to set VF %d TC bandwidth weight, err(%d).",
+			    vf_id, ret);
+		return -EINVAL;
+	}
+
+	/* Store the configuration. */
+	j = 0;
+	for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
+		if (vsi->enabled_tc & BIT_ULL(i)) {
+			vsi->bw_info.bw_ets_share_credits[i] = bw_weight[j];
+			j++;
+		}
+	}
+
+	return 0;
+}
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 224ec4f..9fdb447 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -355,4 +355,30 @@ int rte_pmd_i40e_set_vf_max_bw(uint8_t port,
 			       uint16_t vf_id,
 			       uint32_t bw);
 
+/**
+ * Set all the TCs' bandwidth weight on a specific VF.
+ *
+ * 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 vf_id
+ *    ID specifying VF.
+ * @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_i40e_set_vf_tc_bw_alloc(uint8_t port,
+				    uint16_t vf_id,
+				    uint8_t tc_num,
+				    uint8_t *bw_weight);
+
 #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 1d9dcf8..85bc41d 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -27,5 +27,6 @@ DPDK_17.05 {
 	global:
 
 	rte_pmd_i40e_set_vf_max_bw;
+	rte_pmd_i40e_set_vf_tc_bw_alloc;
 
 } DPDK_17.02;
-- 
1.9.3

  parent reply	other threads:[~2017-02-24  3:24 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-24  3:24 [dpdk-dev] [PATCH 0/8] QoS features on i40e Wenzhuo Lu
2017-02-24  3:24 ` [dpdk-dev] [PATCH 1/8] net/i40e: set VF max bandwidth from PF Wenzhuo Lu
2017-03-24  5:01   ` Wu, Jingjing
2017-02-24  3:24 ` Wenzhuo Lu [this message]
2017-03-24  5:10   ` [dpdk-dev] [PATCH 2/8] net/i40e: allocate VF TC " Wu, Jingjing
2017-02-24  3:24 ` [dpdk-dev] [PATCH 3/8] net/i40e: set VF TC max " Wenzhuo Lu
2017-03-24  5:15   ` Wu, Jingjing
2017-02-24  3:24 ` [dpdk-dev] [PATCH 4/8] net/i40e: set TC strict priority mode Wenzhuo Lu
2017-03-24  5:19   ` Wu, Jingjing
2017-03-24  7:07     ` Lu, Wenzhuo
2017-03-24  9:34       ` Wu, Jingjing
2017-02-24  3:24 ` [dpdk-dev] [PATCH 5/8] app/testpmd: set VF TX max bandwidth Wenzhuo Lu
2017-03-24  5:21   ` Wu, Jingjing
2017-02-24  3:24 ` [dpdk-dev] [PATCH 6/8] app/testpmd: set VF TC TX min bandwidth Wenzhuo Lu
2017-03-24  5:22   ` Wu, Jingjing
2017-02-24  3:24 ` [dpdk-dev] [PATCH 7/8] app/testpmd: set VF TC TX max bandwidth Wenzhuo Lu
2017-03-24  5:22   ` Wu, Jingjing
2017-02-24  3:24 ` [dpdk-dev] [PATCH 8/8] app/testpmd: set TC strict link priority mode Wenzhuo Lu
2017-03-24  5:23   ` Wu, Jingjing
2017-02-24  6:55 ` [dpdk-dev] [PATCH 0/8] QoS features on i40e Stephen Hemminger
2017-02-24  7:23   ` Lu, Wenzhuo
2017-02-24  9:14     ` [dpdk-dev] [PATCH 0/8] QoS features on i40e - Linux kernel divergence Vincent JARDIN
2017-02-28  5:04       ` Lu, Wenzhuo
2017-03-27 15:13 ` [dpdk-dev] [PATCH 0/8] QoS features on i40e Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1487906675-54260-3-git-send-email-wenzhuo.lu@intel.com \
    --to=wenzhuo.lu@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).