DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ting Xu <ting.xu@intel.com>
To: dev@dpdk.org
Cc: qi.z.zhang@intel.com, beilei.xing@intel.com,
	jingjing.wu@intel.com, Ting Xu <ting.xu@intel.com>
Subject: [dpdk-dev] [PATCH v8 3/6] net/iavf: negotiate large VF and request more queues
Date: Thu, 22 Oct 2020 14:48:59 +0800	[thread overview]
Message-ID: <20201022064902.40143-4-ting.xu@intel.com> (raw)
In-Reply-To: <20201022064902.40143-1-ting.xu@intel.com>

Negotiate large VF capability with PF during VF initialization. If large
VF is supported and the number of queues larger than 16 is required, VF
requests additional queues from PF. Mark the state that large VF is
supported.

If the allocated queues number is larger than 16, the max RSS queue
region cannot be 16 anymore. Add the function to query max RSS queue
region from PF, use it in the RSS initialization and future filters
configuration.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/iavf/iavf.h        |  7 +++-
 drivers/net/iavf/iavf_ethdev.c | 74 ++++++++++++++++++++++++++++++++--
 drivers/net/iavf/iavf_vchnl.c  | 31 +++++++++++++-
 3 files changed, 107 insertions(+), 5 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 778b6c23c..49ccfeece 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -19,7 +19,8 @@
 #define IAVF_FRAME_SIZE_MAX       9728
 #define IAVF_QUEUE_BASE_ADDR_UNIT 128
 
-#define IAVF_MAX_NUM_QUEUES       16
+#define IAVF_MAX_NUM_QUEUES_DFLT	 16
+#define IAVF_MAX_NUM_QUEUES_LV		 256
 
 #define IAVF_NUM_MACADDR_MAX      64
 
@@ -149,6 +150,7 @@ struct iavf_info {
 	uint8_t *rss_key;
 	uint16_t nb_msix;   /* number of MSI-X interrupts on Rx */
 	uint16_t msix_base; /* msix vector base from */
+	uint16_t max_rss_qregion; /* max RSS queue region supported by PF */
 	/* queue bitmask for each vector */
 	uint16_t rxq_map[IAVF_MAX_MSIX_VECTORS];
 	struct iavf_flow_list flow_list;
@@ -157,6 +159,8 @@ struct iavf_info {
 	struct iavf_parser_list dist_parser_list;
 
 	struct iavf_fdir_info fdir; /* flow director info */
+	/* indicate large VF support enabled or not */
+	bool lv_enabled;
 };
 
 #define IAVF_MAX_PKT_TYPE 1024
@@ -288,4 +292,5 @@ int iavf_add_del_mc_addr_list(struct iavf_adapter *adapter,
 			struct rte_ether_addr *mc_addrs,
 			uint32_t mc_addrs_num, bool add);
 int iavf_request_queues(struct iavf_adapter *adapter, uint16_t num);
+int iavf_get_max_rss_queue_region(struct iavf_adapter *adapter);
 #endif /* _IAVF_ETHDEV_H_ */
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index a5b06e6bd..87082d1cc 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -209,7 +209,7 @@ iavf_init_rss(struct iavf_adapter *adapter)
 
 	rss_conf = &adapter->eth_dev->data->dev_conf.rx_adv_conf.rss_conf;
 	nb_q = RTE_MIN(adapter->eth_dev->data->nb_rx_queues,
-		       IAVF_MAX_NUM_QUEUES);
+		       vf->max_rss_qregion);
 
 	if (!(vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF)) {
 		PMD_DRV_LOG(DEBUG, "RSS is not supported");
@@ -255,6 +255,31 @@ iavf_init_rss(struct iavf_adapter *adapter)
 	return 0;
 }
 
