[v3] kni: update kernel API to receive packets

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

Checks

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

Commit Message

Gagandeep Singh April 21, 2022, 8:59 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>

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

Comments

humin (Q) May 23, 2022, 9:15 a.m. UTC | #1
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;
>
  
Thomas Monjalon June 26, 2022, 1:25 p.m. UTC | #2
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
  

Patch

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;