aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Chadd <adrian@FreeBSD.org>2024-12-07 16:32:04 +0000
committerAdrian Chadd <adrian@FreeBSD.org>2024-12-18 23:45:24 +0000
commitb71805e991fb955005640bdec81618e37d3af47c (patch)
treecaf918192e7ed2157a1bc14598615e68a8fc986e
parentcf6b389f7c485f735c3d84a7e3fe6833e91321e4 (diff)
rtwn: add APIs for setting transmit power
The RTL8188/RTL8192/RTL8821/RTL8812 NICs all seem happy to have their transmit power changed at runtime - and it does seem to do what's expected - the transmit power level does change. So, add the API call here, even though it's all currently no-ops. A follow-up commit will land changes for the chipsets to both limit transmit power to the configured / regulatory limit AND allow reconfiguration at runtime. Differential Revision: https://reviews.freebsd.org/D47979 Reviewed by: bz, imp
-rw-r--r--sys/dev/rtwn/if_rtwn.c9
-rw-r--r--sys/dev/rtwn/if_rtwn_nop.h6
-rw-r--r--sys/dev/rtwn/if_rtwnvar.h4
-rw-r--r--sys/dev/rtwn/rtl8188e/pci/r88ee_attach.c1
-rw-r--r--sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c1
-rw-r--r--sys/dev/rtwn/rtl8192c/pci/r92ce_attach.c1
-rw-r--r--sys/dev/rtwn/rtl8192c/usb/r92cu_attach.c1
-rw-r--r--sys/dev/rtwn/rtl8192e/usb/r92eu_attach.c1
-rw-r--r--sys/dev/rtwn/rtl8812a/usb/r12au_attach.c1
-rw-r--r--sys/dev/rtwn/rtl8821a/usb/r21au_attach.c1
10 files changed, 26 insertions, 0 deletions
diff --git a/sys/dev/rtwn/if_rtwn.c b/sys/dev/rtwn/if_rtwn.c
index d4b45aa9eea7..fdf44467680b 100644
--- a/sys/dev/rtwn/if_rtwn.c
+++ b/sys/dev/rtwn/if_rtwn.c
@@ -232,6 +232,7 @@ rtwn_attach(struct rtwn_softc *sc)
| IEEE80211_C_WME /* 802.11e */
| IEEE80211_C_SWAMSDUTX /* Do software A-MSDU TX */
| IEEE80211_C_FF /* Atheros fast-frames */
+ | IEEE80211_C_TXPMGT /* TX power control */
;
if (sc->sc_hwcrypto != RTWN_CRYPTO_SW) {
@@ -696,6 +697,14 @@ rtwn_ioctl_reset(struct ieee80211vap *vap, u_long cmd)
case IEEE80211_IOC_LDPC:
error = 0;
break;
+ case IEEE80211_IOC_TXPOWER:
+ {
+ struct rtwn_softc *sc = vap->iv_ic->ic_softc;
+ RTWN_LOCK(sc);
+ error = rtwn_set_tx_power(sc, vap);
+ RTWN_UNLOCK(sc);
+ }
+ break;
default:
error = ENETRESET;
break;
diff --git a/sys/dev/rtwn/if_rtwn_nop.h b/sys/dev/rtwn/if_rtwn_nop.h
index 4d7c63c87cd8..5e205617a12d 100644
--- a/sys/dev/rtwn/if_rtwn_nop.h
+++ b/sys/dev/rtwn/if_rtwn_nop.h
@@ -54,6 +54,12 @@ rtwn_nop_softc_vap(struct rtwn_softc *sc, struct ieee80211vap *vap)
{
}
+static __inline int
+rtwn_nop_int_softc_vap(struct rtwn_softc *sc, struct ieee80211vap *vap)
+{
+ return (0);
+}
+
static __inline void
rtwn_nop_softc_uint8_int(struct rtwn_softc *sc, uint8_t *buf, int len)
{
diff --git a/sys/dev/rtwn/if_rtwnvar.h b/sys/dev/rtwn/if_rtwnvar.h
index 163ab6068ee6..3f14c05eb79d 100644
--- a/sys/dev/rtwn/if_rtwnvar.h
+++ b/sys/dev/rtwn/if_rtwnvar.h
@@ -366,6 +366,8 @@ struct rtwn_softc {
void (*sc_init_antsel)(struct rtwn_softc *);
void (*sc_post_init)(struct rtwn_softc *);
int (*sc_init_bcnq1_boundary)(struct rtwn_softc *);
+ int (*sc_set_tx_power)(struct rtwn_softc *,
+ struct ieee80211vap *);
const uint8_t *chan_list_5ghz[3];
int chan_num_5ghz[3];
@@ -590,6 +592,8 @@ void rtwn_suspend(struct rtwn_softc *);
(((_sc)->sc_post_init)((_sc)))
#define rtwn_init_bcnq1_boundary(_sc) \
(((_sc)->sc_init_bcnq1_boundary)((_sc)))
+#define rtwn_set_tx_power(_sc, _vap) \
+ (((_sc)->sc_set_tx_power)((_sc), (_vap)))
/*
* Methods to access subfields in registers.
diff --git a/sys/dev/rtwn/rtl8188e/pci/r88ee_attach.c b/sys/dev/rtwn/rtl8188e/pci/r88ee_attach.c
index 060572f54800..e4c0027c39a5 100644
--- a/sys/dev/rtwn/rtl8188e/pci/r88ee_attach.c
+++ b/sys/dev/rtwn/rtl8188e/pci/r88ee_attach.c
@@ -191,6 +191,7 @@ r88ee_attach(struct rtwn_pci_softc *pc)
sc->sc_init_antsel = rtwn_nop_softc;
sc->sc_post_init = r88ee_post_init;
sc->sc_init_bcnq1_boundary = rtwn_nop_int_softc;
+ sc->sc_set_tx_power = rtwn_nop_int_softc_vap;
sc->mac_prog = &rtl8188e_mac[0];
sc->mac_size = nitems(rtl8188e_mac);
diff --git a/sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c b/sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c
index fcd26cd9a212..400c0a148f35 100644
--- a/sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c
+++ b/sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c
@@ -184,6 +184,7 @@ r88eu_attach(struct rtwn_usb_softc *uc)
sc->sc_init_antsel = rtwn_nop_softc;
sc->sc_post_init = r88eu_post_init;
sc->sc_init_bcnq1_boundary = rtwn_nop_int_softc;
+ sc->sc_set_tx_power = rtwn_nop_int_softc_vap;
sc->mac_prog = &rtl8188e_mac[0];
sc->mac_size = nitems(rtl8188e_mac);
diff --git a/sys/dev/rtwn/rtl8192c/pci/r92ce_attach.c b/sys/dev/rtwn/rtl8192c/pci/r92ce_attach.c
index 4c12403bf4fb..e992f1c50f26 100644
--- a/sys/dev/rtwn/rtl8192c/pci/r92ce_attach.c
+++ b/sys/dev/rtwn/rtl8192c/pci/r92ce_attach.c
@@ -221,6 +221,7 @@ r92ce_attach(struct rtwn_pci_softc *pc)
sc->sc_init_antsel = rtwn_nop_softc;
sc->sc_post_init = r92ce_post_init;
sc->sc_init_bcnq1_boundary = rtwn_nop_int_softc;
+ sc->sc_set_tx_power = rtwn_nop_int_softc_vap;
sc->mac_prog = &rtl8192ce_mac[0];
sc->mac_size = nitems(rtl8192ce_mac);
diff --git a/sys/dev/rtwn/rtl8192c/usb/r92cu_attach.c b/sys/dev/rtwn/rtl8192c/usb/r92cu_attach.c
index 8585333290bf..6482c933eec2 100644
--- a/sys/dev/rtwn/rtl8192c/usb/r92cu_attach.c
+++ b/sys/dev/rtwn/rtl8192c/usb/r92cu_attach.c
@@ -213,6 +213,7 @@ r92cu_attach(struct rtwn_usb_softc *uc)
sc->sc_init_antsel = r92c_init_antsel;
sc->sc_post_init = r92cu_post_init;
sc->sc_init_bcnq1_boundary = rtwn_nop_int_softc;
+ sc->sc_set_tx_power = rtwn_nop_int_softc_vap;
sc->mac_prog = &rtl8192cu_mac[0];
sc->mac_size = nitems(rtl8192cu_mac);
diff --git a/sys/dev/rtwn/rtl8192e/usb/r92eu_attach.c b/sys/dev/rtwn/rtl8192e/usb/r92eu_attach.c
index e0eadd72056b..c134ba22a430 100644
--- a/sys/dev/rtwn/rtl8192e/usb/r92eu_attach.c
+++ b/sys/dev/rtwn/rtl8192e/usb/r92eu_attach.c
@@ -164,6 +164,7 @@ r92eu_attach(struct rtwn_usb_softc *uc)
sc->sc_init_antsel = rtwn_nop_softc;
sc->sc_post_init = r92eu_post_init;
sc->sc_init_bcnq1_boundary = rtwn_nop_int_softc;
+ sc->sc_set_tx_power = rtwn_nop_int_softc_vap;
sc->mac_prog = &rtl8192eu_mac[0];
sc->mac_size = nitems(rtl8192eu_mac);
diff --git a/sys/dev/rtwn/rtl8812a/usb/r12au_attach.c b/sys/dev/rtwn/rtl8812a/usb/r12au_attach.c
index 70655092d1be..4b86461b2f25 100644
--- a/sys/dev/rtwn/rtl8812a/usb/r12au_attach.c
+++ b/sys/dev/rtwn/rtl8812a/usb/r12au_attach.c
@@ -251,6 +251,7 @@ r12au_attach(struct rtwn_usb_softc *uc)
sc->sc_init_antsel = r12a_init_antsel;
sc->sc_post_init = r12au_post_init;
sc->sc_init_bcnq1_boundary = rtwn_nop_int_softc;
+ sc->sc_set_tx_power = rtwn_nop_int_softc_vap;
sc->chan_list_5ghz[0] = r12a_chan_5ghz_0;
sc->chan_list_5ghz[1] = r12a_chan_5ghz_1;
diff --git a/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c b/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c
index 59fa183fd804..75d8f3669c12 100644
--- a/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c
+++ b/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c
@@ -237,6 +237,7 @@ r21au_attach(struct rtwn_usb_softc *uc)
sc->sc_init_antsel = r12a_init_antsel;
sc->sc_post_init = r12au_post_init;
sc->sc_init_bcnq1_boundary = r21a_init_bcnq1_boundary;
+ sc->sc_set_tx_power = rtwn_nop_int_softc_vap;
sc->chan_list_5ghz[0] = r12a_chan_5ghz_0;
sc->chan_list_5ghz[1] = r12a_chan_5ghz_1;