DPDK patches and discussions
 help / color / mirror / Atom feed
From: SteveX Yang <stevex.yang@intel.com>
To: jingjing.wu@intel.com, beilei.xing@intel.com, dev@dpdk.org
Cc: SteveX Yang <stevex.yang@intel.com>
Subject: [dpdk-dev] [PATCH 5/7] net/iavf: fix multiple interrupts for VF
Date: Tue, 11 Aug 2020 06:29:15 +0000
Message-ID: <20200811062917.7007-6-stevex.yang@intel.com> (raw)
In-Reply-To: <20200811062917.7007-1-stevex.yang@intel.com>

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

Fixes: 69dd4c3d0898 ("net/avf: enable queue and device")

Signed-off-by: SteveX Yang <stevex.yang@intel.com>
---
 drivers/net/iavf/iavf_vchnl.c | 56 ++++++++++++++++++++++++++++-------
 1 file changed, 45 insertions(+), 11 deletions(-)

diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index 33acea54a..614ea7e79 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -18,6 +18,7 @@
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
 #include <rte_dev.h>
+#include <rte_bus_pci.h>
 
 #include "iavf.h"
 #include "iavf_rxtx.h"
@@ -686,20 +687,53 @@ int
 iavf_config_irq_map(struct iavf_adapter *adapter)
 {
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
+	struct iavf_cmd_info args;
+	uint8_t *cmd_buffer = NULL;
 	struct virtchnl_irq_map_info *map_info;
 	struct virtchnl_vector_map *vecmap;
-	struct iavf_cmd_info args;
-	int len, i, err;
+	struct rte_eth_dev *dev = adapter->eth_dev;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+	uint32_t vec, cmd_buffer_size, max_vectors, nb_msix, msix_base, i;
+	uint16_t rxq_map[vf->vf_res->max_vectors];
+	int err;
 
-	len = sizeof(struct virtchnl_irq_map_info) +
-	      sizeof(struct virtchnl_vector_map) * vf->nb_msix;
+	memset(rxq_map, 0, sizeof(rxq_map));
+	if (dev->data->dev_conf.intr_conf.rxq &&
+		rte_intr_allow_others(intr_handle)) {
+		msix_base = IAVF_RX_VEC_START;
+		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 = IAVF_MISC_VEC_ID;
+		nb_msix = 1;
 
-	map_info = rte_zmalloc("map_info", len, 0);
-	if (!map_info)
-		return -ENOMEM;
+		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;
+		}
+	}
 
-	map_info->num_vectors = vf->nb_msix;
-	for (i = 0; i < vf->nb_msix; i++) {
+	cmd_buffer_size = sizeof(struct virtchnl_irq_map_info) +
+	      sizeof(struct virtchnl_vector_map) * nb_msix;
+	cmd_buffer = rte_zmalloc("iavf", cmd_buffer_size, 0);
+	if (!cmd_buffer) {
+		PMD_DRV_LOG(ERR, "Failed to allocate memory");
+		return IAVF_ERR_NO_MEMORY;
+	}
+
+	map_info = (struct virtchnl_irq_map_info *)cmd_buffer;
+	map_info->num_vectors = nb_msix;
+	for (i = 0; i < nb_msix; i++) {
 		vecmap = &map_info->vecmap[i];
 		vecmap->vsi_id = vf->vsi_res->vsi_id;
 		vecmap->rxitr_idx = IAVF_ITR_INDEX_DEFAULT;
@@ -709,8 +743,8 @@ iavf_config_irq_map(struct iavf_adapter *adapter)
 	}
 
 	args.ops = VIRTCHNL_OP_CONFIG_IRQ_MAP;
-	args.in_args = (u8 *)map_info;
-	args.in_args_size = len;
+	args.in_args = (u8 *)cmd_buffer;
+	args.in_args_size = cmd_buffer_size;
 	args.out_buffer = vf->aq_resp;
 	args.out_size = IAVF_AQ_BUF_SZ;
 	err = iavf_execute_vf_cmd(adapter, &args);
-- 
2.17.1


  parent reply	other threads:[~2020-08-11  6:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-11  6:29 [dpdk-dev] [PATCH 0/7] Bugs Porting from I40evf For IAVF Feature SteveX Yang
2020-08-11  6:29 ` [dpdk-dev] [PATCH 1/7] net/iavf: fix scattered Rx enabling SteveX Yang
2020-08-12  2:07   ` Xing, Beilei
2020-08-11  6:29 ` [dpdk-dev] [PATCH 2/7] net/iavf: set speed to undefined for default case SteveX Yang
2020-08-11  6:29 ` [dpdk-dev] [PATCH 3/7] net/iavf: fix port start during configuration restore SteveX Yang
2020-08-11  6:29 ` [dpdk-dev] [PATCH 4/7] net/iavf: fix setting of MAC address on iavf SteveX Yang
2020-08-11  6:29 ` SteveX Yang [this message]
2020-08-11  6:29 ` [dpdk-dev] [PATCH 6/7] net/iavf: downgrade error log SteveX Yang
2020-08-11  6:29 ` [dpdk-dev] [PATCH 7/7] net/iavf: fix port close SteveX Yang
2020-08-11  7:59 [dpdk-dev] [PATCH 0/7] Bugs Porting from I40evf For IAVF Feature SteveX Yang
2020-08-11  7:59 ` [dpdk-dev] [PATCH 5/7] net/iavf: fix multiple interrupts for VF SteveX Yang

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=20200811062917.7007-6-stevex.yang@intel.com \
    --to=stevex.yang@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git