git: ce5b0b7b991f - stable/14 - LinuxKPI: 802.11: hookup net80211 callbacks dependent on (*ampdu_action)()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Thu, 14 Nov 2024 01:53:56 UTC
The branch stable/14 has been updated by bz:

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

commit ce5b0b7b991f302fe1caef0bdbd838c743e6361b
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-01-27 13:24:27 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-11-14 01:53:12 +0000

    LinuxKPI: 802.11: hookup net80211 callbacks dependent on (*ampdu_action)()
    
    If a LinuxkPI base wireless driver does not support the (*ampdu_action)()
    ieee80211_ops function for offloading parts to firmware there is no
    reason for us to hook into the net80211 callbacks either but simply
    to let software (net80211) handle this.
    
    Sponsored by:   The FreeBSD Foundation (commit)
    
    (cherry picked from commit 86bc7259d3d558495511a0a23d137b4a6cd030f3)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 56 +++++++++++++++-------------
 1 file changed, 31 insertions(+), 25 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index b0ad1dee4784..1a07ef0a82fe 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2020-2024 The FreeBSD Foundation
- * Copyright (c) 2020-2022 Bjoern A. Zeeb
+ * Copyright (c) 2020-2024 Bjoern A. Zeeb
  *
  * This software was developed by Björn Zeeb under sponsorship from
  * the FreeBSD Foundation.
@@ -4681,30 +4681,36 @@ linuxkpi_ieee80211_ifattach(struct ieee80211_hw *hw)
 	ic->ic_node_free = lkpi_ic_node_free;
 
 #ifdef LKPI_80211_HT
-	lhw->ic_recv_action = ic->ic_recv_action;
-	ic->ic_recv_action = lkpi_ic_recv_action;
-	lhw->ic_send_action = ic->ic_send_action;
-	ic->ic_send_action = lkpi_ic_send_action;
-
-	lhw->ic_ampdu_enable = ic->ic_ampdu_enable;
-	ic->ic_ampdu_enable = lkpi_ic_ampdu_enable;
-
-	lhw->ic_addba_request = ic->ic_addba_request;
-	ic->ic_addba_request = lkpi_ic_addba_request;
-	lhw->ic_addba_response = ic->ic_addba_response;
-	ic->ic_addba_response = lkpi_ic_addba_response;
-	lhw->ic_addba_stop = ic->ic_addba_stop;
-	ic->ic_addba_stop = lkpi_ic_addba_stop;
-	lhw->ic_addba_response_timeout = ic->ic_addba_response_timeout;
-	ic->ic_addba_response_timeout = lkpi_ic_addba_response_timeout;
-
-	lhw->ic_bar_response = ic->ic_bar_response;
-	ic->ic_bar_response = lkpi_ic_bar_response;
-
-	lhw->ic_ampdu_rx_start = ic->ic_ampdu_rx_start;
-	ic->ic_ampdu_rx_start = lkpi_ic_ampdu_rx_start;
-	lhw->ic_ampdu_rx_stop = ic->ic_ampdu_rx_stop;
-	ic->ic_ampdu_rx_stop = lkpi_ic_ampdu_rx_stop;
+	/*
+	 * Only attach if the driver/firmware supports (*ampdu_action)().
+	 * Otherwise it is in the hands of net80211.
+	 */
+	if (lhw->ops->ampdu_action != NULL) {
+		lhw->ic_recv_action = ic->ic_recv_action;
+		ic->ic_recv_action = lkpi_ic_recv_action;
+		lhw->ic_send_action = ic->ic_send_action;
+		ic->ic_send_action = lkpi_ic_send_action;
+
+		lhw->ic_ampdu_enable = ic->ic_ampdu_enable;
+		ic->ic_ampdu_enable = lkpi_ic_ampdu_enable;
+
+		lhw->ic_addba_request = ic->ic_addba_request;
+		ic->ic_addba_request = lkpi_ic_addba_request;
+		lhw->ic_addba_response = ic->ic_addba_response;
+		ic->ic_addba_response = lkpi_ic_addba_response;
+		lhw->ic_addba_stop = ic->ic_addba_stop;
+		ic->ic_addba_stop = lkpi_ic_addba_stop;
+		lhw->ic_addba_response_timeout = ic->ic_addba_response_timeout;
+		ic->ic_addba_response_timeout = lkpi_ic_addba_response_timeout;
+
+		lhw->ic_bar_response = ic->ic_bar_response;
+		ic->ic_bar_response = lkpi_ic_bar_response;
+
+		lhw->ic_ampdu_rx_start = ic->ic_ampdu_rx_start;
+		ic->ic_ampdu_rx_start = lkpi_ic_ampdu_rx_start;
+		lhw->ic_ampdu_rx_stop = ic->ic_ampdu_rx_stop;
+		ic->ic_ampdu_rx_stop = lkpi_ic_ampdu_rx_stop;
+	}
 #endif
 
 	lkpi_radiotap_attach(lhw);