DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/i40e: fix multiple interrupt for VF
@ 2020-02-17  3:09 Shougang Wang
  2020-02-18  5:50 ` Zhang, Qi Z
  2020-02-18 12:30 ` Ferruh Yigit
  0 siblings, 2 replies; 4+ messages in thread
From: Shougang Wang @ 2020-02-17  3:09 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, qi.z.zhang, Shougang Wang

Interrupt mapping should be 1:n queue(s).This patch fixes the
logic of interrupt bind by code reconstruction.

Fixes: 6a6cf5f88b4a ("net/i40e: enable multi-queue Rx interrupt for VF")

Signed-off-by: Shougang Wang <shougangx.wang@intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c | 63 ++++++++++++++++++++-----------
 1 file changed, 42 insertions(+), 21 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index b84637309..868117508 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -651,47 +651,68 @@ i40evf_config_irq_map(struct rte_eth_dev *dev)
 {
 	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
 	struct vf_cmd_info args;
-	uint8_t cmd_buffer[sizeof(struct virtchnl_irq_map_info) + \
-		sizeof(struct virtchnl_vector_map) * dev->data->nb_rx_queues];
+	uint8_t *cmd_buffer = NULL;
 	struct virtchnl_irq_map_info *map_info;
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
-	uint32_t vector_id;
-	int i, err;
+	uint32_t vec, cmd_buffer_size, max_vectors, nb_msix, msix_base, i;
+	uint16_t rxq_map[vf->vf_res->max_vectors];
+	int err;
 
 	if (dev->data->dev_conf.intr_conf.rxq != 0 &&
-	    rte_intr_allow_others(intr_handle))
-		vector_id = I40E_RX_VEC_START;
-	else
-		vector_id = I40E_MISC_VEC_ID;
+		rte_intr_allow_others(intr_handle)) {
+		msix_base = I40E_RX_VEC_START;
+		/* For interrupt mode, available vector id is from 1. */
+		max_vectors = vf->vf_res->max_vectors - 1;
+		nb_msix = RTE_MIN(max_vectors, intr_handle->nb_efd);
+
+		vec = msix_base;
+		for (i = 0; i < dev->data->nb_rx_queues; i++) {
+			rxq_map[vec] |= 1 << i;
+			intr_handle->intr_vec[i] = vec++;
+			if (vec >= vf->vf_res->max_vectors)
+				vec = msix_base;
+		}
+	} else {
+		msix_base = I40E_MISC_VEC_ID;
+		nb_msix = 1;
+
+		for (i = 0; i < dev->data->nb_rx_queues; i++) {
+			rxq_map[msix_base] |= 1 << i;
+			if (rte_intr_dp_is_en(intr_handle))
+				intr_handle->intr_vec[i] = msix_base;
+		}
+	}
+
+	cmd_buffer_size = sizeof(struct virtchnl_irq_map_info) +
+			sizeof(struct virtchnl_vector_map) * nb_msix;
+	cmd_buffer = rte_zmalloc("i40e", cmd_buffer_size, 0);
+	if (!cmd_buffer) {
+		PMD_DRV_LOG(ERR, "Failed to allocate memory");
+		return I40E_ERR_NO_MEMORY;
+	}
 
 	map_info = (struct virtchnl_irq_map_info *)cmd_buffer;
-	map_info->num_vectors = dev->data->nb_rx_queues;
-	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+	map_info->num_vectors = nb_msix;
+	for (i = 0; i < nb_msix; i++) {
 		map_info->vecmap[i].rxitr_idx = I40E_ITR_INDEX_DEFAULT;
 		map_info->vecmap[i].vsi_id = vf->vsi_res->vsi_id;
-		/* Always use default dynamic MSIX interrupt */
-		map_info->vecmap[i].vector_id = vector_id;
-		/* Don't map any tx queue */
+		map_info->vecmap[i].vector_id = msix_base + i;
 		map_info->vecmap[i].txq_map = 0;
-		map_info->vecmap[i].rxq_map = 1 << i;
-		if (rte_intr_dp_is_en(intr_handle))
-			intr_handle->intr_vec[i] = vector_id;
-		if (vector_id > I40E_MISC_VEC_ID)
-			vector_id++;
-		if (vector_id >= vf->vf_res->max_vectors)
-			vector_id = I40E_RX_VEC_START;
+		map_info->vecmap[i].rxq_map = rxq_map[msix_base + i];
 	}
 
 	args.ops = VIRTCHNL_OP_CONFIG_IRQ_MAP;
 	args.in_args = (u8 *)cmd_buffer;
-	args.in_args_size = sizeof(cmd_buffer);
+	args.in_args_size = cmd_buffer_size;
 	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 OP_ENABLE_QUEUES");
 
+	rte_free(cmd_buffer);
+
 	return err;
 }
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] net/i40e: fix multiple interrupt for VF
  2020-02-17  3:09 [dpdk-dev] [PATCH] net/i40e: fix multiple interrupt for VF Shougang Wang