+static int
+iavf_queues_req_reset(struct rte_eth_dev *dev, uint16_t num)
+{
+	struct iavf_adapter *ad =
+		IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+	struct iavf_info *vf =  IAVF_DEV_PRIVATE_TO_VF(ad);
+	int ret;
+
+	ret = iavf_request_queues(ad, num);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "request queues from PF failed");
+		return ret;
+	}
+	PMD_DRV_LOG(INFO, "change queue pairs from %u to %u",
+			vf->vsi_res->num_queue_pairs, num);
+
+	ret = iavf_dev_reset(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "vf reset failed");
+		return ret;
+	}
+
+	return 0;
+}
+
 static int
 iavf_dev_configure(struct rte_eth_dev *dev)
 {
@@ -262,6 +287,9 @@ iavf_dev_configure(struct rte_eth_dev *dev)
 		IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	struct iavf_info *vf =  IAVF_DEV_PRIVATE_TO_VF(ad);
 	struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
+	uint16_t num_queue_pairs = RTE_MAX(dev->data->nb_rx_queues,
+		dev->data->nb_tx_queues);
+	int ret;
 
 	ad->rx_bulk_alloc_allowed = true;
 	/* Initialize to TRUE. If any of Rx queues doesn't meet the
@@ -273,6 +301,46 @@ iavf_dev_configure(struct rte_eth_dev *dev)
 	if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
 		dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
 
+	/* Large VF setting */
+	if (num_queue_pairs > IAVF_MAX_NUM_QUEUES_DFLT) {
+		if (!(vf->vf_res->vf_cap_flags &
+				VIRTCHNL_VF_LARGE_NUM_QPAIRS)) {
+			PMD_DRV_LOG(ERR, "large VF is not supported");
+			return -1;
+		}
+
+		if (num_queue_pairs > IAVF_MAX_NUM_QUEUES_LV) {
+			PMD_DRV_LOG(ERR, "queue pairs number cannot be larger than %u",
+				IAVF_MAX_NUM_QUEUES_LV);
+			return -1;
+		}
+
+		ret = iavf_queues_req_reset(dev, num_queue_pairs);
+		if (ret)
+			return ret;
+
+		ret = iavf_get_max_rss_queue_region(ad);
+		if (ret) {
+			PMD_INIT_LOG(ERR, "get max rss queue region failed");
+			return ret;
+		}
+
+		vf->lv_enabled = true;
+	} else {
+		/* Check if large VF is already enabled. If so, disable and
+		 * release redundant queue resource.
+		 */
+		if (vf->lv_enabled) {
+			ret = iavf_queues_req_reset(dev, num_queue_pairs);
+			if (ret)
+				return ret;
+
+			vf->lv_enabled = false;
+		}
+		/* if large VF is not required, use default rss queue region */
+		vf->max_rss_qregion = IAVF_MAX_NUM_QUEUES_DFLT;
+	}
+
 	/* Vlan stripping setting */
 	if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN) {
 		if (dev_conf->rxmode.offloads & DEV_RX_OFFLOAD_VLAN_STRIP)
@@ -586,8 +654,8 @@ iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
 
-	dev_info->max_rx_queues = vf->vsi_res->num_queue_pairs;
-	dev_info->max_tx_queues = vf->vsi_res->num_queue_pairs;
+	dev_info->max_rx_queues = IAVF_MAX_NUM_QUEUES_LV;
+	dev_info->max_tx_queues = IAVF_MAX_NUM_QUEUES_LV;
 	dev_info->min_rx_bufsize = IAVF_BUF_SIZE_MIN;
 	dev_info->max_rx_pktlen = IAVF_FRAME_SIZE_MAX;
 	dev_info->max_mtu = dev_info->max_rx_pktlen - IAVF_ETH_OVERHEAD;
diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index 323e2a843..2c49a0e76 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -457,7 +457,8 @@ iavf_get_vf_resource(struct iavf_adapter *adapter)
 		VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC |
 		VIRTCHNL_VF_OFFLOAD_FDIR_PF |
 		VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF |
-		VIRTCHNL_VF_OFFLOAD_REQ_QUEUES;
+		VIRTCHNL_VF_OFFLOAD_REQ_QUEUES |
+		VIRTCHNL_VF_LARGE_NUM_QPAIRS;
 
 	args.in_args = (uint8_t *)&caps;
 	args.in_args_size = sizeof(caps);
@@ -1267,3 +1268,31 @@ iavf_request_queues(struct iavf_adapter *adapter, uint16_t num)
 
 	return -1;
 }
