From patchwork Thu Mar 9 05:44:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lin, Xueqin" X-Patchwork-Id: 21631 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 4D9982C49; Thu, 9 Mar 2017 06:44:13 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id CF3D036E for ; Thu, 9 Mar 2017 06:44:08 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Mar 2017 21:44:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,267,1486454400"; d="scan'208";a="942293042" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga003.jf.intel.com with ESMTP; 08 Mar 2017 21:44:07 -0800 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 8 Mar 2017 21:44:07 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 8 Mar 2017 21:44:07 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.59]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.204]) with mapi id 14.03.0248.002; Thu, 9 Mar 2017 13:44:04 +0800 From: "Lin, Xueqin" To: "dev@dpdk.org" Thread-Topic: dev Digest, Vol 132, Issue 84 Thread-Index: AQHSjk3hwQOfdwQkb0+DPKzR8z463aGMD54g Date: Thu, 9 Mar 2017 05:44:03 +0000 Message-ID: <0D300480287911409D9FF92C1FA2A3355B1B5ECE@SHSMSX104.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [dpdk-dev] dev Digest, Vol 132, Issue 84 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Test by: Lin Xueqin [PATCH] net/i40e: enable statistic reset for VF (Qi Zhang) NIC: 25G NIC Steps: 1. Get the pci device id of DUT ./tools/dpdk-devbind.py --st 0000:81:00.0 'Device 158b' if=eth27 drv=i40e unused=igb_uio 2. Host PF in DPDK driver. root@dpdk-test03:~/dpdk# ./tools/dpdk-devbind.py --bind=igb_uio 81:00.0 root@dpdk-test03:~/dpdk# echo 1 >/sys/bus/pci/devices/0000:81:00.0/max_vfs 3. Detach VF from the host root@dpdk-test03:~/dpdk# rmmod i40evf 0000:81:02.0 'XL710 X710 Virtual Function' unused=igb_uio 4. Launch the VM1 with the VF PCI pass through. 5. Bind port to igb_uio on the VM1 VM1: ./tools/dpdk-devbind.py --bind=igb_uio 00:03.0 6. Setup host and VM1 testpmd host: ./x86_64-native-linuxapp-gcc/app/testpmd -c f -n 4 -- -i --port-topology=chained VM1: ./x86_64-native-linuxapp-gcc/app/testpmd -c f -n 4 -- -i --port-topology=chained Port 0: 1A:BD:C8:42:CA:35 Checking link statuses... Port 0 Link Up - speed 10000 Mbps - full-duplex Done 7. Set mac forwarding and start testpmd testpmd> set fwd mac Set mac packet forwarding mode testpmd> start 8. Send packet from tester 9. Find VF can receive packet, but clear stats can't work. testpmd> show port stats all ######################## NIC statistics for port 0 ######################## RX-packets: 10 RX-missed: 0 RX-bytes: 1080 RX-errors: 0 RX-nombuf: 0 TX-packets: 10 TX-errors: 0 TX-bytes: 1040 Throughput (since last show) Rx-pps: 0 Tx-pps: 0 ############################################################################ testpmd> clear port stats all NIC statistics for port 0 cleared testpmd> show port stats all ######################## NIC statistics for port 0 ######################## RX-packets: 10 RX-missed: 0 RX-bytes: 1080 RX-errors: 0 RX-nombuf: 0 TX-packets: 10 TX-errors: 0 TX-bytes: 1040 Throughput (since last show) Rx-pps: 0 Tx-pps: 0 ############################################################################ Result: clear port stats can't work. Check with Qi about this, change below code not to check version then run cmd can call i40evf_reset_statistics(dev) function. Repeat above test steps verify clear port stats cmd can work. drivers/net/i40e/i40e_ethdev_vf.c static int i40evf_dev_xstats_get(struct rte_eth_dev *dev, { struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); /* only DPDK PF support this */ - if (vf->version_major == I40E_DPDK_VERSION_MAJOR) { + if (vf->version_major != I40E_DPDK_VERSION_MAJOR) { if (i40evf_reset_statistics(dev)) PMD_DRV_LOG(ERR, "Reset statistics failed"); } Best regards, Xueqin -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of dev-request@dpdk.org Sent: Friday, February 24, 2017 11:25 AM To: dev@dpdk.org Subject: dev Digest, Vol 132, Issue 84 Send dev mailing list submissions to dev@dpdk.org To subscribe or unsubscribe via the World Wide Web, visit http://dpdk.org/ml/listinfo/dev or, via email, send a message with subject or body 'help' to dev-request@dpdk.org You can reach the person managing the list at dev-owner@dpdk.org When replying, please edit your Subject line so it is more specific than "Re: Contents of dev digest..." Today's Topics: 1. Re: [PATCH v2] e1000/base: fix multicast setting in VF (Lu, Wenzhuo) 2. [PATCH] net/i40e: enable statistic reset for VF (Qi Zhang) 3. [PATCH 0/8] QoS features on i40e (Wenzhuo Lu) 4. [PATCH 1/8] net/i40e: set VF max bandwidth from PF (Wenzhuo Lu) 5. [PATCH 2/8] net/i40e: allocate VF TC bandwidth from PF (Wenzhuo Lu) 6. [PATCH 3/8] net/i40e: set VF TC max bandwidth from PF (Wenzhuo Lu) ---------------------------------------------------------------------- Message: 1 Date: Fri, 24 Feb 2017 00:32:49 +0000 From: "Lu, Wenzhuo" To: Yong Wang Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v2] e1000/base: fix multicast setting in VF Message-ID: <6A0DE07E22DDAD4C9103DF62FEBC09093B56802E@shsmsx102.ccr.corp.intel.com> Content-Type: text/plain; charset="us-ascii" Hi, > -----Original Message----- > From: Yong Wang [mailto:wang.yong19@zte.com.cn] > Sent: Tuesday, February 21, 2017 5:33 PM > To: Lu, Wenzhuo > Cc: dev@dpdk.org; Yong Wang > Subject: [PATCH v2] e1000/base: fix multicast setting in VF > > In function e1000_update_mc_addr_list_vf(), "msgbuf[0]" is used prior > to initialization at "msgbuf[0] |= E1000_VF_SET_MULTICAST_OVERFLOW". > And "msgbuf[0]" is overwritten at "msgbuf[0] = E1000_VF_SET_MULTICAST". > Fix it by moving the second line prior to the first one that mentioned above. > > --- > v2: > * According to Thomas's suggestion, modify the title. > > Signed-off-by: Yong Wang Acked-by: Wenzhuo Lu ------------------------------ Message: 2 Date: Thu, 23 Feb 2017 13:27:01 -0500 From: Qi Zhang To: jingjing.wu@intel.com, helin.zhang@intel.com Cc: dev@dpdk.org, Qi Zhang Subject: [dpdk-dev] [PATCH] net/i40e: enable statistic reset for VF Message-ID: <1487874421-11934-1-git-send-email-qi.z.zhang@intel.com> The patch implements the dev_ops "stats_reset" for VF. Signed-off-by: Qi Zhang --- drivers/net/i40e/i40e_ethdev_vf.c | 34 ++++++++++++++++++++++++++++++++++ drivers/net/i40e/i40e_pf.c | 25 +++++++++++++++++++++++++ drivers/net/i40e/i40e_pf.h | 1 + 3 files changed, 60 insertions(+) diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 55fd344..5155b25 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -110,6 +110,7 @@ static int i40evf_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete); static void i40evf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); +static void i40evf_dev_stats_reset(struct rte_eth_dev *dev); static int i40evf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); static int i40evf_dev_xstats_get_names(struct rte_eth_dev *dev, @@ -199,6 +200,7 @@ static const struct eth_dev_ops i40evf_eth_dev_ops = { .allmulticast_disable = i40evf_dev_allmulticast_disable, .link_update = i40evf_dev_link_update, .stats_get = i40evf_dev_stats_get, + .stats_reset = i40evf_dev_stats_reset, .xstats_get = i40evf_dev_xstats_get, .xstats_get_names = i40evf_dev_xstats_get_names, .xstats_reset = i40evf_dev_xstats_reset, @@ -988,6 +990,27 @@ i40evf_get_statistics(struct rte_eth_dev *dev, struct rte_eth_stats *stats) return 0; } +static int +i40evf_reset_statistics(struct rte_eth_dev *dev) { + struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); + int err; + struct vf_cmd_info args; + u16 vsi_id = vf->vsi_res->vsi_id; + + args.ops = (enum i40e_virtchnl_ops)I40E_VIRTCHNL_OP_RESET_STATS; + args.in_args = (uint8_t *)&vsi_id; + args.in_args_size = sizeof(vsi_id); + args.out_buffer = vf->aq_resp; + args.out_size = I40E_AQ_BUF_SZ; + + err = i40evf_execute_vf_cmd(dev, &args); + if (err) + PMD_DRV_LOG(ERR, "fail to execute command CFG_VLAN_OFFLOAD"); + + return err; +} + static void i40evf_dev_xstats_reset(struct rte_eth_dev *dev) { @@ -2310,6 +2333,17 @@ i40evf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) } static void +i40evf_dev_stats_reset(struct rte_eth_dev *dev) { + struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); + /* only DPDK PF support this */ + if (vf->version_major == I40E_DPDK_VERSION_MAJOR) { + if (i40evf_reset_statistics(dev)) + PMD_DRV_LOG(ERR, "Reset statistics failed"); + } +} + +static void i40evf_dev_close(struct rte_eth_dev *dev) { struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c index f771dfb..62d2bfd 100644 --- a/drivers/net/i40e/i40e_pf.c +++ b/drivers/net/i40e/i40e_pf.c @@ -1155,6 +1155,27 @@ i40e_pf_host_process_cmd_cfg_pvid(struct i40e_pf_vf *vf, return ret; } +static int +i40e_pf_host_process_cmd_reset_stats(struct i40e_pf_vf *vf, + bool b_op) +{ + vf->vsi->offset_loaded = false; + i40e_update_vsi_stats(vf->vsi); + + if (b_op) + i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_RESET_STATS, + I40E_SUCCESS, + NULL, + 0); + else + i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_RESET_STATS, + I40E_NOT_SUPPORTED, + NULL, + 0); + + return I40E_SUCCESS; +} + void i40e_notify_vf_link_status(struct rte_eth_dev *dev, struct i40e_pf_vf *vf) { @@ -1300,6 +1321,10 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev, PMD_DRV_LOG(INFO, "OP_CFG_VLAN_PVID received"); i40e_pf_host_process_cmd_cfg_pvid(vf, msg, msglen, b_op); break; + case I40E_VIRTCHNL_OP_RESET_STATS: + PMD_DRV_LOG(INFO, "OP_RESET_STATS received"); + i40e_pf_host_process_cmd_reset_stats(vf, b_op); + break; /* Don't add command supported below, which will * return an error code. */ diff --git a/drivers/net/i40e/i40e_pf.h b/drivers/net/i40e/i40e_pf.h index b4c2287..69ef873 100644 --- a/drivers/net/i40e/i40e_pf.h +++ b/drivers/net/i40e/i40e_pf.h @@ -58,6 +58,7 @@ enum i40e_virtchnl_ops_dpdk { I40E_DPDK_OFFSET, I40E_VIRTCHNL_OP_CFG_VLAN_PVID, I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EXT, + I40E_VIRTCHNL_OP_RESET_STATS, }; /* A structure to support extended info of a receive queue. */ -- 2.7.4 ------------------------------ Message: 3 Date: Fri, 24 Feb 2017 11:24:27 +0800 From: Wenzhuo Lu To: dev@dpdk.org Cc: Wenzhuo Lu Subject: [dpdk-dev] [PATCH 0/8] QoS features on i40e Message-ID: <1487906675-54260-1-git-send-email-wenzhuo.lu@intel.com> This patch set enables several QoS features on i40e. 1, VF max bandwidth setting. 2, TC min bandwidth setting on a VF. 3, TC max bandwidth setting on a VF. 4, TC TX scheduling mode setting. As there're no new interface between PF and VF defined, all the settings for VF are done on PF. PF acts as a controller for the VFs. Wenzhuo Lu (8): net/i40e: set VF max bandwidth from PF net/i40e: allocate VF TC bandwidth from PF net/i40e: set VF TC max bandwidth from PF net/i40e: set TC strict priority mode app/testpmd: set VF TX max bandwidth app/testpmd: set VF TC TX min bandwidth app/testpmd: set VF TC TX max bandwidth app/testpmd: set TC strict link priority mode app/test-pmd/cmdline.c | 343 +++++++++++++++++++++ doc/guides/nics/i40e.rst | 21 ++ doc/guides/rel_notes/release_17_05.rst | 20 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 28 ++ drivers/net/i40e/i40e_ethdev.c | 449 ++++++++++++++++++++++++++++ drivers/net/i40e/i40e_ethdev.h | 1 + drivers/net/i40e/rte_pmd_i40e.h | 86 ++++++ drivers/net/i40e/rte_pmd_i40e_version.map | 10 + 8 files changed, 958 insertions(+) -- 1.9.3 ------------------------------ Message: 4 Date: Fri, 24 Feb 2017 11:24:28 +0800 From: Wenzhuo Lu To: dev@dpdk.org Cc: Wenzhuo Lu Subject: [dpdk-dev] [PATCH 1/8] net/i40e: set VF max bandwidth from PF Message-ID: <1487906675-54260-2-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 --- 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 ------------------------------ Message: 5 Date: Fri, 24 Feb 2017 11:24:29 +0800 From: Wenzhuo Lu To: dev@dpdk.org Cc: Wenzhuo Lu Subject: [dpdk-dev] [PATCH 2/8] net/i40e: allocate VF TC bandwidth from PF Message-ID: <1487906675-54260-3-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 --- 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 ------------------------------ Message: 6 Date: Fri, 24 Feb 2017 11:24:30 +0800 From: Wenzhuo Lu To: dev@dpdk.org Cc: Wenzhuo Lu Subject: [dpdk-dev] [PATCH 3/8] net/i40e: set VF TC max bandwidth from PF Message-ID: <1487906675-54260-4-git-send-email-wenzhuo.lu@intel.com> Set a specific TC's max bandwidth on a VF. User can call the API to set VF TC's max bandwidth from PF. Signed-off-by: Wenzhuo Lu --- doc/guides/nics/i40e.rst | 11 +++ doc/guides/rel_notes/release_17_05.rst | 5 ++ drivers/net/i40e/i40e_ethdev.c | 118 ++++++++++++++++++++++++++++++ drivers/net/i40e/rte_pmd_i40e.h | 22 ++++++ drivers/net/i40e/rte_pmd_i40e_version.map | 1 + 5 files changed, 157 insertions(+) diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst index b890613..260287e 100644 --- a/doc/guides/nics/i40e.rst +++ b/doc/guides/nics/i40e.rst @@ -467,3 +467,14 @@ Incorrect Rx statistics when packet is oversize When a packet is over maximum frame size, the packet is dropped. However the Rx statistics, when calling `rte_eth_stats_get` incorrectly shows it as received. + +VF & TC max bandwidth setting +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The per VF max bandwidth and per TC max bandwidth cannot be enabled in parallel. +The dehavior is different when handling per VF and per TC max bandwidth setting. +When enabling per VF max bandwidth, SW will check if per TC max bandwidth is +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. diff --git a/doc/guides/rel_notes/release_17_05.rst b/doc/guides/rel_notes/release_17_05.rst index a726138..d31435c 100644 --- a/doc/guides/rel_notes/release_17_05.rst +++ b/doc/guides/rel_notes/release_17_05.rst @@ -50,6 +50,11 @@ New Features i40e HW supports to set the allocated bandwidth for a TC on a VF. Enable this capability. +* **Added VF TC max bandwidth setting on i40e.** + + i40e HW supports to set the max 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 5a46737..2df9587 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11431,3 +11431,121 @@ int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id, return 0; } + +int +rte_pmd_i40e_set_vf_tc_max_bw(uint8_t port, uint16_t vf_id, + uint8_t tc_no, uint32_t bw) +{ + struct rte_eth_dev *dev; + struct i40e_pf *pf; + struct i40e_vsi *vsi; + struct i40e_hw *hw; + struct i40e_aqc_configure_vsi_ets_sla_bw_data tc_bw; + 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; + + if (tc_no >= I40E_MAX_TRAFFIC_CLASS) { + PMD_DRV_LOG(ERR, "TC No. should be less than %d.", + I40E_MAX_TRAFFIC_CLASS); + return -EINVAL; + } + + hw = I40E_VSI_TO_HW(vsi); + + if (!(vsi->enabled_tc & BIT_ULL(tc_no))) { + PMD_DRV_LOG(ERR, "VF %d TC %d isn't enabled.", + vf_id, tc_no); + return -EINVAL; + } + + /* No change. */ + if (bw == vsi->bw_info.bw_ets_credits[tc_no]) { + PMD_DRV_LOG(INFO, + "No change for TC max bandwidth. Nothing to do."); + return 0; + } + + /** + * VF bandwidth limitation and TC bandwidth limitation cannot be + * enabled in parallel, disable VF bandwidth limitation if it's + * enabled. + * If bw is 0, means disable bandwidth limitation. Then no need to + * care about VF bandwidth limitation configuration. + */ + if (bw && vsi->bw_info.bw_limit) { + ret = i40e_aq_config_vsi_bw_limit(hw, vsi->seid, 0, 0, NULL); + if (ret) { + PMD_DRV_LOG(ERR, + "Failed to disable VF(%d)" + " bandwidth limitation, err(%d).", + vf_id, ret); + return -EINVAL; + } + + PMD_DRV_LOG(INFO, + "VF max bandwidth is disabled according" + " to TC max bandwidth setting."); + } + + /** + * Get all the TCs' info to create a whole picture. + * Because the incremental change isn't permitted. + */ + memset(&tc_bw, 0, sizeof(tc_bw)); + tc_bw.tc_valid_bits = vsi->enabled_tc; + for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { + if (vsi->enabled_tc & BIT_ULL(i)) { + tc_bw.tc_bw_credits[i] = + rte_cpu_to_le_16( + vsi->bw_info.bw_ets_credits[i]); + } + } + tc_bw.tc_bw_credits[tc_no] = rte_cpu_to_le_16((uint16_t)bw); + + ret = i40e_aq_config_vsi_ets_sla_bw_limit(hw, vsi->seid, &tc_bw, NULL); + if (ret) { + PMD_DRV_LOG(ERR, + "Failed to set VF %d TC %d max bandwidth, err(%d).", + vf_id, tc_no, ret); + return -EINVAL; + } + + /* Store the configuration. */ + vsi->bw_info.bw_ets_credits[tc_no] = (uint16_t)bw; + + return 0; +} diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h index 9fdb447..08ee2b0 100644 --- a/drivers/net/i40e/rte_pmd_i40e.h +++ b/drivers/net/i40e/rte_pmd_i40e.h @@ -381,4 +381,26 @@ int rte_pmd_i40e_set_vf_tc_bw_alloc(uint8_t port, uint8_t tc_num, uint8_t *bw_weight); +/** + * Set a specific TC's max bandwidth on a specific VF. + * + * @param port + * The port identifier of the Ethernet device. + * @param vf_id + * ID specifying VF. + * @param tc_no + * Number specifying TC. + * @param bw + * Max bandwidth for this TC. + * @return + * - (0) if successful. + * - (-ENODEV) if *port* invalid. + * - (-EINVAL) if bad parameter. + * - (-ENOTSUP) not supported by firmware. + */ +int rte_pmd_i40e_set_vf_tc_max_bw(uint8_t port, + uint16_t vf_id, + uint8_t tc_no, + 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 85bc41d..bd657ab 100644 --- a/drivers/net/i40e/rte_pmd_i40e_version.map +++ b/drivers/net/i40e/rte_pmd_i40e_version.map @@ -28,5 +28,6 @@ DPDK_17.05 { rte_pmd_i40e_set_vf_max_bw; rte_pmd_i40e_set_vf_tc_bw_alloc; + rte_pmd_i40e_set_vf_tc_max_bw; } DPDK_17.02;