DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] kni: update kernel API to receive packets
@ 2022-04-14 12:23 Gagandeep Singh
  2022-04-15  3:24 ` Harold Huang
  2022-04-20  5:03 ` Gagandeep Singh
  0 siblings, 2 replies; 14+ messages in thread
From: Gagandeep Singh @ 2022-04-14 12:23 UTC (permalink / raw)
  To: dev; +Cc: Gagandeep Singh

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(-)

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] kni: update kernel API to receive packets
  2022-04-14 12:23 [PATCH] kni: update kernel API to receive packets Gagandeep Singh
@ 2022-04-15  3:24 ` Harold Huang
  2022-04-15  4:07   ` Gagandeep Singh
  2022-04-20  5:03 ` Gagandeep Singh
  1 sibling, 1 reply; 14+ messages in thread
From: Harold Huang @ 2022-04-15  3:24 UTC (permalink / raw)
  To: Gagandeep Singh; +Cc: dev

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
>


-- 
Thanks, Harold.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH] kni: update kernel API to receive packets
  2022-04-15  3:24 ` Harold Huang
@ 2022-04-15  4:07   ` Gagandeep Singh
  2022-04-15 12:30     ` Ferruh Yigit
  0 siblings, 1 reply; 14+ messages in thread
From: Gagandeep Singh @ 2022-04-15  4:07 UTC (permalink / raw)
  To: Harold Huang; +Cc: dev

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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] kni: update kernel API to receive packets
  2022-04-15  4:07   ` Gagandeep Singh
@ 2022-04-15 12:30     ` Ferruh Yigit
  2022-04-15 14:59       ` Stephen Hemminger
  0 siblings, 1 reply; 14+ messages in thread
From: Ferruh Yigit @ 2022-04-15 12:30 UTC (permalink / raw)
  To: Gagandeep Singh, Harold Huang; +Cc: dev

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.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] kni: update kernel API to receive packets
  2022-04-15 12:30     ` Ferruh Yigit
@ 2022-04-15 14:59       ` Stephen Hemminger
  2022-04-18 11:33         ` Gagandeep Singh
  0 siblings, 1 reply; 14+ messages in thread
From: Stephen Hemminger @ 2022-04-15 14:59 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: Gagandeep Singh, Harold Huang, dev

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH] kni: update kernel API to receive packets
  2022-04-15 14:59       ` Stephen Hemminger
@ 2022-04-18 11:33         ` Gagandeep Singh
  0 siblings, 0 replies; 14+ messages in thread
From: Gagandeep Singh @ 2022-04-18 11:33 UTC (permalink / raw)
  To: Stephen Hemminger, Ferruh Yigit; +Cc: Harold Huang, dev



> -----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. 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] kni: update kernel API to receive packets
  2022-04-14 12:23 [PATCH] kni: update kernel API to receive packets Gagandeep Singh
  2022-04-15  3:24 ` Harold Huang
@ 2022-04-20  5:03 ` Gagandeep Singh
  2022-04-20  7:45   ` Wang, Haiyue
  2022-04-21  3:45   ` [PATCH v2] " Gagandeep Singh
  1 sibling, 2 replies; 14+ messages in thread
From: Gagandeep Singh @ 2022-04-20  5:03 UTC (permalink / raw)
  To: dev; +Cc: Gagandeep Singh

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() for
kernel version 5.17 and above.

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

diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
index 29e5b9e21f..764ac0b225 100644
--- a/kernel/linux/kni/kni_net.c
+++ b/kernel/linux/kni/kni_net.c
@@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 		/* Call netif interface */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
+		netif_rx(skb);
+#else
 		netif_rx_ni(skb);
+#endif
 
 		/* Update statistics */
 		dev->stats.rx_bytes += len;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH] kni: update kernel API to receive packets
  2022-04-20  5:03 ` Gagandeep Singh
@ 2022-04-20  7:45   ` Wang, Haiyue
  2022-04-20 10:39     ` Gagandeep Singh
  2022-04-21  3:45   ` [PATCH v2] " Gagandeep Singh
  1 sibling, 1 reply; 14+ messages in thread
From: Wang, Haiyue @ 2022-04-20  7:45 UTC (permalink / raw)
  To: Gagandeep Singh, dev

