From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: javen <javen_xu@realsil.com.cn>,
hkallweit1@gmail.com, nic_swsd@realtek.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC Patch net-next v2 4/8] r8169: add support for new interrupt mapping
Date: Wed, 29 Apr 2026 15:32:39 +0100 [thread overview]
Message-ID: <40fadbd2-e138-4000-85b2-dd4188d43e19@linux.dev> (raw)
In-Reply-To: <20260429070750.1477-5-javen_xu@realsil.com.cn>
On 29/04/2026 08:07, javen wrote:
> From: Javen Xu <javen_xu@realsil.com.cn>
>
> To support RSS, the number of hardware interrupt bits should match the
> interrupt of software. So we add support for new interrupt mapping here.
> ISR_VER_MAP_REG is the hardware register to indicate interrupt status.
> IMR_SET_VEC_MAP_REG is interrupt mask which is set to enable irq.
>
> Signed-off-by: Javen Xu <javen_xu@realsil.com.cn>
[...]
>
> napi = &tp->r8169napi[i];
> snprintf(irq->name, len, "%s-%d", dev->name, i);
> @@ -5664,10 +5717,17 @@ static const struct net_device_ops rtl_netdev_ops = {
>
> static void rtl_set_irq_mask(struct rtl8169_private *tp)
> {
> - tp->irq_mask = RxOK | RxErr | TxOK | TxErr | LinkChg;
> + if (tp->features & RTL_VEC_MAP_ENABLE) {
> + tp->irq_mask = ISRIMR_LINKCHG;
> + tp->irq_mask |= ISRIMR_TOK_Q0;
nit: you can set it in one line
> + for (int i = 0; i < tp->num_rx_rings; i++)
> + tp->irq_mask |= ISRIMR_ROK_Q0 << i;
> + } else {
> + tp->irq_mask = RxOK | RxErr | TxOK | TxErr | LinkChg;
>
> - if (tp->mac_version <= RTL_GIGA_MAC_VER_06)
> - tp->irq_mask |= SYSErr | RxFIFOOver;
> + if (tp->mac_version <= RTL_GIGA_MAC_VER_06)
> + tp->irq_mask |= SYSErr | RxFIFOOver;
> + }
> }
>
> static int rtl_alloc_irq(struct rtl8169_private *tp)
> @@ -5695,6 +5755,16 @@ static int rtl_alloc_irq(struct rtl8169_private *tp)
> if (nvecs < 0)
> nvecs = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
>
> + tp->features &= ~RTL_VEC_MAP_ENABLE;
> +
> + if (nvecs > 0) {
> + tp->irq_nvecs = nvecs;
> + tp->irq = pci_irq_vector(pdev, 0);
> + if (nvecs > 1)
> + tp->features |= RTL_VEC_MAP_ENABLE;
> + return 0;
> + }
> +
> tp->irq = pdev->irq;
> tp->irq_nvecs = 1;
now these 2 lines are not needed, because in success they are never
executed, but in error path they provide wrong information.
the whole can be rewritten with error path in case both tries of
pci_alloc_irq_vectors failed and the common code for success path:
if (nvecs < 0)
nvecs = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
if (nvecs < 0)
return nvecs;
tp->irq_nvecs = nvecs;
tp->irq = pci_irq_vector(pdev, 0);
if (nvecs > 1)
tp->features |= RTL_VEC_MAP_ENABLE;
return 0;
>
> @@ -5965,6 +6035,53 @@ static bool rtl_aspm_is_safe(struct rtl8169_private *tp)
> return false;
> }
>
> +static int rtl8169_poll_msix_rx(struct napi_struct *napi, int budget)
> +{
> + struct rtl8169_napi *r8169_napi = container_of(napi, struct rtl8169_napi, napi);
> + struct rtl8169_private *tp = r8169_napi->priv;
> + struct net_device *dev = tp->dev;
> + const int message_id = r8169_napi->index;
reverse xmass tree, please
> + int work_done = 0;
> +
> + if (message_id < tp->num_rx_rings)
> + work_done += rtl_rx(dev, tp, &tp->rx_ring[message_id], budget);
> +
> + if (work_done < budget && napi_complete_done(napi, work_done))
> + rtl8169_enable_hw_interrupt_msix(tp, message_id);
> +
> + return work_done;
> +}
> +
> +static int rtl8169_poll_msix_tx(struct napi_struct *napi, int budget)
> +{
> + struct rtl8169_napi *r8169_napi = container_of(napi, struct rtl8169_napi, napi);
> + struct rtl8169_private *tp = r8169_napi->priv;
> + struct net_device *dev = tp->dev;
> + unsigned int work_done = 0;
> + const int message_id = r8169_napi->index;
> + int tx_ring_idx = message_id - 8;
ditto
> +
> + if (tx_ring_idx >= 0)
> + rtl_tx(dev, tp, budget);
> +
> + if (work_done < budget && napi_complete_done(napi, work_done))
> + rtl8169_enable_hw_interrupt_msix(tp, message_id);
> +
> + return work_done;
> +}
> +
> +static int rtl8169_poll_msix_other(struct napi_struct *napi, int budget)
> +{
> + struct rtl8169_napi *r8169_napi = container_of(napi, struct rtl8169_napi, napi);
> + struct rtl8169_private *tp = r8169_napi->priv;
> + const int message_id = r8169_napi->index;
> +
> + napi_complete_done(napi, budget);
> + rtl8169_enable_hw_interrupt_msix(tp, message_id);
> +
> + return 1;
> +}
> +
> static void r8169_init_napi(struct rtl8169_private *tp)
> {
> for (int i = 0; i < tp->irq_nvecs; i++) {
> @@ -5972,6 +6089,20 @@ static void r8169_init_napi(struct rtl8169_private *tp)
> int (*poll)(struct napi_struct *napi, int budget);
>
> poll = rtl8169_poll;
> + if (tp->features & RTL_VEC_MAP_ENABLE) {
> + switch (tp->hw_curr_isr_ver) {
> + case 6:
> + if (i < R8127_MAX_RX_QUEUES)
> + poll = rtl8169_poll_msix_rx;
> + else if (i > 7 && i < 16)
magic constants?
> + poll = rtl8169_poll_msix_tx;
> + else
> + poll = rtl8169_poll_msix_other;
> + break;
> + default:
> + break;
> + }
> + }
> netif_napi_add(tp->dev, &r8169napi->napi, poll);
> r8169napi->priv = tp;
> r8169napi->index = i;
next prev parent reply other threads:[~2026-04-29 14:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 7:07 [RFC Patch net-next v2 0/8] r8169: add RSS (Receive Side Scaling) support for RTL8127 javen
2026-04-29 7:07 ` [RFC Patch net-next v2 1/8] r8169: add some register definitions javen
2026-04-29 14:06 ` Vadim Fedorenko
2026-04-29 7:07 ` [RFC Patch net-next v2 2/8] r8169: add support for multi irqs javen
2026-04-29 14:13 ` Vadim Fedorenko
2026-04-29 7:07 ` [RFC Patch net-next v2 3/8] r8169: add support for multi rx queues javen
2026-04-29 7:07 ` [RFC Patch net-next v2 4/8] r8169: add support for new interrupt mapping javen
2026-04-29 14:32 ` Vadim Fedorenko [this message]
2026-04-30 3:24 ` Javen
2026-04-29 7:07 ` [RFC Patch net-next v2 5/8] r8169: enable " javen
2026-04-29 7:07 ` [RFC Patch net-next v2 6/8] r8169: add support and enable rss javen
2026-04-29 7:07 ` [RFC Patch net-next v2 7/8] r8169: move struct ethtool_ops javen
2026-04-29 7:07 ` [RFC Patch net-next v2] r8169: add support for ethtool javen
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=40fadbd2-e138-4000-85b2-dd4188d43e19@linux.dev \
--to=vadim.fedorenko@linux.dev \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=javen_xu@realsil.com.cn \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nic_swsd@realtek.com \
--cc=pabeni@redhat.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