git: 4d9e8a65d031 - stable/13 - LinuxKPI: napi_schedule() requires return value, implement napi_is_scheduled()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Wed, 12 Jun 2024 19:16:43 UTC
The branch stable/13 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=4d9e8a65d0318efbd3bc6b427c1580cd3c8200a4

commit 4d9e8a65d0318efbd3bc6b427c1580cd3c8200a4
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-03-31 17:27:45 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-06-12 16:57:33 +0000

    LinuxKPI: napi_schedule() requires return value, implement napi_is_scheduled()
    
    A newer version of iwlwifi requires a return value from napi_schedule();
    unclear if the function always should have been bool. Add the bool to test
    based on the napi_schedule_prep() result.
    
    Also add napi_is_scheduled() for rtw89.
    
    Sponsored by:   The FreeBSD Foundation
    Reviewed by:    emaste (previous version)
    Differential Revision:  https://reviews.freebsd.org/D44591
    
    (cherry picked from commit 21761f2ede4ebad13e78112b9409c1f20f946781)
---
 sys/compat/linuxkpi/common/include/linux/netdevice.h | 9 ++++++++-
 sys/compat/linuxkpi/common/src/linux_netdev.c        | 8 ++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/netdevice.h b/sys/compat/linuxkpi/common/include/linux/netdevice.h
index 02734585bf63..12ff307b3ce4 100644
--- a/sys/compat/linuxkpi/common/include/linux/netdevice.h
+++ b/sys/compat/linuxkpi/common/include/linux/netdevice.h
@@ -233,7 +233,7 @@ void linuxkpi_netif_napi_add(struct net_device *, struct napi_struct *,
 void linuxkpi_netif_napi_del(struct napi_struct *);
 bool linuxkpi_napi_schedule_prep(struct napi_struct *);
 void linuxkpi___napi_schedule(struct napi_struct *);
-void linuxkpi_napi_schedule(struct napi_struct *);
+bool linuxkpi_napi_schedule(struct napi_struct *);
 void linuxkpi_napi_reschedule(struct napi_struct *);
 bool linuxkpi_napi_complete_done(struct napi_struct *, int);
 bool linuxkpi_napi_complete(struct napi_struct *);
@@ -275,6 +275,13 @@ netif_napi_add_tx(struct net_device *dev, struct napi_struct *napi,
 	netif_napi_add(dev, napi, napi_poll);
 }
 
+static inline bool
+napi_is_scheduled(struct napi_struct *napi)
+{
+
+	return (test_bit(LKPI_NAPI_FLAG_IS_SCHEDULED, &napi->state));
+}
+
 /* -------------------------------------------------------------------------- */
 
 static inline void
diff --git a/sys/compat/linuxkpi/common/src/linux_netdev.c b/sys/compat/linuxkpi/common/src/linux_netdev.c
index 61ebcdbf7a39..61342395f03c 100644
--- a/sys/compat/linuxkpi/common/src/linux_netdev.c
+++ b/sys/compat/linuxkpi/common/src/linux_netdev.c
@@ -185,7 +185,7 @@ linuxkpi___napi_schedule(struct napi_struct *napi)
 	}
 }
 
-void
+bool
 linuxkpi_napi_schedule(struct napi_struct *napi)
 {
 
@@ -195,8 +195,12 @@ linuxkpi_napi_schedule(struct napi_struct *napi)
 	 * iwlwifi calls this sequence instead of napi_schedule()
 	 * to be able to test the prep result.
 	 */
-	if (napi_schedule_prep(napi))
+	if (napi_schedule_prep(napi)) {
 		__napi_schedule(napi);
+		return (true);
+	}
+
+	return (false);
 }
 
 void