DPDK patches and discussions
 help / color / mirror / Atom feed
From: <wanry@3snic.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@amd.com>, Renyong Wan <wanry@3snic.com>,
	Steven Song <steven.song@3snic.com>
Subject: [PATCH v5 18/32] net/sssnic: add Rx interrupt support
Date: Mon, 4 Sep 2023 12:56:44 +0800	[thread overview]
Message-ID: <20230904045658.238185-19-wanry@3snic.com> (raw)
In-Reply-To: <20230904045658.238185-1-wanry@3snic.com>

From: Renyong Wan <wanry@3snic.com>

Signed-off-by: Steven Song <steven.song@3snic.com>
Signed-off-by: Renyong Wan <wanry@3snic.com>
---
 doc/guides/nics/features/sssnic.ini   |   1 +
 drivers/net/sssnic/base/sssnic_hw.c   |  14 +++
 drivers/net/sssnic/base/sssnic_hw.h   |   2 +
 drivers/net/sssnic/sssnic_ethdev.c    |   2 +
 drivers/net/sssnic/sssnic_ethdev_rx.c | 135 ++++++++++++++++++++++++++
 drivers/net/sssnic/sssnic_ethdev_rx.h |   6 ++
 6 files changed, 160 insertions(+)

diff --git a/doc/guides/nics/features/sssnic.ini b/doc/guides/nics/features/sssnic.ini
index b75c68cb33..e3b8166629 100644
--- a/doc/guides/nics/features/sssnic.ini
+++ b/doc/guides/nics/features/sssnic.ini
@@ -7,6 +7,7 @@
 Link status          = Y
 Link status event    = Y
 Queue start/stop     = Y
+Rx interrupt         = Y
 Unicast MAC filter   = Y
 Multicast MAC filter = Y
 Linux                = Y
diff --git a/drivers/net/sssnic/base/sssnic_hw.c b/drivers/net/sssnic/base/sssnic_hw.c
index 82eb4ea295..651a0aa7ef 100644
--- a/drivers/net/sssnic/base/sssnic_hw.c
+++ b/drivers/net/sssnic/base/sssnic_hw.c
@@ -145,6 +145,20 @@ sssnic_msix_resend_disable(struct sssnic_hw *hw, uint16_t msix_id)
 	sssnic_cfg_reg_write(hw, SSSNIC_MSIX_CTRL_REG, reg.u32);
 }
 
