[14/32] net/ngbe: support Rx interrupt

Message ID 20210908083758.312055-15-jiawenwu@trustnetic.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series net/ngbe: add many features |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Jiawen Wu Sept. 8, 2021, 8:37 a.m. UTC
  Support Rx queue interrupt.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 doc/guides/nics/features/ngbe.ini |  1 +
 doc/guides/nics/ngbe.rst          |  1 +
 drivers/net/ngbe/ngbe_ethdev.c    | 35 +++++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+)
  

Comments

Ferruh Yigit Sept. 15, 2021, 4:53 p.m. UTC | #1
On 9/8/2021 9:37 AM, Jiawen Wu wrote:
> Support Rx queue interrupt.
> 
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> ---
>  doc/guides/nics/features/ngbe.ini |  1 +
>  doc/guides/nics/ngbe.rst          |  1 +
>  drivers/net/ngbe/ngbe_ethdev.c    | 35 +++++++++++++++++++++++++++++++
>  3 files changed, 37 insertions(+)
> 
> diff --git a/doc/guides/nics/features/ngbe.ini b/doc/guides/nics/features/ngbe.ini
> index 1006c3935b..d14469eb43 100644
> --- a/doc/guides/nics/features/ngbe.ini
> +++ b/doc/guides/nics/features/ngbe.ini
> @@ -7,6 +7,7 @@
>  Speed capabilities   = Y
>  Link status          = Y
>  Link status event    = Y
> +Rx interrupt         = Y

This also requires configuring Rx interrupts if user 'dev_conf.intr_conf.rxq'
config requests it.

Is an application can request and use Rx interrupts with current status of the
driver? Did you test it?
  
Jiawen Wu Oct. 14, 2021, 10:11 a.m. UTC | #2
On September 16, 2021 12:54 AM, Ferruh Yigit wrote:
> On 9/8/2021 9:37 AM, Jiawen Wu wrote:
> > Support Rx queue interrupt.
> >
> > Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> > ---
> >  doc/guides/nics/features/ngbe.ini |  1 +
> >  doc/guides/nics/ngbe.rst          |  1 +
> >  drivers/net/ngbe/ngbe_ethdev.c    | 35
> +++++++++++++++++++++++++++++++
> >  3 files changed, 37 insertions(+)
> >
> > diff --git a/doc/guides/nics/features/ngbe.ini
> > b/doc/guides/nics/features/ngbe.ini
> > index 1006c3935b..d14469eb43 100644
> > --- a/doc/guides/nics/features/ngbe.ini
> > +++ b/doc/guides/nics/features/ngbe.ini
> > @@ -7,6 +7,7 @@
> >  Speed capabilities   = Y
> >  Link status          = Y
> >  Link status event    = Y
> > +Rx interrupt         = Y
> 
> This also requires configuring Rx interrupts if user 'dev_conf.intr_conf.rxq'
> config requests it.
> 
> Is an application can request and use Rx interrupts with current status of the
> driver? Did you test it?

I can't find the corresponding test case in examples, could you give me a suggestion?
I just configured almost the same registers as the kernel driver before.
But now I'll drop this feature first, and wait for a successful test result.
  

Patch

diff --git a/doc/guides/nics/features/ngbe.ini b/doc/guides/nics/features/ngbe.ini
index 1006c3935b..d14469eb43 100644
--- a/doc/guides/nics/features/ngbe.ini
+++ b/doc/guides/nics/features/ngbe.ini
@@ -7,6 +7,7 @@ 
 Speed capabilities   = Y
 Link status          = Y
 Link status event    = Y
+Rx interrupt         = Y
 Queue start/stop     = Y
 MTU update           = Y
 Jumbo frame          = Y
diff --git a/doc/guides/nics/ngbe.rst b/doc/guides/nics/ngbe.rst
index 50a6e85c49..2783c4a3c4 100644
--- a/doc/guides/nics/ngbe.rst
+++ b/doc/guides/nics/ngbe.rst
@@ -20,6 +20,7 @@  Features
 - Port hardware statistics
 - Jumbo frames
 - Link state information
+- Interrupt mode for RX
 - Scattered and gather for TX and RX
 - FW version
 
diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c
index 9caca55df3..52642161b7 100644
--- a/drivers/net/ngbe/ngbe_ethdev.c
+++ b/drivers/net/ngbe/ngbe_ethdev.c
@@ -2095,6 +2095,39 @@  ngbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 	return 0;
 }
 
+static int
+ngbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
+{
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+	uint32_t mask;
+	struct ngbe_hw *hw = ngbe_dev_hw(dev);
+
+	if (queue_id < 32) {
+		mask = rd32(hw, NGBE_IMS(0));
+		mask &= (1 << queue_id);
+		wr32(hw, NGBE_IMS(0), mask);
+	}
+	rte_intr_enable(intr_handle);
+
+	return 0;
+}
+
+static int
+ngbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
+{
+	uint32_t mask;
+	struct ngbe_hw *hw = ngbe_dev_hw(dev);
+
+	if (queue_id < 32) {
+		mask = rd32(hw, NGBE_IMS(0));
+		mask &= ~(1 << queue_id);
+		wr32(hw, NGBE_IMS(0), mask);
+	}
+
+	return 0;
+}
+
 /**
  * Set the IVAR registers, mapping interrupt causes to vectors
  * @param hw
@@ -2215,6 +2248,8 @@  static const struct eth_dev_ops ngbe_eth_dev_ops = {
 	.tx_queue_start	            = ngbe_dev_tx_queue_start,
 	.tx_queue_stop              = ngbe_dev_tx_queue_stop,
 	.rx_queue_setup             = ngbe_dev_rx_queue_setup,
+	.rx_queue_intr_enable       = ngbe_dev_rx_queue_intr_enable,
+	.rx_queue_intr_disable      = ngbe_dev_rx_queue_intr_disable,
 	.rx_queue_release           = ngbe_dev_rx_queue_release,
 	.tx_queue_setup             = ngbe_dev_tx_queue_setup,
 	.tx_queue_release           = ngbe_dev_tx_queue_release,