kni: update kernel API to receive packets

Message ID 20220420050309.1055593-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/intel-Testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Gagandeep Singh April 20, 2022, 5:03 a.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() 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(+)
  

Comments

Wang, Haiyue April 20, 2022, 7:45 a.m. UTC | #1
> -----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
  
Gagandeep Singh April 20, 2022, 10:39 a.m. UTC | #2
> -----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
  

Patch

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;