+void
+sssnic_msix_auto_mask_set(struct sssnic_hw *hw, uint16_t msix_id, int state)
+{
+	struct sssnic_msix_ctrl_reg reg;
+
+	reg.u32 = 0;
+	if (state == SSSNIC_MSIX_ENABLE)
+		reg.auto_msk_set = 1;
+	else
+		reg.auto_msk_clr = 1;
+	reg.msxi_idx = msix_id;
+	sssnic_cfg_reg_write(hw, SSSNIC_MSIX_CTRL_REG, reg.u32);
+}
+
 static void
 sssnic_pf_status_set(struct sssnic_hw *hw, enum sssnic_pf_status status)
 {
diff --git a/drivers/net/sssnic/base/sssnic_hw.h b/drivers/net/sssnic/base/sssnic_hw.h
index e25f5595e6..4820212543 100644
--- a/drivers/net/sssnic/base/sssnic_hw.h
+++ b/drivers/net/sssnic/base/sssnic_hw.h
@@ -100,6 +100,8 @@ int sssnic_hw_init(struct sssnic_hw *hw);
 void sssnic_hw_shutdown(struct sssnic_hw *hw);
 void sssnic_msix_state_set(struct sssnic_hw *hw, uint16_t msix_id, int state);
 void sssnic_msix_resend_disable(struct sssnic_hw *hw, uint16_t msix_id);
+void sssnic_msix_auto_mask_set(struct sssnic_hw *hw, uint16_t msix_id,
+	int state);
 int sssnic_link_event_callback_register(struct sssnic_hw *hw,
 	sssnic_link_event_cb_t *cb, void *priv);
 void sssnic_link_event_callback_unregister(struct sssnic_hw *hw);
diff --git a/drivers/net/sssnic/sssnic_ethdev.c b/drivers/net/sssnic/sssnic_ethdev.c
index 8a18f25889..35bb26a0b1 100644
--- a/drivers/net/sssnic/sssnic_ethdev.c
+++ b/drivers/net/sssnic/sssnic_ethdev.c
@@ -362,6 +362,8 @@ static const struct eth_dev_ops sssnic_ethdev_ops = {
 	.rx_queue_stop = sssnic_ethdev_rx_queue_stop,
 	.tx_queue_start = sssnic_ethdev_tx_queue_start,
 	.tx_queue_stop = sssnic_ethdev_tx_queue_stop,
+	.rx_queue_intr_enable = sssnic_ethdev_rx_queue_intr_enable,
+	.rx_queue_intr_disable = sssnic_ethdev_rx_queue_intr_disable,
 };
 
 static int
diff --git a/drivers/net/sssnic/sssnic_ethdev_rx.c b/drivers/net/sssnic/sssnic_ethdev_rx.c
index d8429e734d..9c1b2f20d1 100644
--- a/drivers/net/sssnic/sssnic_ethdev_rx.c
+++ b/drivers/net/sssnic/sssnic_ethdev_rx.c
@@ -136,6 +136,12 @@ static const uint16_t sssnic_ethdev_rx_buf_size_tbl[] = { 32, 64, 96, 128, 192,
 /* Doorbell offset 8192 */
 #define SSSNIC_ETHDEV_RXQ_DB_OFFSET 0x2000
 
+#define SSSNIC_ETHDEV_RX_MSIX_ID_START 1
+#define SSSNIC_ETHDEV_RX_MSIX_ID_INVAL 0
+#define SSSNIC_ETHDEV_RX_MSIX_PENDING_LIMIT 2
+#define SSSNIC_ETHDEV_RX_MSIX_COALESCING_TIMER 2
+#define SSSNIC_ETHDEV_RX_MSIX_RESNEDING_TIMER 7
+
 struct sssnic_ethdev_rxq_doorbell {
 	union {
 		uint64_t u64;
@@ -750,3 +756,132 @@ sssnic_ethdev_rx_queue_all_stop(struct rte_eth_dev *ethdev)
 
 	return 0;
 }
+
+static int
+sssinc_ethdev_rxq_intr_attr_init(struct sssnic_ethdev_rxq *rxq)
+{
+	int ret;
+	struct sssnic_hw *hw = SSSNIC_ETHDEV_TO_HW(rxq->ethdev);
+	struct sssnic_msix_attr attr;
+
+	attr.lli_set = 0;
+	attr.coalescing_set = 1;
+	attr.pending_limit = SSSNIC_ETHDEV_RX_MSIX_PENDING_LIMIT;
+	attr.coalescing_timer = SSSNIC_ETHDEV_RX_MSIX_COALESCING_TIMER;
+	attr.resend_timer = SSSNIC_ETHDEV_RX_MSIX_RESNEDING_TIMER;
+
+	ret = sssnic_msix_attr_set(hw, rxq->intr.msix_id, &attr);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to set msxi attributes");
+		return ret;
+	}
+
+	return 0;
+}
+
+int
+sssnic_ethdev_rx_queue_intr_enable(struct rte_eth_dev *ethdev, uint16_t qid)
+{
+	struct sssnic_ethdev_rxq *rxq = ethdev->data->rx_queues[qid];
+	struct sssnic_hw *hw = SSSNIC_ETHDEV_TO_HW(ethdev);
+
+	if (rxq->intr.enable)
+		return 0;
+
+	sssnic_msix_auto_mask_set(hw, rxq->intr.msix_id, SSSNIC_MSIX_ENABLE);
+	sssnic_msix_state_set(hw, rxq->intr.msix_id, SSSNIC_MSIX_ENABLE);
+	rxq->intr.enable = 1;
+
+	return 0;
+}
+
+int
+sssnic_ethdev_rx_queue_intr_disable(struct rte_eth_dev *ethdev, uint16_t qid)
+{
+	struct sssnic_ethdev_rxq *rxq = ethdev->data->rx_queues[qid];
+	struct sssnic_hw *hw = SSSNIC_ETHDEV_TO_HW(ethdev);
+
+	if (!rxq->intr.enable)
+		return 0;
+
+	sssnic_msix_auto_mask_set(hw, rxq->intr.msix_id, SSSNIC_MSIX_DISABLE);
+	sssnic_msix_state_set(hw, rxq->intr.msix_id, SSSNIC_MSIX_DISABLE);
+	sssnic_msix_resend_disable(hw, rxq->intr.msix_id);
+	rxq->intr.enable = 0;
+
+	return 0;
+}
+
+int
+sssnic_ethdev_rx_intr_init(struct rte_eth_dev *ethdev)
+{
+	struct rte_intr_handle *intr_handle;
+	struct sssnic_ethdev_rxq *rxq;
+	uint32_t nb_rxq, i;
+	int vec;
+	int ret;
+
+	if (!ethdev->data->dev_conf.intr_conf.rxq)
+		return 0;
+
+	intr_handle = ethdev->intr_handle;
+
+	if (!rte_intr_cap_multiple(intr_handle)) {
+		PMD_DRV_LOG(ERR,
+			"Rx interrupts require MSI-X interrupts (vfio-pci driver)\n");
+		return -ENOTSUP;
+	}
+
+	rte_intr_efd_disable(intr_handle);
+
+	nb_rxq = ethdev->data->nb_rx_queues;
+
+	ret = rte_intr_efd_enable(intr_handle, nb_rxq);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to enable intr efd");
+		return ret;
+	}
+
+	ret = rte_intr_vec_list_alloc(intr_handle, NULL, nb_rxq);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to allocate rx intr vec list");
+		rte_intr_efd_disable(intr_handle);
+		return ret;
+	}
+
+	for (i = 0; i < nb_rxq; i++) {
+		vec = (int)(i + SSSNIC_ETHDEV_RX_MSIX_ID_START);
+		rte_intr_vec_list_index_set(intr_handle, i, vec);
+		rxq = ethdev->data->rx_queues[i];
+		rxq->intr.msix_id = vec;
+
+		ret = sssinc_ethdev_rxq_intr_attr_init(rxq);
+		if (ret != 0) {
+			PMD_DRV_LOG(ERR,
+				"Failed to initialize rxq %u (port %u) msix attribute.",
+				rxq->qid, rxq->port);
+			goto intr_attr_init_fail;
+		}
+	}
+
+	return 0;
+
+intr_attr_init_fail:
+	rte_intr_vec_list_free(intr_handle);
+	rte_intr_efd_disable(intr_handle);
+
+	return ret;
+}
+
+void
+sssnic_ethdev_rx_intr_shutdown(struct rte_eth_dev *ethdev)
+{
+	struct rte_intr_handle *intr_handle = ethdev->intr_handle;
+	uint16_t i;
+
+	for (i = 0; i < ethdev->data->nb_rx_queues; i++)
+		sssnic_ethdev_rx_queue_intr_disable(ethdev, i);
+
+	rte_intr_efd_disable(intr_handle);
+	rte_intr_vec_list_free(intr_handle);
+}
diff --git a/drivers/net/sssnic/sssnic_ethdev_rx.h b/drivers/net/sssnic/sssnic_ethdev_rx.h
index c6ddc366d5..77a116f4a5 100644
--- a/drivers/net/sssnic/sssnic_ethdev_rx.h
+++ b/drivers/net/sssnic/sssnic_ethdev_rx.h
@@ -24,5 +24,11 @@ int sssnic_ethdev_rx_queue_start(struct rte_eth_dev *ethdev, uint16_t queue_id);
 int sssnic_ethdev_rx_queue_stop(struct rte_eth_dev *ethdev, uint16_t queue_id);
 int sssnic_ethdev_rx_queue_all_start(struct rte_eth_dev *ethdev);
 int sssnic_ethdev_rx_queue_all_stop(struct rte_eth_dev *ethdev);