> -----Original Message-----
> From: Gagandeep Singh <g.singh@nxp.com>
> Sent: Wednesday, April 20, 2022 13:03
> To: dev@dpdk.org
> Cc: Gagandeep Singh <g.singh@nxp.com>
> Subject: [PATCH] kni: update kernel API to receive packets
> 
> API 'netif_rx_ni()' has been removed in kernel with commit:
> baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.")
> 

It should be 5.18:
	git describe --contains baebdf48c3600
	v5.18-rc1~136^2~356^2~1

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/core/dev.c?h=v5.18-rc1#n4917

vs

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/net/core/dev.c?h=v5.17.3#n4836

> 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() for
> kernel version 5.17 and above.
> 
> Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
> ---
>  kernel/linux/kni/kni_net.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
> index 29e5b9e21f..764ac0b225 100644
> --- a/kernel/linux/kni/kni_net.c
> +++ b/kernel/linux/kni/kni_net.c
> @@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
>  		skb->ip_summed = CHECKSUM_UNNECESSARY;
> 
>  		/* Call netif interface */
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
> +		netif_rx(skb);
> +#else
>  		netif_rx_ni(skb);
> +#endif
> 
>  		/* Update statistics */
>  		dev->stats.rx_bytes += len;
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH] kni: update kernel API to receive packets
  2022-04-20  7:45   ` Wang, Haiyue
@ 2022-04-20 10:39     ` Gagandeep Singh
  0 siblings, 0 replies; 14+ messages in thread
From: Gagandeep Singh @ 2022-04-20 10:39 UTC (permalink / raw)
  To: Wang, Haiyue, dev



> -----Original Message-----
> From: Wang, Haiyue <haiyue.wang@intel.com>
> Sent: Wednesday, April 20, 2022 1:15 PM
> To: Gagandeep Singh <G.Singh@nxp.com>; dev@dpdk.org
> Subject: RE: [PATCH] kni: update kernel API to receive packets
> 
> > -----Original Message-----
> > From: Gagandeep Singh <g.singh@nxp.com>
> > Sent: Wednesday, April 20, 2022 13:03
> > To: dev@dpdk.org
> > Cc: Gagandeep Singh <g.singh@nxp.com>
> > Subject: [PATCH] kni: update kernel API to receive packets
> >
> > API 'netif_rx_ni()' has been removed in kernel with commit:
> > baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any
> > context.")
> >
> 
> It should be 5.18:
> 	git describe --contains baebdf48c3600
> 	v5.18-rc1~136^2~356^2~1

Thanks, will be updated in next version.
> 
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kernel
> .org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Ftree%
> 2Fnet%2Fcore%2Fdev.c%3Fh%3Dv5.18-
> rc1%23n4917&amp;data=05%7C01%7Cg.singh%40nxp.com%7Cd048462d38074
> e9f595a08da22a1f464%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7
> C637860376235475257%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwM
> DAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C
> &amp;sdata=4S9btzMbli3YF5vA15i4RruVMJAzW1byT9gja0NEyFk%3D&amp;rese
> rved=0
> 
> vs
> 
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kernel
> .org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fstable%2Flinux.git%2Ftree%2F
> net%2Fcore%2Fdev.c%3Fh%3Dv5.17.3%23n4836&amp;data=05%7C01%7Cg.sin
> gh%40nxp.com%7Cd048462d38074e9f595a08da22a1f464%7C686ea1d3bc2b4c
> 6fa92cd99c5c301635%7C0%7C0%7C637860376235475257%7CUnknown%7CT
> WFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXV
> CI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=FRnN7H0aXinhQNXQ932FCNFZ
> G%2B1kau01qMIvNc%2FPW10%3D&amp;reserved=0
> 
> > 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() for kernel
> > version 5.17 and above.
> >
> > Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
> > ---
> >  kernel/linux/kni/kni_net.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
> > index 29e5b9e21f..764ac0b225 100644
> > --- a/kernel/linux/kni/kni_net.c
> > +++ b/kernel/linux/kni/kni_net.c
> > @@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
> >  		skb->ip_summed = CHECKSUM_UNNECESSARY;
> >
> >  		/* Call netif interface */
> > +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
> > +		netif_rx(skb);
> > +#else
> >  		netif_rx_ni(skb);
> > +#endif
> >
> >  		/* Update statistics */
> >  		dev->stats.rx_bytes += len;
> > --
> > 2.25.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2] kni: update kernel API to receive packets
  2022-04-20  5:03 ` Gagandeep Singh
  2022-04-20  7:45   ` Wang, Haiyue