+
+int
+iavf_get_max_rss_queue_region(struct iavf_adapter *adapter)
+{
+	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
+	struct iavf_cmd_info args;
+	uint16_t qregion_width;
+	int err;
+
+	args.ops = VIRTCHNL_OP_GET_MAX_RSS_QREGION;
+	args.in_args = NULL;
+	args.in_args_size = 0;
+	args.out_buffer = vf->aq_resp;
+	args.out_size = IAVF_AQ_BUF_SZ;
+
+	err = iavf_execute_vf_cmd(adapter, &args);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL_OP_GET_MAX_RSS_QREGION");
+		return err;
+	}
+
+	qregion_width =
+	((struct virtchnl_max_rss_qregion *)args.out_buffer)->qregion_width;
+
+	vf->max_rss_qregion = (uint16_t)(1 << qregion_width);
+
+	return 0;
+}
-- 
2.17.1


  parent reply	other threads:[~2020-10-22  6:46 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-09  7:20 [dpdk-dev] [PATCH v1 0/2] enable large VF configuration Ting Xu
2020-09-09  7:20 ` [dpdk-dev] [PATCH v1 1/2] net/iavf: add IAVF request queues Ting Xu
2020-09-09  7:20 ` [dpdk-dev] [PATCH v1 2/2] net/iavf: enable large VF configuration Ting Xu
2020-09-25  5:59 ` [dpdk-dev] [PATCH v2 0/2] " Ting Xu
2020-09-25  5:59   ` [dpdk-dev] [PATCH v2 1/2] net/iavf: add IAVF request queues function Ting Xu
2020-09-25  5:59   ` [dpdk-dev] [PATCH v2 2/2] net/iavf: enable large VF configuration Ting Xu
2020-09-27 12:42 ` [dpdk-dev] [PATCH v3 0/2] " Ting Xu
2020-09-27 12:42   ` [dpdk-dev] [PATCH v3 1/2] net/iavf: add IAVF request queues function Ting Xu
2020-09-27 12:42   ` [dpdk-dev] [PATCH v3 2/2] net/iavf: enable large VF configuration Ting Xu
2020-10-15  5:21 ` [dpdk-dev] [PATCH v4 0/2] " Ting Xu
2020-10-15  5:21   ` [dpdk-dev] [PATCH v4 1/2] net/iavf: add IAVF request queues function Ting Xu
2020-10-15  5:21   ` [dpdk-dev] [PATCH v4 2/2] net/iavf: enable large VF configuration Ting Xu
2020-10-16  1:21 ` [dpdk-dev] [PATCH v5 0/2] " Ting Xu
2020-10-16  1:21   ` [dpdk-dev] [PATCH v5 1/2] net/iavf: add IAVF request queues function Ting Xu
2020-10-16  1:21   ` [dpdk-dev] [PATCH v5 2/2] net/iavf: enable large VF configuration Ting Xu
2020-10-16  1:34 ` [dpdk-dev] [PATCH v5 0/2] " Ting Xu
2020-10-16  1:34   ` [dpdk-dev] [PATCH v5 1/2] net/iavf: add IAVF request queues function Ting Xu
2020-10-16  1:34   ` [dpdk-dev] [PATCH v5 2/2] net/iavf: enable large VF configuration Ting Xu
2020-10-16  1:43 ` [dpdk-dev] [PATCH v6 0/2] " Ting Xu
2020-10-16  1:43   ` [dpdk-dev] [PATCH v6 1/2] net/iavf: add IAVF request queues function Ting Xu
2020-10-16  8:41     ` Xing, Beilei
2020-10-18 10:29       ` Xu, Ting
2020-10-16  1:43   ` [dpdk-dev] [PATCH v6 2/2] net/iavf: enable large VF configuration Ting Xu
2020-10-18 10:34 ` [dpdk-dev] [PATCH v7 0/6] " Ting Xu
2020-10-18 10:34   ` [dpdk-dev] [PATCH v7 1/6] net/iavf: handle virtchnl event message without interrupt Ting Xu
2020-10-21  8:15     ` Xing, Beilei
2020-10-18 10:34   ` [dpdk-dev] [PATCH v7 2/6] net/iavf: add IAVF request queues function Ting Xu
2020-10-18 10:34   ` [dpdk-dev] [PATCH v7 3/6] net/iavf: negotiate large VF and request more queues Ting Xu
2020-10-18 10:34   ` [dpdk-dev] [PATCH v7 4/6] net/iavf: enable multiple queues configurations for large VF Ting Xu
2020-10-18 10:34   ` [dpdk-dev] [PATCH v7 5/6] net/iavf: enable IRQ mapping configuration " Ting Xu
2020-10-18 10:34   ` [dpdk-dev] [PATCH v7 6/6] net/iavf: add enable/disable queues " Ting Xu
2020-10-22  6:48 ` [dpdk-dev] [PATCH v8 0/6] enable large VF configuration Ting Xu
2020-10-22  6:48   ` [dpdk-dev] [PATCH v8 1/6] net/iavf: handle virtchnl event message without interrupt Ting Xu
2020-10-22  6:48   ` [dpdk-dev] [PATCH v8 2/6] net/iavf: add IAVF request queues function Ting Xu
2020-10-23 10:07     ` Ferruh Yigit
2020-10-25  2:28       ` Xu, Ting
2020-10-23 10:11     ` Ferruh Yigit
2020-10-23 10:17       ` Ferruh Yigit
2020-10-22  6:48   ` Ting Xu [this message]
2020-10-22  6:49   ` [dpdk-dev] [PATCH v8 4/6] net/iavf: enable multiple queues configurations for large VF Ting Xu
2020-10-22  6:49   ` [dpdk-dev] [PATCH v8 5/6] net/iavf: enable IRQ mapping configuration " Ting Xu
2020-10-22  6:49   ` [dpdk-dev] [PATCH v8 6/6] net/iavf: add enable/disable queues " Ting Xu
2020-10-22  6:54   ` [dpdk-dev] [PATCH v8 0/6] enable large VF configuration Xing, Beilei
2020-10-22  8:50     ` Zhang, Qi Z

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=20201022064902.40143-4-ting.xu@intel.com \
    --to=ting.xu@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=qi.z.zhang@intel.com \
    /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).