kni: update kernel API to receive packets

Message ID 20220414122319.3519271-1-g.singh@nxp.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series kni: update kernel API to receive packets |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance fail Performance Testing issues
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/intel-Testing success Testing PASS

Commit Message

Gagandeep Singh April 14, 2022, 12:23 p.m. UTC
  API 'netif_rx_ni()' has been removed in kernel with commit:
baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.")

The API netif_rx() can be used for any context to receive packets
from device drivers.

This patch replaces the API netif_rx_ni() with netif_rx().

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 kernel/linux/kni/kni_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Harold Huang April 15, 2022, 3:24 a.m. UTC | #1
On Thu, Apr 14, 2022 at 8:23 PM Gagandeep Singh <g.singh@nxp.com> wrote:
>
> API 'netif_rx_ni()' has been removed in kernel with commit:
> baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.")
>
> The API netif_rx() can be used for any context to receive packets
> from device drivers.
>
> This patch replaces the API netif_rx_ni() with netif_rx().

But this change would cause KNI kernel module does not work in the old
kernel without this patch. I suggested using netif_rx_ni to keep
compatibility.


>
> Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
> ---
>  kernel/linux/kni/kni_net.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
> index 29e5b9e21f..e66b35314a 100644
> --- a/kernel/linux/kni/kni_net.c
> +++ b/kernel/linux/kni/kni_net.c
> @@ -441,7 +441,7 @@ kni_net_rx_normal(struct kni_dev *kni)
>                 skb->ip_summed = CHECKSUM_UNNECESSARY;
>
>                 /* Call netif interface */
> -               netif_rx_ni(skb);
> +               netif_rx(skb);
>
>                 /* Update statistics */
>                 dev->stats.rx_bytes += len;
> --
> 2.25.1
>
  
Gagandeep Singh April 15, 2022, 4:07 a.m. UTC | #2
Hi

> -----Original Message-----
> From: Harold Huang <baymaxhuang@gmail.com>
> Sent: Friday, April 15, 2022 8:54 AM
> To: Gagandeep Singh <G.Singh@nxp.com>
> Cc: dev@dpdk.org
> Subject: Re: [PATCH] kni: update kernel API to receive packets
> 
> On Thu, Apr 14, 2022 at 8:23 PM Gagandeep Singh <g.singh@nxp.com> wrote:
> >
> > API 'netif_rx_ni()' has been removed in kernel with commit:
> > baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any
> > context.")
> >
> > The API netif_rx() can be used for any context to receive packets from
> > device drivers.
> >
> > This patch replaces the API netif_rx_ni() with netif_rx().
> 
> But this change would cause KNI kernel module does not work in the old kernel
> without this patch. I suggested using netif_rx_ni to keep compatibility.

netif_rx() API exists from very older versions of kernel before v2.6. There will be
no compilation issues. Only difference was, netif_rx_ni() can be used in noninterrupt contexts
to improve performance.
Now, in latest kernel, netif_rx_ni() is removed and netif_rx can handle all the contexts.
So we have to replace this API otherwise compilation will break on latest kernel.

> 
> >
> > Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
> > ---
> >  kernel/linux/kni/kni_net.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
> > index 29e5b9e21f..e66b35314a 100644
> > --- a/kernel/linux/kni/kni_net.c
> > +++ b/kernel/linux/kni/kni_net.c
> > @@ -441,7 +441,7 @@ kni_net_rx_normal(struct kni_dev *kni)
> >                 skb->ip_summed = CHECKSUM_UNNECESSARY;
> >
> >                 /* Call netif interface */
> > -               netif_rx_ni(skb);
> > +               netif_rx(skb);
> >
> >                 /* Update statistics */
> >                 dev->stats.rx_bytes += len;
> > --
> > 2.25.1
> >
> 
> 
> --
> Thanks, Harold.
  
Ferruh Yigit April 15, 2022, 12:30 p.m. UTC | #3
On 4/15/2022 5:07 AM, Gagandeep Singh wrote:
> Hi
> 
>> -----Original Message-----
>> From: Harold Huang <baymaxhuang@gmail.com>
>> Sent: Friday, April 15, 2022 8:54 AM
>> To: Gagandeep Singh <G.Singh@nxp.com>
>> Cc: dev@dpdk.org
>> Subject: Re: [PATCH] kni: update kernel API to receive packets
>>
>> On Thu, Apr 14, 2022 at 8:23 PM Gagandeep Singh <g.singh@nxp.com> wrote:
>>>
>>> API 'netif_rx_ni()' has been removed in kernel with commit:
>>> baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any
>>> context.")
>>>
>>> The API netif_rx() can be used for any context to receive packets from
>>> device drivers.
>>>
>>> This patch replaces the API netif_rx_ni() with netif_rx().
>>
>> But this change would cause KNI kernel module does not work in the old kernel
>> without this patch. I suggested using netif_rx_ni to keep compatibility.
> 
> netif_rx() API exists from very older versions of kernel before v2.6. There will be
> no compilation issues. Only difference was, netif_rx_ni() can be used in noninterrupt contexts
> to improve performance.