@ 2022-04-21  3:45   ` Gagandeep Singh
  2022-04-21  8:29     ` Ferruh Yigit
  2022-04-21  8:59     ` [PATCH v3] " Gagandeep Singh
  1 sibling, 2 replies; 14+ messages in thread
From: Gagandeep Singh @ 2022-04-21  3:45 UTC (permalink / raw)
  To: dev; +Cc: Gagandeep Singh

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() for
kernel version 5.18 and above.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>

Change-log:
Added a #if for kernel version 5.18 and above for API change.
---
 kernel/linux/kni/kni_net.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
index 29e5b9e21f..7a576b9ebc 100644
--- a/kernel/linux/kni/kni_net.c
+++ b/kernel/linux/kni/kni_net.c
@@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 		/* Call netif interface */
+#if KERNEL_VERSION(5, 18, 0) <= LINUX_VERSION_CODE
+		netif_rx(skb);
+#else
 		netif_rx_ni(skb);
+#endif
 
 		/* Update statistics */
 		dev->stats.rx_bytes += len;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2] kni: update kernel API to receive packets
  2022-04-21  3:45   ` [PATCH v2] " Gagandeep Singh
@ 2022-04-21  8:29     ` Ferruh Yigit
  2022-04-21  8:59     ` [PATCH v3] " Gagandeep Singh
  1 sibling, 0 replies; 14+ messages in thread
From: Ferruh Yigit @ 2022-04-21  8:29 UTC (permalink / raw)
  To: Gagandeep Singh, dev

On 4/21/2022 4:45 AM, Gagandeep Singh 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() for
> kernel version 5.18 and above.
> 
> Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
> 
> Change-log:
> Added a #if for kernel version 5.18 and above for API change.
> ---
>   kernel/linux/kni/kni_net.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
> index 29e5b9e21f..7a576b9ebc 100644
> --- a/kernel/linux/kni/kni_net.c
> +++ b/kernel/linux/kni/kni_net.c
> @@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
>   		skb->ip_summed = CHECKSUM_UNNECESSARY;
>   
>   		/* Call netif interface */
> +#if KERNEL_VERSION(5, 18, 0) <= LINUX_VERSION_CODE

Can you please put the version check to 'kernel/linux/kni/compat.h', 
there are multiple samples there.
As you will see there, the version comparison is not straightforward 
when distro kernels are involved, so it is good to move that clutter 
away from the source code.

> +		netif_rx(skb);
> +#else
>   		netif_rx_ni(skb);
> +#endif
>   
>   		/* Update statistics */
>   		dev->stats.rx_bytes += len;


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v3] kni: update kernel API to receive packets
  2022-04-21  3:45   ` [PATCH v2] " Gagandeep Singh
  2022-04-21  8:29     ` Ferruh Yigit
@ 2022-04-21  8:59     ` Gagandeep Singh
  2022-05-23  9:15       ` Min Hu (Connor)
  2022-06-26 13:25       ` Thomas Monjalon
  1 sibling, 2 replies; 14+ messages in thread
From: Gagandeep Singh @ 2022-04-21  8:59 UTC (permalink / raw)
  To: dev; +Cc: Gagandeep Singh

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() for
kernel version 5.18 and above.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>

v2 Change-log:
Added a #if for kernel version 5.18 and above for API change.

v3 Change-log:
Moved #if of kernel check to compat.h
---
 kernel/linux/kni/compat.h  | 4 ++++
 kernel/linux/kni/kni_net.c | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/kernel/linux/kni/compat.h b/kernel/linux/kni/compat.h
index 664785674f..6451295270 100644
--- a/kernel/linux/kni/compat.h
+++ b/kernel/linux/kni/compat.h
@@ -141,3 +141,7 @@
 #if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE
 #define HAVE_TSK_IN_GUP
 #endif
+
+#if KERNEL_VERSION(5, 18, 0) <= LINUX_VERSION_CODE
+#define HAVE_CHANGE_NETIF_RX
+#endif
diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
index 29e5b9e21f..80ead13b75 100644
--- a/kernel/linux/kni/kni_net.c
+++ b/kernel/linux/kni/kni_net.c
@@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 		/* Call netif interface */
+#ifdef HAVE_CHANGE_NETIF_RX
+		netif_rx(skb);
+#else
 		netif_rx_ni(skb);
+#endif
 
 		/* Update statistics */
 		dev->stats.rx_bytes += len;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3] kni: update kernel API to receive packets
  2022-04-21  8:59     ` [PATCH v3] " Gagandeep Singh