+int sssnic_ethdev_rx_queue_intr_enable(struct rte_eth_dev *ethdev,
+	uint16_t qid);
+int sssnic_ethdev_rx_queue_intr_disable(struct rte_eth_dev *ethdev,
+	uint16_t qid);
+int sssnic_ethdev_rx_intr_init(struct rte_eth_dev *ethdev);
+void sssnic_ethdev_rx_intr_shutdown(struct rte_eth_dev *ethdev);
 
 #endif
-- 
2.27.0


  parent reply	other threads:[~2023-09-04  4:59 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04  4:56 [PATCH v5 00/32] Introduce sssnic PMD for 3SNIC's 9x0 serials Ethernet adapters wanry
2023-09-04  4:56 ` [PATCH v5 01/32] net/sssnic: add build and doc infrastructure wanry
2023-09-26 13:06   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 02/32] net/sssnic: add log type and log macros wanry
2023-09-04  4:56 ` [PATCH v5 03/32] net/sssnic: support probe and remove wanry
2023-09-18 16:08   ` Stephen Hemminger
2023-09-19  2:00     ` Renyong Wan
2023-09-04  4:56 ` [PATCH v5 04/32] net/sssnic: initialize hardware base wanry
2023-09-18  2:28   ` Stephen Hemminger
2023-09-18  4:47     ` Renyong Wan
2023-09-04  4:56 ` [PATCH v5 05/32] net/sssnic: add event queue wanry
2023-09-04  4:56 ` [PATCH v5 06/32] net/sssnic/base: add message definition and utility wanry
2023-09-18  2:31   ` Stephen Hemminger
2023-09-18  5:08     ` Renyong Wan
2023-09-04  4:56 ` [PATCH v5 07/32] net/sssnic/base: add mailbox support wanry
2023-09-18  2:32   ` Stephen Hemminger
2023-09-18  5:10     ` Renyong Wan
2023-09-26 13:13   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 08/32] net/sssnic/base: add work queue wanry
2023-09-18  2:33   ` Stephen Hemminger
2023-09-18  5:11     ` Renyong Wan
2023-09-04  4:56 ` [PATCH v5 09/32] net/sssnic/base: add control queue wanry
2023-09-18  2:36   ` Stephen Hemminger
2023-09-18  5:22     ` Renyong Wan
2023-09-04  4:56 ` [PATCH v5 10/32] net/sssnic: add dev configure and infos get wanry
2023-09-04  4:56 ` [PATCH v5 11/32] net/sssnic: add dev MAC ops wanry
2023-09-26 13:07   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 12/32] net/sssnic: support dev link status wanry
2023-09-04  4:56 ` [PATCH v5 13/32] net/sssnic: support link status event wanry
2023-09-26 13:08   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 14/32] net/sssnic: support Rx queue setup and release wanry
2023-09-04  4:56 ` [PATCH v5 15/32] net/sssnic: support Tx " wanry
2023-09-04  4:56 ` [PATCH v5 16/32] net/sssnic: support Rx queue start and stop wanry
2023-09-04  4:56 ` [PATCH v5 17/32] net/sssnic: support Tx " wanry
2023-09-04  4:56 ` wanry [this message]
2023-09-04  4:56 ` [PATCH v5 19/32] net/sssnic: support dev " wanry
2023-09-26 13:09   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 20/32] net/sssnic: support dev close and reset wanry
2023-09-26 13:09   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 21/32] net/sssnic: add allmulticast and promiscuous ops wanry
2023-09-04  4:56 ` [PATCH v5 22/32] net/sssnic: add basic and extended stats ops wanry
2023-09-04  4:56 ` [PATCH v5 23/32] net/sssnic: support Rx packet burst wanry
2023-09-04  4:56 ` [PATCH v5 24/32] net/sssnic: support Tx " wanry
2023-09-26 13:10   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 25/32] net/sssnic: add RSS support wanry
2023-09-04  4:56 ` [PATCH v5 26/32] net/sssnic: support dev MTU set wanry
2023-09-04  4:56 ` [PATCH v5 27/32] net/sssnic: support dev queue info get wanry
2023-09-04  4:56 ` [PATCH v5 28/32] net/sssnic: support dev firmware version get wanry
2023-09-04  4:56 ` [PATCH v5 29/32] net/sssnic: add dev flow control ops wanry
2023-09-26 13:12   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 30/32] net/sssnic: support VLAN offload and filter wanry
2023-09-04  4:56 ` [PATCH v5 31/32] net/sssnic: add generic flow ops wanry
2023-09-04  4:56 ` [PATCH v5 32/32] net/sssnic: add VF dev support wanry
2023-09-26 13:11   ` Ferruh Yigit
2023-09-18  2:37 ` [PATCH v5 00/32] Introduce sssnic PMD for 3SNIC's 9x0 serials Ethernet adapters Stephen Hemminger
2023-09-18  3:23   ` Renyong Wan
2023-09-19  3:19 ` Stephen Hemminger
2023-09-19  5:18   ` Renyong Wan
2023-09-19  3:21 ` Stephen Hemminger
2023-09-19  5:18   ` Renyong Wan
2023-09-19  3:23 ` Stephen Hemminger
2023-09-19  5:19   ` Renyong Wan
2023-09-19 15:24 ` Stephen Hemminger
2023-09-26 13:13 ` Ferruh Yigit
2024-03-29 11:32   ` Ferruh Yigit
2024-07-31 17:32     ` Thomas Monjalon

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=20230904045658.238185-19-wanry@3snic.com \
    --to=wanry@3snic.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=steven.song@3snic.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).