[v2] kni: update kernel API to receive packets

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

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS

Commit Message

Gagandeep Singh April 21, 2022, 3:45 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.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(+)
  

Comments

Ferruh Yigit April 21, 2022, 8:29 a.m. UTC | #1
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;
  

Patch

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;