@ 2022-05-23  9:15       ` Min Hu (Connor)
  2022-06-26 13:25       ` Thomas Monjalon
  1 sibling, 0 replies; 14+ messages in thread
From: Min Hu (Connor) @ 2022-05-23  9:15 UTC (permalink / raw)
  To: Gagandeep Singh, dev


Acked-by: Min Hu (Connor) <humin29@huawei.com>
在 2022/4/21 16:59, Gagandeep Singh 写道:
> 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() for
> kernel version 5.18 and above.
> 
> Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
> 
> v2 Change-log:
> Added a #if for kernel version 5.18 and above for API change.
> 
> v3 Change-log:
> Moved #if of kernel check to compat.h
> ---
>   kernel/linux/kni/compat.h  | 4 ++++
>   kernel/linux/kni/kni_net.c | 4 ++++
>   2 files changed, 8 insertions(+)
> 
> diff --git a/kernel/linux/kni/compat.h b/kernel/linux/kni/compat.h
> index 664785674f..6451295270 100644
> --- a/kernel/linux/kni/compat.h
> +++ b/kernel/linux/kni/compat.h
> @@ -141,3 +141,7 @@
>   #if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE
>   #define HAVE_TSK_IN_GUP
>   #endif
> +
> +#if KERNEL_VERSION(5, 18, 0) <= LINUX_VERSION_CODE
> +#define HAVE_CHANGE_NETIF_RX
> +#endif
> diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
> index 29e5b9e21f..80ead13b75 100644
> --- a/kernel/linux/kni/kni_net.c
> +++ b/kernel/linux/kni/kni_net.c
> @@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
>   		skb->ip_summed = CHECKSUM_UNNECESSARY;
>   
>   		/* Call netif interface */
> +#ifdef HAVE_CHANGE_NETIF_RX
> +		netif_rx(skb);
> +#else
>   		netif_rx_ni(skb);
> +#endif
>   
>   		/* Update statistics */
>   		dev->stats.rx_bytes += len;
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3] kni: update kernel API to receive packets
  2022-04-21  8:59     ` [PATCH v3] " Gagandeep Singh
  2022-05-23  9:15       ` Min Hu (Connor)
@ 2022-06-26 13:25       ` Thomas Monjalon
  1 sibling, 0 replies; 14+ messages in thread
From: Thomas Monjalon @ 2022-06-26 13:25 UTC (permalink / raw)
  To: Gagandeep Singh; +Cc: dev

21/04/2022 10:59, Gagandeep Singh:
> 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() for
> kernel version 5.18 and above.
> 
> Signed-off-by: Gagandeep Singh <g.singh@nxp.com>

A similar patch has been merged recently:
https://git.dpdk.org/dpdk/commit/?id=c98600d4bed6d15599



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-06-26 13:25 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14 12:23 [PATCH] kni: update kernel API to receive packets Gagandeep Singh
2022-04-15  3:24 ` Harold Huang
2022-04-15  4:07   ` Gagandeep Singh
2022-04-15 12:30     ` Ferruh Yigit
2022-04-15 14:59       ` Stephen Hemminger
2022-04-18 11:33         ` Gagandeep Singh
2022-04-20  5:03 ` Gagandeep Singh
2022-04-20  7:45   ` Wang, Haiyue
2022-04-20 10:39     ` Gagandeep Singh
2022-04-21  3:45   ` [PATCH v2] " Gagandeep Singh
2022-04-21  8:29     ` Ferruh Yigit
2022-04-21  8:59     ` [PATCH v3] " Gagandeep Singh
2022-05-23  9:15       ` Min Hu (Connor)
2022-06-26 13:25       ` Thomas Monjalon

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).