May not be compilation issue, but with old kernels won't the behavior be 
different when 'netif_rx_ni()' switched to 'netif_rx()'?

> Now, in latest kernel, netif_rx_ni() is removed and netif_rx can handle all the contexts.
> So we have to replace this API otherwise compilation will break on latest kernel.
> 
>>
>>>
>>> Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
>>> ---
>>>   kernel/linux/kni/kni_net.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
>>> index 29e5b9e21f..e66b35314a 100644
>>> --- a/kernel/linux/kni/kni_net.c
>>> +++ b/kernel/linux/kni/kni_net.c
>>> @@ -441,7 +441,7 @@ kni_net_rx_normal(struct kni_dev *kni)
>>>                  skb->ip_summed = CHECKSUM_UNNECESSARY;
>>>
>>>                  /* Call netif interface */
>>> -               netif_rx_ni(skb);
>>> +               netif_rx(skb);
>>>
>>>                  /* Update statistics */
>>>                  dev->stats.rx_bytes += len;
>>> --
>>> 2.25.1
>>>
>>
>>
>> --
>> Thanks, Harold.
  
Stephen Hemminger April 15, 2022, 2:59 p.m. UTC | #4
On Fri, 15 Apr 2022 13:30:33 +0100
Ferruh Yigit <ferruh.yigit@xilinx.com> wrote:

> >> But this change would cause KNI kernel module does not work in the old kernel
> >> without this patch. I suggested using netif_rx_ni to keep compatibility.  
> > 
> > netif_rx() API exists from very older versions of kernel before v2.6. There will be
> > no compilation issues. Only difference was, netif_rx_ni() can be used in noninterrupt contexts
> > to improve performance.  
> 
> May not be compilation issue, but with old kernels won't the behavior be 
> different when 'netif_rx_ni()' switched to 'netif_rx()

Probably best handled by #ifdef on kernel version but will be
a mess for backports to distro kernels.

Looks like:

	Older	   -> New
	netif_rx_ni   netif_rx
	neitf_rx      __netif_rx
  
Gagandeep Singh April 18, 2022, 11:33 a.m. UTC | #5
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Friday, April 15, 2022 8:30 PM
> To: Ferruh Yigit <ferruh.yigit@xilinx.com>
> Cc: Gagandeep Singh <G.Singh@nxp.com>; Harold Huang
> <baymaxhuang@gmail.com>; dev@dpdk.org
> Subject: Re: [PATCH] kni: update kernel API to receive packets
> 
> On Fri, 15 Apr 2022 13:30:33 +0100
> Ferruh Yigit <ferruh.yigit@xilinx.com> wrote:
> 
> > >> But this change would cause KNI kernel module does not work in the
> > >> old kernel without this patch. I suggested using netif_rx_ni to keep
> compatibility.
> > >
> > > netif_rx() API exists from very older versions of kernel before
> > > v2.6. There will be no compilation issues. Only difference was,
> > > netif_rx_ni() can be used in noninterrupt contexts to improve performance.
> >
> > May not be compilation issue, but with old kernels won't the behavior
> > be different when 'netif_rx_ni()' switched to 'netif_rx()
> 
> Probably best handled by #ifdef on kernel version but will be a mess for
> backports to distro kernels.
> 
> Looks like:
> 
> 	Older	   -> New
> 	netif_rx_ni   netif_rx
> 	neitf_rx      __netif_rx

If it is ok for everyone, I can add #ifdef for kernel version >= 5.17 to use API netif_rx, to
avoid any functional/performance impact with old kernels.
  

Patch

diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
index 29e5b9e21f..e66b35314a 100644
--- a/kernel/linux/kni/kni_net.c
+++ b/kernel/linux/kni/kni_net.c
@@ -441,7 +441,7 @@  kni_net_rx_normal(struct kni_dev *kni)
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 		/* Call netif interface */
-		netif_rx_ni(skb);
+		netif_rx(skb);
 
 		/* Update statistics */
 		dev->stats.rx_bytes += len;