Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Sep 2022 14:01:26 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 8823ef8117e0 - stable/13 - LinuxKPI: 80211: implement (*get_antenna) and set ic_[rt]xstream
Message-ID:  <202209211401.28LE1QMI000149@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by bz:

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

commit 8823ef8117e0a21d0d0f6368b554939541fb7a86
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2022-09-03 23:11:05 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2022-09-21 11:46:46 +0000

    LinuxKPI: 80211: implement (*get_antenna) and set ic_[rt]xstream
    
    Implement the mac80211 (*get_antenna) call and after checking any
    antenna information present query the current configuration on startup
    (both informations should be identical at this point in theory).
    Both the wiphy variables and function call report a bitmask not a count.
    Count the bits for net80211 for as long as we get away with just a
    number in ic_[rt]xstream.
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 527687a9e30aef2e5e0c0c5b5e64e6059f1a37a4)
---
 sys/compat/linuxkpi/common/src/linux_80211.c        | 17 +++++++++++++++++
 sys/compat/linuxkpi/common/src/linux_80211.h        |  1 +
 sys/compat/linuxkpi/common/src/linux_80211_macops.c | 18 ++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 9095890c3dbc..b23b2b3f774b 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/sysctl.h>
 #include <sys/queue.h>
 #include <sys/taskqueue.h>
+#include <sys/libkern.h>
 
 #include <net/if.h>
 #include <net/if_var.h>
@@ -3495,6 +3496,22 @@ linuxkpi_ieee80211_ifattach(struct ieee80211_hw *hw)
 	ic->ic_htcaps |= IEEE80211_HTCAP_TXSTBC;
 #endif
 
+	/*
+	 * The wiphy variables report bitmasks of avail antennas.
+	 * (*get_antenna) get the current bitmask sets which can be
+	 * altered by (*set_antenna) for some drivers.
+	 * XXX-BZ will the count alone do us much good long-term in net80211?
+	 */
+	if (hw->wiphy->available_antennas_rx ||
+	    hw->wiphy->available_antennas_tx) {
+		uint32_t rxs, txs;
+
+		if (lkpi_80211_mo_get_antenna(hw, &txs, &rxs) == 0) {
+			ic->ic_rxstream = bitcount32(rxs);
+			ic->ic_txstream = bitcount32(txs);
+		}
+	}
+
 	ic->ic_cryptocaps = 0;
 #ifdef LKPI_80211_HW_CRYPTO
 	if (hw->wiphy->n_cipher_suites > 0) {
diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h
index 3c107f76de32..c6958cf834e3 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.h
+++ b/sys/compat/linuxkpi/common/src/linux_80211.h
@@ -197,6 +197,7 @@ struct lkpi_wiphy {
 
 int lkpi_80211_mo_start(struct ieee80211_hw *);
 void lkpi_80211_mo_stop(struct ieee80211_hw *);
+int lkpi_80211_mo_get_antenna(struct ieee80211_hw *, u32 *, u32 *);
 int lkpi_80211_mo_set_frag_threshold(struct ieee80211_hw *, uint32_t);
 int lkpi_80211_mo_set_rts_threshold(struct ieee80211_hw *, uint32_t);
 int lkpi_80211_mo_add_interface(struct ieee80211_hw *, struct ieee80211_vif *);
diff --git a/sys/compat/linuxkpi/common/src/linux_80211_macops.c b/sys/compat/linuxkpi/common/src/linux_80211_macops.c
index b3e01780e1ce..12cffc11481e 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211_macops.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211_macops.c
@@ -77,6 +77,24 @@ lkpi_80211_mo_stop(struct ieee80211_hw *hw)
 	lhw->sc_flags &= ~LKPI_MAC80211_DRV_STARTED;
 }
 
+int
+lkpi_80211_mo_get_antenna(struct ieee80211_hw *hw, u32 *txs, u32 *rxs)
+{
+	struct lkpi_hw *lhw;
+	int error;
+
+	lhw = HW_TO_LHW(hw);
+	if (lhw->ops->get_antenna == NULL) {
+		error = EOPNOTSUPP;
+		goto out;
+	}
+
+	error = lhw->ops->get_antenna(hw, txs, rxs);
+
+out:
+	return (error);
+}
+
 int
 lkpi_80211_mo_set_frag_threshold(struct ieee80211_hw *hw, uint32_t frag_th)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202209211401.28LE1QMI000149>