* [PATCH net-next 0/2] Link NAPI instances to queues and IRQs
@ 2025-06-10 10:33 Justin Lai
2025-06-10 10:33 ` [PATCH net-next 1/2] rtase: Link IRQs to NAPI instances Justin Lai
2025-06-10 10:33 ` [PATCH net-next 2/2] rtase: Link queues " Justin Lai
0 siblings, 2 replies; 7+ messages in thread
From: Justin Lai @ 2025-06-10 10:33 UTC (permalink / raw)
To: kuba
Cc: davem, edumazet, pabeni, andrew+netdev, linux-kernel, netdev,
horms, jdamato, pkshih, larry.chiu, Justin Lai
This patch series introduces netdev-genl support to rtase, enabling
user-space applications to query the relationships between IRQs,
queues, and NAPI instances.
Justin Lai (2):
rtase: Link IRQs to NAPI instances
rtase: Link queues to NAPI instances
drivers/net/ethernet/realtek/rtase/rtase.h | 4 ++
.../net/ethernet/realtek/rtase/rtase_main.c | 53 ++++++++++++++++---
2 files changed, 49 insertions(+), 8 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next 1/2] rtase: Link IRQs to NAPI instances
2025-06-10 10:33 [PATCH net-next 0/2] Link NAPI instances to queues and IRQs Justin Lai
@ 2025-06-10 10:33 ` Justin Lai
2025-06-11 13:51 ` Joe Damato
2025-06-10 10:33 ` [PATCH net-next 2/2] rtase: Link queues " Justin Lai
1 sibling, 1 reply; 7+ messages in thread
From: Justin Lai @ 2025-06-10 10:33 UTC (permalink / raw)
To: kuba
Cc: davem, edumazet, pabeni, andrew+netdev, linux-kernel, netdev,
horms, jdamato, pkshih, larry.chiu, Justin Lai
Link IRQs to NAPI instances with netif_napi_set_irq. This
information can be queried with the netdev-genl API.
Signed-off-by: Justin Lai <justinlai0215@realtek.com>
---
.../net/ethernet/realtek/rtase/rtase_main.c | 20 +++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c
index 4d37217e9a14..a88af868da8c 100644
--- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
+++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
@@ -1871,6 +1871,18 @@ static void rtase_init_netdev_ops(struct net_device *dev)
dev->ethtool_ops = &rtase_ethtool_ops;
}
+static void rtase_init_napi(struct rtase_private *tp)
+{
+ u16 i;
+
+ for (i = 0; i < tp->int_nums; i++) {
+ netif_napi_add(tp->dev, &tp->int_vector[i].napi,
+ tp->int_vector[i].poll);
+ netif_napi_set_irq(&tp->int_vector[i].napi,
+ tp->int_vector[i].irq);
+ }
+}
+
static void rtase_reset_interrupt(struct pci_dev *pdev,
const struct rtase_private *tp)
{
@@ -1956,9 +1968,6 @@ static void rtase_init_int_vector(struct rtase_private *tp)
memset(tp->int_vector[0].name, 0x0, sizeof(tp->int_vector[0].name));
INIT_LIST_HEAD(&tp->int_vector[0].ring_list);
- netif_napi_add(tp->dev, &tp->int_vector[0].napi,
- tp->int_vector[0].poll);
-
/* interrupt vector 1 ~ 3 */
for (i = 1; i < tp->int_nums; i++) {
tp->int_vector[i].tp = tp;
@@ -1972,9 +1981,6 @@ static void rtase_init_int_vector(struct rtase_private *tp)
memset(tp->int_vector[i].name, 0x0,
sizeof(tp->int_vector[0].name));
INIT_LIST_HEAD(&tp->int_vector[i].ring_list);
-
- netif_napi_add(tp->dev, &tp->int_vector[i].napi,
- tp->int_vector[i].poll);
}
}
@@ -2206,6 +2212,8 @@ static int rtase_init_one(struct pci_dev *pdev,
goto err_out_del_napi;
}
+ rtase_init_napi(tp);
+
rtase_init_netdev_ops(dev);
dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next 2/2] rtase: Link queues to NAPI instances
2025-06-10 10:33 [PATCH net-next 0/2] Link NAPI instances to queues and IRQs Justin Lai
2025-06-10 10:33 ` [PATCH net-next 1/2] rtase: Link IRQs to NAPI instances Justin Lai
@ 2025-06-10 10:33 ` Justin Lai
2025-06-11 14:04 ` Joe Damato
1 sibling, 1 reply; 7+ messages in thread
From: Justin Lai @ 2025-06-10 10:33 UTC (permalink / raw)
To: kuba
Cc: davem, edumazet, pabeni, andrew+netdev, linux-kernel, netdev,
horms, jdamato, pkshih, larry.chiu, Justin Lai
Link queues to NAPI instances with netif_queue_set_napi. This
information can be queried with the netdev-genl API.
Signed-off-by: Justin Lai <justinlai0215@realtek.com>
---
drivers/net/ethernet/realtek/rtase/rtase.h | 4 +++
.../net/ethernet/realtek/rtase/rtase_main.c | 33 +++++++++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/realtek/rtase/rtase.h b/drivers/net/ethernet/realtek/rtase/rtase.h
index 498cfe4d0cac..be98f4de46c4 100644
--- a/drivers/net/ethernet/realtek/rtase/rtase.h
+++ b/drivers/net/ethernet/realtek/rtase/rtase.h
@@ -39,6 +39,9 @@
#define RTASE_FUNC_RXQ_NUM 1
#define RTASE_INTERRUPT_NUM 1
+#define RTASE_TX_RING 0
+#define RTASE_RX_RING 1
+
#define RTASE_MITI_TIME_COUNT_MASK GENMASK(3, 0)
#define RTASE_MITI_TIME_UNIT_MASK GENMASK(7, 4)
#define RTASE_MITI_DEFAULT_TIME 128
@@ -288,6 +291,7 @@ struct rtase_ring {
u32 cur_idx;
u32 dirty_idx;
u16 index;
+ u8 ring_type;
struct sk_buff *skbuff[RTASE_NUM_DESC];
void *data_buf[RTASE_NUM_DESC];
diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c
index a88af868da8c..ef3ada91d555 100644
--- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
+++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
@@ -326,6 +326,7 @@ static void rtase_tx_desc_init(struct rtase_private *tp, u16 idx)
ring->cur_idx = 0;
ring->dirty_idx = 0;
ring->index = idx;
+ ring->ring_type = RTASE_TX_RING;
ring->alloc_fail = 0;
for (i = 0; i < RTASE_NUM_DESC; i++) {
@@ -345,6 +346,10 @@ static void rtase_tx_desc_init(struct rtase_private *tp, u16 idx)
ring->ivec = &tp->int_vector[0];
list_add_tail(&ring->ring_entry, &tp->int_vector[0].ring_list);
}
+
+ netif_queue_set_napi(tp->dev, ring->index,
+ NETDEV_QUEUE_TYPE_TX,
+ &ring->ivec->napi);
}
static void rtase_map_to_asic(union rtase_rx_desc *desc, dma_addr_t mapping,
@@ -590,6 +595,7 @@ static void rtase_rx_desc_init(struct rtase_private *tp, u16 idx)
ring->cur_idx = 0;
ring->dirty_idx = 0;
ring->index = idx;
+ ring->ring_type = RTASE_RX_RING;
ring->alloc_fail = 0;
for (i = 0; i < RTASE_NUM_DESC; i++)
@@ -597,6 +603,9 @@ static void rtase_rx_desc_init(struct rtase_private *tp, u16 idx)
ring->ring_handler = rx_handler;
ring->ivec = &tp->int_vector[idx];
+ netif_queue_set_napi(tp->dev, ring->index,
+ NETDEV_QUEUE_TYPE_RX,
+ &ring->ivec->napi);
list_add_tail(&ring->ring_entry, &tp->int_vector[idx].ring_list);
}
@@ -1161,8 +1170,18 @@ static void rtase_down(struct net_device *dev)
ivec = &tp->int_vector[i];
napi_disable(&ivec->napi);
list_for_each_entry_safe(ring, tmp, &ivec->ring_list,
- ring_entry)
+ ring_entry) {
+ if (ring->ring_type == RTASE_TX_RING)
+ netif_queue_set_napi(tp->dev, ring->index,
+ NETDEV_QUEUE_TYPE_TX,
+ NULL);
+ else
+ netif_queue_set_napi(tp->dev, ring->index,
+ NETDEV_QUEUE_TYPE_RX,
+ NULL);
+
list_del(&ring->ring_entry);
+ }
}
netif_tx_disable(dev);
@@ -1518,8 +1537,18 @@ static void rtase_sw_reset(struct net_device *dev)
for (i = 0; i < tp->int_nums; i++) {
ivec = &tp->int_vector[i];
list_for_each_entry_safe(ring, tmp, &ivec->ring_list,
- ring_entry)
+ ring_entry) {
+ if (ring->ring_type == RTASE_TX_RING)
+ netif_queue_set_napi(tp->dev, ring->index,
+ NETDEV_QUEUE_TYPE_TX,
+ NULL);
+ else
+ netif_queue_set_napi(tp->dev, ring->index,
+ NETDEV_QUEUE_TYPE_RX,
+ NULL);
+
list_del(&ring->ring_entry);
+ }
}
ret = rtase_init_ring(dev);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 1/2] rtase: Link IRQs to NAPI instances
2025-06-10 10:33 ` [PATCH net-next 1/2] rtase: Link IRQs to NAPI instances Justin Lai
@ 2025-06-11 13:51 ` Joe Damato
2025-06-12 3:13 ` Justin Lai
0 siblings, 1 reply; 7+ messages in thread
From: Joe Damato @ 2025-06-11 13:51 UTC (permalink / raw)
To: Justin Lai
Cc: kuba, davem, edumazet, pabeni, andrew+netdev, linux-kernel,
netdev, horms, jdamato, pkshih, larry.chiu
On Tue, Jun 10, 2025 at 06:33:33PM +0800, Justin Lai wrote:
> Link IRQs to NAPI instances with netif_napi_set_irq. This
> information can be queried with the netdev-genl API.
>
> Signed-off-by: Justin Lai <justinlai0215@realtek.com>
> ---
> .../net/ethernet/realtek/rtase/rtase_main.c | 20 +++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> index 4d37217e9a14..a88af868da8c 100644
> --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> @@ -1871,6 +1871,18 @@ static void rtase_init_netdev_ops(struct net_device *dev)
> dev->ethtool_ops = &rtase_ethtool_ops;
> }
>
> +static void rtase_init_napi(struct rtase_private *tp)
> +{
> + u16 i;
> +
> + for (i = 0; i < tp->int_nums; i++) {
> + netif_napi_add(tp->dev, &tp->int_vector[i].napi,
> + tp->int_vector[i].poll);
Maybe netif_napi_add_config can be used either in this patch or in an added
3rd patch to this series to support persitent NAPI config?
Otherwise:
Reviewed-by: Joe Damato <joe@dama.to>
> + netif_napi_set_irq(&tp->int_vector[i].napi,
> + tp->int_vector[i].irq);
> + }
> +}
> +
> static void rtase_reset_interrupt(struct pci_dev *pdev,
> const struct rtase_private *tp)
> {
> @@ -1956,9 +1968,6 @@ static void rtase_init_int_vector(struct rtase_private *tp)
> memset(tp->int_vector[0].name, 0x0, sizeof(tp->int_vector[0].name));
> INIT_LIST_HEAD(&tp->int_vector[0].ring_list);
>
> - netif_napi_add(tp->dev, &tp->int_vector[0].napi,
> - tp->int_vector[0].poll);
> -
> /* interrupt vector 1 ~ 3 */
> for (i = 1; i < tp->int_nums; i++) {
> tp->int_vector[i].tp = tp;
> @@ -1972,9 +1981,6 @@ static void rtase_init_int_vector(struct rtase_private *tp)
> memset(tp->int_vector[i].name, 0x0,
> sizeof(tp->int_vector[0].name));
> INIT_LIST_HEAD(&tp->int_vector[i].ring_list);
> -
> - netif_napi_add(tp->dev, &tp->int_vector[i].napi,
> - tp->int_vector[i].poll);
> }
> }
>
> @@ -2206,6 +2212,8 @@ static int rtase_init_one(struct pci_dev *pdev,
> goto err_out_del_napi;
> }
>
> + rtase_init_napi(tp);
> +
> rtase_init_netdev_ops(dev);
>
> dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
> --
> 2.34.1
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 2/2] rtase: Link queues to NAPI instances
2025-06-10 10:33 ` [PATCH net-next 2/2] rtase: Link queues " Justin Lai
@ 2025-06-11 14:04 ` Joe Damato
2025-06-12 3:28 ` Justin Lai
0 siblings, 1 reply; 7+ messages in thread
From: Joe Damato @ 2025-06-11 14:04 UTC (permalink / raw)
To: Justin Lai
Cc: kuba, davem, edumazet, pabeni, andrew+netdev, linux-kernel,
netdev, horms, jdamato, pkshih, larry.chiu
On Tue, Jun 10, 2025 at 06:33:34PM +0800, Justin Lai wrote:
> Link queues to NAPI instances with netif_queue_set_napi. This
> information can be queried with the netdev-genl API.
>
> Signed-off-by: Justin Lai <justinlai0215@realtek.com>
> ---
> drivers/net/ethernet/realtek/rtase/rtase.h | 4 +++
> .../net/ethernet/realtek/rtase/rtase_main.c | 33 +++++++++++++++++--
> 2 files changed, 35 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/realtek/rtase/rtase.h b/drivers/net/ethernet/realtek/rtase/rtase.h
> index 498cfe4d0cac..be98f4de46c4 100644
> --- a/drivers/net/ethernet/realtek/rtase/rtase.h
> +++ b/drivers/net/ethernet/realtek/rtase/rtase.h
> @@ -39,6 +39,9 @@
> #define RTASE_FUNC_RXQ_NUM 1
> #define RTASE_INTERRUPT_NUM 1
>
> +#define RTASE_TX_RING 0
> +#define RTASE_RX_RING 1
> +
> #define RTASE_MITI_TIME_COUNT_MASK GENMASK(3, 0)
> #define RTASE_MITI_TIME_UNIT_MASK GENMASK(7, 4)
> #define RTASE_MITI_DEFAULT_TIME 128
> @@ -288,6 +291,7 @@ struct rtase_ring {
> u32 cur_idx;
> u32 dirty_idx;
> u16 index;
> + u8 ring_type;
Two questions:
1. why not use enum netdev_queue_type instead of making driver specific
values that are the opposite of the existing enum values ?
If you used the existing enum, you could omit the if below (see below), as
well?
2. is "ring" in the name redundant? maybe just "type"? asking because below
the code becomes "ring->ring_type" and maybe "ring->type" is better?
> struct sk_buff *skbuff[RTASE_NUM_DESC];
> void *data_buf[RTASE_NUM_DESC];
> diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> index a88af868da8c..ef3ada91d555 100644
> --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> @@ -326,6 +326,7 @@ static void rtase_tx_desc_init(struct rtase_private *tp, u16 idx)
> ring->cur_idx = 0;
> ring->dirty_idx = 0;
> ring->index = idx;
> + ring->ring_type = RTASE_TX_RING;
> ring->alloc_fail = 0;
>
> for (i = 0; i < RTASE_NUM_DESC; i++) {
> @@ -345,6 +346,10 @@ static void rtase_tx_desc_init(struct rtase_private *tp, u16 idx)
> ring->ivec = &tp->int_vector[0];
> list_add_tail(&ring->ring_entry, &tp->int_vector[0].ring_list);
> }
> +
> + netif_queue_set_napi(tp->dev, ring->index,
> + NETDEV_QUEUE_TYPE_TX,
> + &ring->ivec->napi);
> }
>
> static void rtase_map_to_asic(union rtase_rx_desc *desc, dma_addr_t mapping,
> @@ -590,6 +595,7 @@ static void rtase_rx_desc_init(struct rtase_private *tp, u16 idx)
> ring->cur_idx = 0;
> ring->dirty_idx = 0;
> ring->index = idx;
> + ring->ring_type = RTASE_RX_RING;
> ring->alloc_fail = 0;
>
> for (i = 0; i < RTASE_NUM_DESC; i++)
> @@ -597,6 +603,9 @@ static void rtase_rx_desc_init(struct rtase_private *tp, u16 idx)
>
> ring->ring_handler = rx_handler;
> ring->ivec = &tp->int_vector[idx];
> + netif_queue_set_napi(tp->dev, ring->index,
> + NETDEV_QUEUE_TYPE_RX,
> + &ring->ivec->napi);
> list_add_tail(&ring->ring_entry, &tp->int_vector[idx].ring_list);
> }
>
> @@ -1161,8 +1170,18 @@ static void rtase_down(struct net_device *dev)
> ivec = &tp->int_vector[i];
> napi_disable(&ivec->napi);
> list_for_each_entry_safe(ring, tmp, &ivec->ring_list,
> - ring_entry)
> + ring_entry) {
> + if (ring->ring_type == RTASE_TX_RING)
> + netif_queue_set_napi(tp->dev, ring->index,
> + NETDEV_QUEUE_TYPE_TX,
> + NULL);
> + else
> + netif_queue_set_napi(tp->dev, ring->index,
> + NETDEV_QUEUE_TYPE_RX,
> + NULL);
> +
Using the existing enum would simplify this block?
netif_queue_set_napi(tp->dev, ring->index, ring->type, NULL);
> list_del(&ring->ring_entry);
> + }
> }
>
> netif_tx_disable(dev);
> @@ -1518,8 +1537,18 @@ static void rtase_sw_reset(struct net_device *dev)
> for (i = 0; i < tp->int_nums; i++) {
> ivec = &tp->int_vector[i];
> list_for_each_entry_safe(ring, tmp, &ivec->ring_list,
> - ring_entry)
> + ring_entry) {
> + if (ring->ring_type == RTASE_TX_RING)
> + netif_queue_set_napi(tp->dev, ring->index,
> + NETDEV_QUEUE_TYPE_TX,
> + NULL);
> + else
> + netif_queue_set_napi(tp->dev, ring->index,
> + NETDEV_QUEUE_TYPE_RX,
> + NULL);
> +
Same as above?
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH net-next 1/2] rtase: Link IRQs to NAPI instances
2025-06-11 13:51 ` Joe Damato
@ 2025-06-12 3:13 ` Justin Lai
0 siblings, 0 replies; 7+ messages in thread
From: Justin Lai @ 2025-06-12 3:13 UTC (permalink / raw)
To: Joe Damato
Cc: kuba@kernel.org, davem@davemloft.net, edumazet@google.com,
pabeni@redhat.com, andrew+netdev@lunn.ch,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
horms@kernel.org, jdamato@fastly.com, Ping-Ke Shih, Larry Chiu
> On Tue, Jun 10, 2025 at 06:33:33PM +0800, Justin Lai wrote:
> > Link IRQs to NAPI instances with netif_napi_set_irq. This information
> > can be queried with the netdev-genl API.
> >
> > Signed-off-by: Justin Lai <justinlai0215@realtek.com>
> > ---
> > .../net/ethernet/realtek/rtase/rtase_main.c | 20 +++++++++++++------
> > 1 file changed, 14 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > index 4d37217e9a14..a88af868da8c 100644
> > --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > @@ -1871,6 +1871,18 @@ static void rtase_init_netdev_ops(struct
> net_device *dev)
> > dev->ethtool_ops = &rtase_ethtool_ops; }
> >
> > +static void rtase_init_napi(struct rtase_private *tp) {
> > + u16 i;
> > +
> > + for (i = 0; i < tp->int_nums; i++) {
> > + netif_napi_add(tp->dev, &tp->int_vector[i].napi,
> > + tp->int_vector[i].poll);
>
> Maybe netif_napi_add_config can be used either in this patch or in an added
> 3rd patch to this series to support persitent NAPI config?
>
> Otherwise:
>
> Reviewed-by: Joe Damato <joe@dama.to>
Hi Joe,
Thank you for your suggestion. I will make the change in this patch in v2.
Thanks,
Justin
>
> > + netif_napi_set_irq(&tp->int_vector[i].napi,
> > + tp->int_vector[i].irq);
> > + }
> > +}
> > +
> > static void rtase_reset_interrupt(struct pci_dev *pdev,
> > const struct rtase_private *tp)
> { @@
> > -1956,9 +1968,6 @@ static void rtase_init_int_vector(struct rtase_private
> *tp)
> > memset(tp->int_vector[0].name, 0x0,
> sizeof(tp->int_vector[0].name));
> > INIT_LIST_HEAD(&tp->int_vector[0].ring_list);
> >
> > - netif_napi_add(tp->dev, &tp->int_vector[0].napi,
> > - tp->int_vector[0].poll);
> > -
> > /* interrupt vector 1 ~ 3 */
> > for (i = 1; i < tp->int_nums; i++) {
> > tp->int_vector[i].tp = tp; @@ -1972,9 +1981,6 @@ static
> > void rtase_init_int_vector(struct rtase_private *tp)
> > memset(tp->int_vector[i].name, 0x0,
> > sizeof(tp->int_vector[0].name));
> > INIT_LIST_HEAD(&tp->int_vector[i].ring_list);
> > -
> > - netif_napi_add(tp->dev, &tp->int_vector[i].napi,
> > - tp->int_vector[i].poll);
> > }
> > }
> >
> > @@ -2206,6 +2212,8 @@ static int rtase_init_one(struct pci_dev *pdev,
> > goto err_out_del_napi;
> > }
> >
> > + rtase_init_napi(tp);
> > +
> > rtase_init_netdev_ops(dev);
> >
> > dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
> > --
> > 2.34.1
> >
> >
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH net-next 2/2] rtase: Link queues to NAPI instances
2025-06-11 14:04 ` Joe Damato
@ 2025-06-12 3:28 ` Justin Lai
0 siblings, 0 replies; 7+ messages in thread
From: Justin Lai @ 2025-06-12 3:28 UTC (permalink / raw)
To: Joe Damato
Cc: kuba@kernel.org, davem@davemloft.net, edumazet@google.com,
pabeni@redhat.com, andrew+netdev@lunn.ch,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
horms@kernel.org, jdamato@fastly.com, Ping-Ke Shih, Larry Chiu
> On Tue, Jun 10, 2025 at 06:33:34PM +0800, Justin Lai wrote:
> > Link queues to NAPI instances with netif_queue_set_napi. This
> > information can be queried with the netdev-genl API.
> >
> > Signed-off-by: Justin Lai <justinlai0215@realtek.com>
> > ---
> > drivers/net/ethernet/realtek/rtase/rtase.h | 4 +++
> > .../net/ethernet/realtek/rtase/rtase_main.c | 33 +++++++++++++++++--
> > 2 files changed, 35 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/realtek/rtase/rtase.h
> > b/drivers/net/ethernet/realtek/rtase/rtase.h
> > index 498cfe4d0cac..be98f4de46c4 100644
> > --- a/drivers/net/ethernet/realtek/rtase/rtase.h
> > +++ b/drivers/net/ethernet/realtek/rtase/rtase.h
> > @@ -39,6 +39,9 @@
> > #define RTASE_FUNC_RXQ_NUM 1
> > #define RTASE_INTERRUPT_NUM 1
> >
> > +#define RTASE_TX_RING 0
> > +#define RTASE_RX_RING 1
> > +
> > #define RTASE_MITI_TIME_COUNT_MASK GENMASK(3, 0)
> > #define RTASE_MITI_TIME_UNIT_MASK GENMASK(7, 4)
> > #define RTASE_MITI_DEFAULT_TIME 128
> > @@ -288,6 +291,7 @@ struct rtase_ring {
> > u32 cur_idx;
> > u32 dirty_idx;
> > u16 index;
> > + u8 ring_type;
>
> Two questions:
>
> 1. why not use enum netdev_queue_type instead of making driver specific
> values that are the opposite of the existing enum values ?
>
> If you used the existing enum, you could omit the if below (see below), as
> well?
>
> 2. is "ring" in the name redundant? maybe just "type"? asking because below
> the code becomes "ring->ring_type" and maybe "ring->type" is better?
>
> > struct sk_buff *skbuff[RTASE_NUM_DESC];
> > void *data_buf[RTASE_NUM_DESC];
> > diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > index a88af868da8c..ef3ada91d555 100644
> > --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > @@ -326,6 +326,7 @@ static void rtase_tx_desc_init(struct rtase_private
> *tp, u16 idx)
> > ring->cur_idx = 0;
> > ring->dirty_idx = 0;
> > ring->index = idx;
> > + ring->ring_type = RTASE_TX_RING;
> > ring->alloc_fail = 0;
> >
> > for (i = 0; i < RTASE_NUM_DESC; i++) { @@ -345,6 +346,10 @@
> > static void rtase_tx_desc_init(struct rtase_private *tp, u16 idx)
> > ring->ivec = &tp->int_vector[0];
> > list_add_tail(&ring->ring_entry,
> &tp->int_vector[0].ring_list);
> > }
> > +
> > + netif_queue_set_napi(tp->dev, ring->index,
> > + NETDEV_QUEUE_TYPE_TX,
> > + &ring->ivec->napi);
> > }
> >
> > static void rtase_map_to_asic(union rtase_rx_desc *desc, dma_addr_t
> > mapping, @@ -590,6 +595,7 @@ static void rtase_rx_desc_init(struct
> rtase_private *tp, u16 idx)
> > ring->cur_idx = 0;
> > ring->dirty_idx = 0;
> > ring->index = idx;
> > + ring->ring_type = RTASE_RX_RING;
> > ring->alloc_fail = 0;
> >
> > for (i = 0; i < RTASE_NUM_DESC; i++) @@ -597,6 +603,9 @@ static
> > void rtase_rx_desc_init(struct rtase_private *tp, u16 idx)
> >
> > ring->ring_handler = rx_handler;
> > ring->ivec = &tp->int_vector[idx];
> > + netif_queue_set_napi(tp->dev, ring->index,
> > + NETDEV_QUEUE_TYPE_RX,
> > + &ring->ivec->napi);
> > list_add_tail(&ring->ring_entry,
> > &tp->int_vector[idx].ring_list); }
> >
> > @@ -1161,8 +1170,18 @@ static void rtase_down(struct net_device *dev)
> > ivec = &tp->int_vector[i];
> > napi_disable(&ivec->napi);
> > list_for_each_entry_safe(ring, tmp, &ivec->ring_list,
> > - ring_entry)
> > + ring_entry) {
> > + if (ring->ring_type == RTASE_TX_RING)
> > + netif_queue_set_napi(tp->dev,
> ring->index,
> > +
> NETDEV_QUEUE_TYPE_TX,
> > + NULL);
> > + else
> > + netif_queue_set_napi(tp->dev,
> ring->index,
> > +
> NETDEV_QUEUE_TYPE_RX,
> > + NULL);
> > +
>
> Using the existing enum would simplify this block?
>
> netif_queue_set_napi(tp->dev, ring->index, ring->type, NULL);
>
> > list_del(&ring->ring_entry);
> > + }
> > }
> >
> > netif_tx_disable(dev);
> > @@ -1518,8 +1537,18 @@ static void rtase_sw_reset(struct net_device
> *dev)
> > for (i = 0; i < tp->int_nums; i++) {
> > ivec = &tp->int_vector[i];
> > list_for_each_entry_safe(ring, tmp, &ivec->ring_list,
> > - ring_entry)
> > + ring_entry) {
> > + if (ring->ring_type == RTASE_TX_RING)
> > + netif_queue_set_napi(tp->dev,
> ring->index,
> > +
> NETDEV_QUEUE_TYPE_TX,
> > + NULL);
> > + else
> > + netif_queue_set_napi(tp->dev,
> ring->index,
> > +
> NETDEV_QUEUE_TYPE_RX,
> > + NULL);
> > +
>
> Same as above?
Hi Joe,
Thank you for your reply. I will use the enum netdev_queue_type to avoid
needing if statements to determine the ring type later. I will also rename
ring_type to type.
Thanks,
Justin
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-06-12 3:28 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-10 10:33 [PATCH net-next 0/2] Link NAPI instances to queues and IRQs Justin Lai
2025-06-10 10:33 ` [PATCH net-next 1/2] rtase: Link IRQs to NAPI instances Justin Lai
2025-06-11 13:51 ` Joe Damato
2025-06-12 3:13 ` Justin Lai
2025-06-10 10:33 ` [PATCH net-next 2/2] rtase: Link queues " Justin Lai
2025-06-11 14:04 ` Joe Damato
2025-06-12 3:28 ` Justin Lai
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).