DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, Somnath Kotur <somnath.kotur@broadcom.com>
Subject: [dpdk-dev] [PATCH v4 24/24] net/bnxt: add support for rx_queue_intr_enable/disable APIs
Date: Thu, 28 Sep 2017 16:43:45 -0500	[thread overview]
Message-ID: <20170928214345.87655-25-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20170928214345.87655-1-ajit.khaparde@broadcom.com>

From: Somnath Kotur <somnath.kotur@broadcom.com>

Implement Rx Queue interrupt enable/disable functions

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 doc/guides/nics/features/bnxt.ini |  1 +
 drivers/net/bnxt/bnxt_ethdev.c    | 54 +++++++++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_irq.h       |  3 +++
 drivers/net/bnxt/bnxt_rxq.c       | 38 +++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_rxq.h       |  4 +++
 5 files changed, 100 insertions(+)

diff --git a/doc/guides/nics/features/bnxt.ini b/doc/guides/nics/features/bnxt.ini
index 0dcf07cc3..ae98de466 100644
--- a/doc/guides/nics/features/bnxt.ini
+++ b/doc/guides/nics/features/bnxt.ini
@@ -22,6 +22,7 @@ Extended stats       = Y
 FW version           = Y
 LED                  = Y
 EEPROM dump          = Y
+Rx interrupt         = Y
 Linux UIO            = Y
 Linux VFIO           = Y
 x86-64               = Y
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 81f66cadd..5490c2aaf 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -202,8 +202,16 @@ static int bnxt_init_chip(struct bnxt *bp)
 {
 	unsigned int i, rss_idx, fw_idx;
 	struct rte_eth_link new;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(bp->eth_dev);
+	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+	uint32_t intr_vector = 0;
+	uint32_t queue_id, base = BNXT_MISC_VEC_ID;
+	uint32_t vec = BNXT_MISC_VEC_ID;
 	int rc;
 
+	/* disable uio/vfio intr/eventfd mapping */
+	rte_intr_disable(intr_handle);
+
 	if (bp->eth_dev->data->mtu > ETHER_MTU) {
 		bp->eth_dev->data->dev_conf.rxmode.jumbo_frame = 1;
 		bp->flags |= BNXT_FLAG_JUMBO;
@@ -306,6 +314,48 @@ static int bnxt_init_chip(struct bnxt *bp)
 		goto err_out;
 	}
 
+	/* check and configure queue intr-vector mapping */
+	if ((rte_intr_cap_multiple(intr_handle) ||
+	     !RTE_ETH_DEV_SRIOV(bp->eth_dev).active) &&
+	    bp->eth_dev->data->dev_conf.intr_conf.rxq != 0) {
+		intr_vector = bp->eth_dev->data->nb_rx_queues;
+		RTE_LOG(INFO, PMD, "%s(): intr_vector = %d\n", __func__,
+			intr_vector);
+		if (intr_vector > bp->rx_cp_nr_rings) {
+			RTE_LOG(ERR, PMD, "At most %d intr queues supported",
+					bp->rx_cp_nr_rings);
+			return -ENOTSUP;
+		}
+		if (rte_intr_efd_enable(intr_handle, intr_vector))
+			return -1;
+	}
+
+	if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
+		intr_handle->intr_vec =
+			rte_zmalloc("intr_vec",
+				    bp->eth_dev->data->nb_rx_queues *
+				    sizeof(int), 0);
+		if (intr_handle->intr_vec == NULL) {
+			RTE_LOG(ERR, PMD, "Failed to allocate %d rx_queues"
+				" intr_vec", bp->eth_dev->data->nb_rx_queues);
+			return -ENOMEM;
+		}
+		RTE_LOG(DEBUG, PMD, "%s(): intr_handle->intr_vec = %p "
+			"intr_handle->nb_efd = %d intr_handle->max_intr = %d\n",
+			 __func__, intr_handle->intr_vec, intr_handle->nb_efd,
+			intr_handle->max_intr);
+	}
+
+	for (queue_id = 0; queue_id < bp->eth_dev->data->nb_rx_queues;
+	     queue_id++) {
+		intr_handle->intr_vec[queue_id] = vec;
+		if (vec < base + intr_handle->nb_efd - 1)
+			vec++;
+	}
+
+	/* enable uio/vfio intr/eventfd mapping */
+	rte_intr_enable(intr_handle);
+
 	rc = bnxt_get_hwrm_link_config(bp, &new);
 	if (rc) {
 		RTE_LOG(ERR, PMD, "HWRM Get link config failure rc: %x\n", rc);
@@ -421,6 +471,8 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
 	};
 	eth_dev->data->dev_conf.intr_conf.lsc = 1;
 
