git: 5431dafdb965 - main - mtw: convert to new net80211 crypto key API
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 14 Nov 2025 02:26:22 UTC
The branch main has been updated by adrian:
URL: https://cgit.FreeBSD.org/src/commit/?id=5431dafdb9659fb578fa2b9944005e15f50d4038
commit 5431dafdb9659fb578fa2b9944005e15f50d4038
Author: Adrian Chadd <adrian@FreeBSD.org>
AuthorDate: 2025-09-25 18:29:00 +0000
Commit: Adrian Chadd <adrian@FreeBSD.org>
CommitDate: 2025-11-14 02:25:34 +0000
mtw: convert to new net80211 crypto key API
* constify mtw_write_region_1()'s data field
* convert to use ieee80211_crypto_get_*()
* .. note that rx/tx mic data routines are explicitly being called,
as this NIC is doing TKIP + MIC offload
Differential Revision: https://reviews.freebsd.org/D53704
Reviewed by: bz
---
sys/dev/usb/wlan/if_mtw.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/sys/dev/usb/wlan/if_mtw.c b/sys/dev/usb/wlan/if_mtw.c
index 6967e5081542..8384c0a2d9fc 100644
--- a/sys/dev/usb/wlan/if_mtw.c
+++ b/sys/dev/usb/wlan/if_mtw.c
@@ -174,7 +174,7 @@ static int mtw_read(struct mtw_softc *, uint16_t, uint32_t *);
static int mtw_read_region_1(struct mtw_softc *, uint16_t, uint8_t *, int);
static int mtw_write_2(struct mtw_softc *, uint16_t, uint16_t);
static int mtw_write(struct mtw_softc *, uint16_t, uint32_t);
-static int mtw_write_region_1(struct mtw_softc *, uint16_t, uint8_t *, int);
+static int mtw_write_region_1(struct mtw_softc *, uint16_t, const uint8_t *, int);
static int mtw_set_region_4(struct mtw_softc *, uint16_t, uint32_t, int);
static int mtw_efuse_read_2(struct mtw_softc *, uint16_t, uint16_t *);
static int mtw_bbp_read(struct mtw_softc *, uint8_t, uint8_t *);
@@ -1277,7 +1277,8 @@ mtw_write(struct mtw_softc *sc, uint16_t reg, uint32_t val)
}
static int
-mtw_write_region_1(struct mtw_softc *sc, uint16_t reg, uint8_t *buf, int len)
+mtw_write_region_1(struct mtw_softc *sc, uint16_t reg, const uint8_t *buf,
+ int len)
{
usb_device_request_t req;
@@ -1286,7 +1287,8 @@ mtw_write_region_1(struct mtw_softc *sc, uint16_t reg, uint8_t *buf, int len)
USETW(req.wValue, 0);
USETW(req.wIndex, reg);
USETW(req.wLength, len);
- return (usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, buf));
+ return (usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req,
+ __DECONST(uint8_t *, buf)));
}
static int
@@ -1911,7 +1913,7 @@ mtw_key_set_cb(void *arg)
/* map net80211 cipher to RT2860 security mode */
switch (cipher) {
case IEEE80211_CIPHER_WEP:
- if (k->wk_keylen < 8)
+ if (ieee80211_crypto_get_key_len(k) < 8)
mode = MTW_MODE_WEP40;
else
mode = MTW_MODE_WEP104;
@@ -1936,13 +1938,19 @@ mtw_key_set_cb(void *arg)
}
if (cipher == IEEE80211_CIPHER_TKIP) {
- mtw_write_region_1(sc, base, k->wk_key, 16);
- mtw_write_region_1(sc, base + 16, &k->wk_key[24], 8);
- mtw_write_region_1(sc, base + 24, &k->wk_key[16], 8);
+ /* TODO: note the direct use of tx/rx mic offsets! ew! */
+ mtw_write_region_1(sc, base,
+ ieee80211_crypto_get_key_data(k), 16);
+ /* rxmic */
+ mtw_write_region_1(sc, base + 16,
+ ieee80211_crypto_get_key_rxmic_data(k), 8);
+ /* txmic */
+ mtw_write_region_1(sc, base + 24,
+ ieee80211_crypto_get_key_txmic_data(k), 8);
} else {
/* roundup len to 16-bit: XXX fix write_region_1() instead */
mtw_write_region_1(sc, base, k->wk_key,
- (k->wk_keylen + 1) & ~1);
+ (ieee80211_crypto_get_key_len(k) + 1) & ~1);
}
if (!(k->wk_flags & IEEE80211_KEY_GROUP) ||