git: 86bc7259d3d5 - main - LinuxKPI: 802.11: hookup net80211 callbacks dependent on (*ampdu_action)()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Thu, 31 Oct 2024 20:52:37 UTC
The branch main has been updated by bz:

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

commit 86bc7259d3d558495511a0a23d137b4a6cd030f3
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-01-27 13:24:27 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-10-31 20:52:27 +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)
    MFC after:      3 days
---
 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 6de5c42fe59d..3417c7776567 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.
@@ -4675,30 +4675,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);