+	eth_dev->data->dev_conf.intr_conf.rxq = 1;
+
 	/* *INDENT-ON* */
 
 	/*
@@ -2009,6 +2061,8 @@ static const struct eth_dev_ops bnxt_dev_ops = {
 	.rx_queue_release = bnxt_rx_queue_release_op,
 	.tx_queue_setup = bnxt_tx_queue_setup_op,
 	.tx_queue_release = bnxt_tx_queue_release_op,
+	.rx_queue_intr_enable = bnxt_rx_queue_intr_enable_op,
+	.rx_queue_intr_disable = bnxt_rx_queue_intr_disable_op,
 	.reta_update = bnxt_reta_update_op,
 	.reta_query = bnxt_reta_query_op,
 	.rss_hash_update = bnxt_rss_hash_update_op,
diff --git a/drivers/net/bnxt/bnxt_irq.h b/drivers/net/bnxt/bnxt_irq.h
index e21bec568..4d2f7af9f 100644
--- a/drivers/net/bnxt/bnxt_irq.h
+++ b/drivers/net/bnxt/bnxt_irq.h
@@ -34,6 +34,9 @@
 #ifndef _BNXT_IRQ_H_
 #define _BNXT_IRQ_H_
 
+#define BNXT_MISC_VEC_ID               RTE_INTR_VEC_ZERO_OFFSET
+#define BNXT_RX_VEC_START              RTE_INTR_VEC_RXTX_OFFSET
+
 struct bnxt_irq {
 	rte_intr_callback_fn	handler;
 	unsigned int		vector;
diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
index 690a59987..0c4e0f6ec 100644
--- a/drivers/net/bnxt/bnxt_rxq.c
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -362,3 +362,41 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 out:
 	return rc;
 }
+
+int
+bnxt_rx_queue_intr_enable_op(struct rte_eth_dev *eth_dev, uint16_t queue_id)
+{
+	struct bnxt_rx_queue *rxq;
+	struct bnxt_cp_ring_info *cpr;
+	int rc = 0;
+
+	if (eth_dev->data->rx_queues) {
+		rxq = eth_dev->data->rx_queues[queue_id];
+		if (!rxq) {
+			rc = -EINVAL;
+			return rc;
+		}
+		cpr = rxq->cp_ring;
+		B_CP_DB_ARM(cpr);
+	}
+	return rc;
+}
+
+int
+bnxt_rx_queue_intr_disable_op(struct rte_eth_dev *eth_dev, uint16_t queue_id)
+{
+	struct bnxt_rx_queue *rxq;
+	struct bnxt_cp_ring_info *cpr;
+	int rc = 0;
+
+	if (eth_dev->data->rx_queues) {
+		rxq = eth_dev->data->rx_queues[queue_id];
+		if (!rxq) {
+			rc = -EINVAL;
+			return rc;
+		}
+		cpr = rxq->cp_ring;
+		B_CP_DB_DISARM(cpr);
+	}
+	return rc;
+}
diff --git a/drivers/net/bnxt/bnxt_rxq.h b/drivers/net/bnxt/bnxt_rxq.h
index 01aaa007f..a867a4b56 100644
--- a/drivers/net/bnxt/bnxt_rxq.h
+++ b/drivers/net/bnxt/bnxt_rxq.h
@@ -73,5 +73,9 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 			       const struct rte_eth_rxconf *rx_conf,
 			       struct rte_mempool *mp);
 void bnxt_free_rx_mbufs(struct bnxt *bp);
+int bnxt_rx_queue_intr_enable_op(struct rte_eth_dev *eth_dev,
+				 uint16_t queue_id);
+int bnxt_rx_queue_intr_disable_op(struct rte_eth_dev *eth_dev,
+				  uint16_t queue_id);
 
 #endif
-- 
2.13.5 (Apple Git-94)

  parent reply	other threads:[~2017-09-28 21:44 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28 21:43 [dpdk-dev] [PATCH v4 00/24] bnxt patchset Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 01/24] net/bnxt: fix HWRM_*() macros and locking Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 02/24] net/bnxt: use 64-bits of address for vlan_table Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 03/24] net/bnxt: fix an issue with group id calculation Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 04/24] net/bnxt: fix calculation of number of pools Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 05/24] net/bnxt: handle multi queue mode properly Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 06/24] net/bnxt: fix rx handling and buffer allocation logic Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 07/24] net/bnxt: fix an issue with broadcast traffic Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 08/24] net/bnxt: fix usage of ETH_VMDQ_* flags Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 09/24] net/bnxt: set checksum offload flags correctly Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 10/24] net/bnxt: update status of Rx IP/L4 CKSUM Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 11/24] net/bnxt: add support for xstats get by id Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 12/24] net/bnxt: fix config rss update Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 13/24] net/bnxt: set the hash_key_size Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 14/24] net/bnxt: add support for rx_queue_count Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 15/24] net/bnxt: add support for rx_descriptor_status Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 16/24] net/bnxt: add support for tx_descriptor_status Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 17/24] net/bnxt: add new HWRM structs to support flow filtering Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 18/24] net/bnxt: add support for flow filter ops Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 19/24] doc: update release notes Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 20/24] net/bnxt: fix per queue stats display in xstats Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 21/24] net/bnxt: prevent interrupt handler from accessing freed memory Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 22/24] net/bnxt: add dev_supported_ptypes_get dev_op Ajit Khaparde
2017-09-28 21:43 ` [dpdk-dev] [PATCH v4 23/24] net/bnxt: add support for get/set EEPROM Ajit Khaparde
2017-09-28 21:43 ` Ajit Khaparde [this message]
2017-10-02 21:28 ` [dpdk-dev] [PATCH v4 00/24] bnxt patchset 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=20170928214345.87655-25-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=somnath.kotur@broadcom.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).