@ 2020-02-18  5:50 ` Zhang, Qi Z
  2020-02-18  9:38   ` Ye Xiaolong
  2020-02-18 12:30 ` Ferruh Yigit
  1 sibling, 1 reply; 4+ messages in thread
From: Zhang, Qi Z @ 2020-02-18  5:50 UTC (permalink / raw)
  To: Wang, ShougangX, dev; +Cc: Yang, Qiming



> -----Original Message-----
> From: Wang, ShougangX <shougangx.wang@intel.com>
> Sent: Monday, February 17, 2020 11:10 AM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; Wang, ShougangX <shougangx.wang@intel.com>
> Subject: [PATCH] net/i40e: fix multiple interrupt for VF
> 
> Interrupt mapping should be 1:n queue(s).This patch fixes the logic of interrupt
> bind by code reconstruction.
> 
> Fixes: 6a6cf5f88b4a ("net/i40e: enable multi-queue Rx interrupt for VF")
> 
> Signed-off-by: Shougang Wang <shougangx.wang@intel.com>

Acked-by: Qi Zhang <qi.z.zhang@intel.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] net/i40e: fix multiple interrupt for VF
  2020-02-18  5:50 ` Zhang, Qi Z
@ 2020-02-18  9:38   ` Ye Xiaolong
  0 siblings, 0 replies; 4+ messages in thread
From: Ye Xiaolong @ 2020-02-18  9:38 UTC (permalink / raw)
  To: Zhang, Qi Z; +Cc: Wang, ShougangX, dev, Yang, Qiming

On 02/18, Zhang, Qi Z wrote:
>
>
>> -----Original Message-----
>> From: Wang, ShougangX <shougangx.wang@intel.com>
>> Sent: Monday, February 17, 2020 11:10 AM
>> To: dev@dpdk.org
>> Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
>> <qi.z.zhang@intel.com>; Wang, ShougangX <shougangx.wang@intel.com>
>> Subject: [PATCH] net/i40e: fix multiple interrupt for VF
>> 
>> Interrupt mapping should be 1:n queue(s).This patch fixes the logic of interrupt
>> bind by code reconstruction.
>> 
>> Fixes: 6a6cf5f88b4a ("net/i40e: enable multi-queue Rx interrupt for VF")
>> 
>> Signed-off-by: Shougang Wang <shougangx.wang@intel.com>
>
>Acked-by: Qi Zhang <qi.z.zhang@intel.com>
>

Applied to dpdk-next-net-intel, Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] net/i40e: fix multiple interrupt for VF
  2020-02-17  3:09 [dpdk-dev] [PATCH] net/i40e: fix multiple interrupt for VF Shougang Wang
  2020-02-18  5:50 ` Zhang, Qi Z
@ 2020-02-18 12:30 ` Ferruh Yigit
  1 sibling, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2020-02-18 12:30 UTC (permalink / raw)
  To: Shougang Wang, dev; +Cc: qiming.yang, qi.z.zhang

On 2/17/2020 3:09 AM, Shougang Wang wrote:
> Interrupt mapping should be 1:n queue(s).This patch fixes the
> logic of interrupt bind by code reconstruction.
> 
> Fixes: 6a6cf5f88b4a ("net/i40e: enable multi-queue Rx interrupt for VF")
> 
> Signed-off-by: Shougang Wang <shougangx.wang@intel.com>
> ---
>  drivers/net/i40e/i40e_ethdev_vf.c | 63 ++++++++++++++++++++-----------
>  1 file changed, 42 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
> index b84637309..868117508 100644
> --- a/drivers/net/i40e/i40e_ethdev_vf.c
> +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> @@ -651,47 +651,68 @@ i40evf_config_irq_map(struct rte_eth_dev *dev)
>  {
>  	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
>  	struct vf_cmd_info args;
> -	uint8_t cmd_buffer[sizeof(struct virtchnl_irq_map_info) + \
> -		sizeof(struct virtchnl_vector_map) * dev->data->nb_rx_queues];
> +	uint8_t *cmd_buffer = NULL;
>  	struct virtchnl_irq_map_info *map_info;
>  	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
>  	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
> -	uint32_t vector_id;
> -	int i, err;
> +	uint32_t vec, cmd_buffer_size, max_vectors, nb_msix, msix_base, i;
> +	uint16_t rxq_map[vf->vf_res->max_vectors];
> +	int err;
>  
>  	if (dev->data->dev_conf.intr_conf.rxq != 0 &&
> -	    rte_intr_allow_others(intr_handle))
> -		vector_id = I40E_RX_VEC_START;
> -	else
> -		vector_id = I40E_MISC_VEC_ID;
> +		rte_intr_allow_others(intr_handle)) {
> +		msix_base = I40E_RX_VEC_START;
> +		/* For interrupt mode, available vector id is from 1. */
> +		max_vectors = vf->vf_res->max_vectors - 1;
> +		nb_msix = RTE_MIN(max_vectors, intr_handle->nb_efd);
> +
> +		vec = msix_base;
> +		for (i = 0; i < dev->data->nb_rx_queues; i++) {
> +			rxq_map[vec] |= 1 << i;

ICC is causing following error [1] which looks like a valid one, what do you
thing memset the array before using it?

[1]
.../drivers/net/i40e/i40e_ethdev_vf.c(671): warning #3656: variable "rxq_map"
may be used before its value is set
        rxq_map[vec] |= 1 << i;
        ^

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-18 12:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-17  3:09 [dpdk-dev] [PATCH] net/i40e: fix multiple interrupt for VF Shougang Wang
2020-02-18  5:50 ` Zhang, Qi Z
2020-02-18  9:38   ` Ye Xiaolong
2020-02-18 12:30 ` Ferruh Yigit

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).