From: Wenzhuo Lu <wenzhuo.lu@intel.com>
To: dev@dpdk.org
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Subject: [dpdk-dev] [PATCH 1/8] net/i40e: set VF max bandwidth from PF
Date: Fri, 24 Feb 2017 11:24:28 +0800 [thread overview]
Message-ID: <1487906675-54260-2-git-send-email-wenzhuo.lu@intel.com> (raw)
In-Reply-To: <1487906675-54260-1-git-send-email-wenzhuo.lu@intel.com>
Support setting VF max bandwidth from PF.
User can call the API on PF to set a specific VF's
max bandwidth.
Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
doc/guides/rel_notes/release_17_05.rst | 3 +
drivers/net/i40e/i40e_ethdev.c | 94 +++++++++++++++++++++++++++++++
drivers/net/i40e/rte_pmd_i40e.h | 23 ++++++++
drivers/net/i40e/rte_pmd_i40e_version.map | 7 +++
4 files changed, 127 insertions(+)
diff --git a/doc/guides/rel_notes/release_17_05.rst b/doc/guides/rel_notes/release_17_05.rst
index e25ea9f..f41a839 100644
--- a/doc/guides/rel_notes/release_17_05.rst
+++ b/doc/guides/rel_notes/release_17_05.rst
@@ -41,6 +41,9 @@ New Features
Also, make sure to start the actual text at the margin.
=========================================================
+* **Added VF max bandwidth setting on i40e.**
+
+ i40e HW supports to set the max bandwidth for a VF. Enable this capability.
Resolved Issues
---------------
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 508fcc8..cb8f1a4 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -243,6 +243,11 @@
/* Bit mask of Extended Tag enable/disable */
#define PCI_DEV_CTRL_EXT_TAG_MASK (1 << PCI_DEV_CTRL_EXT_TAG_SHIFT)
+/* The max bandwidth of i40e is 40Gbps. */
+#define I40E_QOS_BW_MAX 40000
+/* The bandwidth should be the multiple of 50Mbps. */
+#define I40E_QOS_BW_GRANULARITY 50
+
static int eth_i40e_dev_init(struct rte_eth_dev *eth_dev);
static int eth_i40e_dev_uninit(struct rte_eth_dev *eth_dev);
static int i40e_dev_configure(struct rte_eth_dev *dev);
@@ -11219,3 +11224,92 @@ int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
return 0;
}
+
+int
+rte_pmd_i40e_set_vf_max_bw(uint8_t port, uint16_t vf_id, uint32_t bw)
+{
+ struct rte_eth_dev *dev;
+ struct i40e_pf *pf;
+ struct i40e_vsi *vsi;
+ struct i40e_hw *hw;
+ int ret = 0;
+ int i;
+
+ 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 (bw > I40E_QOS_BW_MAX) {
+ PMD_DRV_LOG(ERR, "Bandwidth should not be larger than %dMbps.",
+ I40E_QOS_BW_MAX);
+ return -EINVAL;
+ }
+
+ if (bw % I40E_QOS_BW_GRANULARITY) {
+ PMD_DRV_LOG(ERR, "Bandwidth should be the multiple of %dMbps.",
+ I40E_QOS_BW_GRANULARITY);
+ return -EINVAL;
+ }
+
+ bw /= I40E_QOS_BW_GRANULARITY;
+
+ hw = I40E_VSI_TO_HW(vsi);
+
+ /* No change. */
+ if (bw == vsi->bw_info.bw_limit) {
+ PMD_DRV_LOG(INFO,
+ "No change for VF max bandwidth. Nothing to do.");
+ return 0;
+ }
+
+ /**
+ * VF bandwidth limitation and TC bandwidth limitation cannot be
+ * enabled in parallel, quit if TC bandwidth limitation is enabled.
+ *
+ * If bw is 0, means disable bandwidth limitation. Then no need to
+ * check TC bandwidth limitation.
+ */
+ if (bw) {
+ for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
+ if ((vsi->enabled_tc & BIT_ULL(i)) &&
+ vsi->bw_info.bw_ets_credits[i])
+ break;
+ }
+ if (i != I40E_MAX_TRAFFIC_CLASS) {
+ PMD_DRV_LOG(ERR,
+ "TC max bandwidth has been set on this VF,"
+ " please disable it first.");
+ return -EINVAL;
+ }
+ }
+
+ ret = i40e_aq_config_vsi_bw_limit(hw, vsi->seid, (uint16_t)bw, 0, NULL);
+ if (ret) {
+ PMD_DRV_LOG(ERR,
+ "Failed to set VF %d bandwidth, err(%d).",
+ vf_id, ret);
+ return -EINVAL;
+ }
+
+ /* Store the configuration. */
+ vsi->bw_info.bw_limit = (uint16_t)bw;
+ vsi->bw_info.bw_max = 0;
+
+ return 0;
+}
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index a0ad88c..224ec4f 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -332,4 +332,27 @@ int rte_pmd_i40e_get_vf_stats(uint8_t port,
int rte_pmd_i40e_reset_vf_stats(uint8_t port,
uint16_t vf_id);
+/**
+ * Set VF's max bandwidth.
+ *
+ * Per VF bandwidth limitation and per TC bandwidth limitation cannot
+ * be enabled in parallel. If per TC bandwidth is enabled, this function
+ * will disable it.
+ *
+ * @param port
+ * The port identifier of the Ethernet device.
+ * @param vf_id
+ * ID specifying VF.
+ * @param bw
+ * Bandwidth for this VF.
+ * @return
+ * - (0) if successful.
+ * - (-ENODEV) if *port* invalid.
+ * - (-EINVAL) if bad parameter.
+ * - (-ENOTSUP) not supported by firmware.
+ */
+int rte_pmd_i40e_set_vf_max_bw(uint8_t port,
+ uint16_t vf_id,
+ uint32_t bw);
+
#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 7a5d211..1d9dcf8 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -22,3 +22,10 @@ DPDK_17.02 {
rte_pmd_i40e_set_vf_vlan_tag;
} DPDK_2.0;
+
+DPDK_17.05 {
+ global:
+
+ rte_pmd_i40e_set_vf_max_bw;
+
+} DPDK_17.02;
--
1.9.3
next prev 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 ` Wenzhuo Lu [this message]
2017-03-24 5:01 ` [dpdk-dev] [PATCH 1/8] net/i40e: set VF max bandwidth from PF Wu, Jingjing
2017-02-24 3:24 ` [dpdk-dev] [PATCH 2/8] net/i40e: allocate VF TC " Wenzhuo Lu
2017-03-24 5:10 ` 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-2-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).