git: 2589197adb19 - main - net80211: migrate the group/unicast key check into inline functions
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=2589197adb199ec37f132dd7e279eb0795713f1e commit 2589197adb199ec37f132dd7e279eb0795713f1e Author: Adrian Chadd AuthorDate: 2024-06-06 17:28:03 + Commit: Adrian Chadd CommitDate: 2024-07-15 18:45:30 + net80211: migrate the group/unicast key check into inline functions The way that net80211 and drivers are checking for the /type/ of key is to check if it's in the vap WEP key array and if so, it's a group key. If not, it's a unicast key. That's not only kind of terrible, but it's also going to be problematic with future 802.11 support (for multiple unicast keys and IGTK keys for management frame protection.) So as part of this, remove the places where this is done and instead use a pair inline functions - ieee80211_is_key_global() and ieee80211_is_key_unicast(). They currenly still use the same logic but the drivers and net80211 stack isn't doing it itself. There are still open questions about why keys are not being correctly tagged as GROUP, GTK, PTK, etc. That will be investigated and addressed in follow-up work as a pre-cursor to MFP, IGTK, etc. as mentioned above. Testing: * iwn, rtwn - STA mode Differential Revision: https://reviews.freebsd.org/D45516 --- sys/dev/ath/if_ath_keycache.c | 3 +-- sys/dev/mwl/if_mwl.c| 3 +-- sys/dev/rtwn/if_rtwn_cam.c | 6 ++ sys/dev/usb/wlan/if_rsu.c | 7 +++ sys/dev/usb/wlan/if_rum.c | 10 -- sys/dev/wpi/if_wpi.c| 11 +-- sys/net80211/ieee80211.c| 31 +++ sys/net80211/ieee80211_crypto.c | 16 sys/net80211/ieee80211_var.h| 5 + 9 files changed, 60 insertions(+), 32 deletions(-) diff --git a/sys/dev/ath/if_ath_keycache.c b/sys/dev/ath/if_ath_keycache.c index bc94273bf5ce..a58625ad2803 100644 --- a/sys/dev/ath/if_ath_keycache.c +++ b/sys/dev/ath/if_ath_keycache.c @@ -434,8 +434,7 @@ ath_key_alloc(struct ieee80211vap *vap, struct ieee80211_key *k, /* * Only global keys should have key index assigned. */ - if (!(&vap->iv_nw_keys[0] <= k && - k < &vap->iv_nw_keys[IEEE80211_WEP_NKID])) { + if (!ieee80211_is_key_global(vap, k)) { /* should not happen */ DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s: bogus group key\n", __func__); diff --git a/sys/dev/mwl/if_mwl.c b/sys/dev/mwl/if_mwl.c index 479f3144dce3..49b8b3279c7f 100644 --- a/sys/dev/mwl/if_mwl.c +++ b/sys/dev/mwl/if_mwl.c @@ -1519,8 +1519,7 @@ mwl_key_alloc(struct ieee80211vap *vap, struct ieee80211_key *k, if (k->wk_keyix != IEEE80211_KEYIX_NONE || (k->wk_flags & IEEE80211_KEY_GROUP)) { - if (!(&vap->iv_nw_keys[0] <= k && - k < &vap->iv_nw_keys[IEEE80211_WEP_NKID])) { + if (!ieee80211_is_key_global(vap, k)) { /* should not happen */ DPRINTF(sc, MWL_DEBUG_KEYCACHE, "%s: bogus group key\n", __func__); diff --git a/sys/dev/rtwn/if_rtwn_cam.c b/sys/dev/rtwn/if_rtwn_cam.c index 864c13d78285..d142cd0476e4 100644 --- a/sys/dev/rtwn/if_rtwn_cam.c +++ b/sys/dev/rtwn/if_rtwn_cam.c @@ -113,8 +113,7 @@ rtwn_key_alloc(struct ieee80211vap *vap, struct ieee80211_key *k, struct rtwn_softc *sc = vap->iv_ic->ic_softc; int i, start; - if (&vap->iv_nw_keys[0] <= k && - k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) { + if (ieee80211_is_key_global(vap, k)) { *keyix = ieee80211_crypto_get_key_wepidx(vap, k); if (sc->sc_hwcrypto != RTWN_CRYPTO_FULL) k->wk_flags |= IEEE80211_KEY_SWCRYPT; @@ -308,8 +307,7 @@ rtwn_process_key(struct ieee80211vap *vap, const struct ieee80211_key *k, return (1); } - if (&vap->iv_nw_keys[0] <= k && - k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) { + if (ieee80211_is_key_global(vap, k)) { if (sc->sc_hwcrypto == RTWN_CRYPTO_FULL) { struct rtwn_vap *rvp = RTWN_VAP(vap); diff --git a/sys/dev/usb/wlan/if_rsu.c b/sys/dev/usb/wlan/if_rsu.c index e000d1fb5992..c967435250ee 100644 --- a/sys/dev/usb/wlan/if_rsu.c +++ b/sys/dev/usb/wlan/if_rsu.c @@ -1526,10 +1526,10 @@ rsu_key_alloc(struct ieee80211vap *vap, struct ieee80211_key *k, struct rsu_softc *sc = vap->iv_ic->ic_softc; int is_checked = 0; - if (&vap->iv_nw_keys[0] <= k && - k < &va
git: 3ab5e2977883 - main - net80211: fix RSN capability parsing
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=3ab5e29778835065d80cbb6610ece981ac65c4c7 commit 3ab5e29778835065d80cbb6610ece981ac65c4c7 Author: Adrian Chadd AuthorDate: 2024-07-09 16:54:21 + Commit: Adrian Chadd CommitDate: 2024-07-15 18:45:40 + net80211: fix RSN capability parsing The RSN capability field may be the last two bytes in the IE. 802.11-2016 9.4.2.25.1 (General) doesn't require anything afterwards - the PMKID/List and Group Management Cipher Suite are optional. Thus having a check of len > 2 will miss the situation where it IS the last field. This showed up when developing MFP, as I'm using optional MFP at home and optional MFP doesn't encrypt group management frames. (It should only add the BIP message integrity check IE in each action frame.) Differential Revision: https://reviews.freebsd.org/D45936 --- sys/net80211/ieee80211_hostap.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/net80211/ieee80211_hostap.c b/sys/net80211/ieee80211_hostap.c index 82d8f8b2907b..1d741ca4d7bf 100644 --- a/sys/net80211/ieee80211_hostap.c +++ b/sys/net80211/ieee80211_hostap.c @@ -1539,9 +1539,14 @@ ieee80211_parse_rsn(struct ieee80211vap *vap, const uint8_t *frm, rsn->rsn_keymgmt = RSN_ASE_8021X_PSK; /* optional RSN capabilities */ - if (len > 2) + if (len >= 2) { rsn->rsn_caps = le16dec(frm); - /* XXXPMKID */ + frm += 2, len -= 2; + } + + /* XXX PMK Count / PMKID */ + + /* XXX Group Cipher Management Suite */ return 0; }
git: 3e52b265efe9 - main - net80211: fix fast BSS transition element ID name
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=3e52b265efe9b617d57e7bf47d2cc1455313ee02 commit 3e52b265efe9b617d57e7bf47d2cc1455313ee02 Author: Adrian Chadd AuthorDate: 2024-09-01 16:37:37 + Commit: Adrian Chadd CommitDate: 2024-09-13 21:13:51 + net80211: fix fast BSS transition element ID name This is a straight up typo! Differential Revision: https://reviews.freebsd.org/D46504 --- sys/net80211/ieee80211.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h index fe2a0a7f3b64..2e07c875ae01 100644 --- a/sys/net80211/ieee80211.h +++ b/sys/net80211/ieee80211.h @@ -421,7 +421,7 @@ struct ieee80211_action { #defineIEEE80211_ACTION_CAT_BA 3 /* 9.6.4 Block Ack */ #defineIEEE80211_ACTION_CAT_PUBLIC 4 /* 9.6.7 Public */ #defineIEEE80211_ACTION_CAT_RADIO_MEASUREMENT 5 /* 9.6.6 Radio Measurement */ -#defineIEEE80211_ACTION_CAT_FAST_BBS_TRANSITION 6 /* 9.6.8 Fast BSS Transition */ +#defineIEEE80211_ACTION_CAT_FAST_BSS_TRANSITION 6 /* 9.6.8 Fast BSS Transition */ #defineIEEE80211_ACTION_CAT_HT 7 /* 9.6.11 HT */ #defineIEEE80211_ACTION_CAT_SA_QUERY 8 /* 9.6.9 SA Query */ #defineIEEE80211_ACTION_CAT_PROTECTED_DUAL_OF_PUBLIC_ACTION 9 /* 9.6.10 Protected Dual of Public Action */
git: 50982d26e45b - main - net80211: add MMIC element ID (for management frame protected group action frames)
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=50982d26e45ba36dceee471a5a6bed4a2e5f171b commit 50982d26e45ba36dceee471a5a6bed4a2e5f171b Author: Adrian Chadd AuthorDate: 2024-09-01 16:40:30 + Commit: Adrian Chadd CommitDate: 2024-09-13 21:13:58 + net80211: add MMIC element ID (for management frame protected group action frames) * add the MMIC element ID * add a comment showing the source of this table from the 802.11-2016 specification. Differential Revision: https://reviews.freebsd.org/D46505 --- sys/net80211/ieee80211.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h index 2e07c875ae01..4203952367ca 100644 --- a/sys/net80211/ieee80211.h +++ b/sys/net80211/ieee80211.h @@ -1017,6 +1017,8 @@ struct ieee80211_ie_vht_txpwrenv { /* * Management information element payloads. + * + * 802.11-2016 Table 9-77 (Element IDs). */ enum { @@ -1058,6 +1060,7 @@ enum { IEEE80211_ELEMID_COEX_2040 = 72, IEEE80211_ELEMID_INTOL_CHN_REPORT = 73, IEEE80211_ELEMID_OVERLAP_BSS_SCAN_PARAM = 74, + IEEE80211_ELEMID_MMIC = 76, IEEE80211_ELEMID_TSF_REQ= 91, IEEE80211_ELEMID_TSF_RESP = 92, IEEE80211_ELEMID_WNM_SLEEP_MODE = 93,
git: 1116e8b95c60 - main - net80211: add a new field specifically for announcing specific ciphers
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=1116e8b95c601ddaac2feb4ab0904f77801a520f commit 1116e8b95c601ddaac2feb4ab0904f77801a520f Author: Adrian Chadd AuthorDate: 2024-04-17 01:53:52 + Commit: Adrian Chadd CommitDate: 2024-05-09 00:48:40 + net80211: add a new field specifically for announcing specific ciphers This dates way, way back with the original net80211 support w/ atheros chips. The earliest chip (AR5210) had limitations supporting software encryption. It only had the four WEP slots, and not any keycache entries. So when trying to do CCMP/TKIP encryption would be enabled and the key slots would have nothing useful in them, resulting in garbage encryption/decryption. I changed this back in 2012 to disable supporting hardware WEP for AR5210 so if_ath(4) / net80211 crypto is all done in software and yes, I could do CCMP/TKIP on AR5210 in software. Fast-forward to newer-ish hardware - the Qualcomm 11ac hardware. Those also don't support pass-through keycache slots! Well, the hardware does at that layer, but then there's a whole offload data path encap/decap layer that's turning the frames from raw wifi into ethernet frames (for "dumb" AP behaviours) or "wifi direct" frames (ie, "windows".) This hides a bunch of header frame contents required for doing the software encryption / decryption path. But then if you enable the raw transmit/receive frame format it ALSO bypasses the hardware encryption/decryption engine! So for those NICs: * If you want to do encryption, you can only use the firmware supported ciphers w/ wifi direct or ethernet; * If you want to use software encrypt/decrypt, you MUST disable all encryption and instead use 100% software encryption. The wpa_supplicant bsd driver code has a specific comment about this and flips on supporting WEP/TKIP/CCMP, which is understandable but it doesn't fix the ACTUAL intention of all of this stuff. So: * create a new field, ic_sw_cryptocaps * populate it with the default supported set of ciphers for net80211 (right now wep, tkip, ccmp) * Communicate the combination of both ic_sw_cryptocaps and ic_cryptocaps to wpa_supplicant via the relevant devcap ioctl. * Update manpage. I'll follow this up with a driver_bsd.c change in wpa_supplicant to trust this again, and then start adding the other cipher support there. Differential Revision: https://reviews.freebsd.org/D44820 --- share/man/man9/ieee80211.9 | 4 +++- sys/net80211/ieee80211_crypto.c | 12 sys/net80211/ieee80211_ioctl.c | 6 +- sys/net80211/ieee80211_ioctl.h | 4 ++-- sys/net80211/ieee80211_var.h| 4 +++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/share/man/man9/ieee80211.9 b/share/man/man9/ieee80211.9 index 100b4e7540a5..40c8c243a77c 100644 --- a/share/man/man9/ieee80211.9 +++ b/share/man/man9/ieee80211.9 @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd January 26, 2021 +.Dd April 24, 2024 .Dt IEEE80211 9 .Os .Sh NAME @@ -514,6 +514,8 @@ General capabilities are specified by .Vt ic_caps . Hardware cryptographic capabilities are specified by .Vt ic_cryptocaps . +Software cryptographic capabilities are specified by +.Vt ic_sw_cryptocaps . 802.11n capabilities, if any, are specified by .Vt ic_htcaps . The diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c index 6a1182b52480..ff78600e2f0e 100644 --- a/sys/net80211/ieee80211_crypto.c +++ b/sys/net80211/ieee80211_crypto.c @@ -142,6 +142,18 @@ ieee80211_crypto_attach(struct ieee80211com *ic) { /* NB: we assume everything is pre-zero'd */ ciphers[IEEE80211_CIPHER_NONE] = &ieee80211_cipher_none; + + /* +* Default set of net80211 supported ciphers. +* +* These are the default set that all drivers are expected to +* support, either/or in hardware and software. +* +* Drivers can add their own support to this and the +* hardware cipher list (ic_cryptocaps.) +*/ + ic->ic_sw_cryptocaps = IEEE80211_CRYPTO_WEP | + IEEE80211_CRYPTO_TKIP | IEEE80211_CRYPTO_AES_CCM; } /* diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c index d5b242b679d0..c0ba19b5db89 100644 --- a/sys/net80211/ieee80211_ioctl.c +++ b/sys/net80211/ieee80211_ioctl.c @@ -709,7 +709,11 @@ ieee80211_ioctl_getdevcaps(struct ieee80211com *ic, if (dc == NULL) return ENOMEM; dc->dc_drivercaps = ic->ic_caps; - dc->dc_cryptocaps = ic->ic_cryptocaps; + /* +* Announce the set of both
git: 491938d7435f - main - wpa: Remove the now not-needed local logic to hard-code cipher support
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=491938d7435f6a1ee7b6e5a669a72e4c12bd7d2b commit 491938d7435f6a1ee7b6e5a669a72e4c12bd7d2b Author: Adrian Chadd AuthorDate: 2024-04-17 01:55:28 + Commit: Adrian Chadd CommitDate: 2024-05-09 00:48:58 + wpa: Remove the now not-needed local logic to hard-code cipher support A previous commit now exposes the supported net80211 ciphers for the given NIC, rather than the hardware cipher list. This is going to be especially important moving forward when we add more cipher and key management support. Differential Revision: https://reviews.freebsd.org/D44821 --- contrib/wpa/src/drivers/driver_bsd.c | 12 1 file changed, 12 deletions(-) diff --git a/contrib/wpa/src/drivers/driver_bsd.c b/contrib/wpa/src/drivers/driver_bsd.c index d5ff51cee456..14c19eb1246c 100644 --- a/contrib/wpa/src/drivers/driver_bsd.c +++ b/contrib/wpa/src/drivers/driver_bsd.c @@ -1557,17 +1557,6 @@ static int wpa_driver_bsd_capa(struct bsd_driver_data *drv) if (devcaps.dc_drivercaps & IEEE80211_C_WPA2) drv->capa.key_mgmt = WPA_DRIVER_CAPA_KEY_MGMT_WPA2 | WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK; -#ifdef __FreeBSD__ - drv->capa.enc |= WPA_DRIVER_CAPA_ENC_WEP40 | - WPA_DRIVER_CAPA_ENC_WEP104 | - WPA_DRIVER_CAPA_ENC_TKIP | - WPA_DRIVER_CAPA_ENC_CCMP; -#else - /* -* XXX -* FreeBSD exports hardware cryptocaps. These have no meaning for wpa -* since net80211 performs software crypto. -*/ if (devcaps.dc_cryptocaps & IEEE80211_CRYPTO_WEP) drv->capa.enc |= WPA_DRIVER_CAPA_ENC_WEP40 | @@ -1576,7 +1565,6 @@ static int wpa_driver_bsd_capa(struct bsd_driver_data *drv) drv->capa.enc |= WPA_DRIVER_CAPA_ENC_TKIP; if (devcaps.dc_cryptocaps & IEEE80211_CRYPTO_AES_CCM) drv->capa.enc |= WPA_DRIVER_CAPA_ENC_CCMP; -#endif if (devcaps.dc_drivercaps & IEEE80211_C_HOSTAP) drv->capa.flags |= WPA_DRIVER_FLAGS_AP;
git: e9961ea16496 - main - net80211: add driver / crypto methods to set the hardware / software cipher suites
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=e9961ea164968bf2bdab210eab69201b4bf2cb37 commit e9961ea164968bf2bdab210eab69201b4bf2cb37 Author: Adrian Chadd AuthorDate: 2024-04-18 01:47:07 + Commit: Adrian Chadd CommitDate: 2024-05-09 00:49:12 + net80211: add driver / crypto methods to set the hardware / software cipher suites Drivers currently announce hardware crypto cipher support by setting up ic_cryptocaps. This adds two public function calls: * ieee80211_set_software_ciphers() - set the software cipher set; * ieee80211_set_hardware_ciphers() - set the hardware cipher set. For now these just call into the newly crypto routines to set the ciphers. This then adds the two crypto routines, similarly named, to set the hardware/software cipher suite. This is a no-op right now - wep/tkip/ccmp are already set by default so drivers aren't required to call these routines for software encryption, and drivers already set ic_cryptocaps for hardware encryption. Differential Revision: https://reviews.freebsd.org/D44827 --- sys/net80211/ieee80211.c| 22 ++ sys/net80211/ieee80211_crypto.c | 21 + sys/net80211/ieee80211_crypto.h | 4 sys/net80211/ieee80211_var.h| 4 4 files changed, 51 insertions(+) diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index 15785a8f0966..1c82493274bb 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -434,6 +434,28 @@ ieee80211_ifdetach(struct ieee80211com *ic) IEEE80211_LOCK_DESTROY(ic); } +/* + * Called by drivers during attach to set the supported + * cipher set for software encryption. + */ +void +ieee80211_set_software_ciphers(struct ieee80211com *ic, +uint32_t cipher_suite) +{ + ieee80211_crypto_set_supported_software_ciphers(ic, cipher_suite); +} + +/* + * Called by drivers during attach to set the supported + * cipher set for hardware encryption. + */ +void +ieee80211_set_hardware_ciphers(struct ieee80211com *ic, +uint32_t cipher_suite) +{ + ieee80211_crypto_set_supported_hardware_ciphers(ic, cipher_suite); +} + struct ieee80211com * ieee80211_find_com(const char *name) { diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c index ff78600e2f0e..e849fe06db65 100644 --- a/sys/net80211/ieee80211_crypto.c +++ b/sys/net80211/ieee80211_crypto.c @@ -164,6 +164,27 @@ ieee80211_crypto_detach(struct ieee80211com *ic) { } +/* + * Set the supported ciphers for software encryption. + */ +void +ieee80211_crypto_set_supported_software_ciphers(struct ieee80211com *ic, +uint32_t cipher_set) +{ + ic->ic_sw_cryptocaps = cipher_set; +} + +/* + * Set the supported ciphers for hardware encryption. + */ +void +ieee80211_crypto_set_supported_hardware_ciphers(struct ieee80211com *ic, +uint32_t cipher_set) +{ + ic->ic_cryptocaps = cipher_set; +} + + /* * Setup crypto support for a vap. */ diff --git a/sys/net80211/ieee80211_crypto.h b/sys/net80211/ieee80211_crypto.h index fc7c13cfdfb4..9637278701ff 100644 --- a/sys/net80211/ieee80211_crypto.h +++ b/sys/net80211/ieee80211_crypto.h @@ -162,6 +162,10 @@ MALLOC_DECLARE(M_80211_CRYPTO); void ieee80211_crypto_attach(struct ieee80211com *); void ieee80211_crypto_detach(struct ieee80211com *); +void ieee80211_crypto_set_supported_software_ciphers(struct ieee80211com *, + uint32_t cipher_set); +void ieee80211_crypto_set_supported_hardware_ciphers(struct ieee80211com *, + uint32_t cipher_set); void ieee80211_crypto_vattach(struct ieee80211vap *); void ieee80211_crypto_vdetach(struct ieee80211vap *); intieee80211_crypto_newkey(struct ieee80211vap *, diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index 2c13113b92a1..21fdff0b88a3 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -751,6 +751,10 @@ MALLOC_DECLARE(M_80211_VAP); intic_printf(struct ieee80211com *, const char *, ...) __printflike(2, 3); void ieee80211_ifattach(struct ieee80211com *); void ieee80211_ifdetach(struct ieee80211com *); +void ieee80211_set_software_ciphers(struct ieee80211com *, + uint32_t cipher_suite); +void ieee80211_set_hardware_ciphers(struct ieee80211com *, + uint32_t cipher_suite); intieee80211_vap_setup(struct ieee80211com *, struct ieee80211vap *, const char name[IFNAMSIZ], int unit, enum ieee80211_opmode opmode, int flags,
git: c2a005a0a97d - main - net80211: add new ciphers and RSN flags
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=c2a005a0a97d98472d81c5c9606e5d6e546dd40a commit c2a005a0a97d98472d81c5c9606e5d6e546dd40a Author: Adrian Chadd AuthorDate: 2024-04-19 14:05:44 + Commit: Adrian Chadd CommitDate: 2024-05-09 00:49:34 + net80211: add new ciphers and RSN flags These are the rest of the ciphers and RSN flags from 802.11-2016. * add the rest of the ciphers from 802.11-2016 * add the rest of the RSN flags from 802.11-2016 Of special interest here are the extended key ID field for supporting >1 unicast key (to support seamless rekeying w/out dropping frames) and the MFP (management frame protection) config bits. This is a no-op; no code is using these new fields. (In particular, no code in net80211 uses the RSN capability bits; but that will change when we start on MFP support.) Differential Revision: https://reviews.freebsd.org/D44864 --- sys/net80211/ieee80211.h | 67 ++-- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h index 47e496bf42a1..fe2a0a7f3b64 100644 --- a/sys/net80211/ieee80211.h +++ b/sys/net80211/ieee80211.h @@ -1266,7 +1266,7 @@ struct ieee80211_csa_ie { #defineWPA_CSE_NULL0x00 #defineWPA_CSE_WEP40 0x01 #defineWPA_CSE_TKIP0x02 -#defineWPA_CSE_CCMP0x04 +#defineWPA_CSE_CCMP0x04/* CCMP 128-bit */ #defineWPA_CSE_WEP104 0x05 #defineWPA_ASE_NONE0x00 @@ -1275,21 +1275,62 @@ struct ieee80211_csa_ie { #defineWPS_OUI_TYPE0x04 +/* 802.11-2016 Table 9-131 - Cipher Suite Selectors */ #defineRSN_OUI 0xac0f00 #defineRSN_VERSION 1 /* current supported version */ -#defineRSN_CSE_NULL0x00 -#defineRSN_CSE_WEP40 0x01 -#defineRSN_CSE_TKIP0x02 -#defineRSN_CSE_WRAP0x03 -#defineRSN_CSE_CCMP0x04 -#defineRSN_CSE_WEP104 0x05 - -#defineRSN_ASE_NONE0x00 -#defineRSN_ASE_8021X_UNSPEC0x01 -#defineRSN_ASE_8021X_PSK 0x02 - -#defineRSN_CAP_PREAUTH 0x01 +/* RSN cipher suite element */ +#defineRSN_CSE_NULL0 +#defineRSN_CSE_WEP40 1 +#defineRSN_CSE_TKIP2 +#defineRSN_CSE_WRAP3 /* Reserved in the 802.11-2016 */ +#defineRSN_CSE_CCMP4 /* CCMP 128 bit */ +#defineRSN_CSE_WEP104 5 +#defineRSN_CSE_BIP_CMAC_1286 +/* 7 - "Group addressed traffic not allowed" */ +#defineRSN_CSE_GCMP_1288 +#defineRSN_CSE_GCMP_2569 +#defineRSN_CSE_CCMP_25610 +#defineRSN_CSE_BIP_GMAC_12811 +#defineRSN_CSE_BIP_GMAC_25612 +#defineRSN_CSE_BIP_CMAC_25613 + +/* 802.11-2016 Table 9-133 - AKM suite selectors */ +/* RSN AKM suite element */ +#defineRSN_ASE_NONE0 +#defineRSN_ASE_8021X_UNSPEC1 +#defineRSN_ASE_8021X_PSK 2 +#defineRSN_ASE_FT_8021X3 /* SHA-256 */ +#defineRSN_ASE_FT_PSK 4 /* SHA-256 */ +#defineRSN_ASE_8021X_UNSPEC_SHA256 5 +#defineRSN_ASE_8021X_PSK_SHA2566 +#defineRSN_ASE_8021X_TDLS 7 /* SHA-256 */ +#defineRSN_ASE_SAE_UNSPEC 8 /* SHA-256 */ +#defineRSN_ASE_FT_SAE 9 /* SHA-256 */ +#defineRSN_ASE_AP_PEERKEY 10 /* SHA-256 */ +#defineRSN_ASE_8021X_SUITE_B_SHA25611 +#defineRSN_ASE_8021X_SUITE_B_SHA38412 +#defineRSN_ASE_FT_8021X_SHA384 13 + +/* 802.11-2016 Figure 9-257 - RSN Capabilities (2 byte field) */ +#defineRSN_CAP_PREAUTH 0x0001 +#defineRSN_CAP_NO_PAIRWISE 0x0002 +#defineRSN_CAP_PTKSA_REPLAY_COUNTER0x000c /* 2 bit field */ +#defineRSN_CAP_GTKSA_REPLAY_COUNTER0x0030 /* 2 bit field */ +#defineRSN_CAP_MFP_REQUIRED0x0040 +#defineRSN_CAP_MFP_CAPABLE 0x0080 +#defineRSN_CAP_JOINT_MULTIBAND_RSNA0x0100 +#defineRSN_CAP_PEERKEY_ENABLED 0x0200 +#defineRSN_CAP_SPP_AMSDU_CAPABLE 0x0400 +#defineRSN_CAP_SPP_AMSDU_REQUIRED 0x0800 +#defineRSN_CAP_PBAC_CAPABLE0x1000 +#defineRSN_CAP_EXT_KEYID_CAPABLE 0x0200 + +/* 802.11-2016 Table 9-134 PTKSA/GTKSA/STKSA replay counters usage */ +#defineRSN_CAP_REPLAY_COUNTER_1_PER0 +#defineRSN_CAP_REPLAY_COUNTER_2_PER
git: 05540e62e75f - main - net80211: add the 802.11-2016 cipher list to the crypto array set.
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=05540e62e75f8b2de7e337738eacfb0b159515a6 commit 05540e62e75f8b2de7e337738eacfb0b159515a6 Author: Adrian Chadd AuthorDate: 2024-04-22 03:25:33 + Commit: Adrian Chadd CommitDate: 2024-05-14 21:39:00 + net80211: add the 802.11-2016 cipher list to the crypto array set. These are the bitmap / cipher module number fields used for net80211 ciphers. This requires a kernel recompile, but nothing (currently) in userland is using these. Differential Revision: https://reviews.freebsd.org/D44899 Reviewed by:bz, cc --- sys/net80211/ieee80211_crypto.h | 22 -- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sys/net80211/ieee80211_crypto.h b/sys/net80211/ieee80211_crypto.h index 9637278701ff..e09b822289d7 100644 --- a/sys/net80211/ieee80211_crypto.h +++ b/sys/net80211/ieee80211_crypto.h @@ -137,8 +137,17 @@ struct ieee80211_key { #defineIEEE80211_CIPHER_TKIPMIC4 /* TKIP MIC capability */ #defineIEEE80211_CIPHER_CKIP 5 #defineIEEE80211_CIPHER_NONE 6 /* pseudo value */ +#defineIEEE80211_CIPHER_AES_CCM_2567 +#defineIEEE80211_CIPHER_BIP_CMAC_128 8 +#defineIEEE80211_CIPHER_BIP_CMAC_256 9 +#defineIEEE80211_CIPHER_BIP_GMAC_128 10 +#defineIEEE80211_CIPHER_BIP_GMAC_256 11 +#defineIEEE80211_CIPHER_AES_GCM_12812 +#defineIEEE80211_CIPHER_AES_GCM_25613 -#defineIEEE80211_CIPHER_MAX(IEEE80211_CIPHER_NONE+1) +#defineIEEE80211_CIPHER_LAST 13 + +#defineIEEE80211_CIPHER_MAX(IEEE80211_CIPHER_LAST+1) /* capability bits in ic_cryptocaps/iv_cryptocaps */ #defineIEEE80211_CRYPTO_WEP(1<
git: 98e8df90b5cc - main - net80211: add placeholder module names for the new ciphers
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=98e8df90b5cc5180c09e71998e5f3e05c76a4fe1 commit 98e8df90b5cc5180c09e71998e5f3e05c76a4fe1 Author: Adrian Chadd AuthorDate: 2024-04-22 03:29:08 + Commit: Adrian Chadd CommitDate: 2024-05-14 21:39:11 + net80211: add placeholder module names for the new ciphers This is effectively a no-op as we currently don't advertise these ciphers as available anywhere. Note though the intent to support 128 and 256 bit ciphers in the same crypto module. Differential Revision: https://reviews.freebsd.org/D44900 Reviewed by:cc, cy Approved by:cc, cy --- sys/net80211/ieee80211_crypto.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c index e849fe06db65..3659d3f7c79a 100644 --- a/sys/net80211/ieee80211_crypto.c +++ b/sys/net80211/ieee80211_crypto.c @@ -274,6 +274,13 @@ static const char *cipher_modnames[IEEE80211_CIPHER_MAX] = { [IEEE80211_CIPHER_TKIPMIC] = "#4", /* NB: reserved */ [IEEE80211_CIPHER_CKIP]= "wlan_ckip", [IEEE80211_CIPHER_NONE]= "wlan_none", + [IEEE80211_CIPHER_AES_CCM_256] = "wlan_ccmp", + [IEEE80211_CIPHER_BIP_CMAC_128] = "wlan_bip_cmac", + [IEEE80211_CIPHER_BIP_CMAC_256] = "wlan_bip_cmac", + [IEEE80211_CIPHER_BIP_GMAC_128] = "wlan_bip_gmac", + [IEEE80211_CIPHER_BIP_GMAC_256] = "wlan_bip_gmac", + [IEEE80211_CIPHER_AES_GCM_128] = "wlan_gcmp", + [IEEE80211_CIPHER_AES_GCM_256] = "wlan_gcmp", }; /* NB: there must be no overlap between user-supplied and device-owned flags */
git: dcf6ab2f2e38 - main - net80211: allow a single wlan crypto module to register for >1 cipher
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=dcf6ab2f2e38238f11b8f3b20f05ab43f73618c3 commit dcf6ab2f2e38238f11b8f3b20f05ab43f73618c3 Author: Adrian Chadd AuthorDate: 2024-04-22 03:36:05 + Commit: Adrian Chadd CommitDate: 2024-05-14 21:39:24 + net80211: allow a single wlan crypto module to register for >1 cipher This allows a single wlan crypto module to register for more than one cipher. Without it, duplicate linkerset structs are initialised for the actual module loading machinery itself. I've tested this in my private tree with wlan_ccmp providing both 128 and 256 bit cipher support. Differential Revision: https://reviews.freebsd.org/D44901 Reviewed by:bz, cc, cy Approved by:bz, cc, cy --- sys/net80211/ieee80211_freebsd.h | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/net80211/ieee80211_freebsd.h b/sys/net80211/ieee80211_freebsd.h index ec017bb21ec4..b58c55cc7652 100644 --- a/sys/net80211/ieee80211_freebsd.h +++ b/sys/net80211/ieee80211_freebsd.h @@ -417,8 +417,7 @@ MODULE_DEPEND(wlan_##name, wlan, 1, 1, 1) /* * Crypto modules implement cipher support. */ -#defineIEEE80211_CRYPTO_MODULE(name, version) \ -_IEEE80211_POLICY_MODULE(crypto, name, version); \ +#defineIEEE80211_CRYPTO_MODULE_ADD(name) \ static void\ name##_modevent(int type) \ { \ @@ -429,6 +428,10 @@ name##_modevent(int type) \ } \ TEXT_SET(crypto##_set, name##_modevent) +#defineIEEE80211_CRYPTO_MODULE(name, version) \ + _IEEE80211_POLICY_MODULE(crypto, name, version);\ + IEEE80211_CRYPTO_MODULE_ADD(name) + /* * Scanner modules provide scanning policy. */
git: c7f5f140bfdd - main - net80211: add initial key management suites from 802.11-2016, APIs to register them
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=c7f5f140bfdde730dcd4380ac364a084488c962f commit c7f5f140bfdde730dcd4380ac364a084488c962f Author: Adrian Chadd AuthorDate: 2024-04-23 21:59:43 + Commit: Adrian Chadd CommitDate: 2024-05-14 21:39:33 + net80211: add initial key management suites from 802.11-2016, APIs to register them The WPA1/WPA2 driver capabilities aren't really enough in today's world. There are a /lot/ more key management suites to support! So, add initial support for net80211 and drivers to announce what key management suites are supported. These are the list from 802.11-2016 section 9.4.2.25.3 (AKM suites.) The flags are for software supported key management. Drivers may support more key management suites and are welcome to announce more; net80211 will only announce ones that we know net80211 knows "enough" about to support correctly. There /are/ other suites that may be interesting to some people in the future that are not part of this set - eg if anyone ever wants to support the Chinese WAPI standard - so this bitmap is not specifically just the AKM suites in the RSN OUI. This should eventually be communicated up to the wpa_supplicant and hostapd via a replacement driver/vap capabilities call so they know what to enable rather than just IEEE80211_C_WPA1 / IEEE80211_C_WPA2. Differential Revision: https://reviews.freebsd.org/D44919 Reviewed by:bz --- sys/net80211/_ieee80211.h | 21 + sys/net80211/ieee80211.c| 12 sys/net80211/ieee80211_crypto.c | 35 +++ sys/net80211/ieee80211_crypto.h | 2 ++ sys/net80211/ieee80211_var.h| 4 5 files changed, 74 insertions(+) diff --git a/sys/net80211/_ieee80211.h b/sys/net80211/_ieee80211.h index 1ac9328714f7..5c7e6110026d 100644 --- a/sys/net80211/_ieee80211.h +++ b/sys/net80211/_ieee80211.h @@ -536,6 +536,27 @@ struct ieee80211_mimo_info { "\21AMPDU\22AMSDU\23HT\24SMPS\25RIFS\32TXLDPC\33RXAMSDUAMPDU" \ "\34TXAMSDUAMPDU" +/* + * AKM (key management) suite capability list. + * + * These represent what's in 802.11-2016 - Table 9-133 - AKM Suite Selectors. + * Note that they do not match what the table values are, in case other key + * management suites want to be added with different OUIs. + */ +#defineIEEE80211_KEYMGMT_RSN_UNSPEC_802_1X 0x0001 /* RSN suite 1 */ +#defineIEEE80211_KEYMGMT_RSN_PSK_OVER_802_1X 0x0002 /* RSN suite 2 */ +#defineIEEE80211_KEYMGMT_RSN_FT_OVER_802_1X0x0004 /* RSN suite 3 */ +#defineIEEE80211_KEYMGMT_RSN_FT_PSK0x0008 /* RSN suite 4 */ +#defineIEEE80211_KEYMGMT_RSN_802_1X_SHA256 0x0010 /* RSN suite 5 */ +#defineIEEE80211_KEYMGMT_RSN_PSK_SHA2560x0020 /* RSN suite 6 */ +#defineIEEE80211_KEYMGMT_RSN_TPK_HANDSHAKE 0x0040 /* RSN suite 7 */ +#defineIEEE80211_KEYMGMT_RSN_SAE 0x0080 /* RSN suite 8 */ +#defineIEEE80211_KEYMGMT_RSN_FT_SAE0x0100 /* RSN suite 9 */ +#defineIEEE80211_KEYMGMT_RSN_APPEERKEY_SHA256 0x0200 /* RSN suite 10 */ +#defineIEEE80211_KEYMGMT_RSN_802_1X_SUITE_B0x0400 /* RSN suite 11 */ +#defineIEEE80211_KEYMGMT_RSN_802_1X_SUITE_B_1920x0800 /* RSN suite 12 */ +#defineIEEE80211_KEYMGMT_RSN_FT_802_1X_SHA384 0x1000 /* RSN suite 13 */ + /* * RX status notification - which fields are valid. */ diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index 1c82493274bb..ecb46e08713c 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -456,6 +456,18 @@ ieee80211_set_hardware_ciphers(struct ieee80211com *ic, ieee80211_crypto_set_supported_hardware_ciphers(ic, cipher_suite); } +/* + * Called by drivers during attach to set the supported + * key management suites by the driver/hardware. + */ +void +ieee80211_set_driver_keymgmt_suites(struct ieee80211com *ic, +uint32_t keymgmt_set) +{ + ieee80211_crypto_set_supported_driver_keymgmt(ic, + keymgmt_set); +} + struct ieee80211com * ieee80211_find_com(const char *name) { diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c index 3659d3f7c79a..829653ff1335 100644 --- a/sys/net80211/ieee80211_crypto.c +++ b/sys/net80211/ieee80211_crypto.c @@ -154,6 +154,25 @@ ieee80211_crypto_attach(struct ieee80211com *ic) */ ic->ic_sw_cryptocaps = IEEE80211_CRYPTO_WEP | IEEE80211_CRYPTO_TKIP | IEEE80211_CRYPTO_AES_CCM; + + /* +* Default set of key management types supported by net80211. +* +
git: e8de31caceaa - main - net80211: Fix traffic hang on STA/AP VAPs on a multi-VAP interface
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=e8de31caceaa36caf5d7b4355072f148e2433b82 commit e8de31caceaa36caf5d7b4355072f148e2433b82 Author: Adrian Chadd AuthorDate: 2022-04-12 20:20:28 + Commit: Adrian Chadd CommitDate: 2022-04-22 05:49:01 + net80211: Fix traffic hang on STA/AP VAPs on a multi-VAP interface This took an embarrasingly long time to find. The state changes for a radio with a STA /and/ AP VAP gets a bit messy. The AP maps are marked as waiting, waiting for the STA AP to find a channel to use before the AP VAPs become active. However, the code path that clears the OACTIVE flag on a VAP only runs during a successful run of ieee80211_newstate_cb(). So here is how it goes: * the STA VAP goes down and needs to scan; * the AP vap goes RUN->INIT; but it doesn't YET call ieee80211_newstate_cb(); * meanwhile - a send on the AP VAP causes the VAP to set the OACTIVE flag here; * then the STA VAP finishes scan and goes to RUN; * which will call wakeupwaiting() as part of the STA VAP transition to RUN; * .. then the AP VAP goes INIT->RUN directly via a call to hostap_newstate in wakeupwaiting rather than it being through the deferred path; * /then/ the ieee80211_newstate_cb() is called, but it sees the state go RUN->RUN; * .. which results in the OACTIVE flag never being cleared. This clears the OACTIVE flag when a VAP transitions RUN->RUN; the driver layer or net80211 layer can set it if required in a subsequent transmit. Differential Revision: https://reviews.freebsd.org/D34920 Reviewed by: bz --- sys/net80211/ieee80211_proto.c | 47 ++ 1 file changed, 47 insertions(+) diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c index 2228983050a2..d2bde99ce79c 100644 --- a/sys/net80211/ieee80211_proto.c +++ b/sys/net80211/ieee80211_proto.c @@ -2469,6 +2469,29 @@ wakeupwaiting(struct ieee80211vap *vap0) vap->iv_flags_ext &= ~IEEE80211_FEXT_SCANWAIT; /* NB: sta's cannot go INIT->RUN */ /* NB: iv_newstate may drop the lock */ + + /* +* This is problematic if the interface has OACTIVE +* set. Only the deferred ieee80211_newstate_cb() +* will end up actually /clearing/ the OACTIVE +* flag on a state transition to RUN from a non-RUN +* state. +* +* But, we're not actually deferring this callback; +* and when the deferred call occurs it shows up as +* a RUN->RUN transition! So the flag isn't/wasn't +* cleared! +* +* I'm also not sure if it's correct to actually +* do the transitions here fully through the deferred +* paths either as other things can be invoked as +* part of that state machine. +* +* So just keep this in mind when looking at what +* the markwaiting/wakeupwaiting routines are doing +* and how they invoke vap state changes. +*/ + vap->iv_newstate(vap, vap->iv_opmode == IEEE80211_M_STA ? IEEE80211_S_SCAN : IEEE80211_S_RUN, 0); @@ -2543,6 +2566,30 @@ ieee80211_newstate_cb(void *xvap, int npending) goto done; } + /* +* Handle the case of a RUN->RUN transition occuring when STA + AP +* VAPs occur on the same radio. +* +* The mark and wakeup waiting routines call iv_newstate() directly, +* but they do not end up deferring state changes here. +* Thus, although the VAP newstate method sees a transition +* of RUN->INIT->RUN, the deferred path here only sees a RUN->RUN +* transition. If OACTIVE is set then it is never cleared. +* +* So, if we're here and the state is RUN, just clear OACTIVE. +* At some point if the markwaiting/wakeupwaiting paths end up +* also invoking the deferred state updates then this will +* be no-op code - and also if OACTIVE is finally retired, it'll +* also be no-op code. +*/ + if (nstate == IEEE80211_S_RUN) { + /* +* Unblock the VAP queue; a RUN->RUN state can happen +* on a STA+AP setup on the AP vap. See wakeupwaiting(). +*/ + vap->iv_ifp->if
git: 697684325da8 - main - [vale] Fix valectl to compile on a 32-bit platform
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=697684325da855f0dcb1ad02b09779575b05a906 commit 697684325da855f0dcb1ad02b09779575b05a906 Author: Adrian Chadd AuthorDate: 2020-12-29 18:20:43 + Commit: Adrian Chadd CommitDate: 2020-12-30 18:40:43 + [vale] Fix valectl to compile on a 32-bit platform This shows up when compiling valectl on a 32 bit platform like i386 and mips32. gcc-6.4 complains about this (-Wint-to-pointer-cast). Reviewed by: vmaffione Differential Revision: https://reviews.freebsd.org/D27814 --- usr.sbin/valectl/valectl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/valectl/valectl.c b/usr.sbin/valectl/valectl.c index 7e219e2df7a3..bf1bc6229fb8 100644 --- a/usr.sbin/valectl/valectl.c +++ b/usr.sbin/valectl/valectl.c @@ -181,7 +181,7 @@ list_all(int fd, struct nmreq_header *hdr) { int error; struct nmreq_vale_list *vale_list = - (struct nmreq_vale_list *)hdr->nr_body; + (struct nmreq_vale_list *)(uintptr_t)hdr->nr_body; for (;;) { hdr->nr_name[0] = '\0'; ___ dev-commits-src-main@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"
git: 7c5a624afae4 - main - [wpa] Add support for hostapd/wpa_supplicant when WITHOUT_CRYPT=YES is enabled.
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=7c5a624afae43c44d8e57eb8c5073b9b07f88064 commit 7c5a624afae43c44d8e57eb8c5073b9b07f88064 Author: Adrian Chadd AuthorDate: 2021-01-04 20:39:53 + Commit: Adrian Chadd CommitDate: 2021-01-13 00:43:19 + [wpa] Add support for hostapd/wpa_supplicant when WITHOUT_CRYPT=YES is enabled. This builds wpa_supplicant / hostpad using internal encryption routines rather than using libcrypt. This has been supported in wpa for years now, however since we use local makefiles for this, we bitrotted dependencies and configuration options. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D27958 --- share/mk/src.opts.mk | 1 - usr.sbin/wpa/Makefile.crypto | 31 +-- usr.sbin/wpa/hostapd/Makefile| 4 usr.sbin/wpa/wpa_supplicant/Makefile | 2 +- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index b87826781318..55d07dac42dd 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -438,7 +438,6 @@ MK_LDNS:= no MK_PKGBOOTSTRAP:= no MK_SVN:= no MK_SVNLITE:= no -MK_WIRELESS:= no .endif .if ${MK_LDNS} == "no" diff --git a/usr.sbin/wpa/Makefile.crypto b/usr.sbin/wpa/Makefile.crypto index 1b67c79650af..bed452bf8592 100644 --- a/usr.sbin/wpa/Makefile.crypto +++ b/usr.sbin/wpa/Makefile.crypto @@ -16,9 +16,13 @@ CONFIG_INTERNAL_RC4=y CONFIG_INTERNAL_SHA1=y NEED_SHA256=y CONFIG_INTERNAL_SHA256=y +NEED_SHA384=y +CONFIG_INTERNAL_SHA384=y +NEED_SHA512=y +CONFIG_INTERNAL_SHA512=y CONFIG_INTERNAL_TLS=y +NEED_DH_GROUPS=y CONFIG_INTERNAL_DH5=y -CONFIG_INTERNAL_DH=y NEED_AES_ENC=true NEED_AES_CBC=true .endif @@ -45,6 +49,7 @@ SRCS+=asn1.c \ tlsv1_client.c \ tlsv1_client_write.c \ tlsv1_client_read.c \ + tlsv1_client_ocsp.c \ x509v3.c NEED_DES=y NEED_MD4=y @@ -123,14 +128,36 @@ SRCS+=sha256-internal.c sha256-prf.c .endif .endif +.if defined(NEED_SHA384) +CFLAGS+=-DCONFIG_SHA384 +SRCS+= sha384.c +.if defined(CONFIG_INTERNAL_SHA384) +SRCS+= sha384-internal.c sha384-prf.c +.endif +.endif + +.if defined(NEED_SHA512) +CFLAGS+=-DCONFIG_SHA512 +SRCS+= sha512.c +.if defined(CONFIG_INTERNAL_SHA512) +SRCS+= sha512-internal.c sha512-prf.c +.endif +.endif + .if defined(NEED_TLS_PRF) SRCS+= sha1-tlsprf.c .endif .if defined(CONFIG_INTERNAL_DH5) +.if defined(NEED_DH_GROUPS) SRCS+= dh_group5.c .endif +.endif -.if defined(CONFIG_INTERNAL_DH) +.if defined(NEED_DH_GROUPS) SRCS+= dh_groups.c .endif + +.if defined(NEED_DH_GROUPS_ALL) +CFLAGS+=-DALL_DH_GROUPS +.endif diff --git a/usr.sbin/wpa/hostapd/Makefile b/usr.sbin/wpa/hostapd/Makefile index 24c25ffc0b94..579694046989 100644 --- a/usr.sbin/wpa/hostapd/Makefile +++ b/usr.sbin/wpa/hostapd/Makefile @@ -163,6 +163,10 @@ SRCS+= eap_server_gtc.c \ eapol_auth_sm.c TLS_FUNCS=y +# For WPS, EAP modes, etc +NEED_DH_GROUPS=y +NEED_DH_GROUPS_ALL=y + .if !empty(CFLAGS:M*-DCONFIG_WPS) NEED_SIM_COMMON=y .endif diff --git a/usr.sbin/wpa/wpa_supplicant/Makefile b/usr.sbin/wpa/wpa_supplicant/Makefile index 7556e9b8d26a..dc8178ccf9b8 100644 --- a/usr.sbin/wpa/wpa_supplicant/Makefile +++ b/usr.sbin/wpa/wpa_supplicant/Makefile @@ -14,7 +14,7 @@ PROG= wpa_supplicant SRCS= base64.c bitfield.c blacklist.c bss.c cli.c common.c \ config.c config_file.c \ ctrl_iface.c ctrl_iface_common.c ctrl_iface_unix.c \ - dh_groups.c driver_bsd.c driver_common.c \ + driver_bsd.c driver_common.c \ driver_ndis.c driver_wired.c driver_wired_common.c drivers.c \ eap_register.c eloop.c \ events.c gas.c gas_query.c \ ___ dev-commits-src-main@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"
git: bd72252aace3 - main - [mips] revert r366664 - flip mips back from -O2 to -O
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=bd72252aace382921840ddbceea712b96f4ad242 commit bd72252aace382921840ddbceea712b96f4ad242 Author: Adrian Chadd AuthorDate: 2021-01-12 21:13:20 + Commit: Adrian Chadd CommitDate: 2021-01-14 07:03:53 + [mips] revert r34 - flip mips back from -O2 to -O Now that I have -head fitting in 8MB of flash again, I can test out freebsd-head on my home AP test setup. Unfortunately, the introduction of -O2 in r34 causes the following infinite loop shortly after boot: -- MAP: No valid partition found at map/rootfs.uzip Warning: no time-of-day clock registered, system time will not be set accurately start_init: trying /sbin/init BAD_PAGE_FAULT: pid 1 tid 11 (init), uid 0: pc 0x4042c320 got a read fault (type 0x2) at 0x2e3a0 Trapframe Register Dump: zero: 0 at: 0 v0: 0 v1: 0 a0: 0x1af34 a1: 0 a2: 0 a3: 0x7fffeff0 t0: 0 t1: 0 t2: 0 t3: 0 t4: 0 t5: 0 t6: 0 t7: 0 t8: 0 t9: 0x152e8 s0: 0x7fffee84 s1: 0 s2: 0 s3: 0 s4: 0 s5: 0 s6: 0 s7: 0 k0: 0 k1: 0 gp: 0x362c0 sp: 0x7fffedf0 s8: 0 ra: 0x40417df0 sr: 0xf413 mullo: 0mulhi: 0badvaddr: 0x2e3a0 cause: 0x8008 pc: 0x4042c31c Page table info for pc address 0x4042c320: pde = 0x80712000, pte = 0xa002065a Dumping 4 words starting at pc address 0x4042c320: 8f9980e0 8082 10400067 00809825 Page table info for bad address 0x2e3a0: pde = 0, pte = 0 -- I'm not yet sure why, but until I figure it out with the mips64/cheri folk this should be reverted. This should only use -O on GCC generated code for MIPS platforms. Tested: * QCA934x (mips74k) - WDR-3600/WDR-4300 APs Differential Revision: https://reviews.freebsd.org/D28122 --- share/mk/sys.mk | 7 +++ 1 file changed, 7 insertions(+) diff --git a/share/mk/sys.mk b/share/mk/sys.mk index 8f456b28593a..72f458397683 100644 --- a/share/mk/sys.mk +++ b/share/mk/sys.mk @@ -166,7 +166,14 @@ CC ?= c89 CFLAGS ?= -O .else CC ?= cc +.if ${MACHINE_CPUARCH} == "mips" && ${COMPILER_TYPE} == "gcc" +# Note: there are currently issues generating code gcc-6.x targeting +# code for at least mips32. The system hits infinite page faults +# when starting /sbin/init if -O2 is used. +CFLAGS ?= -O -pipe +.else CFLAGS ?= -O2 -pipe +.endif .if defined(NO_STRICT_ALIASING) CFLAGS += -fno-strict-aliasing .endif ___ dev-commits-src-main@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"
git: 547739cc003a - main - [ar71xx] Fix routerstation / routerstation pro redboot FIS probing
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=547739cc003a68f43a13981e5de1143861eca08c commit 547739cc003a68f43a13981e5de1143861eca08c Author: Adrian Chadd AuthorDate: 2021-02-25 21:06:03 + Commit: Adrian Chadd CommitDate: 2021-02-25 21:14:55 + [ar71xx] Fix routerstation / routerstation pro redboot FIS probing Some changes back in ye olde times somewhere has changed the default block size the flash device exposes. So, the default geom redboot FIS probing (to find the partition table structure in flash!) is no longer finding it. So, force it to probe at the last 64k of flash regardless of the underlying flash block size. Tested: * Ubiquiti Routerstation pro, boots -HEAD MIPS --- sys/mips/conf/ROUTERSTATION.hints | 4 sys/mips/conf/RSPRO.hints | 4 2 files changed, 8 insertions(+) diff --git a/sys/mips/conf/ROUTERSTATION.hints b/sys/mips/conf/ROUTERSTATION.hints index 7b35b229af30..c5740c035d8f 100644 --- a/sys/mips/conf/ROUTERSTATION.hints +++ b/sys/mips/conf/ROUTERSTATION.hints @@ -46,3 +46,7 @@ hint.gpioled.0.at="gpiobus0" hint.gpioled.0.name="rf" # pin 2 hint.gpioled.0.pins=0x0004 + +# Override this to ensure we definitely point to the last 64K of the +# 16MiB flash chip in case underlying block size of the flash driver changes. +hint.redboot.0.fisoffset="0xff" diff --git a/sys/mips/conf/RSPRO.hints b/sys/mips/conf/RSPRO.hints index a802328db3b5..6ed26ec0b9e6 100644 --- a/sys/mips/conf/RSPRO.hints +++ b/sys/mips/conf/RSPRO.hints @@ -47,3 +47,7 @@ hint.gpioled.0.at="gpiobus0" hint.gpioled.0.name="rf" # pin 2 hint.gpioled.0.pins=0x0004 + +# Override this to ensure we definitely point to the last 64K of the +# 16MiB flash chip in case underlying block size of the flash driver changes. +hint.redboot.0.fisoffset="0xff" ___ dev-commits-src-main@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"
git: 51dfae383bf6 - main - [ath] validate ts_antenna before updating tx statistics
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=51dfae383bf6298af9e6d816a78b92b6f34d68be commit 51dfae383bf6298af9e6d816a78b92b6f34d68be Author: Adrian Chadd AuthorDate: 2021-03-13 01:29:09 + Commit: Adrian Chadd CommitDate: 2021-03-13 01:33:07 + [ath] validate ts_antenna before updating tx statistics Right now ts_antenna is either 0 or 1 in each supported HAL so this is purely a sanity check. Later on if I ever get magical free time I may add some extensions for the NICs that can have slightly more complicated antenna switches for transmit and I'd like this to not bust memory. --- sys/dev/ath/if_ath.c | 5 + 1 file changed, 5 insertions(+) diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index 34a9311c834a..0ef10e529dd5 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -4175,6 +4175,11 @@ ath_tx_update_stats(struct ath_softc *sc, struct ath_tx_status *ts, if (ts->ts_status == 0) { u_int8_t txant = ts->ts_antenna; + /* +* Handle weird/corrupted tx antenna field +*/ + if (txant >= ATH_IOCTL_STATS_NUM_TX_ANTENNA) + txant = 0; sc->sc_stats.ast_ant_tx[txant]++; sc->sc_ant_tx[txant]++; if (ts->ts_finaltsi != 0) ___ dev-commits-src-main@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"
git: fb3edd4f3ff8 - main - [ath] do a cold reset if TSFOOR triggers
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=fb3edd4f3ff89f5883b8309ff71ff4a426279c85 commit fb3edd4f3ff89f5883b8309ff71ff4a426279c85 Author: Adrian Chadd AuthorDate: 2021-03-13 07:30:25 + Commit: Adrian Chadd CommitDate: 2021-03-13 07:30:25 + [ath] do a cold reset if TSFOOR triggers TSFOOR happens if a beacon with a given TSF isn't received within the programmed/expected TSF value, plus/minus a fudge range. (OOR == out of range.) If this happens then it could be because the baseband/mac is stuck, or the baseband is deaf. So, do a cold reset and resync the beacon to try and unstick the hardware. It also happens when a bad AP decides to err, slew its TSF because they themselves are resetting and they don't preserve the TSF "well." This has fixed a bunch of weird corner cases on my 2GHz AP radio upstairs here where it occasionally goes deaf due to how much 2GHz noise is up here (and ANI gets a little sideways) and this unsticks the station VAP. For AP modes a hung baseband/mac usually ends up as a stuck beacon and those have been addressed for a long time by just resetting the hardware. But similar hangs in station mode didn't have a similar recovery mechanism. Tested: * AR9380, STA mode, 2GHz/5GHz * AR9580, STA mode, 5GHz * QCA9344 SoC w/ on-board wifi (TL-WDR4300/3600 devices); 2GHz STA mode --- sys/dev/ath/if_ath.c | 50 ++- sys/dev/ath/if_athioctl.h | 1 + sys/dev/ath/if_athvar.h | 1 + 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index 0ef10e529dd5..698b8d1a2853 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -165,6 +165,7 @@ static void ath_parent(struct ieee80211com *); static voidath_fatal_proc(void *, int); static voidath_bmiss_vap(struct ieee80211vap *); static voidath_bmiss_proc(void *, int); +static voidath_tsfoor_proc(void *, int); static voidath_key_update_begin(struct ieee80211vap *); static voidath_key_update_end(struct ieee80211vap *); static voidath_update_mcast_hw(struct ath_softc *); @@ -761,6 +762,7 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) TASK_INIT(&sc->sc_rxtask, 0, sc->sc_rx.recv_tasklet, sc); TASK_INIT(&sc->sc_bmisstask, 0, ath_bmiss_proc, sc); + TASK_INIT(&sc->sc_tsfoortask, 0, ath_tsfoor_proc, sc); TASK_INIT(&sc->sc_bstucktask,0, ath_bstuck_proc, sc); TASK_INIT(&sc->sc_resettask,0, ath_reset_proc, sc); TASK_INIT(&sc->sc_txqtask, 0, ath_txq_sched_tasklet, sc); @@ -2333,13 +2335,18 @@ ath_intr(void *arg) sc->sc_stats.ast_rxorn++; } if (status & HAL_INT_TSFOOR) { - /* out of range beacon - wake the chip up, -* but don't modify self-gen frame config */ - device_printf(sc->sc_dev, "%s: TSFOOR\n", __func__); - sc->sc_syncbeacon = 1; + /* +* out of range beacon - wake the chip up, +* but don't modify self-gen frame config. +* Do a full reset to clear any potential stuck +* PHY/MAC that generated this condition. +*/ + sc->sc_stats.ast_tsfoor++; ATH_LOCK(sc); ath_power_setpower(sc, HAL_PM_AWAKE, 0); ATH_UNLOCK(sc); + taskqueue_enqueue(sc->sc_tq, &sc->sc_tsfoortask); + device_printf(sc->sc_dev, "%s: TSFOOR\n", __func__); } if (status & HAL_INT_MCI) { ath_btcoex_mci_intr(sc); @@ -2483,7 +2490,7 @@ ath_bmiss_proc(void *arg, int pending) ath_beacon_miss(sc); /* -* Do a reset upon any becaon miss event. +* Do a reset upon any beacon miss event. * * It may be a non-recognised RX clear hang which needs a reset * to clear. @@ -2505,6 +2512,39 @@ ath_bmiss_proc(void *arg, int pending) ATH_UNLOCK(sc); } +/* + * Handle a TSF out of range interrupt in STA mode. + * + * This may be due to a partially deaf looking radio, so + * do a full reset just in case it is indeed deaf and + * resync the beacon. + */ +static void +ath_tsfoor_proc(void *arg, int pending) +{ + struct ath_softc *sc = arg; + + DPRINTF(sc, ATH_DEBUG_ANY, "%s: pending %u\n", __func__, pending); + + ATH_LOCK(sc); + ath_power_set_power_state(sc, HAL_PM_AWAKE); + ATH_UNLOCK(sc); + + /* +* Do a full reset
git: 25bfa448602c - main - Add device and ifnet logging methods, similar to device_printf / if_printf
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=25bfa448602cac74723115d0b0bd145ac795b685 commit 25bfa448602cac74723115d0b0bd145ac795b685 Author: Adrian Chadd AuthorDate: 2021-03-21 18:49:05 + Commit: Adrian Chadd CommitDate: 2021-03-22 00:02:34 + Add device and ifnet logging methods, similar to device_printf / if_printf * device_printf() is effectively a printf * if_printf() is effectively a LOG_INFO This allows subsystems to log device/netif stuff using different log levels, rather than having to invent their own way to prefix unit/netif names. Differential Revision: https://reviews.freebsd.org/D29320 Reviewed by: imp --- sys/kern/subr_bus.c | 41 + sys/net/if.c| 26 +++--- sys/net/if_var.h| 1 + sys/sys/bus.h | 1 + 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index ecd6c9685e36..31975fb8977c 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -2435,6 +2435,47 @@ device_printf(device_t dev, const char * fmt, ...) return (retval); } +/** + * @brief Print the name of the device followed by a colon, a space + * and the result of calling log() with the value of @p fmt and + * the following arguments. + * + * @returns the number of characters printed + */ +int +device_log(device_t dev, int pri, const char * fmt, ...) +{ + char buf[128]; + struct sbuf sb; + const char *name; + va_list ap; + size_t retval; + + retval = 0; + + sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN); + + name = device_get_name(dev); + + if (name == NULL) + sbuf_cat(&sb, "unknown: "); + else + sbuf_printf(&sb, "%s%d: ", name, device_get_unit(dev)); + + va_start(ap, fmt); + sbuf_vprintf(&sb, fmt, ap); + va_end(ap); + + sbuf_finish(&sb); + + log(pri, "%.*s", (int) sbuf_len(&sb), sbuf_data(&sb)); + retval = sbuf_len(&sb); + + sbuf_delete(&sb); + + return (retval); +} + /** * @internal */ diff --git a/sys/net/if.c b/sys/net/if.c index 86c60cfcfa7f..bbd677e0153c 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -3968,15 +3968,35 @@ if_initname(struct ifnet *ifp, const char *name, int unit) strlcpy(ifp->if_xname, name, IFNAMSIZ); } +static int +if_vlog(struct ifnet *ifp, int pri, const char *fmt, va_list ap) +{ + char if_fmt[256]; + + snprintf(if_fmt, sizeof(if_fmt), "%s: %s", ifp->if_xname, fmt); + vlog(pri, if_fmt, ap); + return (0); +} + + int if_printf(struct ifnet *ifp, const char *fmt, ...) { - char if_fmt[256]; va_list ap; - snprintf(if_fmt, sizeof(if_fmt), "%s: %s", ifp->if_xname, fmt); va_start(ap, fmt); - vlog(LOG_INFO, if_fmt, ap); + if_vlog(ifp, LOG_INFO, fmt, ap); + va_end(ap); + return (0); +} + +int +if_log(struct ifnet *ifp, int pri, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + if_vlog(ifp, pri, fmt, ap); va_end(ap); return (0); } diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 33a737880a8d..1f82dd028379 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -659,6 +659,7 @@ voidif_free(struct ifnet *); void if_initname(struct ifnet *, const char *, int); void if_link_state_change(struct ifnet *, int); intif_printf(struct ifnet *, const char *, ...) __printflike(2, 3); +intif_log(struct ifnet *, int, const char *, ...) __printflike(3, 4); void if_ref(struct ifnet *); void if_rele(struct ifnet *); bool if_try_ref(struct ifnet *); diff --git a/sys/sys/bus.h b/sys/sys/bus.h index fbc69ca625c1..25fb86d3c42d 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -607,6 +607,7 @@ int device_is_quiet(device_t dev); device_t device_lookup_by_name(const char *name); intdevice_print_prettyname(device_t dev); intdevice_printf(device_t dev, const char *, ...) __printflike(2, 3); +intdevice_log(device_t dev, int pri, const char *, ...) __printflike(3, 4); intdevice_probe(device_t dev); intdevice_probe_and_attach(device_t dev); intdevice_probe_child(device_t bus, device_t dev); ___ dev-commits-src-main@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"
git: b6fd00791f2b - main - [iwn] Flip over to use VAP flags rather than ic flags for things
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=b6fd00791f2b9690b0a5d8670fc03f74eda96da2 commit b6fd00791f2b9690b0a5d8670fc03f74eda96da2 Author: Adrian Chadd AuthorDate: 2021-03-22 16:47:43 + Commit: Adrian Chadd CommitDate: 2021-03-26 01:26:09 + [iwn] Flip over to use VAP flags rather than ic flags for things net80211 changed a while back to support per-VAP config for things rather than it being global. This is to support firmware NICs that support per-VAP flags and configuration where the firmware will figure out how to combine them. However, it introduced a fun timing issue - those changes used to happen to the shared ic state before newstate() was called, but now they're also tasks and they can happen /after/. This isn't a problem for ath(4), but it exposed some interesting timing and config bugs here. Notably, I saw short slot NOT being configured in 5GHz mode during some associations, so 5GHz stuff would hang or behave poorly. Other times the follow-up auth has the right config, so it didn't hang. So for now, just flip this over to using the per-VAP flags which are correct when newstate() is called. net80211 should also have those flags synch'ed to the global ic state before newstate() runs and that can come in a subsequent commit. Whilst here also fix plcp to be consistently logged as a hex value. Tested: * iwn(4) Intel 6205, STA mode, both 2GHz and 5GHz Differential Revision: https://reviews.freebsd.org/D29379 Reviewed by: bz --- sys/dev/iwn/if_iwn.c | 41 +++-- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index 2121a15bad6e..b07b52cbea7c 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -4450,7 +4450,7 @@ iwn_check_rate_needs_protection(struct iwn_softc *sc, /* * 11bg protection not enabled? Then don't use it. */ - if ((ic->ic_flags & IEEE80211_F_USEPROT) == 0) + if ((vap->iv_flags & IEEE80211_F_USEPROT) == 0) return (0); /* @@ -4936,7 +4936,7 @@ iwn_tx_cmd(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni, data->ni = ni; DPRINTF(sc, IWN_DEBUG_XMIT, "%s: qid %d idx %d len %d nsegs %d " - "plcp %d\n", + "plcp 0x%x\n", __func__, ring->qid, ring->cur, totlen, nsegs, tx->rate); /* Fill TX descriptor. */ @@ -6654,18 +6654,18 @@ iwn5000_runtime_calib(struct iwn_softc *sc) } static uint32_t -iwn_get_rxon_ht_flags(struct iwn_softc *sc, struct ieee80211_channel *c) +iwn_get_rxon_ht_flags(struct iwn_softc *sc, struct ieee80211vap *vap, +struct ieee80211_channel *c) { - struct ieee80211com *ic = &sc->sc_ic; uint32_t htflags = 0; if (! IEEE80211_IS_CHAN_HT(c)) return (0); - htflags |= IWN_RXON_HT_PROTMODE(ic->ic_curhtprotmode); + htflags |= IWN_RXON_HT_PROTMODE(vap->iv_curhtprotmode); if (IEEE80211_IS_CHAN_HT40(c)) { - switch (ic->ic_curhtprotmode) { + switch (vap->iv_curhtprotmode) { case IEEE80211_HTINFO_OPMODE_HT20PR: htflags |= IWN_RXON_HT_MODEPURE40; break; @@ -6912,7 +6912,7 @@ iwn_config(struct iwn_softc *sc) sc->rxchainmask, sc->nrxchains); - sc->rxon->flags |= htole32(iwn_get_rxon_ht_flags(sc, ic->ic_curchan)); + sc->rxon->flags |= htole32(iwn_get_rxon_ht_flags(sc, vap, ic->ic_curchan)); DPRINTF(sc, IWN_DEBUG_RESET, "%s: setting configuration; flags=0x%08x\n", @@ -7285,9 +7285,17 @@ iwn_auth(struct iwn_softc *sc, struct ieee80211vap *vap) sc->rxon->flags = htole32(IWN_RXON_TSF | IWN_RXON_CTS_TO_SELF); if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan)) sc->rxon->flags |= htole32(IWN_RXON_AUTO | IWN_RXON_24GHZ); - if (ic->ic_flags & IEEE80211_F_SHSLOT) + + /* +* We always set short slot on 5GHz channels. +* We optionally set it for 2.4GHz channels. +*/ + if (IEEE80211_IS_CHAN_5GHZ(ni->ni_chan)) + sc->rxon->flags |= htole32(IWN_RXON_SHSLOT); + else if (vap->iv_flags & IEEE80211_F_SHSLOT) sc->rxon->flags |= htole32(IWN_RXON_SHSLOT); - if (ic->ic_flags & IEEE80211_F_SHPREAMBLE) + + if (vap->iv_flags & IEEE80211_F_SHPREAMBLE) sc->rxon->flags |= htole32(IWN_RXON_SHPREAMBLE); if (IEEE80211_IS_CHAN_A(ni->ni_chan)) { sc->rxon->cck_mask = 0; @@ -7302,7 +7310,7 @@ iwn_auth(struct iwn_softc *sc,
git: 8e53cd709943 - main - ipq4018: add TCSR definitions from Linux.
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=8e53cd70994369510b24248aad1352aed70727c9 commit 8e53cd70994369510b24248aad1352aed70727c9 Author: Adrian Chadd AuthorDate: 2021-10-16 03:11:46 + Commit: Adrian Chadd CommitDate: 2021-10-18 19:18:01 + ipq4018: add TCSR definitions from Linux. These are hardware configuration options which are required in the linux/openwrt device trees for the IPQ4018/IPQ4019 devices. Since this isn't obtained from linux upstream but instead from openwrt, this can't go in contrib; instead it is going in sys/dts/include/ . Obtained from: OpenWRT Tested: * IPQ4019 ASUS RT-AC58U AP, initial bootstrapping --- sys/conf/Makefile.arm | 2 +- sys/dts/include/dt-bindings/soc/qcom,tcsr.h | 27 +++ sys/tools/fdt/make_dtb.sh | 2 +- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/sys/conf/Makefile.arm b/sys/conf/Makefile.arm index 754b43131d6d..9034ffb5e29a 100644 --- a/sys/conf/Makefile.arm +++ b/sys/conf/Makefile.arm @@ -30,7 +30,7 @@ S=../../.. .endif .include "$S/conf/kern.pre.mk" -INCLUDES+= -I$S/contrib/libfdt -I$S/contrib/device-tree/include +INCLUDES+= -I$S/contrib/libfdt -I$S/contrib/device-tree/include -I$$/dts/include LINUX_DTS_VERSION!=awk '/freebsd,dts-version/ { sub(/;$$/,"", $$NF); print $$NF }' $S/dts/freebsd-compatible.dts CFLAGS += -DLINUX_DTS_VERSION=\"${LINUX_DTS_VERSION}\" diff --git a/sys/dts/include/dt-bindings/soc/qcom,tcsr.h b/sys/dts/include/dt-bindings/soc/qcom,tcsr.h new file mode 100644 index ..47540b3b8a04 --- /dev/null +++ b/sys/dts/include/dt-bindings/soc/qcom,tcsr.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. */ +#ifndef__DT_BINDINGS_QCOM_TCSR_H__ +#define__DT_BINDINGS_QCOM_TCSR_H__ + +#defineTCSR_USB_SELECT_USB3_P0 0x1 +#defineTCSR_USB_SELECT_USB3_P1 0x2 +#defineTCSR_USB_SELECT_USB3_DUAL 0x3 + +#defineTCSR_USB_HSPHY_HOST_MODE0x00E700E7 +#defineTCSR_USB_HSPHY_DEVICE_MODE 0x00C700E7 + +#defineTCSR_ESS_PSGMII 0 +#defineTCSR_ESS_PSGMII_RGMII5 1 +#defineTCSR_ESS_PSGMII_RMII0 2 +#defineTCSR_ESS_PSGMII_RMII1 4 +#defineTCSR_ESS_PSGMII_RMII0_RMII1 6 +#defineTCSR_ESS_PSGMII_RGMII4 9 + +#defineTCSR_WIFI_GLB_CFG 0x4100 + +#defineTCSR_WIFI_NOC_MEMTYPE_M0_M2 0x0222 + +#defineIPQ806X_TCSR_REG_A_ADM_CRCI_MUX_SEL 0 +#defineIPQ806X_TCSR_REG_B_ADM_CRCI_MUX_SEL 1 + +#endif diff --git a/sys/tools/fdt/make_dtb.sh b/sys/tools/fdt/make_dtb.sh index 09d0b3bd9f42..e1a2fa4b1d8a 100755 --- a/sys/tools/fdt/make_dtb.sh +++ b/sys/tools/fdt/make_dtb.sh @@ -23,6 +23,6 @@ fi for d in ${dts}; do dtb="${dtb_path}/$(basename "$d" .dts).dtb" ${ECHO} "converting $d -> $dtb" -${CPP} -P -x assembler-with-cpp -I "$S/contrib/device-tree/include" -I "$S/dts/${MACHINE}" -I "$S/contrib/device-tree/src/${MACHINE}" -I "$S/contrib/device-tree/src/" -include "$d" -include "$S/dts/freebsd-compatible.dts" /dev/null | +${CPP} -P -x assembler-with-cpp -I "$S/dts/include" -I "$S/contrib/device-tree/include" -I "$S/dts/${MACHINE}" -I "$S/contrib/device-tree/src/${MACHINE}" -I "$S/contrib/device-tree/src/" -include "$d" -include "$S/dts/freebsd-compatible.dts" /dev/null | ${DTC} -@ -O dtb -o "$dtb" -b 0 -p 1024 -i "$S/dts/${MACHINE}" -i "$S/contrib/device-tree/src/${MACHINE}" -i "$S/contrib/device-tree/src/" done
git: 8398d52d6541 - main - arm: print out the undefined instruction upon an undefined instruction panic
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=8398d52d6541d316fcd88c856b5a72bb9cce0534 commit 8398d52d6541d316fcd88c856b5a72bb9cce0534 Author: Adrian Chadd AuthorDate: 2021-10-16 03:15:15 + Commit: Adrian Chadd CommitDate: 2021-10-18 19:18:52 + arm: print out the undefined instruction upon an undefined instruction panic It's SUPER useful to be able to see the actual undefined instruction when we hit said undefined instruction. --- sys/arm/arm/undefined.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/arm/arm/undefined.c b/sys/arm/arm/undefined.c index ef9e72c89163..4e9a5295d338 100644 --- a/sys/arm/arm/undefined.c +++ b/sys/arm/arm/undefined.c @@ -341,7 +341,8 @@ undefinedinstruction(struct trapframe *frame) return; } else - panic("Undefined instruction in kernel.\n"); + panic("Undefined instruction in kernel (0x%08x).\n", + fault_instruction); } userret(td, frame);
git: c29c0e68765f - main - arm: allow the debug stuff in CP14 to be disabled at compile time
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=c29c0e68765f4b98c8507d0dabb976e589b74d4b commit c29c0e68765f4b98c8507d0dabb976e589b74d4b Author: Adrian Chadd AuthorDate: 2021-10-16 18:32:08 + Commit: Adrian Chadd CommitDate: 2021-10-18 19:18:56 + arm: allow the debug stuff in CP14 to be disabled at compile time The upcoming QCA ipq401x support detects the CP14 debug features, but any attempt to use it causes an undefined instruction error. It apparently needs a specific TZ image loaded by the early bootloader (SBL) in order to enable these kinds of features. So add a new kernel option that explicitly disables this in the arm code - the debugger works fine without it. --- sys/arm/arm/debug_monitor.c | 5 + sys/conf/options.arm| 1 + 2 files changed, 6 insertions(+) diff --git a/sys/arm/arm/debug_monitor.c b/sys/arm/arm/debug_monitor.c index b73249bedcf1..b9678a5040af 100644 --- a/sys/arm/arm/debug_monitor.c +++ b/sys/arm/arm/debug_monitor.c @@ -960,6 +960,10 @@ vectr_clr: void dbg_monitor_init(void) { +#ifdef ARM_FORCE_DBG_MONITOR_DISABLE + db_printf("ARM Debug Architecture disabled in kernel compilation.\n"); + return; +#else int err; /* Fetch ARM Debug Architecture model */ @@ -1001,6 +1005,7 @@ dbg_monitor_init(void) db_printf("HW Breakpoints/Watchpoints not enabled on CPU%d\n", PCPU_GET(cpuid)); +#endif /* ARM_FORCE_DBG_MONITOR_DISABLE */ } CTASSERT(sizeof(struct dbreg) == sizeof(((struct pcpu *)NULL)->pc_dbreg)); diff --git a/sys/conf/options.arm b/sys/conf/options.arm index 62f1a79fe314..0e5726e9713e 100644 --- a/sys/conf/options.arm +++ b/sys/conf/options.arm @@ -1,6 +1,7 @@ #$FreeBSD$ ARMV6 opt_global.h ARMV7 opt_global.h +ARM_FORCE_DBG_MONITOR_DISABLE opt_ddb.h CPSW_ETHERSWITCH opt_cpsw.h CPU_ARM1176opt_global.h CPU_CORTEXAopt_global.h
git: fb7a00772898 - main - arm: add a std.qca for 32 bit armv7 platforms
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=fb7a00772898a6dce16f790e013cbdc7e8591363 commit fb7a00772898a6dce16f790e013cbdc7e8591363 Author: Adrian Chadd AuthorDate: 2021-10-16 18:48:02 + Commit: Adrian Chadd CommitDate: 2021-10-18 19:19:03 + arm: add a std.qca for 32 bit armv7 platforms This is the minimal config required to boot on the IPQ4018 SoC and likely future ones as well in this family. --- sys/arm/conf/std.qca | 28 1 file changed, 28 insertions(+) diff --git a/sys/arm/conf/std.qca b/sys/arm/conf/std.qca new file mode 100644 index ..cabd5f309121 --- /dev/null +++ b/sys/arm/conf/std.qca @@ -0,0 +1,28 @@ +# +# QCA SoC support (32 bit) +# + +machinearm armv7 +cpuCPU_CORTEXA +makeoptionsCONF_CFLAGS="-march=armv7a" + +files "../qualcomm/std.ipq4018" + +# Serial (COM) ports +device uart +device uart_msm# Qualcomm MSM UART driver + +device gic + +# MMC/SD/SDIO Card slot support +device mmc +device sdhci + +# Timers +device generic_timer +device mpcore_timer + +optionsFDT + +# Disable CP14 work in DDB as TZ won't let us by default +optionsARM_FORCE_DBG_MONITOR_DISABLE
git: 9264bd386cfc - main - ipq4018: add a device tree file for the ASUS rt-ac58u router
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=9264bd386cfcb3c081f9b7e2a695f25c367c0891 commit 9264bd386cfcb3c081f9b7e2a695f25c367c0891 Author: Adrian Chadd AuthorDate: 2021-10-16 03:13:04 + Commit: Adrian Chadd CommitDate: 2021-10-18 19:18:46 + ipq4018: add a device tree file for the ASUS rt-ac58u router This is the initial device tree file describing the ASUS RT-AC58U 2GHz/5GHz 11ac router. Obtained from: OpenWRT --- sys/dts/arm/qcom-ipq4018-rt-ac58u.dts | 312 ++ 1 file changed, 312 insertions(+) diff --git a/sys/dts/arm/qcom-ipq4018-rt-ac58u.dts b/sys/dts/arm/qcom-ipq4018-rt-ac58u.dts new file mode 100644 index ..8a280c79e942 --- /dev/null +++ b/sys/dts/arm/qcom-ipq4018-rt-ac58u.dts @@ -0,0 +1,312 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "qcom-ipq4019.dtsi" +#include +#include +#include + +/ { + model = "ASUS RT-AC58U"; + compatible = "asus,rt-ac58u"; + + memory { + device_type = "memory"; + reg = <0x8000 0x800>; + }; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + serial0 = &blsp1_uart1; + }; + + chosen { + bootargs-append = " ubi.mtd=UBI_DEV"; +// stdout-path = "serial0:115200n8"; + stdout-path = "serial0"; + }; + + soc { + rng@22000 { + status = "okay"; + }; + + mdio@9 { + status = "okay"; + }; + + ess-psgmii@98000 { + status = "okay"; + }; + + tcsr@1949000 { + compatible = "qcom,tcsr"; + reg = <0x1949000 0x100>; + qcom,wifi_glb_cfg = ; + }; + + tcsr@194b000 { + compatible = "qcom,tcsr"; + reg = <0x194b000 0x100>; + qcom,usb-hsphy-mode-select = ; + }; + + ess_tcsr@1953000 { + compatible = "qcom,tcsr"; + reg = <0x1953000 0x1000>; + qcom,ess-interface-select = ; + }; + + tcsr@1957000 { + compatible = "qcom,tcsr"; + reg = <0x1957000 0x100>; + qcom,wifi_noc_memtype_m0_m2 = ; + }; + + usb3@8af8800 { + status = "okay"; + + dwc3@8a0 { + #address-cells = <1>; + #size-cells = <0>; + + usb3_port1: port@1 { + reg = <1>; + #trigger-source-cells = <0>; + }; + + usb3_port2: port@2 { + reg = <2>; + #trigger-source-cells = <0>; + }; + }; + }; + + crypto@8e3a000 { + status = "okay"; + }; + + watchdog@b017000 { + status = "okay"; + }; + + ess-switch@c00 { + status = "okay"; + }; + + edma@c08 { + status = "okay"; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 4 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&tlmm 63 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_power: status { + label = "blue:status"; + gpios = <&tlmm 3 GPIO_ACTIVE_HIGH>; + }; + + wan { + label = "blue:wan"; + gpios = <&tlmm 1 GPIO_ACTIVE_HIGH>; + }; + + wlan2G {
git: 015ff812d6b7 - main - ipq4018: add initial IPQ4018/IPQ4019 support
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=015ff812d6b7eda57f87789173bad675ca685bb2 commit 015ff812d6b7eda57f87789173bad675ca685bb2 Author: Adrian Chadd AuthorDate: 2021-10-16 18:48:37 + Commit: Adrian Chadd CommitDate: 2021-10-18 19:19:06 + ipq4018: add initial IPQ4018/IPQ4019 support Summary: This adds required IPQ4018/IPQ4019 SoC support to boot. It also includes support for disabling the ARMv7 hardware breakpoint / debug stuff at compile time as this is required for the IPQ SoCs, and printing out the undefined instruction itself. Test Plan: * compiled/booted on an IPQ4019 SoC AP Reviewers: #core_team! Subscribers: imp, andrew Differential Revision: https://reviews.freebsd.org/D32538 --- sys/arm/conf/ASUS_AC1300 | 52 1 file changed, 52 insertions(+) diff --git a/sys/arm/conf/ASUS_AC1300 b/sys/arm/conf/ASUS_AC1300 new file mode 100644 index ..73d3d9f37eb7 --- /dev/null +++ b/sys/arm/conf/ASUS_AC1300 @@ -0,0 +1,52 @@ +# +# ASUS_AC1300 -- Qualcomm kernel configuration file for FreeBSD/arm +# +# For more information on this file, please read the config(5) manual page, +# and/or the handbook section on Kernel Configuration Files: +# +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config +# +# The handbook is also available locally in /usr/share/doc/handbook +# if you've installed the doc distribution, otherwise always see the +# FreeBSD World Wide Web server (https://www.FreeBSD.org/) for the +# latest information. +# +# An exhaustive list of options and more detailed explanations of the +# device lines is also present in the ../../conf/NOTES and NOTES files. +# If you are in doubt as to the purpose or necessity of a line, check first +# in NOTES. +# + +#NO_UNIVERSE + +include"std.armv7" +include"std.qca" + +cpuCPU_CORTEXA +ident ASUS_AC1300 +machinearm armv7 + +# Use a low VA here so we get the early printf stuff working all the +# way up to cninit(). +#options SOCDEV_PA=0x0780 +#options SOCDEV_VA=0x0780 +#options EARLY_PRINTF +optionsBOOTVERBOSE + +optionsFDT_DTB_STATIC +makeoptionsFDT_DTS_FILE=qcom-ipq4018-rt-ac58u.dts + +optionsLINUX_BOOT_ABI +optionsSCHED_ULE +# DEFINITELY not ready for SMP yet! +# options SMP +optionsPLATFORM + +device loop +device pty +device md +device gpio + +device ether +device mii +device bpf
git: 02438ce5fd18 - main - ipq4018: add initial IPQ4018/IPQ4019 support
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=02438ce5fd1892e3f59e4f1e83a0ac810396853f commit 02438ce5fd1892e3f59e4f1e83a0ac810396853f Author: Adrian Chadd AuthorDate: 2021-10-16 18:47:44 + Commit: Adrian Chadd CommitDate: 2021-10-18 19:19:00 + ipq4018: add initial IPQ4018/IPQ4019 support This is for the Qualcomm Atheros quad-core ARMv7 SoC with built-in 2x2 2GHz and 5GHz ath10k devices. It's enough (with an upcoming set of config files) to netboot on an ASUS router I have here and get to a single core mountroot prompt. --- sys/arm/qualcomm/ipq4018_machdep.c | 194 + sys/arm/qualcomm/ipq4018_machdep.h | 38 sys/arm/qualcomm/ipq4018_mp.c | 61 sys/arm/qualcomm/ipq4018_reg.h | 42 sys/arm/qualcomm/std.ipq4018 | 2 + 5 files changed, 337 insertions(+) diff --git a/sys/arm/qualcomm/ipq4018_machdep.c b/sys/arm/qualcomm/ipq4018_machdep.c new file mode 100644 index ..b3f841575ebb --- /dev/null +++ b/sys/arm/qualcomm/ipq4018_machdep.c @@ -0,0 +1,194 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Adrian Chadd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "opt_platform.h" + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "platform_if.h" + +static int +ipq4018_attach(platform_t plat) +{ + return (0); +} + +static void +ipq4018_late_init(platform_t plat) +{ + /* +* XXX FIXME This is needed because we're not parsing +* the fdt reserved memory regions in a consistent way +* between arm/arm64. Once the reserved region parsing +* is fixed up this will become unneccessary. +* +* These cover the SRAM/TZ regions that are not fully +* accessible from the OS. They're in the ipq4018.dtsi +* tree. +* +* Without these, the system fails to boot because we +* aren't parsing the regions correctly. +* +* These will be unnecessary once the parser and setup +* code is fixed. +*/ + physmem_exclude_region(IPQ4018_MEM_SMEM_START, + IPQ4018_MEM_SMEM_SIZE, + EXFLAG_NODUMP | EXFLAG_NOALLOC); + physmem_exclude_region(IPQ4018_MEM_TZ_START, + IPQ4018_MEM_TZ_SIZE, + EXFLAG_NODUMP | EXFLAG_NOALLOC); +} + +static int +ipq4018_devmap_init(platform_t plat) +{ + /* +* This covers the boot UART. Without it we can't boot successfully: +* there's a mutex uninit panic in subr_vmem.c that occurs when doing +* a call to pmap_mapdev() when the bus space code is doing its thing. +*/ + devmap_add_entry(IPQ4018_MEM_UART1_START, IPQ4018_MEM_UART1_SIZE); + return (0); +} + +static void +ipq4018_cpu_reset(platform_t plat) +{ +} + +/* + * Early putc routine for EARLY_PRINTF support. To use, add to kernel config: + * option SOCDEV_PA=0x0780 + * option SOCDEV_VA=0x0780 + * option EARLY_PRINTF + * Resist the temptation to change the #if 0 to #ifdef EARLY_PRINTF here. It + * makes sense now, but if multiple SOCs do that it will make early_putc another + * duplicate symbol to be eliminated on the path to a generic kernel. + */ +#if 0 +void +qca_msm_early_putc(int c) +{ + static int is_init = 0; + + int limit; +/* + * This must match what's put into SOCDEV_VA. You have to
git: d524e370c4db - main - iwm: Update SCD register accesses
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=d524e370c4dbabf607546aec6e4bcc8d64758851 commit d524e370c4dbabf607546aec6e4bcc8d64758851 Author: Adrian Chadd AuthorDate: 2021-10-25 04:29:53 + Commit: Adrian Chadd CommitDate: 2021-10-27 03:28:55 + iwm: Update SCD register accesses This brings it inline with what's in openbsd. I tested it locally with 2G and 5G association; it seems to work. Tested: Intel 7260 AC, hw 0x140, STA mode, 2G/5G Differential Revision: https://reviews.freebsd.org/D32627 Subscribers: imp Obtainde from: OpenBSD --- sys/dev/iwm/if_iwmreg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/iwm/if_iwmreg.h b/sys/dev/iwm/if_iwmreg.h index c3c51a25c4b0..ee5c5ec07b21 100644 --- a/sys/dev/iwm/if_iwmreg.h +++ b/sys/dev/iwm/if_iwmreg.h @@ -1410,14 +1410,14 @@ static inline unsigned int IWM_SCD_QUEUE_RDPTR(unsigned int chnl) { if (chnl < 20) return IWM_SCD_BASE + 0x68 + chnl * 4; - return IWM_SCD_BASE + 0x2B4 + (chnl - 20) * 4; + return IWM_SCD_BASE + 0x2B4 + chnl * 4; } static inline unsigned int IWM_SCD_QUEUE_STATUS_BITS(unsigned int chnl) { if (chnl < 20) return IWM_SCD_BASE + 0x10c + chnl * 4; - return IWM_SCD_BASE + 0x384 + (chnl - 20) * 4; + return IWM_SCD_BASE + 0x334 + chnl * 4; } /*** END TX SCHEDULER */
git: 355c15130aef - main - iwm: update if_iwmreg.h to the latest (as of today) openbsd changes
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=355c15130aef13484821051a655da9b9066e1015 commit 355c15130aef13484821051a655da9b9066e1015 Author: Adrian Chadd AuthorDate: 2021-10-24 15:47:04 + Commit: Adrian Chadd CommitDate: 2021-10-27 03:28:54 + iwm: update if_iwmreg.h to the latest (as of today) openbsd changes Summary: This updates the if_iwmreg.h definitions to; OpenBSD: if_iwmreg.h,v 1.65 2021/10/11 09:03:22 stsp Exp A few things haven't been fully converted, namely: * I left a couple things as enums for now just to reduce the other diffs needed; but they're the same values * The IWM_SCD_QUEUE_* macros have different offsets which I didn't update in case they broke things / changed based on later firmware. But they also may be real bugfixes which are needed for later chips. It'll need more testing before flipping this on. The c file updates are: * Use the newer names for things if the name changed but the semantics didn't * Explicitly use the earlier firmware structs which maintain compat with the current firmware and code. The newer ones are in here and they'll get converted when more openbsd code is merged into this tree. * Use the older iwm rate table for now, which has entries for legacy rates, HT and VHT. Our code works with that right now, updating it to openbsd's err, "different" version can be done at a later date when HT/VHT support is added. Notably, a bunch of definitions were deleted that weren't used. They're not used either in the openbsd/dfbsd drivers so I think it's safe to delete them in the long run. Test Plan: 7260 hw 0x140 Subscribers: imp Differential Revision: https://reviews.freebsd.org/D32627 Reviewed by: md5 Obtained From: OpenBSD --- sys/dev/iwm/if_iwm.c | 112 +- sys/dev/iwm/if_iwm_binding.c |2 +- sys/dev/iwm/if_iwm_phy_db.c | 37 +- sys/dev/iwm/if_iwm_scan.c| 10 +- sys/dev/iwm/if_iwmreg.h | 3522 -- sys/dev/iwm/if_iwmvar.h |2 +- 6 files changed, 2030 insertions(+), 1655 deletions(-) diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c index f994e8e75307..3e34c3cac98e 100644 --- a/sys/dev/iwm/if_iwm.c +++ b/sys/dev/iwm/if_iwm.c @@ -1914,98 +1914,6 @@ iwm_nvm_read_section(struct iwm_softc *sc, /* iwlwifi/iwl-nvm-parse.c */ -/* NVM offsets (in words) definitions */ -enum iwm_nvm_offsets { - /* NVM HW-Section offset (in words) definitions */ - IWM_HW_ADDR = 0x15, - -/* NVM SW-Section offset (in words) definitions */ - IWM_NVM_SW_SECTION = 0x1C0, - IWM_NVM_VERSION = 0, - IWM_RADIO_CFG = 1, - IWM_SKU = 2, - IWM_N_HW_ADDRS = 3, - IWM_NVM_CHANNELS = 0x1E0 - IWM_NVM_SW_SECTION, - -/* NVM calibration section offset (in words) definitions */ - IWM_NVM_CALIB_SECTION = 0x2B8, - IWM_XTAL_CALIB = 0x316 - IWM_NVM_CALIB_SECTION -}; - -enum iwm_8000_nvm_offsets { - /* NVM HW-Section offset (in words) definitions */ - IWM_HW_ADDR0_WFPM_8000 = 0x12, - IWM_HW_ADDR1_WFPM_8000 = 0x16, - IWM_HW_ADDR0_PCIE_8000 = 0x8A, - IWM_HW_ADDR1_PCIE_8000 = 0x8E, - IWM_MAC_ADDRESS_OVERRIDE_8000 = 1, - - /* NVM SW-Section offset (in words) definitions */ - IWM_NVM_SW_SECTION_8000 = 0x1C0, - IWM_NVM_VERSION_8000 = 0, - IWM_RADIO_CFG_8000 = 0, - IWM_SKU_8000 = 2, - IWM_N_HW_ADDRS_8000 = 3, - - /* NVM REGULATORY -Section offset (in words) definitions */ - IWM_NVM_CHANNELS_8000 = 0, - IWM_NVM_LAR_OFFSET_8000_OLD = 0x4C7, - IWM_NVM_LAR_OFFSET_8000 = 0x507, - IWM_NVM_LAR_ENABLED_8000 = 0x7, - - /* NVM calibration section offset (in words) definitions */ - IWM_NVM_CALIB_SECTION_8000 = 0x2B8, - IWM_XTAL_CALIB_8000 = 0x316 - IWM_NVM_CALIB_SECTION_8000 -}; - -/* SKU Capabilities (actual values from NVM definition) */ -enum nvm_sku_bits { - IWM_NVM_SKU_CAP_BAND_24GHZ = (1 << 0), - IWM_NVM_SKU_CAP_BAND_52GHZ = (1 << 1), - IWM_NVM_SKU_CAP_11N_ENABLE = (1 << 2), - IWM_NVM_SKU_CAP_11AC_ENABLE = (1 << 3), -}; - -/* radio config bits (actual values from NVM definition) */ -#define IWM_NVM_RF_CFG_DASH_MSK(x) (x & 0x3) /* bits 0-1 */ -#define IWM_NVM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */ -#define IWM_NVM_RF_CFG_TYPE_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */ -#define IWM_NVM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */ -#define IWM_NVM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */ -#define IWM_NVM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */ - -#define IWM_NVM_RF_CFG_FLAVOR_M
git: 6325f105aad2 - main - ipq4018: toggle ps-hold to allow SoC reset
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=6325f105aad2d6d8ba08efe5aff1c860cc7df198 commit 6325f105aad2d6d8ba08efe5aff1c860cc7df198 Author: Adrian Chadd AuthorDate: 2021-10-20 05:33:27 + Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:21 + ipq4018: toggle ps-hold to allow SoC reset This is enough to allow this ASUS router to reboot successfully. I tried the watchdog path and although it fires, it isn't rebooting! It's just hanging, likely somewhere in TZ. Tested: * ASUS RT-AC58U router, IPQ4019 Reviewed by: andrew, manu, imp Differential Revision: https://reviews.freebsd.org/D32723 --- sys/arm/qualcomm/ipq4018_machdep.c | 42 ++ sys/arm/qualcomm/ipq4018_reg.h | 3 +++ 2 files changed, 45 insertions(+) diff --git a/sys/arm/qualcomm/ipq4018_machdep.c b/sys/arm/qualcomm/ipq4018_machdep.c index b3f841575ebb..39510c8294ae 100644 --- a/sys/arm/qualcomm/ipq4018_machdep.c +++ b/sys/arm/qualcomm/ipq4018_machdep.c @@ -36,10 +36,12 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include #include #include #include @@ -94,12 +96,52 @@ ipq4018_devmap_init(platform_t plat) * a call to pmap_mapdev() when the bus space code is doing its thing. */ devmap_add_entry(IPQ4018_MEM_UART1_START, IPQ4018_MEM_UART1_SIZE); + + /* +* This covers a bunch of the reset block, which includes the PS-HOLD +* register for dropping power. +*/ + devmap_add_entry(IPQ4018_MEM_PSHOLD_START, IPQ4018_MEM_PSHOLD_SIZE); + return (0); } +/* + * This toggles the PS-HOLD register which on most IPQ devices will toggle + * the power control block and reset the SoC. + * + * However, there are apparently some units out there where this is not + * appropriate and instead the watchdog needs to be used. + * + * For now since there's only going to be one or two initial supported boards + * this will be fine. But if this doesn't reboot cleanly, now you know. + */ +static void +ipq4018_cpu_reset_pshold(void) +{ + bus_space_handle_t pshold; + + printf("%s: called\n", __func__); + + bus_space_map(fdtbus_bs_tag, IPQ4018_MEM_PSHOLD_START, + IPQ4018_MEM_PSHOLD_SIZE, 0, &pshold); + bus_space_write_4(fdtbus_bs_tag, pshold, 0, 0); + bus_space_barrier(fdtbus_bs_tag, pshold, 0, 0x4, + BUS_SPACE_BARRIER_WRITE); +} + static void ipq4018_cpu_reset(platform_t plat) { + spinlock_enter(); + dsb(); + + ipq4018_cpu_reset_pshold(); + + /* Spin */ + printf("%s: spinning\n", __func__); + while(1) + ; } /* diff --git a/sys/arm/qualcomm/ipq4018_reg.h b/sys/arm/qualcomm/ipq4018_reg.h index 945d650dcfd6..9c09605eab1a 100644 --- a/sys/arm/qualcomm/ipq4018_reg.h +++ b/sys/arm/qualcomm/ipq4018_reg.h @@ -39,4 +39,7 @@ #defineIPQ4018_MEM_UART1_START 0x078af000 #defineIPQ4018_MEM_UART1_SIZE 0x1000 +#defineIPQ4018_MEM_PSHOLD_START0x004ab000 +#defineIPQ4018_MEM_PSHOLD_SIZE 0x1000 + #endif
git: a516ccc4ae04 - main - ipq4018: add SoC reset and qcom_rnd driver
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=a516ccc4ae04975a54882651104c4a0369c3eaba commit a516ccc4ae04975a54882651104c4a0369c3eaba Author: Adrian Chadd AuthorDate: 2021-10-21 03:08:56 + Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:30 + ipq4018: add SoC reset and qcom_rnd driver Summary: This is enough to allow this ASUS router to reboot successfully. I tried the watchdog path and although it fires, it isn't rebooting! It's just hanging, likely somewhere in TZ. This is the MVP required to initialise and consume random data from the QCA PRNG hardware found on the IPQ401x. Test Plan: * ASUS RT-AC58U router, IPQ4019 Subscribers: imp, andrew Differential Revision: https://reviews.freebsd.org/D32723 --- sys/arm/conf/std.qca | 3 +++ sys/arm/qualcomm/std.ipq4018 | 2 ++ 2 files changed, 5 insertions(+) diff --git a/sys/arm/conf/std.qca b/sys/arm/conf/std.qca index cabd5f309121..091de6178094 100644 --- a/sys/arm/conf/std.qca +++ b/sys/arm/conf/std.qca @@ -12,6 +12,9 @@ files "../qualcomm/std.ipq4018" device uart device uart_msm# Qualcomm MSM UART driver +# Random +device qcom_rnd + device gic # MMC/SD/SDIO Card slot support diff --git a/sys/arm/qualcomm/std.ipq4018 b/sys/arm/qualcomm/std.ipq4018 index 9a9801fa6415..823d7e74cb50 100644 --- a/sys/arm/qualcomm/std.ipq4018 +++ b/sys/arm/qualcomm/std.ipq4018 @@ -1,2 +1,4 @@ arm/qualcomm/ipq4018_machdep.c standard arm/qualcomm/ipq4018_mp.c optional smp + +dev/qcom_rnd/qcom_rnd.coptional qcom_rnd
git: 1492c8c0d825 - main - qcom_rnd: add initial qualcomm prng driver.
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=1492c8c0d825d1dcd8a2b2975fe35e4269b0b7de commit 1492c8c0d825d1dcd8a2b2975fe35e4269b0b7de Author: Adrian Chadd AuthorDate: 2021-10-21 03:05:10 + Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:27 + qcom_rnd: add initial qualcomm prng driver. This is the MVP required to initialise and consume random data from the QCA PRNG hardware found on the IPQ401x. Reviewed by: andrew, manu, imp Differential Revision: https://reviews.freebsd.org/D32723 --- sys/dev/qcom_rnd/qcom_rnd.c | 257 sys/dev/qcom_rnd/qcom_rnd_reg.h | 43 +++ sys/sys/random.h| 1 + 3 files changed, 301 insertions(+) diff --git a/sys/dev/qcom_rnd/qcom_rnd.c b/sys/dev/qcom_rnd/qcom_rnd.c new file mode 100644 index ..c78438a29ba0 --- /dev/null +++ b/sys/dev/qcom_rnd/qcom_rnd.c @@ -0,0 +1,257 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021, Adrian Chadd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice unmodified, this list of conditions, and the following + *disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Driver for Qualcomm MSM entropy device. */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +struct qcom_rnd_softc { + device_t dev; + int reg_rid; + struct resource *reg; +}; + +static int qcom_rnd_modevent(module_t, int, void *); + +static int qcom_rnd_probe(device_t); +static int qcom_rnd_attach(device_t); +static int qcom_rnd_detach(device_t); + +static int qcom_rnd_harvest(struct qcom_rnd_softc *, void *, size_t *); +static unsignedqcom_rnd_read(void *, unsigned); + +static struct random_source random_qcom_rnd = { + .rs_ident = "Qualcomm Entropy Adapter", + .rs_source = RANDOM_PURE_QUALCOMM, + .rs_read = qcom_rnd_read, +}; + +/* Kludge for API limitations of random(4). */ +static _Atomic(struct qcom_rnd_softc *) g_qcom_rnd_softc; + +static int +qcom_rnd_modevent(module_t mod, int type, void *unused) +{ + int error; + + switch (type) { + case MOD_LOAD: + case MOD_QUIESCE: + case MOD_UNLOAD: + case MOD_SHUTDOWN: + error = 0; + break; + default: + error = EOPNOTSUPP; + break; + } + + return (error); +} + +static int +qcom_rnd_probe(device_t dev) +{ + if (! ofw_bus_status_okay(dev)) { + return (ENXIO); + } + + if (ofw_bus_is_compatible(dev, "qcom,prng") == 0) { + return (ENXIO); + } + + return (0); +} + +static int +qcom_rnd_attach(device_t dev) +{ + struct qcom_rnd_softc *sc, *exp; + uint32_t reg; + + sc = device_get_softc(dev); + + + /* Found a compatible device! */ + + sc->dev = dev; + + exp = NULL; + if (!atomic_compare_exchange_strong_explicit(&g_qcom_rnd_softc, &exp, + sc, memory_order_release, memory_order_acquire)) { + return (ENXIO); + } + + sc->reg_rid = 0; + sc->reg = bus_alloc_resource_anywhere(dev, SYS_RES_MEMORY, + &sc->reg_rid, 0x140, RF_ACTIVE); + if (sc->reg == NULL) { + device_printf(dev, "Couldn't allocate memory resource!\n"); + return (ENXIO); + } + + device_set_desc(dev, "Qualcomm PRNG"); + + /* +* Check to see whether the PRNG has already been setup or not. +*/ +
git: 960e65d23aaa - main - qcom: add initial SCM legacy API
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=960e65d23aaa55dd00255e95f14c2f6256a4fce3 commit 960e65d23aaa55dd00255e95f14c2f6256a4fce3 Author: Adrian Chadd AuthorDate: 2021-10-30 03:34:08 + Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:33 + qcom: add initial SCM legacy API This is a very simple implementation of Qualcomm's SCM API. It is just the structure/field definitions and the atomic SCM call which doesn't use the structs yet - it uses the field definitions inside registers. I've tested that setting the cold boot address via the atomic API is fine - Linux does the same thing. But not all SCM calls can be done via the legacy API. This is a reimplementation based on the Linux qualcomm SCM legacy code and definitions. Tested: * Qualcomm IPQ4018 AP, as part of other changes for doing SMP bring-up Reviewed by: andrew, manu, imp Differential Revision: https://reviews.freebsd.org/D32723 --- sys/arm/conf/std.qca| 3 + sys/arm/qualcomm/qcom_scm_defs.h| 122 ++ sys/arm/qualcomm/qcom_scm_legacy.c | 88 +++ sys/arm/qualcomm/qcom_scm_legacy.h | 41 + sys/arm/qualcomm/qcom_scm_legacy_defs.h | 149 sys/arm/qualcomm/std.ipq4018| 1 + 6 files changed, 404 insertions(+) diff --git a/sys/arm/conf/std.qca b/sys/arm/conf/std.qca index 091de6178094..00d627b77b7b 100644 --- a/sys/arm/conf/std.qca +++ b/sys/arm/conf/std.qca @@ -25,6 +25,9 @@ devicesdhci device generic_timer device mpcore_timer +# PSCI - SMC calls, needed for qualcomm SCM +device psci + optionsFDT # Disable CP14 work in DDB as TZ won't let us by default diff --git a/sys/arm/qualcomm/qcom_scm_defs.h b/sys/arm/qualcomm/qcom_scm_defs.h new file mode 100644 index ..f4fe0fd76b52 --- /dev/null +++ b/sys/arm/qualcomm/qcom_scm_defs.h @@ -0,0 +1,122 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Adrian Chadd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef__QCOM_SCM_DEFS_H__ +#define__QCOM_SCM_DEFS_H__ + +/* + * Maximum SCM arguments and return values. + */ +#defineMAX_QCOM_SCM_ARGS 10 +#defineMAX_QCOM_SCM_RETS 3 + +/* + * SCM argument type definitions. + */ +#defineQCOM_SCM_ARGTYPE_VAL0x00 +#defineQCOM_SCM_ARGTYPE_RO 0x01 +#defineQCOM_SCM_ARGTYPE_RW 0x02 +#defineQCOM_SCM_ARGTYPE_BUFVAL 0x03 + +/* + * SCM calls + arguments. + */ +#defineQCOM_SCM_SVC_BOOT 0x01 +#defineQCOM_SCM_BOOT_SET_ADDR 0x01 +#defineQCOM_SCM_BOOT_TERMINATE_PC 0x02 +#defineQCOM_SCM_BOOT_SET_DLOAD_MODE0x10 +#defineQCOM_SCM_BOOT_SET_REMOTE_STATE 0x0a +#defineQCOM_SCM_FLUSH_FLAG_MASK0x3 + +/* Flags for QCOM_SCM_BOOT_SET_ADDR argv[0] */ +/* Note: no COLDBOOT for CPU0, it's already booted */ +#defineQCOM_SCM_FLAG_COLDBOOT_CPU1 0x01 +#defineQCOM_SCM_FLAG_WARMBOOT_CPU1 0x02 +#defineQCOM_SCM_FLAG_WARMBOOT_CPU0 0x04 +#defineQCOM_SCM_FLAG_COLDBOOT_CPU2 0x08 +#defineQCOM_SCM_FLAG_WARMBOOT_CPU2 0x10 +#defineQCOM_SCM_F
git: d3514c294207 - main - ipq401x: add MP core start-up path for the CPU regulator/clock gate used
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=d3514c294207bd5cda7f4276ebff5235bb239b8a commit d3514c294207bd5cda7f4276ebff5235bb239b8a Author: Adrian Chadd AuthorDate: 2021-10-30 04:27:02 + Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:36 + ipq401x: add MP core start-up path for the CPU regulator/clock gate used This code implements the "kpssv2" flavour of CPU regulator/clock gating in Linux. It's used by at least the ipq4018/4019 to power on and off CPU cores. This is based on the Linux implementation - the register definitions and values are from Linux and I've reverse engineered the sequencing requirements. The MP bring-up is: * set cold boot address via an SCM call - this is the address used by the bootloader/TZ firmware to jump to when the CPUs boot * power down the LDO feeding the CPU core and wait for it to settle * program in the right set of LDO and power tree configuration for the CPU regulator to power up the core. Unfortunately these are magic numbers that I've not found documented anywhere. * (I think) power up the shared L2 cache connect if it isn't. * Clamp the power into the core down; put the core into reset * Unclamp the power rail; release reset; and then set the core to boot. The MP core will then boot the bootloader/TZ firmware and then will wait until an incoming interrupt kicks it to start @ mpentry. Tested: * IPQ4019, 4 CPUs Release APs CPU(3) applied BP hardening: not necessary CPU(1) applied BP hardening: not necessary CPU(2) applied BP hardening: not necessary Reviewed by: andrew, manu, imp Differential Revision: https://reviews.freebsd.org/D32723 --- sys/arm/qualcomm/ipq4018_mp.c | 55 + sys/arm/qualcomm/qcom_cpu_kpssv2.c | 211 + sys/arm/qualcomm/qcom_cpu_kpssv2.h | 35 ++ sys/arm/qualcomm/qcom_cpu_kpssv2_reg.h | 58 + sys/arm/qualcomm/std.ipq4018 | 1 + 5 files changed, 360 insertions(+) diff --git a/sys/arm/qualcomm/ipq4018_mp.c b/sys/arm/qualcomm/ipq4018_mp.c index 37b7cc3e097d..a7ebb7d7d6c8 100644 --- a/sys/arm/qualcomm/ipq4018_mp.c +++ b/sys/arm/qualcomm/ipq4018_mp.c @@ -35,27 +35,82 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include #include #include +#include #include #include +#include #include +#include +#include #include "platform_if.h" void ipq4018_mp_setmaxid(platform_t plat) { + int ncpu; + + /* If we've already set the global vars don't bother to do it again. */ + if (mp_ncpus != 0) + return; + + /* Read current CP15 Cache Size ID Register */ + ncpu = cp15_l2ctlr_get(); + ncpu = CPUV7_L2CTLR_NPROC(ncpu); + + mp_ncpus = ncpu; + mp_maxid = ncpu - 1; + + printf("SMP: ncpu=%d\n", ncpu); +} + +static boolean_t +ipq4018_start_ap(u_int id, phandle_t node, u_int addr_cells, pcell_t *arg) +{ + + /* +* For the IPQ401x we assume the enable method is +* "qcom,kpss-acc-v2". If this path gets turned into +* something more generic for other 32 bit qualcomm +* SoCs then we'll likely want to turn this into a +* switch based on "enable-method". +*/ + return qcom_cpu_kpssv2_regulator_start(id, node); } void ipq4018_mp_start_ap(platform_t plat) { + int ret; + + /* +* First step - SCM call to set the cold boot address to mpentry, so +* CPUs hopefully start in the MP path. +*/ + ret = qcom_scm_legacy_mp_set_cold_boot_address((vm_offset_t) mpentry); + if (ret != 0) + panic("%s: Couldn't set cold boot address via SCM " + "(error 0x%08x)", __func__, ret); + + /* +* Next step - loop over the CPU nodes and do the per-CPU setup +* required to power on the CPUs themselves. +*/ + ofw_cpu_early_foreach(ipq4018_start_ap, true); + + /* +* The next set of IPIs to the CPUs will wake them up and enter +* mpentry. +*/ } diff --git a/sys/arm/qualcomm/qcom_cpu_kpssv2.c b/sys/arm/qualcomm/qcom_cpu_kpssv2.c new file mode 100644 index ..4193f952549b --- /dev/null +++ b/sys/arm/qualcomm/qcom_cpu_kpssv2.c @@ -0,0 +1,211 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Adrian Chadd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this l
git: bc06496744a1 - main - ipq401x: flip on SMP for the ASUS AC1300
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=bc06496744a1a658c1cd9c6488dd23326b52390e commit bc06496744a1a658c1cd9c6488dd23326b52390e Author: Adrian Chadd AuthorDate: 2021-10-30 04:31:50 + Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:38 + ipq401x: flip on SMP for the ASUS AC1300 This actually enables SMP and yes it boots. Reviewed by: andrew, manu, imp Differential Revision: https://reviews.freebsd.org/D32723 --- sys/arm/conf/ASUS_AC1300 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/arm/conf/ASUS_AC1300 b/sys/arm/conf/ASUS_AC1300 index 73d3d9f37eb7..67ee0b541c2e 100644 --- a/sys/arm/conf/ASUS_AC1300 +++ b/sys/arm/conf/ASUS_AC1300 @@ -38,8 +38,7 @@ makeoptions FDT_DTS_FILE=qcom-ipq4018-rt-ac58u.dts optionsLINUX_BOOT_ABI optionsSCHED_ULE -# DEFINITELY not ready for SMP yet! -# options SMP +optionsSMP optionsPLATFORM device loop @@ -50,3 +49,4 @@ devicegpio device ether device mii device bpf +
git: cfd06987029a - main - ipq4018: add qcom-gcc-ipq4018 and dependencies into the build
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=cfd06987029ac1bf5f6a6be2d87ade7358bd59ca commit cfd06987029ac1bf5f6a6be2d87ade7358bd59ca Author: Adrian Chadd AuthorDate: 2021-10-31 03:45:17 + Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:43 + ipq4018: add qcom-gcc-ipq4018 and dependencies into the build * add the extres stuff into the build, I'm going to end up leveraging all of it * include the qcom-gcc-ipq4018 driver which currently implements the hwreset side of the API. Reviewed by: andrew, manu, imp Differential Revision: https://reviews.freebsd.org/D32723 --- sys/arm/conf/std.qca | 12 + sys/arm/qualcomm/qcom_gcc_ipq4018_clock.c | 82 +++ sys/arm/qualcomm/std.ipq4018 | 1 + 3 files changed, 95 insertions(+) diff --git a/sys/arm/conf/std.qca b/sys/arm/conf/std.qca index 00d627b77b7b..09cd61078870 100644 --- a/sys/arm/conf/std.qca +++ b/sys/arm/conf/std.qca @@ -12,6 +12,15 @@ files"../qualcomm/std.ipq4018" device uart device uart_msm# Qualcomm MSM UART driver +# EXT_RESOURCES pseudo devices +optionsEXT_RESOURCES +device clk +device phy +device hwreset +device nvmem +device regulator +device syscon + # Random device qcom_rnd @@ -28,6 +37,9 @@ devicempcore_timer # PSCI - SMC calls, needed for qualcomm SCM device psci +# Clock/Reset provider +device qcom_gcc_ipq4018 + optionsFDT # Disable CP14 work in DDB as TZ won't let us by default diff --git a/sys/arm/qualcomm/qcom_gcc_ipq4018_clock.c b/sys/arm/qualcomm/qcom_gcc_ipq4018_clock.c new file mode 100644 index ..f7f7a6c348ba --- /dev/null +++ b/sys/arm/qualcomm/qcom_gcc_ipq4018_clock.c @@ -0,0 +1,82 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021, Adrian Chadd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice unmodified, this list of conditions, and the following + *disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Driver for Qualcomm IPQ4018 clock and reset device */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#include + + +/* + * Fixed frequency clock sources: + * + * P_XO - 48MHz + * sleep-clk - is really 32KHz, although older DTS have it as 32.768KHz + */ + +/* + * PLL derived sources: + * + * P_FEPLL125 - 125MHz + * P_FEPLL125DLY - 125MHz + * P_FEPLL200 - 200MHz + * P_FEPLL500 - 500MHz + * P_FEPLLWCSS2G - TBD + * P_FEPLLWCSS5G - TBD + * + * Then there are two DDR PLLs which are treated/configured slightly + * differently: + * + * P_DDRPLLAPSS - TBD + * P_DDRPLLSDCC - TBD + */ + +/* + * Interesting stuff in Linux whilst I reverse engineer + figure it out: + * /sys/kernel/debug/clk + */ diff --git a/sys/arm/qualcomm/std.ipq4018 b/sys/arm/qualcomm/std.ipq4018 index 7e8ac39e7222..913314e92301 100644 --- a/sys/arm/qualcomm/std.ipq4018 +++ b/sys/arm/qualcomm/std.ipq4018 @@ -6,4 +6,5 @@ arm/qualcomm/qcom_cpu_kpssv2.c optional smp dev/qcom_rnd/qcom_rnd.coptional qcom_rnd arm/qualcomm/qcom_gcc_ipq4018.coptional qcom_gcc_ipq4018 arm/qualcomm/qcom_gcc_ipq4018_reset.c optional qcom_gcc_ipq4018 +arm/qualcomm/qcom_gcc_ipq4018_clock.c optional qcom_gcc_ipq4018
git: b12a863a1e14 - main - ipq4018: add initial reset driver support for the clock/reset controller.
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=b12a863a1e14610f6b145f235aa7452602038f9a commit b12a863a1e14610f6b145f235aa7452602038f9a Author: Adrian Chadd AuthorDate: 2021-10-31 03:43:27 + Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:41 + ipq4018: add initial reset driver support for the clock/reset controller. This implements the "reset controller" side of the clock/reset controller. It's a simple array of registers and bits to set. The register table itself comes from Linux; the rest of the code is a reimplementation. It doesn't yet implement or expose the clock side - I have a lot of reverse engineering to do before that! Reviewed by: andrew, manu, imp Differential Revision: https://reviews.freebsd.org/D32723 Obtained from: Linux (registers) --- sys/arm/qualcomm/qcom_gcc_ipq4018.c | 167 +++ sys/arm/qualcomm/qcom_gcc_ipq4018_reset.c | 181 ++ sys/arm/qualcomm/qcom_gcc_ipq4018_var.h | 50 + sys/arm/qualcomm/std.ipq4018 | 3 + 4 files changed, 401 insertions(+) diff --git a/sys/arm/qualcomm/qcom_gcc_ipq4018.c b/sys/arm/qualcomm/qcom_gcc_ipq4018.c new file mode 100644 index ..3002ae32a597 --- /dev/null +++ b/sys/arm/qualcomm/qcom_gcc_ipq4018.c @@ -0,0 +1,167 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021, Adrian Chadd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice unmodified, this list of conditions, and the following + *disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Driver for Qualcomm IPQ4018 clock and reset device */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#include "hwreset_if.h" + +#include + +#include + + +static int qcom_gcc_ipq4018_modevent(module_t, int, void *); + +static int qcom_gcc_ipq4018_probe(device_t); +static int qcom_gcc_ipq4018_attach(device_t); +static int qcom_gcc_ipq4018_detach(device_t); + +static int +qcom_gcc_ipq4018_modevent(module_t mod, int type, void *unused) +{ + int error; + + switch (type) { + case MOD_LOAD: + case MOD_QUIESCE: + case MOD_UNLOAD: + case MOD_SHUTDOWN: + error = 0; + break; + default: + error = EOPNOTSUPP; + break; + } + + return (error); +} + +static int +qcom_gcc_ipq4018_probe(device_t dev) +{ + if (! ofw_bus_status_okay(dev)) + return (ENXIO); + + if (ofw_bus_is_compatible(dev, "qcom,gcc-ipq4019") == 0) + return (ENXIO); + + return (0); +} + +static int +qcom_gcc_ipq4018_attach(device_t dev) +{ + struct qcom_gcc_ipq4018_softc *sc; + + sc = device_get_softc(dev); + + /* Found a compatible device! */ + sc->dev = dev; + + sc->reg_rid = 0; + sc->reg = bus_alloc_resource_anywhere(dev, SYS_RES_MEMORY, + &sc->reg_rid, 0x6, RF_ACTIVE); + if (sc->reg == NULL) { + device_printf(dev, "Couldn't allocate memory resource!\n"); + return (ENXIO); + } + + device_set_desc(dev, "Qualcomm IPQ4018 Clock/Reset Controller"); + + mtx_init(&sc->mtx, device_get_nameunit(dev), NULL, MTX_DEF); + + /* +* Register as a reset provider. +*/ + hwreset_register_ofw_provider(dev); + + return (0); +} + +static int +qcom_gcc_ipq4018_detach(device_t dev) +{ + struct qcom_gcc_ipq4018_softc *sc; + +
git: dead34f82219 - main - [ath_hal] ar9300: save TSF across full chip reset
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=dead34f82219b4017effc3a2e50ae3476870f6ab commit dead34f82219b4017effc3a2e50ae3476870f6ab Author: Adrian Chadd AuthorDate: 2021-03-31 03:30:24 + Commit: Adrian Chadd CommitDate: 2021-04-19 05:49:54 + [ath_hal] ar9300: save TSF across full chip reset This saves the TSF across a a full reset. The TSF is otherwise cleared and subsequent beaconing stops until the TSF catches up to nexttbtt. --- sys/contrib/dev/ath/ath_hal/ar9300/ar9300_reset.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_reset.c b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_reset.c index 96a0e8741592..97276398c4d4 100644 --- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_reset.c +++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_reset.c @@ -4538,7 +4538,7 @@ ar9300_reset(struct ath_hal *ah, HAL_OPMODE opmode, struct ieee80211_channel *ch u_int8_tclk_25mhz = AH9300(ah)->clk_25mhz; HAL_BOOLstopped, cal_ret; HAL_BOOLapply_last_iqcorr = AH_FALSE; - +uint64_t tsf; if (OS_REG_READ(ah, AR_IER) == AR_IER_ENABLE) { HALDEBUG(AH_NULL, HAL_DEBUG_UNMASKABLE, "** Reset called with WLAN " @@ -4869,10 +4869,15 @@ ar9300_reset(struct ath_hal *ah, HAL_OPMODE opmode, struct ieee80211_channel *ch /* Mark PHY inactive prior to reset, to be undone in ar9300_init_bb () */ ar9300_mark_phy_inactive(ah); +/* Save/restore TSF across a potentially full reset */ +/* XXX TODO: only do this if we do a cold reset */ +tsf = ar9300_get_tsf64(ah); if (!ar9300_chip_reset(ah, chan, reset_type)) { HALDEBUG(ah, HAL_DEBUG_RESET, "%s: chip reset failed\n", __func__); FAIL(HAL_EIO); } +if (tsf != 0) +ar9300_set_tsf64(ah, tsf); OS_MARK(ah, AH_MARK_RESET_LINE, __LINE__); ___ dev-commits-src-main@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"
git: bed90bf8ed5c - main - [ath_hal] Add get/set NAV functions
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=bed90bf8ed5c8fd69822529a839bacad762817a2 commit bed90bf8ed5c8fd69822529a839bacad762817a2 Author: Adrian Chadd AuthorDate: 2021-03-31 16:38:15 + Commit: Adrian Chadd CommitDate: 2021-04-19 05:52:31 + [ath_hal] Add get/set NAV functions The NAV (network allocation vector) register reflects the current MAC tracking of NAV - when it will stay quiet before transmitting. Other devices transmit their frame durations in their 802.11 PHY headers and all devices that hear a frame - even if it's one in an encoding they don't understand - will understand the low bitrate PHY header that includes the frame duration. So, they'll set NAV to this value so they'll stay quiet until the transmit completes. Anyway, sometimes the PHY NAV header is garbled and sometimes, notably older broadcom devices, will fake a long NAV so they can get "cleaner" air for local calibration. When this happens, the hardware will stay quiet for quite some time and this can lead to missed/stuck beacons, or (for Very Large Values) a MAC hang. This code just adds the ability to get/set the NAV; the driver will need to take care of using it during transmit hangs and beacon misses to see if it's due to a trash looking NAV. --- .../dev/ath/ath_hal/ar9300/ar9300_freebsd.c| 19 +++ sys/dev/ath/ath_hal/ah.h | 2 ++ sys/dev/ath/ath_hal/ar5210/ar5210.h| 2 ++ sys/dev/ath/ath_hal/ar5210/ar5210_attach.c | 2 ++ sys/dev/ath/ath_hal/ar5210/ar5210_misc.c | 23 ++ sys/dev/ath/ath_hal/ar5211/ar5211.h| 2 ++ sys/dev/ath/ath_hal/ar5211/ar5211_attach.c | 2 ++ sys/dev/ath/ath_hal/ar5211/ar5211_misc.c | 23 ++ sys/dev/ath/ath_hal/ar5212/ar5212.h| 2 ++ sys/dev/ath/ath_hal/ar5212/ar5212_attach.c | 2 ++ sys/dev/ath/ath_hal/ar5212/ar5212_misc.c | 27 ++ 11 files changed, 106 insertions(+) diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c index 37e64bc86cdd..68e5f018cc6c 100644 --- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c +++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c @@ -69,6 +69,23 @@ ar9300_get_next_tbtt(struct ath_hal *ah) return (OS_REG_READ(ah, AR_NEXT_TBTT_TIMER)); } +static u_int +ar9300_get_nav(struct ath_hal *ah) +{ + uint32_t reg; + + reg = OS_REG_READ(ah, AR_NAV); + if (reg == 0xdeadbeef) + return 0; + return reg; +} + +static void +ar9300_set_nav(struct ath_hal *ah, u_int nav) +{ + + OS_REG_WRITE(ah, AR_NAV, nav); +} /* * TODO: implement the antenna diversity control for AR9485 and @@ -484,6 +501,8 @@ ar9300_attach_freebsd_ops(struct ath_hal *ah) /* ah_get11nExtBusy */ ah->ah_set11nMac2040 = ar9300_set_11n_mac2040; ah->ah_setChainMasks = ar9300SetChainMasks; + ah->ah_getNav = ar9300_get_nav; + ah->ah_setNav = ar9300_set_nav; /* ah_get11nRxClear */ /* ah_set11nRxClear */ diff --git a/sys/dev/ath/ath_hal/ah.h b/sys/dev/ath/ath_hal/ah.h index e39ff2b7d03d..4e811a5237ac 100644 --- a/sys/dev/ath/ath_hal/ah.h +++ b/sys/dev/ath/ath_hal/ah.h @@ -1404,6 +1404,8 @@ struct ath_hal { HAL_QUIET_FLAG flag); void __ahdecl(*ah_setChainMasks)(struct ath_hal *, uint32_t, uint32_t); + u_int __ahdecl(*ah_getNav)(struct ath_hal*); + void __ahdecl(*ah_setNav)(struct ath_hal*, u_int); /* DFS functions */ void __ahdecl(*ah_enableDfs)(struct ath_hal *ah, diff --git a/sys/dev/ath/ath_hal/ar5210/ar5210.h b/sys/dev/ath/ath_hal/ar5210/ar5210.h index 373c676e25b3..f09e99b1ce9e 100644 --- a/sys/dev/ath/ath_hal/ar5210/ar5210.h +++ b/sys/dev/ath/ath_hal/ar5210/ar5210.h @@ -269,6 +269,8 @@ extern void ar5210SetChainMasks(struct ath_hal *, uint32_t, uint32_t); extern void ar5210EnableDfs(struct ath_hal *, HAL_PHYERR_PARAM *); extern void ar5210GetDfsThresh(struct ath_hal *, HAL_PHYERR_PARAM *); extern void ar5210UpdateDiagReg(struct ath_hal *ah, uint32_t val); +extern void ar5210SetNav(struct ath_hal *ah, u_int val); +extern u_int ar5210GetNav(struct ath_hal *ah); extern u_int ar5210GetKeyCacheSize(struct ath_hal *); extern HAL_BOOL ar5210IsKeyCacheEntryValid(struct ath_hal *, uint16_t); diff --git a/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c b/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c index 22afc12a6dcc..8bbd7e9d600e 100644 --- a/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c +++ b/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c @@ -145,6 +145,8 @@ static const struct ath_hal_private ar5210hal = {{ .ah_g
git: 61c83c4e8b6f - main - [ath] Add ath_hal_getnav and ath_hal_setnav so the driver layer can check the NAV as appropriate.
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=61c83c4e8b6fba915b2261fb019ad77d107c7b2b commit 61c83c4e8b6fba915b2261fb019ad77d107c7b2b Author: Adrian Chadd AuthorDate: 2021-04-01 04:48:59 + Commit: Adrian Chadd CommitDate: 2021-04-19 05:59:28 + [ath] Add ath_hal_getnav and ath_hal_setnav so the driver layer can check the NAV as appropriate. --- sys/dev/ath/if_athvar.h | 4 1 file changed, 4 insertions(+) diff --git a/sys/dev/ath/if_athvar.h b/sys/dev/ath/if_athvar.h index 1d2f842197cd..f36f66f6c3f4 100644 --- a/sys/dev/ath/if_athvar.h +++ b/sys/dev/ath/if_athvar.h @@ -1492,6 +1492,10 @@ void ath_intr(void *); ((*(_ah)->ah_setChainMasks)((_ah), (_txchainmask), (_rxchainmask))) #defineath_hal_set_quiet(_ah, _p, _d, _o, _f) \ ((*(_ah)->ah_setQuiet)((_ah), (_p), (_d), (_o), (_f))) +#defineath_hal_getnav(_ah) \ + ((*(_ah)->ah_getNav)((_ah))) +#defineath_hal_setnav(_ah, _val) \ + ((*(_ah)->ah_setNav)((_ah), (_val))) #defineath_hal_spectral_supported(_ah) \ (ath_hal_getcapability(_ah, HAL_CAP_SPECTRAL_SCAN, 0, NULL) == HAL_OK) ___ dev-commits-src-main@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"
git: 114f4b17d5b6 - main - [ar71xx] During reset, don't spin, just keep trying
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=114f4b17d5b60a5d53ca98f08cc7e8d78c6984de commit 114f4b17d5b60a5d53ca98f08cc7e8d78c6984de Author: Adrian Chadd AuthorDate: 2021-04-19 05:48:13 + Commit: Adrian Chadd CommitDate: 2021-05-22 22:53:00 + [ar71xx] During reset, don't spin, just keep trying I've seen this fail from time to time and just hang during reset. Instead of it just hanging, just poke it again. I've not seen it fail in hundreds of test resets now. Tested: * AR9344 AP/STA configuration --- sys/mips/atheros/ar71xx_machdep.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/mips/atheros/ar71xx_machdep.c b/sys/mips/atheros/ar71xx_machdep.c index 2bb6d5845d16..72beec972de2 100644 --- a/sys/mips/atheros/ar71xx_machdep.c +++ b/sys/mips/atheros/ar71xx_machdep.c @@ -80,10 +80,13 @@ platform_cpu_init() void platform_reset(void) { - ar71xx_device_stop(RST_RESET_FULL_CHIP); - /* Wait for reset */ - while(1) - ; + while(1) { + printf("%s: resetting via AHB FULL_CHIP register...\n", __func__); + ar71xx_device_start(RST_RESET_FULL_CHIP); + DELAY(100 * 1000); + ar71xx_device_stop(RST_RESET_FULL_CHIP); + DELAY(1000 * 1000); + } } /* ___ dev-commits-src-main@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"
git: 079bd2e750ad - main - [athstats] Add some (but not all, sigh) missing statistics.
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=079bd2e750adae17e0f13cc4e876249fd4c2016e commit 079bd2e750adae17e0f13cc4e876249fd4c2016e Author: Adrian Chadd AuthorDate: 2021-03-13 22:16:37 + Commit: Adrian Chadd CommitDate: 2021-05-22 22:54:25 + [athstats] Add some (but not all, sigh) missing statistics. This adds a few recent statistics, including TSFOOR that I just added to the driver. --- tools/tools/ath/athstats/athstats.c | 38 - 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/tools/tools/ath/athstats/athstats.c b/tools/tools/ath/athstats/athstats.c index 911526755ee4..34e95b7c3885 100644 --- a/tools/tools/ath/athstats/athstats.c +++ b/tools/tools/ath/athstats/athstats.c @@ -297,8 +297,23 @@ static const struct fmt athstats[] = { { 4,"txaggrfail", "TXAF", "A-MPDU sub-frame TX attempt failures" }, #defineS_TX_AGGR_FAILALL AFTER(S_TX_AGGR_FAIL) { 7,"txaggrfailall","TXAFALL", "A-MPDU TX frame failures" }, -#ifndef __linux__ -#defineS_CABQ_XMIT AFTER(S_TX_AGGR_FAILALL) +#defineS_TX_MCASTQ_OVERFLOWAFTER(S_TX_AGGR_FAILALL) + { 8,"txmcastqovf", "TXMCQOVF", "TX multicast queue overflow" }, +#defineS_RX_KEYMISSAFTER(S_TX_MCASTQ_OVERFLOW) + { 4,"rxkeymiss","RXKM", "RX crypto key miss" }, +#defineS_TX_SWFILTERED AFTER(S_RX_KEYMISS) + { 7,"txswfilt", "TXSWFLT", "TX frames filtered by hw and retried" }, +#defineS_TX_NODE_PSQ_OVERFLOW AFTER(S_TX_SWFILTERED) + { 8,"txpsqovf", "TXPSQOVF", "TX frames overflowed the power save queue" }, +#defineS_TX_NODEQ_OVERFLOW AFTER(S_TX_NODE_PSQ_OVERFLOW) + { 8,"txnqovf", "TXNQOVF", "TX frames overflowed the node queue" }, +#defineS_TX_LDPC AFTER(S_TX_NODEQ_OVERFLOW) + { 6,"txldpc", "TXLDPC", "TX frames transmitted with LDPC" }, +#defineS_TX_STBC AFTER(S_TX_LDPC) + { 6,"txstbc", "TXSTBC", "TX frames transmitted with STBC" }, +#defineS_TSFOORAFTER(S_TX_STBC) + { 6,"tsfoor", "TSFOOR", "TSF overflow interrupt/restarts" }, +#defineS_CABQ_XMIT AFTER(S_TSFOOR) { 7,"cabxmit", "cabxmit", "cabq frames transmitted" }, #defineS_CABQ_BUSY AFTER(S_CABQ_XMIT) { 8,"cabqbusy", "cabqbusy", "cabq xmit overflowed beacon interval" }, @@ -309,9 +324,6 @@ static const struct fmt athstats[] = { #defineS_RX_BUSDMA AFTER(S_TX_BUSDMA) { 8,"rxbusdma", "rxbusdma", "rx setup failed for dma resrcs" }, #defineS_FF_TXOK AFTER(S_RX_BUSDMA) -#else -#defineS_FF_TXOK AFTER(S_TX_AGGR_FAILALL) -#endif { 5,"fftxok", "fftxok", "fast frames xmit successfully" }, #defineS_FF_TXERR AFTER(S_FF_TXOK) { 5,"fftxerr", "fftxerr", "fast frames not xmit due to error" }, @@ -770,6 +782,14 @@ ath_get_curstat(struct bsdstat *sf, int s, char b[], size_t bs) case S_TX_AGGR_OK: STAT(tx_aggr_ok); case S_TX_AGGR_FAIL:STAT(tx_aggr_fail); case S_TX_AGGR_FAILALL: STAT(tx_aggr_failall); + case S_TX_MCASTQ_OVERFLOW: STAT(tx_mcastq_overflow); + case S_RX_KEYMISS: STAT(rx_keymiss); + case S_TX_SWFILTERED: STAT(tx_swfiltered); + case S_TX_NODE_PSQ_OVERFLOW:STAT(tx_node_psq_overflow); + case S_TX_NODEQ_OVERFLOW: STAT(tx_nodeq_overflow); + case S_TX_LDPC: STAT(tx_ldpc); + case S_TX_STBC: STAT(tx_stbc); + case S_TSFOOR: STAT(tsfoor); } b[0] = '\0'; return 0; @@ -1015,6 +1035,14 @@ ath_get_totstat(struct bsdstat *sf, int s, char b[], size_t bs) case S_TX_AGGR_OK: STAT(tx_aggr_ok); case S_TX_AGGR_FAIL:STAT(tx_aggr_fail); case S_TX_AGGR_FAILALL: STAT(tx_aggr_failall); + case S_TX_MCASTQ_OVERFLOW: STAT(tx_mcastq_overflow); + case S_RX_KEYMISS: STAT(rx_keymiss); + case S_TX_SWFILTERED: STAT(tx_swfiltered); + case S_TX_NODE_PSQ
git: da7f6e67901b - main - [athstats] Add a tag to listen for beacon stuff
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=da7f6e67901bddbeee47f8608334d1567ecdce4d commit da7f6e67901bddbeee47f8608334d1567ecdce4d Author: Adrian Chadd AuthorDate: 2021-03-31 19:37:47 + Commit: Adrian Chadd CommitDate: 2021-05-22 22:54:44 + [athstats] Add a tag to listen for beacon stuff I'm debugging weird beacon issues and thus here we are. --- tools/tools/ath/athstats/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/tools/ath/athstats/main.c b/tools/tools/ath/athstats/main.c index 29e86365c83b..23bdb25981d5 100644 --- a/tools/tools/ath/athstats/main.c +++ b/tools/tools/ath/athstats/main.c @@ -65,6 +65,9 @@ static struct { { "tdma", "input,output,bexmit,tdmau,tdmadj,crcerr,phyerr,phytor,rssi,noise,rate" }, + { "beacon", +"bstuck,bmiss,bexmit,beacons,bmisscount,reset,ofdm,cck,input,output" + }, }; static const char * ___ dev-commits-src-main@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"
git: 1ca399682822 - main - [ath] Add ast_tsfoor to the sysctl statistics array.
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=1ca39968282266283251f2d3e4c27bcb67bb14f1 commit 1ca39968282266283251f2d3e4c27bcb67bb14f1 Author: Adrian Chadd AuthorDate: 2021-03-13 22:16:17 + Commit: Adrian Chadd CommitDate: 2021-05-22 22:54:16 + [ath] Add ast_tsfoor to the sysctl statistics array. --- sys/dev/ath/if_ath_sysctl.c | 4 1 file changed, 4 insertions(+) diff --git a/sys/dev/ath/if_ath_sysctl.c b/sys/dev/ath/if_ath_sysctl.c index 3c873d3e8b34..de852158f991 100644 --- a/sys/dev/ath/if_ath_sysctl.c +++ b/sys/dev/ath/if_ath_sysctl.c @@ -1301,6 +1301,10 @@ ath_sysctl_stats_attach(struct ath_softc *sc) CTLFLAG_RD, &sc->sc_stats.ast_tx_ldpc, 0, "Number of LDPC frames transmitted"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tsfoor", + CTLFLAG_RD, &sc->sc_stats.ast_tsfoor, 0, + "Number of TSF out of range interrupts/resets"); + /* Attach the RX phy error array */ ath_sysctl_stats_attach_rxphyerr(sc, child); ___ dev-commits-src-main@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"
git: f858e9281c60 - main - [ath] Handle STA + AP beacon programming without stomping over HW AP beacon programming
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=f858e9281c60d0730ab20ed94eef5c52e66795ee commit f858e9281c60d0730ab20ed94eef5c52e66795ee Author: Adrian Chadd AuthorDate: 2021-05-22 23:39:16 + Commit: Adrian Chadd CommitDate: 2021-05-22 23:39:16 + [ath] Handle STA + AP beacon programming without stomping over HW AP beacon programming I've been using STA+AP modes at home for a couple years now and I've been finding and fixing a lot of weird corner cases. This is the eventual patchset I've landed on. * Don't force beacon resync in STA mode if we're using sw beacon tracking. This stops a variety of stomping issues when the STA VAP is reconfigured; the AP hardware beacons were being stomped on! * Use the first AP VAP to configure beacons on, rather than the first VAP. This prevents weird behaviour in ath_beacon_config() when the hardware is being reconfigured and the STA VAP was the first one created. * Ensure the beacon interval / timing programming is within the AR9300 HAL bounds by masking off any flags that may have been there before shifting the value up to 1/8 TUs rather than the 1 TU resolution the previous chips used. Now I don't get weird beacon reprogramming during startup, STA state changes and hardware recovery which showed up as HI-LARIOUS beacon configurations and STAs that would just disconnect from the AP very frequently. Tested: * AR9344/AR9380, STA and AP and STA+AP modes --- sys/dev/ath/if_ath.c| 34 sys/dev/ath/if_ath_beacon.c | 48 +++-- sys/dev/ath/if_ath_rx.c | 1 + 3 files changed, 61 insertions(+), 22 deletions(-) diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index 698b8d1a2853..4bc5c31812e7 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -2450,13 +2450,15 @@ ath_bmiss_vap(struct ieee80211vap *vap) ath_power_setpower(sc, HAL_PM_AWAKE, 0); ath_power_restore_power_state(sc); ATH_UNLOCK(sc); + DPRINTF(sc, ATH_DEBUG_BEACON, "%s: forced awake; force syncbeacon=1\n", __func__); - - /* -* Attempt to force a beacon resync. -*/ - sc->sc_syncbeacon = 1; + if ((vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) == 0) { + /* +* Attempt to force a beacon resync. +*/ + sc->sc_syncbeacon = 1; + } ATH_VAP(vap)->av_bmiss(vap); } @@ -6061,19 +6063,25 @@ ath_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) * In that case, we may not receive an actual * beacon to update the beacon timer and thus we * won't get notified of the missing beacons. +* +* Also, don't do any of this if we're not running +* with hardware beacon support, as that'll interfere +* with an AP VAP. */ if (ostate != IEEE80211_S_RUN && ostate != IEEE80211_S_SLEEP) { - DPRINTF(sc, ATH_DEBUG_BEACON, - "%s: STA; syncbeacon=1\n", __func__); - sc->sc_syncbeacon = 1; + + if ((vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) == 0) { + DPRINTF(sc, ATH_DEBUG_BEACON, + "%s: STA; syncbeacon=1\n", __func__); + sc->sc_syncbeacon = 1; + if (csa_run_transition) + ath_beacon_config(sc, vap); + } /* Quiet time handling - ensure we resync */ memset(&avp->quiet_ie, 0, sizeof(avp->quiet_ie)); - if (csa_run_transition) - ath_beacon_config(sc, vap); - /* * PR: kern/175227 * @@ -6086,7 +6094,9 @@ ath_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) * timer fires (too often), leading to a STA * disassociation. */ - sc->sc_beacons = 1; + if ((vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) == 0) { + sc->sc_beacons = 1; + }
git: c50346bcf5c5 - main - ath: bump the default node queue size to 128 frames, not 64
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=c50346bcf5c5ccd0ef65d273edea6143f66c999f commit c50346bcf5c5ccd0ef65d273edea6143f66c999f Author: Adrian Chadd AuthorDate: 2021-05-23 04:23:00 + Commit: Adrian Chadd CommitDate: 2021-05-23 04:23:00 + ath: bump the default node queue size to 128 frames, not 64 It turns out that, silly adrian, setting it to 64 means only two AMPDU frames of 32 subframes each. Thus, whilst those are in-flight, any subsequent queues frames to that node get dropped. This ends up being pretty no bueno for performance if any receive is also going on at that point. Instead, set it to 128 for the time being to ensure that SOME frames get queued in the meantime. This results in some frames being immediately available in the software queue for transmit when the two existing A-MPDU frames have been completely sent, rather than the queue remaining empty until at least one is sent. It's not the best solution - I still think I'm scheduling receive far more often than giving time to schedule transmit work - but at least now I'm not starving the transmit side. Before this, a bidirectional iperf would show receive at ~ 150mbit/sec. but the transmit side at like 10kbit/sec. With it set to 128 it's now 150mbit/sec receive, and ~ 10mbit receive. It's better than 10kbit/sec, but still not as far as I'd like it to be. Tested: * AR9380/QCA934x (TL-WDR4300 AP), Macbook pro test STA + AR9380 test STA --- sys/dev/ath/if_ath.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index 4bc5c31812e7..3675cfc78654 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -1083,9 +1083,16 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) /* * Default the maximum queue to 1/4'th the TX buffers, or -* 64, whichever is smaller. -*/ - sc->sc_txq_node_maxdepth = MIN(64, ath_txbuf / 4); +* 128, whichever is smaller. +* +* Set it to 128 instead of the previous default (64) because +* at 64, two full A-MPDU subframes of 32 frames each is +* enough to treat this node queue as full and all subsequent +* traffic is dropped. Setting it to 128 means there'll +* hopefully be another 64 frames in the software queue +* to begin making A-MPDU frames out of. +*/ + sc->sc_txq_node_maxdepth = MIN(128, ath_txbuf / 4); /* Enable CABQ by default */ sc->sc_cabq_enable = 1; ___ dev-commits-src-main@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"
git: 288a92252bd8 - main - ahci: Add Intel Comet Lake RAID/RST controller PCI ID
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=288a92252bd8ec06bb5e200f75b6c4859fc6bd25 commit 288a92252bd8ec06bb5e200f75b6c4859fc6bd25 Author: Adrian Chadd AuthorDate: 2021-12-05 21:28:39 + Commit: Adrian Chadd CommitDate: 2021-12-05 21:28:39 + ahci: Add Intel Comet Lake RAID/RST controller PCI ID This is needed on my ASUS motherboard / Intel Comet Lake i5-10500 desktop machine. This with some work arounds for nvme behind the RST controller boots and works. Reviewed by: cognet --- sys/dev/ahci/ahci_pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/dev/ahci/ahci_pci.c b/sys/dev/ahci/ahci_pci.c index 9e4987e38bfb..5f8663b96609 100644 --- a/sys/dev/ahci/ahci_pci.c +++ b/sys/dev/ahci/ahci_pci.c @@ -135,6 +135,7 @@ static const struct { {0x3b298086, 0x00, "Intel Ibex Peak-M", 0}, {0x3b2c8086, 0x00, "Intel Ibex Peak-M (RAID)", 0}, {0x3b2f8086, 0x00, "Intel Ibex Peak-M", 0}, + {0x06d68086, 0x00, "Intel Comet Lake (RAID)", 0}, {0x19b08086, 0x00, "Intel Denverton", 0}, {0x19b18086, 0x00, "Intel Denverton", 0}, {0x19b28086, 0x00, "Intel Denverton", 0},
git: 05860ffdb428 - main - cpufreq: Support operating-mode-v2 tables with no voltages
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=05860ffdb42877ab1e40fd6df8a12f3d45727289 commit 05860ffdb42877ab1e40fd6df8a12f3d45727289 Author: Adrian Chadd AuthorDate: 2021-11-23 05:43:25 + Commit: Adrian Chadd CommitDate: 2021-12-14 17:49:17 + cpufreq: Support operating-mode-v2 tables with no voltages Summary: The linux device tree documentation for this states that for v1 voltages are required, but for v2 voltages are optional. So, handle that here - if there's no regulator/supply provided for a v1 opmode then error out; but keep it optional for v2. Then just don't both doing any regulator calls if it's not configured. This isn't the best/final solution - mmel@ has suggested that this should be flipped around a bit and print warnings if we get an opp-microvolt property but we don't have a regulator. Subscribers: imp Reviewed by: mmel, jrtc27, manu Test Plan: * IPQ4018, with no voltage tables; the freq set is called appropriately. Differential Revision: https://reviews.freebsd.org/D33140 --- sys/dev/cpufreq/cpufreq_dt.c | 178 --- 1 file changed, 116 insertions(+), 62 deletions(-) diff --git a/sys/dev/cpufreq/cpufreq_dt.c b/sys/dev/cpufreq/cpufreq_dt.c index 4ab021a97d31..30d9d56e66af 100644 --- a/sys/dev/cpufreq/cpufreq_dt.c +++ b/sys/dev/cpufreq/cpufreq_dt.c @@ -73,6 +73,8 @@ struct cpufreq_dt_opp { boolopp_suspend; }; +#defineCPUFREQ_DT_HAVE_REGULATOR(sc) ((sc)->reg != NULL) + struct cpufreq_dt_softc { device_t dev; clk_t clk; @@ -181,24 +183,31 @@ cpufreq_dt_set(device_t dev, const struct cf_setting *set) device_printf(dev, "Can't get current clk freq\n"); return (ENXIO); } - /* Try to get current valtage by using regulator first. */ - error = regulator_get_voltage(sc->reg, &uvolt); - if (error != 0) { - /* -* Try oppoints table as backup way. However, -* this is insufficient because the actual processor -* frequency may not be in the table. PLL frequency -* granularity can be different that granularity of -* oppoint table. -*/ - copp = cpufreq_dt_find_opp(sc->dev, freq); - if (copp == NULL) { - device_printf(dev, - "Can't find the current freq in opp\n"); - return (ENOENT); + + /* +* Only do the regulator work if it's required. +*/ + if (CPUFREQ_DT_HAVE_REGULATOR(sc)) { + /* Try to get current valtage by using regulator first. */ + error = regulator_get_voltage(sc->reg, &uvolt); + if (error != 0) { + /* +* Try oppoints table as backup way. However, +* this is insufficient because the actual processor +* frequency may not be in the table. PLL frequency +* granularity can be different that granularity of +* oppoint table. +*/ + copp = cpufreq_dt_find_opp(sc->dev, freq); + if (copp == NULL) { + device_printf(dev, + "Can't find the current freq in opp\n"); + return (ENOENT); + } + uvolt = copp->uvolt_target; } - uvolt = copp->uvolt_target; - } + } else + uvolt = 0; opp = cpufreq_dt_find_opp(sc->dev, set->freq * 100); if (opp == NULL) { @@ -209,7 +218,7 @@ cpufreq_dt_set(device_t dev, const struct cf_setting *set) DPRINTF(sc->dev, "Target freq %ju, , uvolt: %d\n", opp->freq, opp->uvolt_target); - if (uvolt < opp->uvolt_target) { + if (CPUFREQ_DT_HAVE_REGULATOR(sc) && (uvolt < opp->uvolt_target)) { DPRINTF(dev, "Changing regulator from %u to %u\n", uvolt, opp->uvolt_target); error = regulator_set_voltage(sc->reg, @@ -226,13 +235,14 @@ cpufreq_dt_set(device_t dev, const struct cf_setting *set) if (error != 0) { DPRINTF(dev, "Failed, backout\n"); /* Restore previous voltage (best effort) */ - error = regulator_set_voltage(sc->reg, - copp->uvolt_min, - copp->uvolt_max); + if (CPUFREQ_DT_HAVE_REGULATOR(sc)) + error = regul
git: 0727f7b52086 - main - arm: add dwc3 as a compilable driver
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=0727f7b520860cdd25ddef05ca0e856568e0c259 commit 0727f7b520860cdd25ddef05ca0e856568e0c259 Author: Adrian Chadd AuthorDate: 2021-12-23 18:36:51 + Commit: Adrian Chadd CommitDate: 2021-12-23 18:36:51 + arm: add dwc3 as a compilable driver The IPQ4018/IPQ4019 cores use the DWC3 core. So make it available here. --- sys/conf/files.arm | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/conf/files.arm b/sys/conf/files.arm index 4a5e9cc0bac9..eed9933129ec 100644 --- a/sys/conf/files.arm +++ b/sys/conf/files.arm @@ -99,6 +99,7 @@ dev/psci/psci.c optionalpsci dev/psci/smccc_arm.S optionalpsci dev/syscons/scgfbrndr.coptionalsc dev/uart/uart_cpu_fdt.coptionaluart fdt +dev/usb/controller/dwc3.c optionalfdt dwc3 kern/msi_if.m optionalintrng kern/pic_if.m optionalintrng
git: 95a70e9ea807 - main - qca: add the TLMM code into the build
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=95a70e9ea807732d7a7fcde36bc4fdeb2cd8b74b commit 95a70e9ea807732d7a7fcde36bc4fdeb2cd8b74b Author: Adrian Chadd AuthorDate: 2021-12-19 04:06:49 + Commit: Adrian Chadd CommitDate: 2021-12-23 18:42:00 + qca: add the TLMM code into the build This adds the IPQ4018 TLMM code into the IPQ4018 build. Differential Revision: https://reviews.freebsd.org/D33554 --- sys/arm/conf/std.qca | 5 + 1 file changed, 5 insertions(+) diff --git a/sys/arm/conf/std.qca b/sys/arm/conf/std.qca index 09cd61078870..38c35761e3aa 100644 --- a/sys/arm/conf/std.qca +++ b/sys/arm/conf/std.qca @@ -40,6 +40,11 @@ device psci # Clock/Reset provider device qcom_gcc_ipq4018 +# TLMM (gpio/pinmux) +device gpio +device qcom_tlmm_ipq4018 +device fdt_pinctrl + optionsFDT # Disable CP14 work in DDB as TZ won't let us by default
git: 4abe6533e9a2 - main - qcom_tlmm: add initial gpio/pinmux controller (TLMM)
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=4abe6533e9a2a2252faed907246eab96c4541210 commit 4abe6533e9a2a2252faed907246eab96c4541210 Author: Adrian Chadd AuthorDate: 2021-12-19 04:03:40 + Commit: Adrian Chadd CommitDate: 2021-12-23 18:41:41 + qcom_tlmm: add initial gpio/pinmux controller (TLMM) The qualcomm TLMM (top level mode manager) is their gpio/pinmux hardware controller. Although the pinmux is generic enough to use for the IPQ/APQ series chips, I'm directly calling the IPQ4018 routines to expedite bring-up. Notably, I'm not yet implementing the interrupt support - it's not required at this stage of bring-up. Differential Revision: https://reviews.freebsd.org/D33554 --- sys/arm/qualcomm/std.ipq4018 | 5 + sys/dev/qcom_tlmm/qcom_tlmm_debug.c | 66 sys/dev/qcom_tlmm/qcom_tlmm_debug.h | 43 +++ sys/dev/qcom_tlmm/qcom_tlmm_ipq4018.c | 400 ++ sys/dev/qcom_tlmm/qcom_tlmm_ipq4018_hw.c | 530 + sys/dev/qcom_tlmm/qcom_tlmm_ipq4018_hw.h | 88 + sys/dev/qcom_tlmm/qcom_tlmm_ipq4018_reg.h | 85 + sys/dev/qcom_tlmm/qcom_tlmm_pin.c | 322 ++ sys/dev/qcom_tlmm/qcom_tlmm_pin.h | 50 +++ sys/dev/qcom_tlmm/qcom_tlmm_pinmux.c | 533 ++ sys/dev/qcom_tlmm/qcom_tlmm_var.h | 168 ++ 11 files changed, 2290 insertions(+) diff --git a/sys/arm/qualcomm/std.ipq4018 b/sys/arm/qualcomm/std.ipq4018 index 913314e92301..6676a896086e 100644 --- a/sys/arm/qualcomm/std.ipq4018 +++ b/sys/arm/qualcomm/std.ipq4018 @@ -8,3 +8,8 @@ arm/qualcomm/qcom_gcc_ipq4018.c optional qcom_gcc_ipq4018 arm/qualcomm/qcom_gcc_ipq4018_reset.c optional qcom_gcc_ipq4018 arm/qualcomm/qcom_gcc_ipq4018_clock.c optional qcom_gcc_ipq4018 +dev/qcom_tlmm/qcom_tlmm_debug.coptional qcom_tlmm_ipq4018 +dev/qcom_tlmm/qcom_tlmm_ipq4018.c optional qcom_tlmm_ipq4018 +dev/qcom_tlmm/qcom_tlmm_ipq4018_hw.c optional qcom_tlmm_ipq4018 +dev/qcom_tlmm/qcom_tlmm_pin.c optional qcom_tlmm_ipq4018 +dev/qcom_tlmm/qcom_tlmm_pinmux.c optional qcom_tlmm_ipq4018 diff --git a/sys/dev/qcom_tlmm/qcom_tlmm_debug.c b/sys/dev/qcom_tlmm/qcom_tlmm_debug.c new file mode 100644 index ..607561f69c44 --- /dev/null +++ b/sys/dev/qcom_tlmm/qcom_tlmm_debug.c @@ -0,0 +1,66 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Adrian Chadd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice unmodified, this list of conditions, and the following + *disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#include "qcom_tlmm_var.h" +#include "qcom_tlmm_debug.h" + +void +qcom_tlmm_debug_sysctl_attach(struct qcom_tlmm_softc *sc) +{ + struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->dev); + struct sysctl_oid *tree = device_get_sysctl_tree(sc->dev); + + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "debug", CTLFLAG_RW, &sc->sc_debug, 0, + "control debugging printfs"); +} diff --git a/sys/dev/qcom_tlmm/qcom_tlmm_debug.h b/sys/dev/qcom_tlmm/qcom_tlmm_debug.h new file mode 100644 index ..3e2e690e572c --- /dev/null +++ b/sys/dev/qcom_tlmm/qcom_tlmm_debug.h @@ -0,0 +1,43 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Adrian Chadd + * + * Redistribution and
git: 9df53d07e6bc - main - clk: add call for nodes to get the programmed/decided frequency passed back
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=9df53d07e6bce5d38fca860367da546f6a420a90 commit 9df53d07e6bce5d38fca860367da546f6a420a90 Author: Adrian Chadd AuthorDate: 2021-12-14 18:01:08 + Commit: Adrian Chadd CommitDate: 2021-12-26 12:18:53 + clk: add call for nodes to get the programmed/decided frequency passed back Summary: The existing call can only really be used for a node wishing to configure its parent, but as we don't pass in a pointer to the freq, we can't set it to what it would be for a DRY_RUN pass. So for clock nodes that wish to try setting parent frequencies to see which would be the best for its own target frequency, we really do need a way to call in and pass in a flag /and/ a pointer to freq so it can be updated for us as the clock tree is recursed through. Reviewers: manu Approved by: manu Subscribers: imp Differential Revision: https://reviews.freebsd.org/D33445 --- sys/dev/extres/clk/clk.c | 35 +-- sys/dev/extres/clk/clk.h | 2 ++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/sys/dev/extres/clk/clk.c b/sys/dev/extres/clk/clk.c index f4284fcd59ba..2be233c465a9 100644 --- a/sys/dev/extres/clk/clk.c +++ b/sys/dev/extres/clk/clk.c @@ -965,8 +965,8 @@ clknode_get_freq(struct clknode *clknode, uint64_t *freq) return (0); } -int -clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, +static int +_clknode_set_freq(struct clknode *clknode, uint64_t *freq, int flags, int enablecnt) { int rv, done; @@ -976,7 +976,7 @@ clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, CLK_TOPO_XASSERT(); /* Check for no change */ - if (clknode->freq == freq) + if (clknode->freq == *freq) return (0); parent_freq = 0; @@ -1003,7 +1003,7 @@ clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, } /* Set frequency for this clock. */ - rv = CLKNODE_SET_FREQ(clknode, parent_freq, &freq, flags, &done); + rv = CLKNODE_SET_FREQ(clknode, parent_freq, freq, flags, &done); if (rv != 0) { printf("Cannot set frequency for clk: %s, error: %d\n", clknode->name, rv); @@ -1015,7 +1015,7 @@ clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, if (done) { /* Success - invalidate frequency cache for all children. */ if ((flags & CLK_SET_DRYRUN) == 0) { - clknode->freq = freq; + clknode->freq = *freq; /* Clock might have reparent during set_freq */ if (clknode->parent_cnt > 0) { rv = clknode_get_freq(clknode->parent, @@ -1028,7 +1028,8 @@ clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, } } else if (clknode->parent != NULL) { /* Nothing changed, pass request to parent. */ - rv = clknode_set_freq(clknode->parent, freq, flags, enablecnt); + rv = _clknode_set_freq(clknode->parent, freq, flags, + enablecnt); } else { /* End of chain without action. */ printf("Cannot set frequency for clk: %s, end of chain\n", @@ -1039,6 +1040,28 @@ clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, return (rv); } +int +clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, +int enablecnt) +{ + + return (_clknode_set_freq(clknode, &freq, flags, enablecnt)); +} + +int +clknode_try_freq(struct clknode *clknode, uint64_t freq, int flags, +int enablecnt, uint64_t *out_freq) +{ + int rv; + + rv = _clknode_set_freq(clknode, &freq, flags | CLK_SET_DRYRUN, + enablecnt); + if (out_freq != NULL) + *out_freq = freq; + + return (rv); +} + int clknode_enable(struct clknode *clknode) { diff --git a/sys/dev/extres/clk/clk.h b/sys/dev/extres/clk/clk.h index 3ddf8fc574de..5daf3c0731ee 100644 --- a/sys/dev/extres/clk/clk.h +++ b/sys/dev/extres/clk/clk.h @@ -115,6 +115,8 @@ struct clknode *clknode_find_by_id(struct clkdom *clkdom, intptr_t id); int clknode_get_freq(struct clknode *clknode, uint64_t *freq); int clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, int enablecnt); +int clknode_try_freq(struct clknode *clknode, uint64_t freq, int flags, +int enablecnt, uint64_t *out_freq); int clknode_enable(struct clknode *clknode); int clknode_disable(struct clknode *clknode); int clknode_stop(struct clknode *clknode, int depth);
git: a82907ed131a - main - clk: rename clknode_try_freq to clknode_test_freq
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=a82907ed131a093a4fcc1960fc5ae162bf29bb7c commit a82907ed131a093a4fcc1960fc5ae162bf29bb7c Author: Adrian Chadd AuthorDate: 2021-12-26 14:16:02 + Commit: Adrian Chadd CommitDate: 2021-12-26 14:16:02 + clk: rename clknode_try_freq to clknode_test_freq This brings it in line with what the clk_*_freq routines are named. --- sys/dev/extres/clk/clk.c | 2 +- sys/dev/extres/clk/clk.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/extres/clk/clk.c b/sys/dev/extres/clk/clk.c index 2be233c465a9..26034a91919f 100644 --- a/sys/dev/extres/clk/clk.c +++ b/sys/dev/extres/clk/clk.c @@ -1049,7 +1049,7 @@ clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, } int -clknode_try_freq(struct clknode *clknode, uint64_t freq, int flags, +clknode_test_freq(struct clknode *clknode, uint64_t freq, int flags, int enablecnt, uint64_t *out_freq) { int rv; diff --git a/sys/dev/extres/clk/clk.h b/sys/dev/extres/clk/clk.h index 5daf3c0731ee..68a7811a736f 100644 --- a/sys/dev/extres/clk/clk.h +++ b/sys/dev/extres/clk/clk.h @@ -115,7 +115,7 @@ struct clknode *clknode_find_by_id(struct clkdom *clkdom, intptr_t id); int clknode_get_freq(struct clknode *clknode, uint64_t *freq); int clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, int enablecnt); -int clknode_try_freq(struct clknode *clknode, uint64_t freq, int flags, +int clknode_test_freq(struct clknode *clknode, uint64_t freq, int flags, int enablecnt, uint64_t *out_freq); int clknode_enable(struct clknode *clknode); int clknode_disable(struct clknode *clknode);
git: e34a491b3562 - main - qcom_clk: add the qualcomm clock nodes for the IPQ4018
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=e34a491b35626b4209ef0a195e85a03a1089c572 commit e34a491b35626b4209ef0a195e85a03a1089c572 Author: Adrian Chadd AuthorDate: 2021-12-26 17:07:21 + Commit: Adrian Chadd CommitDate: 2021-12-27 21:02:30 + qcom_clk: add the qualcomm clock nodes for the IPQ4018 These clock nodes are used by the IPQ4018/IPQ4019 and derivatives. They're also used by other 32 and 64 bit qualcomm parts; so it's best to put these nodes here in a single qcom_clk driver and add to it as we grow new Qualcomm SoC support. Tested: * IPQ4018, boot Differential Revision: https://reviews.freebsd.org/D33665 --- sys/arm/qualcomm/std.ipq4018| 8 + sys/dev/qcom_clk/qcom_clk_apssdiv.c | 287 ++ sys/dev/qcom_clk/qcom_clk_apssdiv.h | 48 +++ sys/dev/qcom_clk/qcom_clk_branch2.c | 290 ++ sys/dev/qcom_clk/qcom_clk_branch2.h | 70 sys/dev/qcom_clk/qcom_clk_branch2_reg.h | 39 ++ sys/dev/qcom_clk/qcom_clk_fdiv.c| 115 ++ sys/dev/qcom_clk/qcom_clk_fdiv.h| 41 ++ sys/dev/qcom_clk/qcom_clk_fepll.c | 153 sys/dev/qcom_clk/qcom_clk_fepll.h | 45 +++ sys/dev/qcom_clk/qcom_clk_freqtbl.c | 56 +++ sys/dev/qcom_clk/qcom_clk_freqtbl.h | 44 +++ sys/dev/qcom_clk/qcom_clk_rcg2.c| 660 sys/dev/qcom_clk/qcom_clk_rcg2.h| 61 +++ sys/dev/qcom_clk/qcom_clk_rcg2_reg.h| 58 +++ sys/dev/qcom_clk/qcom_clk_ro_div.c | 153 sys/dev/qcom_clk/qcom_clk_ro_div.h | 49 +++ 17 files changed, 2177 insertions(+) diff --git a/sys/arm/qualcomm/std.ipq4018 b/sys/arm/qualcomm/std.ipq4018 index 6676a896086e..38e561f4079c 100644 --- a/sys/arm/qualcomm/std.ipq4018 +++ b/sys/arm/qualcomm/std.ipq4018 @@ -8,6 +8,14 @@ arm/qualcomm/qcom_gcc_ipq4018.coptional qcom_gcc_ipq4018 arm/qualcomm/qcom_gcc_ipq4018_reset.c optional qcom_gcc_ipq4018 arm/qualcomm/qcom_gcc_ipq4018_clock.c optional qcom_gcc_ipq4018 +dev/qcom_clk/qcom_clk_fepll.c optional qcom_gcc_ipq4018 +dev/qcom_clk/qcom_clk_fdiv.c optional qcom_gcc_ipq4018 +dev/qcom_clk/qcom_clk_apssdiv.coptional qcom_gcc_ipq4018 +dev/qcom_clk/qcom_clk_freqtbl.coptional qcom_gcc_ipq4018 +dev/qcom_clk/qcom_clk_rcg2.c optional qcom_gcc_ipq4018 +dev/qcom_clk/qcom_clk_branch2.coptional qcom_gcc_ipq4018 +dev/qcom_clk/qcom_clk_ro_div.c optional qcom_gcc_ipq4018 + dev/qcom_tlmm/qcom_tlmm_debug.coptional qcom_tlmm_ipq4018 dev/qcom_tlmm/qcom_tlmm_ipq4018.c optional qcom_tlmm_ipq4018 dev/qcom_tlmm/qcom_tlmm_ipq4018_hw.c optional qcom_tlmm_ipq4018 diff --git a/sys/dev/qcom_clk/qcom_clk_apssdiv.c b/sys/dev/qcom_clk/qcom_clk_apssdiv.c new file mode 100644 index ..75216ba60172 --- /dev/null +++ b/sys/dev/qcom_clk/qcom_clk_apssdiv.c @@ -0,0 +1,287 @@ +/*- + * Copyright (c) 2021 Adrian Chadd . + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "qcom_clk_freqtbl.h" +#include "qcom_clk_apssdiv.h" + +#include "clkdev_if.h" + +/* + * This is a combination gate, divisor/PLL configuration + * for the APSS CPU clock. + */ + +#if 0 +#define DPRINTF(dev, msg...) device_printf(dev, "cpufreq_dt: " msg); +#else +#define DPRINTF(dev, msg...) +#endif + +struct qcom_clk_apssdiv_sc { + struct clknode *clknode; +
git: cd32ac640b88 - main - Add support for qualcomm clock nodes the the IPQ4018/IPQ4019 clock tree.
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=cd32ac640b884eda4e34673256b3816897e754d4 commit cd32ac640b884eda4e34673256b3816897e754d4 Author: Adrian Chadd AuthorDate: 2021-12-26 17:08:57 + Commit: Adrian Chadd CommitDate: 2021-12-27 21:02:31 + Add support for qualcomm clock nodes the the IPQ4018/IPQ4019 clock tree. Summary: I've tested this with cpufreq_dt, SPI and USB. They all seem to work fine. Test Plan: * IPQ4018, boot Subscribers: imp, andrew Differential Revision: https://reviews.freebsd.org/D33665 --- sys/arm/qualcomm/qcom_gcc_ipq4018_clock.c | 82 --- sys/arm/qualcomm/std.ipq4018 | 7 +- .../qualcomm => dev/qcom_gcc}/qcom_gcc_ipq4018.c | 25 +- sys/dev/qcom_gcc/qcom_gcc_ipq4018_clock.c | 770 + .../qcom_gcc}/qcom_gcc_ipq4018_reset.c | 3 +- .../qcom_gcc}/qcom_gcc_ipq4018_var.h | 17 + 6 files changed, 813 insertions(+), 91 deletions(-) diff --git a/sys/arm/qualcomm/qcom_gcc_ipq4018_clock.c b/sys/arm/qualcomm/qcom_gcc_ipq4018_clock.c deleted file mode 100644 index f7f7a6c348ba.. --- a/sys/arm/qualcomm/qcom_gcc_ipq4018_clock.c +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2021, Adrian Chadd - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - *notice unmodified, this list of conditions, and the following - *disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - *notice, this list of conditions and the following disclaimer in the - *documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* Driver for Qualcomm IPQ4018 clock and reset device */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#include - - -/* - * Fixed frequency clock sources: - * - * P_XO - 48MHz - * sleep-clk - is really 32KHz, although older DTS have it as 32.768KHz - */ - -/* - * PLL derived sources: - * - * P_FEPLL125 - 125MHz - * P_FEPLL125DLY - 125MHz - * P_FEPLL200 - 200MHz - * P_FEPLL500 - 500MHz - * P_FEPLLWCSS2G - TBD - * P_FEPLLWCSS5G - TBD - * - * Then there are two DDR PLLs which are treated/configured slightly - * differently: - * - * P_DDRPLLAPSS - TBD - * P_DDRPLLSDCC - TBD - */ - -/* - * Interesting stuff in Linux whilst I reverse engineer + figure it out: - * /sys/kernel/debug/clk - */ diff --git a/sys/arm/qualcomm/std.ipq4018 b/sys/arm/qualcomm/std.ipq4018 index 38e561f4079c..8a9dba579e48 100644 --- a/sys/arm/qualcomm/std.ipq4018 +++ b/sys/arm/qualcomm/std.ipq4018 @@ -4,9 +4,10 @@ arm/qualcomm/qcom_scm_legacy.c standard arm/qualcomm/qcom_cpu_kpssv2.c optional smp dev/qcom_rnd/qcom_rnd.coptional qcom_rnd -arm/qualcomm/qcom_gcc_ipq4018.coptional qcom_gcc_ipq4018 -arm/qualcomm/qcom_gcc_ipq4018_reset.c optional qcom_gcc_ipq4018 -arm/qualcomm/qcom_gcc_ipq4018_clock.c optional qcom_gcc_ipq4018 + +dev/qcom_gcc/qcom_gcc_ipq4018.coptional qcom_gcc_ipq4018 +dev/qcom_gcc/qcom_gcc_ipq4018_reset.c optional qcom_gcc_ipq4018 +dev/qcom_gcc/qcom_gcc_ipq4018_clock.c optional qcom_gcc_ipq4018 dev/qcom_clk/qcom_clk_fepll.c optional qcom_gcc_ipq4018 dev/qcom_clk/qcom_clk_fdiv.c optional qcom_gcc_ipq4018 diff --git a/sys/arm/qualcomm/qcom_gcc_ipq4018.c b/sys/dev/qcom_gcc/qcom_gcc_ipq4018.c similarity index 87% rename from sys/arm/qualcomm/qcom_gcc_ipq4018.c rename to sys/dev/qcom_gcc/qcom_gcc_ipq4018.c index 3002ae32a597..12bd721c1e29 100644 --- a/sys/arm/qualcomm/qcom_gcc_ipq4018.c +++ b/sys/dev/qcom_gcc/qcom_gcc_ipq4018.c @@ -49,11 +49,12 @@ __FBSDID("$FreeBSD$"); #include +#include "clkdev_if.h" #include "hwreset_if.h" #include -#i
git: 7b36da48435d - main - qca: add cpufreq into the build
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=7b36da48435d6c2571329d6a1f04f0a290403af8 commit 7b36da48435d6c2571329d6a1f04f0a290403af8 Author: Adrian Chadd AuthorDate: 2021-12-27 21:13:38 + Commit: Adrian Chadd CommitDate: 2021-12-27 21:13:38 + qca: add cpufreq into the build Now that the clock drivers are in the tree, the cpufreq driver will "just work". Tested: * IPQ4018, testing performance of dd from /dev/zero->/dev/null at each frequency step. --- sys/arm/conf/std.qca | 4 1 file changed, 4 insertions(+) diff --git a/sys/arm/conf/std.qca b/sys/arm/conf/std.qca index 38c35761e3aa..a78e27074ea4 100644 --- a/sys/arm/conf/std.qca +++ b/sys/arm/conf/std.qca @@ -24,8 +24,12 @@ device syscon # Random device qcom_rnd +# interrupt controller device gic +# cpu frequency +device cpufreq + # MMC/SD/SDIO Card slot support device mmc device sdhci
git: d27ba3088424 - main - qcom_qup: add initial v1/v2 QUP SPI driver
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=d27ba3088424e53eabc0b0186ed122ec43119501 commit d27ba3088424e53eabc0b0186ed122ec43119501 Author: Adrian Chadd AuthorDate: 2021-12-27 23:27:29 + Commit: Adrian Chadd CommitDate: 2021-12-27 23:27:29 + qcom_qup: add initial v1/v2 QUP SPI driver The Qualcomm Universal Peripherals Engine (QUP) is a unified SPI and I2C peripheral that ships with a variety of Qualcomm SoCs. It supports three transfer modes - single PIO, block PIO and DMA. This driver only supports the single PIO mode, which is enough to bootstrap the rest of the SPI NAND/NOR support and means I can do things like read the Wifi calibration data from NOR. It has some hardware support code for the other transfer modes as well as some support for split transfers (ie, transfers with no read or write phase), but I haven't yet implemented those. This driver is based on four sources - the linux driver, the u-boot driver, some initial work done for APQ8064 by mmel@, and the APQ8064 Technical Reference Manual which is surprisingly free and open to read. The linux and u-boot drivers approach a variety of things completely differently, from how PIO is done, the hardware support for re-ordering bytes in a transfer word and how the CS lines are used. Tested: * IPQ4018, SPI to NAND/NOR flash, PIO only --- sys/arm/conf/std.qca | 5 + sys/arm/qualcomm/std.ipq4018 | 3 + sys/dev/qcom_qup/qcom_qup_reg.h | 115 + sys/dev/qcom_qup/qcom_spi.c | 911 +++ sys/dev/qcom_qup/qcom_spi_debug.h | 49 ++ sys/dev/qcom_qup/qcom_spi_hw.c| 985 ++ sys/dev/qcom_qup/qcom_spi_reg.h | 76 +++ sys/dev/qcom_qup/qcom_spi_var.h | 162 +++ 8 files changed, 2306 insertions(+) diff --git a/sys/arm/conf/std.qca b/sys/arm/conf/std.qca index a78e27074ea4..7caae2f645ca 100644 --- a/sys/arm/conf/std.qca +++ b/sys/arm/conf/std.qca @@ -24,6 +24,11 @@ device syscon # Random device qcom_rnd +# SPI +device spibus +device qcom_qup_spi +device mx25l + # interrupt controller device gic diff --git a/sys/arm/qualcomm/std.ipq4018 b/sys/arm/qualcomm/std.ipq4018 index 8a9dba579e48..2187e3f17516 100644 --- a/sys/arm/qualcomm/std.ipq4018 +++ b/sys/arm/qualcomm/std.ipq4018 @@ -5,6 +5,9 @@ arm/qualcomm/qcom_cpu_kpssv2.c optional smp dev/qcom_rnd/qcom_rnd.coptional qcom_rnd +dev/qcom_qup/qcom_spi.coptional qcom_qup_spi +dev/qcom_qup/qcom_spi_hw.c optional qcom_qup_spi + dev/qcom_gcc/qcom_gcc_ipq4018.coptional qcom_gcc_ipq4018 dev/qcom_gcc/qcom_gcc_ipq4018_reset.c optional qcom_gcc_ipq4018 dev/qcom_gcc/qcom_gcc_ipq4018_clock.c optional qcom_gcc_ipq4018 diff --git a/sys/dev/qcom_qup/qcom_qup_reg.h b/sys/dev/qcom_qup/qcom_qup_reg.h new file mode 100644 index ..18931e560959 --- /dev/null +++ b/sys/dev/qcom_qup/qcom_qup_reg.h @@ -0,0 +1,115 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Adrian Chadd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef__QCOM_QUP_REG_H__ +#define__QCOM_QUP_REG_H__ + +#defineQUP_CONFIG 0x +#defineQUP_CONFIG_N0x001f +#defineQUP_CONFIG_SPI_MODE (1U << 8) +#defineQUP_CONFIG_MINI_CORE_I2C_MAST
git: d11f81afd5a4 - main - qcom_tcsr: add initial top control and status register (TCSR) support
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=d11f81afd5a4a71d5f725950b0592ca212084780 commit d11f81afd5a4a71d5f725950b0592ca212084780 Author: Adrian Chadd AuthorDate: 2021-12-27 23:45:40 + Commit: Adrian Chadd CommitDate: 2021-12-27 23:56:28 + qcom_tcsr: add initial top control and status register (TCSR) support The Qualcomm TCSR is some top level glue between multiple IP blocks, both for doing configuration of said IP blocks, some IPC between them (mostly between multiple execution environments - eg trustzone and non-TZ), and interrupt status bits for them. However, for the IPQ4018/IPQ4019, it only is used as a small subset of IP block configuration. As for what it actually gets used as for other Qualcomm chipsets? Well, that'll have to wait. It's a bit of a mess in linux and openwrt. See, every different SoC support branch ends up with some different TCSR code for it. So instead, I'm going to land a single TCSR driver that I'm going to use for the IPQ4018/IPQ4019. When I add the next chipset, I'll figure out how to organise things so there's a single TCSR driver that works for multiple platforms. --- sys/arm/conf/std.qca | 3 + sys/arm/qualcomm/std.ipq4018 | 2 + sys/dev/qcom_tcsr/qcom_tcsr.c | 240 ++ sys/dev/qcom_tcsr/qcom_tcsr_reg.h | 44 +++ sys/dev/qcom_tcsr/qcom_tcsr_var.h | 46 5 files changed, 335 insertions(+) diff --git a/sys/arm/conf/std.qca b/sys/arm/conf/std.qca index 7caae2f645ca..bb884531508b 100644 --- a/sys/arm/conf/std.qca +++ b/sys/arm/conf/std.qca @@ -54,6 +54,9 @@ devicegpio device qcom_tlmm_ipq4018 device fdt_pinctrl +# TCSR (core top control and status registers) +device qcom_tcsr + optionsFDT # Disable CP14 work in DDB as TZ won't let us by default diff --git a/sys/arm/qualcomm/std.ipq4018 b/sys/arm/qualcomm/std.ipq4018 index 2187e3f17516..d4bb26fe8167 100644 --- a/sys/arm/qualcomm/std.ipq4018 +++ b/sys/arm/qualcomm/std.ipq4018 @@ -25,3 +25,5 @@ dev/qcom_tlmm/qcom_tlmm_ipq4018.c optional qcom_tlmm_ipq4018 dev/qcom_tlmm/qcom_tlmm_ipq4018_hw.c optional qcom_tlmm_ipq4018 dev/qcom_tlmm/qcom_tlmm_pin.c optional qcom_tlmm_ipq4018 dev/qcom_tlmm/qcom_tlmm_pinmux.c optional qcom_tlmm_ipq4018 + +dev/qcom_tcsr/qcom_tcsr.c optional qcom_tcsr diff --git a/sys/dev/qcom_tcsr/qcom_tcsr.c b/sys/dev/qcom_tcsr/qcom_tcsr.c new file mode 100644 index ..35d7c4436b1c --- /dev/null +++ b/sys/dev/qcom_tcsr/qcom_tcsr.c @@ -0,0 +1,240 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021, Adrian Chadd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice unmodified, this list of conditions, and the following + *disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include + +/* + * The linux-msm branches that support IPQ4018 use "ipq,tcsr". + * The openwrt addons use qcom,tcsr. So for now support both. + * + * Also, it's not quite clear yet (since this is the first port!) + * whether these options and registers are specific to the QCA IPQ401x + * part or show up in different linux branches as different registers + * but with the same driver/naming here. Let's hope that doesn't + * happen. + */ +static st
git: 777963afb5a0 - main - qcom_dwc3: add initial Qualcomm SoC DWC3 controller glue
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=777963afb5a0dba75cdd7117d3070d9486b2ee96 commit 777963afb5a0dba75cdd7117d3070d9486b2ee96 Author: Adrian Chadd AuthorDate: 2021-12-28 02:25:32 + Commit: Adrian Chadd CommitDate: 2021-12-28 02:25:32 + qcom_dwc3: add initial Qualcomm SoC DWC3 controller glue This adds some very simple DWC3 glue for the IPQ4018/IPQ4019. Other chipsets introduce reset line iteration, some further clock line iteration and some customisations; I'll look at adding those later. This is enough to finally bring up USB 3.0 on my IPQ4018 ASUS RT-58U router. --- sys/arm/conf/std.qca | 7 ++ sys/arm/qualcomm/std.ipq4018 | 2 + sys/dev/qcom_dwc3/qcom_dwc3.c | 180 ++ 3 files changed, 189 insertions(+) diff --git a/sys/arm/conf/std.qca b/sys/arm/conf/std.qca index c835b3c94616..5cc6ac8ff9aa 100644 --- a/sys/arm/conf/std.qca +++ b/sys/arm/conf/std.qca @@ -65,3 +65,10 @@ options ARM_FORCE_DBG_MONITOR_DISABLE # USB PHY support device qcom_ipq4018_hs_usbphy device qcom_ipq4018_ss_usbphy + +# USB support +device usb +device xhci +device dwc3 +device qcom_dwc3 +optionsUSB_HOST_ALIGN=64 diff --git a/sys/arm/qualcomm/std.ipq4018 b/sys/arm/qualcomm/std.ipq4018 index ed771179b3a0..d567b041078c 100644 --- a/sys/arm/qualcomm/std.ipq4018 +++ b/sys/arm/qualcomm/std.ipq4018 @@ -6,6 +6,8 @@ arm/qualcomm/qcom_cpu_kpssv2.c optional smp arm/qualcomm/ipq4018_usb_hs_phy.c optional qcom_ipq4018_hs_usbphy arm/qualcomm/ipq4018_usb_ss_phy.c optional qcom_ipq4018_ss_usbphy +dev/qcom_dwc3/qcom_dwc3.c optional qcom_dwc3 + dev/qcom_rnd/qcom_rnd.coptional qcom_rnd dev/qcom_qup/qcom_spi.coptional qcom_qup_spi diff --git a/sys/dev/qcom_dwc3/qcom_dwc3.c b/sys/dev/qcom_dwc3/qcom_dwc3.c new file mode 100644 index ..b027bc609453 --- /dev/null +++ b/sys/dev/qcom_dwc3/qcom_dwc3.c @@ -0,0 +1,180 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Adrian Chadd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Qualcomm DWC3 glue + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +static struct ofw_compat_data compat_data[] = { + { "qcom,dwc3", 1}, + { NULL, 0 } +}; + +struct qcom_dwc3_softc { + struct simplebus_softc sc; + device_tdev; + clk_t clk_master; + clk_t clk_sleep; + clk_t clk_mock_utmi; + int type; +}; + +static int +qcom_dwc3_probe(device_t dev) +{ + phandle_t node; + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + + /* Binding says that we need a child node for the actual dwc3 controller */ + node = ofw_bus_get_node(dev); + if (OF_child(node) <= 0) + return (ENXIO); + + device_set_desc(dev, "Qualcomm DWC3"); + return (BUS_PROBE_DEFAULT); +} + +static int +qcom_dwc3_attach(device_t dev) +{ + struct qcom_dwc3_softc *sc; + device_t cdev; + phandle_t node, child; +
git: 86f0c3ec13aa - main - ipq4018_usb_phy: add USB 2.0 and 3.0 PHY support
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=86f0c3ec13aa6d583a586f343329d15faf22bd75 commit 86f0c3ec13aa6d583a586f343329d15faf22bd75 Author: Adrian Chadd AuthorDate: 2021-12-28 02:21:36 + Commit: Adrian Chadd CommitDate: 2021-12-28 02:21:36 + ipq4018_usb_phy: add USB 2.0 and 3.0 PHY support This adds the USB 2.0 and 3.0 PHY support for the IPQ4018/IPQ4019. All it really needs to do is gate the relevant clocks on/off in the right order with the right delays. --- sys/arm/conf/std.qca | 4 + sys/arm/qualcomm/ipq4018_usb_hs_phy.c | 236 ++ sys/arm/qualcomm/ipq4018_usb_ss_phy.c | 218 +++ sys/arm/qualcomm/std.ipq4018 | 3 + 4 files changed, 461 insertions(+) diff --git a/sys/arm/conf/std.qca b/sys/arm/conf/std.qca index bb884531508b..c835b3c94616 100644 --- a/sys/arm/conf/std.qca +++ b/sys/arm/conf/std.qca @@ -61,3 +61,7 @@ options FDT # Disable CP14 work in DDB as TZ won't let us by default optionsARM_FORCE_DBG_MONITOR_DISABLE + +# USB PHY support +device qcom_ipq4018_hs_usbphy +device qcom_ipq4018_ss_usbphy diff --git a/sys/arm/qualcomm/ipq4018_usb_hs_phy.c b/sys/arm/qualcomm/ipq4018_usb_hs_phy.c new file mode 100644 index ..8e03d2f27e6f --- /dev/null +++ b/sys/arm/qualcomm/ipq4018_usb_hs_phy.c @@ -0,0 +1,236 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 Michal Meloun + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include "phynode_if.h" +#include "phynode_usb_if.h" + +static struct ofw_compat_data compat_data[] = { + {"qcom,usb-hs-ipq4019-phy", 1}, + {NULL, 0}, +}; + +struct ipq4018_usb_hs_phy_softc { + device_tdev; +}; + +struct ipq4018_usb_hs_phynode_sc { + struct phynode_usb_sc usb_sc; + int mode; + hwreset_t por_rst; + hwreset_t srif_rst; +}; + +static int +ipq4018_usb_hs_phynode_phy_enable(struct phynode *phynode, bool enable) +{ + struct ipq4018_usb_hs_phynode_sc *sc; + device_t dev; + int rv; + + dev = phynode_get_device(phynode); + sc = phynode_get_softc(phynode); + + /* +* +* For power-off - assert por, sleep for 10ms, assert srif, +* sleep for 10ms +*/ + rv = hwreset_assert(sc->por_rst); + if (rv != 0) + goto done; + DELAY(10*1000); + rv = hwreset_assert(sc->srif_rst); + if (rv != 0) + goto done; + DELAY(10*1000); + + /* +* For power-on - power off first, then deassert srif, then +* sleep for 10ms, then deassert por. +*/ + if (enable) { + rv = hwreset_deassert(sc->srif_rst); + if (rv != 0) + goto done; + DELAY(10*1000); + rv = hwreset_deassert(sc->por_rst); + if (rv != 0) + goto done; + DELAY(10*1000); + } + +done: + if (rv != 0) { + device_printf(dev, "%s: failed, rv=%d\n", __func__, rv); + } + return (rv); +} + + /* Phy controller class and methods. */ +static phynode_method_t ipq4018_usb_hs_phynode_methods[] = { +
git: c7f93ee5cc29 - main - ipq4018_usb_phy: remove old debugging routine
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=c7f93ee5cc29fdf3ccecb11921f419919616d1d9 commit c7f93ee5cc29fdf3ccecb11921f419919616d1d9 Author: Adrian Chadd AuthorDate: 2021-12-28 02:33:06 + Commit: Adrian Chadd CommitDate: 2021-12-28 02:33:06 + ipq4018_usb_phy: remove old debugging routine This isn't needed anymore, I know that these work! --- sys/arm/qualcomm/ipq4018_usb_ss_phy.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/arm/qualcomm/ipq4018_usb_ss_phy.c b/sys/arm/qualcomm/ipq4018_usb_ss_phy.c index 4751213e8cab..3fe6d8115975 100644 --- a/sys/arm/qualcomm/ipq4018_usb_ss_phy.c +++ b/sys/arm/qualcomm/ipq4018_usb_ss_phy.c @@ -74,8 +74,6 @@ ipq4018_usb_ss_phynode_phy_enable(struct phynode *phynode, bool enable) dev = phynode_get_device(phynode); sc = phynode_get_softc(phynode); - device_printf(dev, "%s: called, enable=%d\n", __func__, enable); - /* * For power-off - assert por, sleep for 10ms */
git: 2e9d05fd6848 - main - asmc: Add support for 10 byte light sensor payloads; MacBookAir6,1
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=2e9d05fd684803dbba7dd52eb64856c639e4fde2 commit 2e9d05fd684803dbba7dd52eb64856c639e4fde2 Author: Adrian Chadd AuthorDate: 2023-02-08 04:06:16 + Commit: Adrian Chadd CommitDate: 2023-02-08 04:06:16 + asmc: Add support for 10 byte light sensor payloads; MacBookAir6,1 The later macbook models use a different packet payload for the light sensors: * There's only one, done in the camera * It's a 4 byte sensor value, not a 2 byte value * It's in a 10 byte payload. So, this adds support for that and flips it on for the MacbookAir6,2. It also adds support for MacBookAir6,1 as that now works fine here. Tested - MacBookAir6,1 and 6,2 Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D38365 --- sys/dev/asmc/asmc.c | 46 +- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c index 337f641e4513..442463b9f47a 100644 --- a/sys/dev/asmc/asmc.c +++ b/sys/dev/asmc/asmc.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -106,6 +107,7 @@ static int asmc_mb_sysctl_sms_z(SYSCTL_HANDLER_ARGS); static int asmc_mbp_sysctl_light_left(SYSCTL_HANDLER_ARGS); static int asmc_mbp_sysctl_light_right(SYSCTL_HANDLER_ARGS); static int asmc_mbp_sysctl_light_control(SYSCTL_HANDLER_ARGS); +static int asmc_mbp_sysctl_light_left_10byte(SYSCTL_HANDLER_ARGS); struct asmc_model { const char *smc_model;/* smbios.system.product env var. */ @@ -151,6 +153,11 @@ static const struct asmc_model *asmc_match(device_t dev); asmc_mbp_sysctl_light_right, \ asmc_mbp_sysctl_light_control +#define ASMC_LIGHT_FUNCS_10BYTE \ +asmc_mbp_sysctl_light_left_10byte, \ +NULL, \ +asmc_mbp_sysctl_light_control + #define ASMC_LIGHT_FUNCS_DISABLED NULL, NULL, NULL static const struct asmc_model asmc_models[] = { @@ -427,11 +434,18 @@ static const struct asmc_model asmc_models[] = { ASMC_LIGHT_FUNCS, ASMC_MBA5_TEMPS, ASMC_MBA5_TEMPNAMES, ASMC_MBA5_TEMPDESCS }, + { + "MacBookAir6,1", "Apple SMC MacBook Air 11-inch (Early 2013)", + ASMC_SMS_FUNCS_DISABLED, + ASMC_FAN_FUNCS2, + ASMC_LIGHT_FUNCS_10BYTE, + ASMC_MBA6_TEMPS, ASMC_MBA6_TEMPNAMES, ASMC_MBA6_TEMPDESCS + }, { "MacBookAir6,2", "Apple SMC MacBook Air 13-inch (Early 2013)", ASMC_SMS_FUNCS_DISABLED, ASMC_FAN_FUNCS2, - ASMC_LIGHT_FUNCS, + ASMC_LIGHT_FUNCS_10BYTE, ASMC_MBA6_TEMPS, ASMC_MBA6_TEMPNAMES, ASMC_MBA6_TEMPDESCS }, { @@ -1540,3 +1554,33 @@ asmc_mbp_sysctl_light_control(SYSCTL_HANDLER_ARGS) } return (error); } + +static int +asmc_mbp_sysctl_light_left_10byte(SYSCTL_HANDLER_ARGS) +{ + device_t dev = (device_t) arg1; + uint8_t buf[10]; + int error; + uint32_t v; + + asmc_key_read(dev, ASMC_KEY_LIGHTLEFT, buf, sizeof buf); + + /* +* This seems to be a 32 bit big endian value from buf[6] -> buf[9]. +* +* Extract it out manually here, then shift/clamp it. +*/ + v = be32dec(&buf[6]); + + /* +* Shift out, clamp at 255; that way it looks like the +* earlier SMC firmware version responses. +*/ + v = v >> 8; + if (v > 255) + v = 255; + + error = sysctl_handle_int(oidp, &v, 0, req); + + return (error); +}
git: 2889cbe29e30 - main - net80211: add an IEEE80211_IS_PROTECTED() macro
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=2889cbe29e30cc03412e4727b4ad753950094c32 commit 2889cbe29e30cc03412e4727b4ad753950094c32 Author: Adrian Chadd AuthorDate: 2022-08-12 20:56:00 + Commit: Adrian Chadd CommitDate: 2022-08-14 16:48:06 + net80211: add an IEEE80211_IS_PROTECTED() macro Summary: This returns whether the given 802.11 frame has the protected bit set. Test Plan: * tested in AP/STA mode * STA mode - local athp/ath10k driver * AP mode - in tree ath driver Subscribers: imp, melifaro, glebius Reviewed by: bz Approved by: bz Differential Revision: https://reviews.freebsd.org/D36183 --- sys/net80211/ieee80211.h| 3 +++ sys/net80211/ieee80211_adhoc.c | 4 ++-- sys/net80211/ieee80211_hostap.c | 4 ++-- sys/net80211/ieee80211_mesh.c | 2 +- sys/net80211/ieee80211_output.c | 2 +- sys/net80211/ieee80211_proto.c | 2 +- sys/net80211/ieee80211_sta.c| 4 ++-- sys/net80211/ieee80211_wds.c| 4 ++-- 8 files changed, 14 insertions(+), 11 deletions(-) diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h index 715bb3da898e..1125810ee6ac 100644 --- a/sys/net80211/ieee80211.h +++ b/sys/net80211/ieee80211.h @@ -196,6 +196,9 @@ struct ieee80211_qosframe_addr4 { #defineIEEE80211_FC1_PROTECTED 0x40 #defineIEEE80211_FC1_ORDER 0x80 +#defineIEEE80211_IS_PROTECTED(wh) \ + ((wh)->i_fc[1] & IEEE80211_FC1_PROTECTED) + #define IEEE80211_HAS_SEQ(type, subtype) \ ((type) != IEEE80211_FC0_TYPE_CTL && \ !((type) == IEEE80211_FC0_TYPE_DATA && \ diff --git a/sys/net80211/ieee80211_adhoc.c b/sys/net80211/ieee80211_adhoc.c index 57e46dd5ad0b..6aa66db59cac 100644 --- a/sys/net80211/ieee80211_adhoc.c +++ b/sys/net80211/ieee80211_adhoc.c @@ -495,7 +495,7 @@ adhoc_input(struct ieee80211_node *ni, struct mbuf *m, * crypto cipher modules used to do delayed update * of replay sequence numbers. */ - if (is_hw_decrypted || wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + if (is_hw_decrypted || IEEE80211_IS_PROTECTED(wh)) { if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) { /* * Discard encrypted frames when privacy is off. @@ -655,7 +655,7 @@ adhoc_input(struct ieee80211_node *ni, struct mbuf *m, ether_sprintf(wh->i_addr2), rssi); } #endif - if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + if (IEEE80211_IS_PROTECTED(wh)) { IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT, wh, NULL, "%s", "WEP set but not permitted"); vap->iv_stats.is_rx_mgtdiscard++; /* XXX */ diff --git a/sys/net80211/ieee80211_hostap.c b/sys/net80211/ieee80211_hostap.c index f3a85848fc84..17c1de6c2894 100644 --- a/sys/net80211/ieee80211_hostap.c +++ b/sys/net80211/ieee80211_hostap.c @@ -683,7 +683,7 @@ hostap_input(struct ieee80211_node *ni, struct mbuf *m, * crypto cipher modules used to do delayed update * of replay sequence numbers. */ - if (is_hw_decrypted || wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + if (is_hw_decrypted || IEEE80211_IS_PROTECTED(wh)) { if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) { /* * Discard encrypted frames when privacy is off. @@ -849,7 +849,7 @@ hostap_input(struct ieee80211_node *ni, struct mbuf *m, ether_sprintf(wh->i_addr2), rssi); } #endif - if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + if (IEEE80211_IS_PROTECTED(wh)) { if (subtype != IEEE80211_FC0_SUBTYPE_AUTH) { /* * Only shared key auth frames with a challenge diff --git a/sys/net80211/ieee80211_mesh.c b/sys/net80211/ieee80211_mesh.c index 8dcbfa918e3b..6d1f5a99fda5 100644 --- a/sys/net80211/ieee80211_mesh.c +++ b/sys/net80211/ieee80211_mesh.c @@ -1797,7 +1797,7 @@ mesh_input(struct ieee80211_node *ni, struct mbuf *m, ether_sprintf(wh->i_addr2), rssi); } #endif - if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + if (IEEE80211_IS_PROTECTED(wh)) { IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT, wh, NULL, "%s", "WEP set but not permitted"); vap->iv_stats.is_rx_mgtdiscard++; /* XXX */ diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee802
git: 7d0e83c60bed - main - arm: add dwc3/xhci as build options for ARM
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=7d0e83c60bedf601e61d80187cdfa785fa4b1963 commit 7d0e83c60bedf601e61d80187cdfa785fa4b1963 Author: Adrian Chadd AuthorDate: 2022-09-11 23:57:52 + Commit: Adrian Chadd CommitDate: 2022-09-12 02:36:42 + arm: add dwc3/xhci as build options for ARM Summary: This mirrors the recentish changes to armv8; the ipq4018 port uses dwc3 + xhci and thus needs this. Subscribers: imp, andrew Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D36530 --- sys/conf/files.arm | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/conf/files.arm b/sys/conf/files.arm index 85afa4893d3c..c7e8a52a813d 100644 --- a/sys/conf/files.arm +++ b/sys/conf/files.arm @@ -99,7 +99,10 @@ dev/psci/psci.c optionalpsci dev/psci/smccc_arm.S optionalpsci dev/syscons/scgfbrndr.coptionalsc dev/uart/uart_cpu_fdt.coptionaluart fdt -dev/usb/controller/dwc3.c optionalfdt dwc3 + +dev/usb/controller/dwc3.c optionalfdt dwc3 +dev/usb/controller/generic_xhci.c optionalxhci +dev/usb/controller/generic_xhci_fdt.c optionalxhci fdt kern/msi_if.m optionalintrng kern/pic_if.m optionalintrng
git: f05b3c9f4741 - main - qcom_gcc: fix the parent clock to work again
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=f05b3c9f47411526bb7530210931fac0054075d4 commit f05b3c9f47411526bb7530210931fac0054075d4 Author: Adrian Chadd AuthorDate: 2022-09-12 02:31:23 + Commit: Adrian Chadd CommitDate: 2022-09-13 03:10:24 + qcom_gcc: fix the parent clock to work again Rename it to match the clock-output-names field in the device tree. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D36531 --- sys/dev/qcom_gcc/qcom_gcc_ipq4018_clock.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/dev/qcom_gcc/qcom_gcc_ipq4018_clock.c b/sys/dev/qcom_gcc/qcom_gcc_ipq4018_clock.c index 9f3261b3db8c..f25ad53d2c8c 100644 --- a/sys/dev/qcom_gcc/qcom_gcc_ipq4018_clock.c +++ b/sys/dev/qcom_gcc/qcom_gcc_ipq4018_clock.c @@ -581,7 +581,7 @@ static struct qcom_clk_branch2_def branch2_tbl[] = { 0x1e00c, 0, 0, 0, 0x1e00c, QCOM_CLK_BRANCH2_BRANCH_HALT, false, 0), F_BRANCH2(GCC_USB2_SLEEP_CLK, "gcc_usb2_sleep_clk", - "sleep_clk", 0x1e010, 0, 0, 0, 0x1e010, + "gcc_sleep_clk_src", 0x1e010, 0, 0, 0, 0x1e010, QCOM_CLK_BRANCH2_BRANCH_HALT, false, 0), F_BRANCH2(GCC_USB2_MOCK_UTMI_CLK, "gcc_usb2_mock_utmi_clk", @@ -591,7 +591,7 @@ static struct qcom_clk_branch2_def branch2_tbl[] = { F_BRANCH2(GCC_USB3_MASTER_CLK, "gcc_usb3_master_clk", "fepll125", 0x1e028, 0, 0, 0, 0x1e028, QCOM_CLK_BRANCH2_BRANCH_HALT, false, 0), - F_BRANCH2(GCC_USB3_SLEEP_CLK, "gcc_usb3_sleep_clk", "sleep_clk", + F_BRANCH2(GCC_USB3_SLEEP_CLK, "gcc_usb3_sleep_clk", "gcc_sleep_clk_src", 0x1e02c, 0, 0, 0, 0x1e02c, QCOM_CLK_BRANCH2_BRANCH_HALT, false, 0), F_BRANCH2(GCC_USB3_MOCK_UTMI_CLK, "gcc_usb3_mock_utmi_clk", @@ -605,7 +605,7 @@ static struct qcom_clk_branch2_def branch2_tbl[] = { F_BRANCH2(GCC_WCSS2G_REF_CLK, "gcc_wcss2g_ref_clk", "xo", 0x1f00c, 0, 0, 0, 0x1f00c, QCOM_CLK_BRANCH2_BRANCH_HALT, false, QCOM_CLK_BRANCH2_FLAGS_SET_RATE_PARENT), - F_BRANCH2(GCC_WCSS2G_RTC_CLK, "gcc_wcss2g_rtc_clk", "sleep_clk", + F_BRANCH2(GCC_WCSS2G_RTC_CLK, "gcc_wcss2g_rtc_clk", "gcc_sleep_clk_src", 0x1f010, 0, 0, 0, 0x1f010, QCOM_CLK_BRANCH2_BRANCH_HALT, false, 0), @@ -616,7 +616,7 @@ static struct qcom_clk_branch2_def branch2_tbl[] = { F_BRANCH2(GCC_WCSS5G_REF_CLK, "gcc_wcss5g_ref_clk", "xo", 0x1f00c, 0, 0, 0, 0x2000c, QCOM_CLK_BRANCH2_BRANCH_HALT, false, QCOM_CLK_BRANCH2_FLAGS_SET_RATE_PARENT), - F_BRANCH2(GCC_WCSS5G_RTC_CLK, "gcc_wcss5g_rtc_clk", "sleep_clk", + F_BRANCH2(GCC_WCSS5G_RTC_CLK, "gcc_wcss5g_rtc_clk", "gcc_sleep_clk_src", 0x1f010, 0, 0, 0, 0x20010, QCOM_CLK_BRANCH2_BRANCH_HALT, false, 0),
git: f060362adeb4 - main - ipq4018: remove write-only variables in USB ehci/xhci bus glue
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=f060362adeb422e1a70c2ff377ddcba9a244e527 commit f060362adeb422e1a70c2ff377ddcba9a244e527 Author: Adrian Chadd AuthorDate: 2022-09-12 02:32:29 + Commit: Adrian Chadd CommitDate: 2022-09-13 03:10:24 + ipq4018: remove write-only variables in USB ehci/xhci bus glue Changes in compilers / warnings/errors caused this to stop compiling. Delete the write-only code. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D36532 --- sys/arm/qualcomm/ipq4018_usb_hs_phy.c | 2 -- sys/arm/qualcomm/ipq4018_usb_ss_phy.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/sys/arm/qualcomm/ipq4018_usb_hs_phy.c b/sys/arm/qualcomm/ipq4018_usb_hs_phy.c index 4d3d0d70a9a3..611db46e678d 100644 --- a/sys/arm/qualcomm/ipq4018_usb_hs_phy.c +++ b/sys/arm/qualcomm/ipq4018_usb_hs_phy.c @@ -212,8 +212,6 @@ fail: static int ipq4018_usb_hs_usbphy_detach(device_t dev) { - struct ipq4018_usb_hs_phy_softc *sc; - sc = device_get_softc(dev); return (0); } diff --git a/sys/arm/qualcomm/ipq4018_usb_ss_phy.c b/sys/arm/qualcomm/ipq4018_usb_ss_phy.c index ad7ff8a5ff44..2b55d5c44500 100644 --- a/sys/arm/qualcomm/ipq4018_usb_ss_phy.c +++ b/sys/arm/qualcomm/ipq4018_usb_ss_phy.c @@ -192,8 +192,6 @@ fail: static int ipq4018_usb_ss_usbphy_detach(device_t dev) { - struct ipq4018_usb_ss_phy_softc *sc; - sc = device_get_softc(dev); return (0); }
git: 3d9bd8252205 - main - qcom_clk: compilation fixes
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=3d9bd8252205c5e4b02a68cf5345bcdc3cbb5239 commit 3d9bd8252205c5e4b02a68cf5345bcdc3cbb5239 Author: Adrian Chadd AuthorDate: 2022-09-12 02:33:18 + Commit: Adrian Chadd CommitDate: 2022-09-13 03:10:25 + qcom_clk: compilation fixes * remove dead code * mark enabled as unused, happens if debugging isn't enabled * log the enabled state if debugging is enabled Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D36533 --- sys/dev/qcom_clk/qcom_clk_apssdiv.c | 3 --- sys/dev/qcom_clk/qcom_clk_rcg2.c| 8 +--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/sys/dev/qcom_clk/qcom_clk_apssdiv.c b/sys/dev/qcom_clk/qcom_clk_apssdiv.c index 75216ba60172..d76c5953f278 100644 --- a/sys/dev/qcom_clk/qcom_clk_apssdiv.c +++ b/sys/dev/qcom_clk/qcom_clk_apssdiv.c @@ -131,9 +131,6 @@ qcom_clk_apssdiv_get_gate_locked(struct qcom_clk_apssdiv_sc *sc) static int qcom_clk_apssdiv_init(struct clknode *clk, device_t dev) { - struct qcom_clk_apssdiv_sc *sc; - - sc = clknode_get_softc(clk); /* * There's only a single parent here for an fixed divisor, diff --git a/sys/dev/qcom_clk/qcom_clk_rcg2.c b/sys/dev/qcom_clk/qcom_clk_rcg2.c index 6257f79259fe..b6ae03e02ced 100644 --- a/sys/dev/qcom_clk/qcom_clk_rcg2.c +++ b/sys/dev/qcom_clk/qcom_clk_rcg2.c @@ -265,7 +265,7 @@ qcom_clk_rcg2_init(struct clknode *clk, device_t dev) struct qcom_clk_rcg2_sc *sc; uint32_t reg; uint32_t idx; - bool enabled; + bool enabled __unused; sc = clknode_get_softc(clk); @@ -282,6 +282,7 @@ qcom_clk_rcg2_init(struct clknode *clk, device_t dev) enabled = false; else enabled = true; + /* mux settings */ CLKDEV_READ_4(clknode_get_device(sc->clknode), QCOM_CLK_RCG2_CFG_OFFSET(sc), ®); @@ -289,8 +290,9 @@ qcom_clk_rcg2_init(struct clknode *clk, device_t dev) idx = (reg & QCOM_CLK_RCG2_CFG_SRC_SEL_MASK) >> QCOM_CLK_RCG2_CFG_SRC_SEL_SHIFT; - DPRINTF(clknode_get_device(sc->clknode), "%s: mux index %u\n", - __func__, idx); + DPRINTF(clknode_get_device(sc->clknode), + "%s: mux index %u, enabled=%d\n", + __func__, idx, enabled); clknode_init_parent_idx(clk, idx); /*
git: 82302a49fde3 - main - qcom_tlmm: use return code instead of always returning true.
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=82302a49fde3ff063e4f8187fc3ddf355084f786 commit 82302a49fde3ff063e4f8187fc3ddf355084f786 Author: Adrian Chadd AuthorDate: 2022-09-12 02:33:48 + Commit: Adrian Chadd CommitDate: 2022-09-13 03:10:25 + qcom_tlmm: use return code instead of always returning true. This was failing due to unused/ignored return values; so just use them. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D36534 --- sys/dev/qcom_tlmm/qcom_tlmm_pin.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/qcom_tlmm/qcom_tlmm_pin.c b/sys/dev/qcom_tlmm/qcom_tlmm_pin.c index 0d35908a58a6..6974041fe0d9 100644 --- a/sys/dev/qcom_tlmm/qcom_tlmm_pin.c +++ b/sys/dev/qcom_tlmm/qcom_tlmm_pin.c @@ -257,7 +257,7 @@ qcom_tlmm_pin_set(device_t dev, uint32_t pin, unsigned int value) ret = qcom_tlmm_ipq4018_hw_pin_set_output_value(sc, pin, value); GPIO_UNLOCK(sc); - return (0); + return (ret); } int @@ -273,7 +273,7 @@ qcom_tlmm_pin_get(device_t dev, uint32_t pin, unsigned int *val) ret = qcom_tlmm_ipq4018_hw_pin_get_input_value(sc, pin, val); GPIO_UNLOCK(sc); - return (0); + return (ret); } int @@ -289,7 +289,7 @@ qcom_tlmm_pin_toggle(device_t dev, uint32_t pin) ret = qcom_tlmm_ipq4018_hw_pin_toggle_output_value(sc, pin); GPIO_UNLOCK(sc); - return (0); + return (ret); } int
git: 633d178c63be - main - qcom_qup: compilation fixes
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=633d178c63bef1110acde1932f97eb90da8881e8 commit 633d178c63bef1110acde1932f97eb90da8881e8 Author: Adrian Chadd AuthorDate: 2022-09-12 02:35:02 + Commit: Adrian Chadd CommitDate: 2022-09-13 03:10:25 + qcom_qup: compilation fixes Fix compilation warning/errors - in this instance we do need the register IO. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D36535 --- sys/dev/qcom_qup/qcom_spi_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/qcom_qup/qcom_spi_hw.c b/sys/dev/qcom_qup/qcom_spi_hw.c index 6b21fd239f5d..71cbcc671766 100644 --- a/sys/dev/qcom_qup/qcom_spi_hw.c +++ b/sys/dev/qcom_qup/qcom_spi_hw.c @@ -723,14 +723,14 @@ qcom_spi_hw_ack_write_pio_fifo(struct qcom_spi_softc *sc) int qcom_spi_hw_ack_opmode(struct qcom_spi_softc *sc) { - uint32_t reg; QCOM_SPI_ASSERT_LOCKED(sc); QCOM_SPI_BARRIER_READ(sc); - reg = QCOM_SPI_READ_4(sc, QUP_OPERATIONAL); + QCOM_SPI_READ_4(sc, QUP_OPERATIONAL); QCOM_SPI_WRITE_4(sc, QUP_OPERATIONAL, QUP_OP_OUT_SERVICE_FLAG); QCOM_SPI_BARRIER_WRITE(sc); + return (0); }
git: ffc58e2ca365 - main - asmc: Add MacbookAir6,2
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=ffc58e2ca36546d866bb6bd36a3aa8f762a01663 commit ffc58e2ca36546d866bb6bd36a3aa8f762a01663 Author: Adrian Chadd AuthorDate: 2023-01-21 04:34:31 + Commit: Adrian Chadd CommitDate: 2023-01-21 04:34:31 + asmc: Add MacbookAir6,2 Add in the zones for my MacbookAir6,2, a 2013 Macbook Air. Tested - said Macbook Air 2013. Thermal Zones and keyboard backlight control works fine. Differential Revision: https://reviews.freebsd.org/D38073 Approved by: jrtc27 --- sys/dev/asmc/asmc.c| 9 +++-- sys/dev/asmc/asmcvar.h | 25 + 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c index bec0054e2dd7..337f641e4513 100644 --- a/sys/dev/asmc/asmc.c +++ b/sys/dev/asmc/asmc.c @@ -427,7 +427,13 @@ static const struct asmc_model asmc_models[] = { ASMC_LIGHT_FUNCS, ASMC_MBA5_TEMPS, ASMC_MBA5_TEMPNAMES, ASMC_MBA5_TEMPDESCS }, - + { + "MacBookAir6,2", "Apple SMC MacBook Air 13-inch (Early 2013)", + ASMC_SMS_FUNCS_DISABLED, + ASMC_FAN_FUNCS2, + ASMC_LIGHT_FUNCS, + ASMC_MBA6_TEMPS, ASMC_MBA6_TEMPNAMES, ASMC_MBA6_TEMPDESCS + }, { "MacBookAir7,1", "Apple SMC MacBook Air 11-inch (Early 2015)", ASMC_SMS_FUNCS_DISABLED, @@ -435,7 +441,6 @@ static const struct asmc_model asmc_models[] = { ASMC_LIGHT_FUNCS, ASMC_MBA7_TEMPS, ASMC_MBA7_TEMPNAMES, ASMC_MBA7_TEMPDESCS }, - { "MacBookAir7,2", "Apple SMC MacBook Air 13-inch (Early 2015)", ASMC_SMS_FUNCS_DISABLED, diff --git a/sys/dev/asmc/asmcvar.h b/sys/dev/asmc/asmcvar.h index a594710f1cbe..9db544a1450d 100644 --- a/sys/dev/asmc/asmcvar.h +++ b/sys/dev/asmc/asmcvar.h @@ -773,6 +773,31 @@ struct asmc_softc { "Ta0P", "Heatpipe", "Mainboard Proximity 1", "Mainboard Proximity 2", \ "Palm Rest", "Memory Proximity" } +/* + * TODO: validate the temp zones for MBA 6.x ! + */ +#defineASMC_MBA6_TEMPS { "TB0T", "TB1T", "TB2T", \ + "TC0E", "TC0F", "TC0P", \ + "TC1C", "TC2C", "TCGC", "TCSA", \ + "TCXC", "THSP", "TM0P", "TPCD", \ + "Ta0P", "Th1H", "Tm0P", \ + "Ts0P", "Ts0S", NULL } + +#defineASMC_MBA6_TEMPNAMES { "enclosure1", "enclosure2", "enclosure3", \ + "cputemp1", "cputemp2", "cpuproximity", \ + "cpucore1", "cpucore2", "cpupeci", "pecisa", \ + "TCXC", "THSP", "memorybank", "pchdie", \ + "Ta0P", "heatpipe", "mainboardproximity1", \ + "palmrest", "memoryproximity" } + +#defineASMC_MBA6_TEMPDESCS { "Enclosure Bottom 1", "Enclosure Bottom 2", "Enclosure Bottom 3", \ + "CPU Temp 1", "CPU Temp 2", "CPU Proximity", \ + "CPU Core 1", "CPU Core 2", "CPU Peci Core", "PECI SA", \ + "TCXC", "THSP", "Memory Bank A", "PCH Die", \ + "Ta0P", "Heatpipe", "Mainboard Proximity 1", \ + "Palm Rest", "Memory Proximity" } + + #defineASMC_MBA7_TEMPS { "TB0T", "TB1T", "TB2T", \ "TC0E", "TC0F", "TC0P", \ "TC1C", "TC2C", \
Re: git: ffc58e2ca365 - main - asmc: Add MacbookAir6,2
yeah i meant markj, but i was sick and tired and somehow my brain crossed streams. sorry! -a On Fri, 20 Jan 2023 at 21:55, Jessica Clarke wrote: > On 21 Jan 2023, at 04:43, Adrian Chadd wrote: > > > > The branch main has been updated by adrian: > > > > URL: > https://cgit.FreeBSD.org/src/commit/?id=ffc58e2ca36546d866bb6bd36a3aa8f762a01663 > > > > commit ffc58e2ca36546d866bb6bd36a3aa8f762a01663 > > Author: Adrian Chadd > > AuthorDate: 2023-01-21 04:34:31 + > > Commit: Adrian Chadd > > CommitDate: 2023-01-21 04:34:31 + > > > >asmc: Add MacbookAir6,2 > > > >Add in the zones for my MacbookAir6,2, a 2013 Macbook Air. > > > >Tested - said Macbook Air 2013. Thermal Zones and keyboard backlight > >control works fine. > > > >Differential Revision: https://reviews.freebsd.org/D38073 > >Approved by: jrtc27 > > Uh this is the first I’m hearing of this patch? > > Jess > > > --- > > sys/dev/asmc/asmc.c| 9 +++-- > > sys/dev/asmc/asmcvar.h | 25 + > > 2 files changed, 32 insertions(+), 2 deletions(-) > > > > diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c > > index bec0054e2dd7..337f641e4513 100644 > > --- a/sys/dev/asmc/asmc.c > > +++ b/sys/dev/asmc/asmc.c > > @@ -427,7 +427,13 @@ static const struct asmc_model asmc_models[] = { > > ASMC_LIGHT_FUNCS, > > ASMC_MBA5_TEMPS, ASMC_MBA5_TEMPNAMES, ASMC_MBA5_TEMPDESCS > > }, > > - > > + { > > + "MacBookAir6,2", "Apple SMC MacBook Air 13-inch (Early 2013)", > > + ASMC_SMS_FUNCS_DISABLED, > > + ASMC_FAN_FUNCS2, > > + ASMC_LIGHT_FUNCS, > > + ASMC_MBA6_TEMPS, ASMC_MBA6_TEMPNAMES, ASMC_MBA6_TEMPDESCS > > + }, > > { > > "MacBookAir7,1", "Apple SMC MacBook Air 11-inch (Early 2015)", > > ASMC_SMS_FUNCS_DISABLED, > > @@ -435,7 +441,6 @@ static const struct asmc_model asmc_models[] = { > > ASMC_LIGHT_FUNCS, > > ASMC_MBA7_TEMPS, ASMC_MBA7_TEMPNAMES, ASMC_MBA7_TEMPDESCS > > }, > > - > > { > > "MacBookAir7,2", "Apple SMC MacBook Air 13-inch (Early 2015)", > > ASMC_SMS_FUNCS_DISABLED, > > diff --git a/sys/dev/asmc/asmcvar.h b/sys/dev/asmc/asmcvar.h > > index a594710f1cbe..9db544a1450d 100644 > > --- a/sys/dev/asmc/asmcvar.h > > +++ b/sys/dev/asmc/asmcvar.h > > @@ -773,6 +773,31 @@ struct asmc_softc { > > "Ta0P", "Heatpipe", "Mainboard Proximity > 1", "Mainboard Proximity 2", \ > > "Palm Rest", "Memory Proximity" } > > > > +/* > > + * TODO: validate the temp zones for MBA 6.x ! > > + */ > > +#define ASMC_MBA6_TEMPS { "TB0T", "TB1T", "TB2T", \ > > + "TC0E", "TC0F", "TC0P", \ > > + "TC1C", "TC2C", "TCGC", "TCSA", \ > > + "TCXC", "THSP", "TM0P", "TPCD", \ > > + "Ta0P", "Th1H", "Tm0P", \ > > + "Ts0P", "Ts0S", NULL } > > + > > +#define ASMC_MBA6_TEMPNAMES { "enclosure1", "enclosure2", > "enclosure3", \ > > + "cputemp1", "cputemp2", "cpuproximity", \ > > + "cpucore1", "cpucore2", "cpupeci", > "pecisa", \ > > + "TCXC", "THSP", "memorybank", "pchdie", \ > > + "Ta0P", "heatpipe", > "mainboardproximity1", \ > > + "palmrest", "memoryproximity" } > > + > > +#define ASMC_MBA6_TEMPDESCS { "Enclosure Bottom 1", "Enclosure > Bottom 2", "Enclosure Bottom 3", \ > > + "CPU Temp 1", "CPU Temp 2", "CPU > Proximity", \ > > + "CPU Core 1", "CPU Core 2", "CPU Peci > Core", "PECI SA", \ > > + "TCXC", "THSP", "Memory Bank A", "PCH > Die", \ > > + "Ta0P", "Heatpipe", "Mainboard Proximity > 1", \ > > + "Palm Rest", "Memory Proximity" } > > + > > + > > #define ASMC_MBA7_TEMPS { "TB0T", "TB1T", "TB2T", \ > > "TC0E", "TC0F", "TC0P", \ > > "TC1C", "TC2C", \ > >
git: 29332c0dcee1 - main - qcom_mdio: add initial IPQ4018 MDIO support
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=29332c0dcee1e80c9fb871e06c3160bd5deb1b44 commit 29332c0dcee1e80c9fb871e06c3160bd5deb1b44 Author: Adrian Chadd AuthorDate: 2022-01-30 02:27:58 + Commit: Adrian Chadd CommitDate: 2022-02-04 05:26:14 + qcom_mdio: add initial IPQ4018 MDIO support This adds support for the IPQ4018/IPQ4019 MDIO bus. This is used to talk to external PHYs and switches. (There's an internal switch in the IPQ4018/IPQ4019 as well, but it's accessible via MMIO/AXI.) Differential Revision: https://reviews.freebsd.org/D34110 Reviewed by: manu --- sys/arm/conf/std.qca | 6 + sys/arm/qualcomm/std.ipq4018 | 2 + sys/dev/qcom_mdio/qcom_mdio_debug.h | 40 sys/dev/qcom_mdio/qcom_mdio_ipq4018.c | 298 ++ sys/dev/qcom_mdio/qcom_mdio_ipq4018_reg.h | 44 + sys/dev/qcom_mdio/qcom_mdio_ipq4018_var.h | 68 +++ 6 files changed, 458 insertions(+) diff --git a/sys/arm/conf/std.qca b/sys/arm/conf/std.qca index 5cc6ac8ff9aa..e7cfe58c6d5d 100644 --- a/sys/arm/conf/std.qca +++ b/sys/arm/conf/std.qca @@ -72,3 +72,9 @@ devicexhci device dwc3 device qcom_dwc3 optionsUSB_HOST_ALIGN=64 + +# Ethernet support +device mdio +device mii +device miibus +device qcom_mdio_ipq4018 diff --git a/sys/arm/qualcomm/std.ipq4018 b/sys/arm/qualcomm/std.ipq4018 index d567b041078c..8e8108669ac8 100644 --- a/sys/arm/qualcomm/std.ipq4018 +++ b/sys/arm/qualcomm/std.ipq4018 @@ -32,3 +32,5 @@ dev/qcom_tlmm/qcom_tlmm_pin.c optional qcom_tlmm_ipq4018 dev/qcom_tlmm/qcom_tlmm_pinmux.c optional qcom_tlmm_ipq4018 dev/qcom_tcsr/qcom_tcsr.c optional qcom_tcsr + +dev/qcom_mdio/qcom_mdio_ipq4018.c optional qcom_mdio_ipq4018 diff --git a/sys/dev/qcom_mdio/qcom_mdio_debug.h b/sys/dev/qcom_mdio/qcom_mdio_debug.h new file mode 100644 index ..73a733f7af80 --- /dev/null +++ b/sys/dev/qcom_mdio/qcom_mdio_debug.h @@ -0,0 +1,40 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2022 Adrian Chadd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef__QCOM_MDIO_DEBUG_H__ +#define__QCOM_MDIO_DEBUG_H__ + +#defineQCOM_MDIO_DEBUG_REG_READ0x0001 +#defineQCOM_MDIO_DEBUG_REG_WRITE 0x0002 + +#defineQCOM_MDIO_DPRINTF(sc, flags, ...) \ + do {\ + if ((sc)->sc_debug & (flags)) \ + device_printf((sc)->sc_dev, __VA_ARGS__); \ + } while (0) + +#endif /* __QCOM_MDIO_DEBUG_H__ */ diff --git a/sys/dev/qcom_mdio/qcom_mdio_ipq4018.c b/sys/dev/qcom_mdio/qcom_mdio_ipq4018.c new file mode 100644 index ..031c454a27f6 --- /dev/null +++ b/sys/dev/qcom_mdio/qcom_mdio_ipq4018.c @@ -0,0 +1,298 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2022 Adrian Chadd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice unmodified, this list of conditions, and the following + *disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *
git: b509e538967b - main - dts: add IPQ4018/IPQ4019 ethernet MAC and ethernet switch definitions
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=b509e538967b0a5e825c8849ab33bdebd67ea6bc commit b509e538967b0a5e825c8849ab33bdebd67ea6bc Author: Adrian Chadd AuthorDate: 2022-01-30 19:15:42 + Commit: Adrian Chadd CommitDate: 2022-02-04 05:26:45 + dts: add IPQ4018/IPQ4019 ethernet MAC and ethernet switch definitions This adds the ethernet MAC and ethernet switch definitions. I've rewritten the header file and the DTS based on documentation and the required driver fields rather than the GPL'ed ones from openwrt. Differential Revision: https://reviews.freebsd.org/D34111 Reviewed by: manu --- sys/dts/arm/qcom-ipq4018-rt-ac58u.dts | 2 + sys/dts/arm/qcom-ipq4019-ethernet.dtsi | 238 + sys/dts/include/dt-bindings/net/qcom-qca807x.h | 81 + 3 files changed, 321 insertions(+) diff --git a/sys/dts/arm/qcom-ipq4018-rt-ac58u.dts b/sys/dts/arm/qcom-ipq4018-rt-ac58u.dts index 8a280c79e942..7db535b881dc 100644 --- a/sys/dts/arm/qcom-ipq4018-rt-ac58u.dts +++ b/sys/dts/arm/qcom-ipq4018-rt-ac58u.dts @@ -1,6 +1,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT #include "qcom-ipq4019.dtsi" +#include "qcom-ipq4019-ethernet.dtsi" + #include #include #include diff --git a/sys/dts/arm/qcom-ipq4019-ethernet.dtsi b/sys/dts/arm/qcom-ipq4019-ethernet.dtsi new file mode 100644 index ..930f8be34367 --- /dev/null +++ b/sys/dts/arm/qcom-ipq4019-ethernet.dtsi @@ -0,0 +1,238 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2022 Adrian Chadd . + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +/ { + soc { + mdio: mdio@9 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,ipq4019-mdio"; + reg = <0x9 0x64>; + status = "disabled"; + }; + + ess-switch@c00 { + compatible = "qcom,ess-switch"; + reg = <0xc00 0x8>; + resets = <&gcc ESS_RESET>; + reset-names = "ess_rst"; + clocks = <&gcc GCC_ESS_CLK>; + clock-names = "ess_clk"; + + /* +* The port bitmap describing which ports are CPU +* facing. It's almost always going to be port 0 +* (ie bit 0.) +*/ + switch_cpu_bmp = <0x1>; + + /* +* The port bitmap describing which ports are in +* the LAN group. This defaults to VLAN 1 in the +* switch driver. +*/ + switch_lan_bmp = <0x1e>; + + /* +* The port bitmap describing which ports are +* in the WAN group. This defaults to VLAN 2 +* in the switch driver. +*/ + switch_wan_bmp = <0x20>; + + /* +* Which interface to use to talk to an external +* PHY. In this instance we default to +* PORT_WRAPPER_PSGMII as we're defaulting to +* a PSGMII (well, Qualcomm SGMII) facing a 5
git: e388de98bd02 - main - ar40xx_switch: add initial switch for the IPQ4018/IPQ4019.
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=e388de98bd0272b4ba237dcd44dcf12360d70d41 commit e388de98bd0272b4ba237dcd44dcf12360d70d41 Author: Adrian Chadd AuthorDate: 2022-01-30 03:04:19 + Commit: Adrian Chadd CommitDate: 2022-02-04 05:27:13 + ar40xx_switch: add initial switch for the IPQ4018/IPQ4019. Summary: This switch is based off of the AR8327/AR8337 external switch/PHY. However unlike the AR8327/AR8337 it itself doesn't have any PHYs; instead an external PHY connects to it using the PSGMII port. Differential Revision: https://reviews.freebsd.org/D34112 Reviewed by: manu This code is inspired by the ar40xx code in openwrt, which itself is based on the Qualcomm QCA-SSDK. Both of these sources are, amusingly, BSD licenced - and thus I have included some of the comments in the hardware workaround paths to document some of the magic numbers. --- sys/arm/conf/std.qca | 2 + sys/arm/qualcomm/std.ipq4018 | 21 + sys/dev/etherswitch/ar40xx/ar40xx_debug.h | 44 ++ sys/dev/etherswitch/ar40xx/ar40xx_hw.c| 357 ++ sys/dev/etherswitch/ar40xx/ar40xx_hw.h| 42 ++ sys/dev/etherswitch/ar40xx/ar40xx_hw_atu.c| 216 ++ sys/dev/etherswitch/ar40xx/ar40xx_hw_atu.h| 37 + sys/dev/etherswitch/ar40xx/ar40xx_hw_mdio.c | 129 sys/dev/etherswitch/ar40xx/ar40xx_hw_mdio.h | 40 ++ sys/dev/etherswitch/ar40xx/ar40xx_hw_mib.c| 194 ++ sys/dev/etherswitch/ar40xx/ar40xx_hw_mib.h| 36 + sys/dev/etherswitch/ar40xx/ar40xx_hw_mirror.c | 132 sys/dev/etherswitch/ar40xx/ar40xx_hw_mirror.h | 33 + sys/dev/etherswitch/ar40xx/ar40xx_hw_port.c | 287 sys/dev/etherswitch/ar40xx/ar40xx_hw_port.h | 42 ++ sys/dev/etherswitch/ar40xx/ar40xx_hw_psgmii.c | 437 sys/dev/etherswitch/ar40xx/ar40xx_hw_psgmii.h | 41 ++ sys/dev/etherswitch/ar40xx/ar40xx_hw_vtu.c| 196 ++ sys/dev/etherswitch/ar40xx/ar40xx_hw_vtu.h| 39 ++ sys/dev/etherswitch/ar40xx/ar40xx_main.c | 968 ++ sys/dev/etherswitch/ar40xx/ar40xx_phy.c | 252 +++ sys/dev/etherswitch/ar40xx/ar40xx_phy.h | 39 ++ sys/dev/etherswitch/ar40xx/ar40xx_reg.h | 348 + sys/dev/etherswitch/ar40xx/ar40xx_var.h | 135 24 files changed, 4067 insertions(+) diff --git a/sys/arm/conf/std.qca b/sys/arm/conf/std.qca index e7cfe58c6d5d..b7bd2729a0dc 100644 --- a/sys/arm/conf/std.qca +++ b/sys/arm/conf/std.qca @@ -78,3 +78,5 @@ devicemdio device mii device miibus device qcom_mdio_ipq4018 +device etherswitch +device ar40xx_switch diff --git a/sys/arm/qualcomm/std.ipq4018 b/sys/arm/qualcomm/std.ipq4018 index 8e8108669ac8..e6719efb9bce 100644 --- a/sys/arm/qualcomm/std.ipq4018 +++ b/sys/arm/qualcomm/std.ipq4018 @@ -6,6 +6,27 @@ arm/qualcomm/qcom_cpu_kpssv2.c optional smp arm/qualcomm/ipq4018_usb_hs_phy.c optional qcom_ipq4018_hs_usbphy arm/qualcomm/ipq4018_usb_ss_phy.c optional qcom_ipq4018_ss_usbphy +dev/etherswitch/ar40xx/ar40xx_main.c \ + optional mdio etherswitch ar40xx_switch +dev/etherswitch/ar40xx/ar40xx_phy.c\ + optional mdio etherswitch ar40xx_switch +dev/etherswitch/ar40xx/ar40xx_hw.c \ + optional mdio etherswitch ar40xx_switch +dev/etherswitch/ar40xx/ar40xx_hw_atu.c \ + optional mdio etherswitch ar40xx_switch +dev/etherswitch/ar40xx/ar40xx_hw_port.c\ + optional mdio etherswitch ar40xx_switch +dev/etherswitch/ar40xx/ar40xx_hw_psgmii.c \ + optional mdio etherswitch ar40xx_switch +dev/etherswitch/ar40xx/ar40xx_hw_mib.c \ + optional mdio etherswitch ar40xx_switch +dev/etherswitch/ar40xx/ar40xx_hw_mirror.c \ + optional mdio etherswitch ar40xx_switch +dev/etherswitch/ar40xx/ar40xx_hw_vtu.c \ + optional mdio etherswitch ar40xx_switch +dev/etherswitch/ar40xx/ar40xx_hw_mdio.c\ + optional mdio etherswitch ar40xx_switch + dev/qcom_dwc3/qcom_dwc3.c optional qcom_dwc3 dev/qcom_rnd/qcom_rnd.coptional qcom_rnd diff --git a/sys/dev/etherswitch/ar40xx/ar40xx_debug.h b/sys/dev/etherswitch/ar40xx/ar40xx_debug.h new file mode 100644 index ..0aa5524dab71 --- /dev/null +++ b/sys/dev/etherswitch/ar40xx/ar40xx_debug.h @@ -0,0 +1,44 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2022 Adrian Chadd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer.
git: 8838f3c32ac0 - main - rtwn: ensure TX work isn't scheduled during reset / abort
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=8838f3c32ac0ebcb8b20863f8c455375039a505e commit 8838f3c32ac0ebcb8b20863f8c455375039a505e Author: Adrian Chadd AuthorDate: 2024-11-08 16:26:05 + Commit: Adrian Chadd CommitDate: 2024-11-08 16:26:05 + rtwn: ensure TX work isn't scheduled during reset / abort Don't schedule work during reset / abort. For USB NICs, work must not be scheduled during a call to rtwn_usb_abort_xfers(), as then it'll cause the call to usbd_transfer_drain() to hang. This fixes a hang I've been seeing where the NIC hits a TX timeout and then the reset/re-init path is called. If data is scheduled to be transmitted in that window, the call to usbd_transfer_drain() would hang and require a hard reboot to recover. Differential Revision: https://reviews.freebsd.org/D47479 --- sys/dev/rtwn/if_rtwn_tx.c | 5 + 1 file changed, 5 insertions(+) diff --git a/sys/dev/rtwn/if_rtwn_tx.c b/sys/dev/rtwn/if_rtwn_tx.c index f5e97933b314..bf45d14f7edc 100644 --- a/sys/dev/rtwn/if_rtwn_tx.c +++ b/sys/dev/rtwn/if_rtwn_tx.c @@ -263,6 +263,11 @@ rtwn_start(struct rtwn_softc *sc) struct mbuf *m; RTWN_ASSERT_LOCKED(sc); + + /* Ensure no work is scheduled during reset/teardown */ + if ((sc->sc_flags & RTWN_RUNNING) == 0) + return; + while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { if (sc->qfullmsk != 0) { mbufq_prepend(&sc->sc_snd, m);
git: 37e54466cf7a - main - net80211: clean up / add more macros to check the frame types
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=37e54466cf7a7c60f3d57c23c09b832db876e2fc commit 37e54466cf7a7c60f3d57c23c09b832db876e2fc Author: Adrian Chadd AuthorDate: 2024-11-09 21:10:08 + Commit: Adrian Chadd CommitDate: 2024-11-11 01:11:58 + net80211: clean up / add more macros to check the frame types * Add new macros to check the version+type and version+type+subtype of a frame. * Use these for existing frame checks. * Convert the flag checks in net80211 to use the macros, rather than direct header poking. Notably I'm callign out things like QOS any versus QOS data, the kind of NULL frames, etc. Eg, in the TKIP code it's checking whether a frame is ANY kind of QOS frame, not just QOS data. These macros should hopefully make the header checks clearer and less error prone. They're also useful in drivers that are doing their own header parsing. Locally: * ath(4), AP, STA, AP+STA modes * local ath10k/athp - AP, STA modes * rtwn - STA mode Differential Revision: https://reviews.freebsd.org/D36615 --- sys/net80211/ieee80211.h | 54 sys/net80211/ieee80211_adhoc.c | 3 +- sys/net80211/ieee80211_crypto_tkip.c | 3 +- sys/net80211/ieee80211_hostap.c | 3 +- sys/net80211/ieee80211_ht.c | 2 +- sys/net80211/ieee80211_mesh.c| 3 +- sys/net80211/ieee80211_output.c | 3 +- sys/net80211/ieee80211_sta.c | 3 +- sys/net80211/ieee80211_wds.c | 3 +- 9 files changed, 52 insertions(+), 25 deletions(-) diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h index 4203952367ca..a2d6b3040032 100644 --- a/sys/net80211/ieee80211.h +++ b/sys/net80211/ieee80211.h @@ -161,6 +161,7 @@ struct ieee80211_qosframe_addr4 { /* 0001-0011 Reserved 0x10-0x30 *//* Were: CF_ACK, CF_POLL, CF_ACPL */ #defineIEEE80211_FC0_SUBTYPE_NODATA0x40/* Null */ /* 0101-0111 Reserved 0x50-0x70 *//* Were: CFACK, CFPOLL, CF_ACK_CF_ACK */ +#defineIEEE80211_FC0_SUBTYPE_QOS_MASK_ANY 0x80/* QoS mask - matching any subtypes 8..15 */ #defineIEEE80211_FC0_SUBTYPE_QOS_DATA 0x80/* QoS Data */ #defineIEEE80211_FC0_SUBTYPE_QOS_DATA_CFACK0x90/* QoS Data +CF-Ack */ #defineIEEE80211_FC0_SUBTYPE_QOS_DATA_CFPOLL 0xa0/* QoS Data +CF-Poll */ @@ -190,24 +191,55 @@ struct ieee80211_qosframe_addr4 { #defineIEEE80211_CTL_EXT_TDD_BF0x0b/* TDD Beamforming, 80211ay-2021 */ /* 1100- Reserved 0xc-0xf */ -#defineIEEE80211_IS_MGMT(wh) \ - (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \ - == IEEE80211_FC0_TYPE_MGT)) +/* Check the version field */ +#defineIEEE80211_IS_FC0_CHECK_VER(wh, v) \ + (((wh)->i_fc[0] & IEEE80211_FC0_VERSION_MASK) == (v)) + +/* Check the version and type field */ +#defineIEEE80211_IS_FC0_CHECK_VER_TYPE(wh, v, t) \ + (wh)->i_fc[0] & IEEE80211_FC0_VERSION_MASK) == (v))) && \ + (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == (t))) + +/* Check the version, type and subtype field */ +#defineIEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, v, t, st) \ + (wh)->i_fc[0] & IEEE80211_FC0_VERSION_MASK) == (v))) && \ + (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == (t)) && \ + (((wh)->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == (st))) + +#defineIEEE80211_IS_MGMT(wh) \ + (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \ +IEEE80211_FC0_TYPE_MGT)) #defineIEEE80211_IS_CTL(wh)\ - (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \ - == IEEE80211_FC0_TYPE_CTL)) + (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \ +IEEE80211_FC0_TYPE_CTL)) #defineIEEE80211_IS_DATA(wh) \ - (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \ - == IEEE80211_FC0_TYPE_DATA)) + (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \ +IEEE80211_FC0_TYPE_DATA)) #defineIEEE80211_IS_EXT(wh)\ - (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \ - == IEEE80211_FC0_TYPE_EXT)) + (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \ +IEEE80211_FC0_TYPE_EXT)) #defineIEEE80211_FC0_QOSDATA \ (IEEE80211_FC0_TYPE_DATA|IEEE80211_FC0
git: d99eb8230eb7 - main - rtwn: change the USB TX transfers to only do one pending transfer per endpoint
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=d99eb8230eb717ab0b2eba948614d0f2f2b5dd2b commit d99eb8230eb717ab0b2eba948614d0f2f2b5dd2b Author: Adrian Chadd AuthorDate: 2024-11-12 04:48:12 + Commit: Adrian Chadd CommitDate: 2024-11-21 01:56:56 + rtwn: change the USB TX transfers to only do one pending transfer per endpoint I found I was getting constant device timeouts when doing anything more complicated than a single SSH on laptop with RTL8811AU. After digging into it, i found a variety of fun situations, including traffic stalls that would recover w/ a shorter (1 second) USB transfer timeout. However, the big one is a straight up hang of any TX endpoint until the NIC was reset. The RX side kept going just fine; only the TX endpoints would hang. Reproducing it was easy - just start up a couple of traffic streams on different WME AC's - eg a best effort + bulk transfer, like browsing the web and doing an ssh clone - throw in a ping -i 0.1 to your gateway, and it would very quickly hit device timeouts every couple of seconds. I put everything into a single TX EP and the hangs went away. Well, mostly. So after some MORE digging, I found that this driver isn't checking if the transfers are going into the correct EPs for the packet WME access category / 802.11 TID; and would frequently be able to schedule multiple transfers into the same endpoint. Then there's a second problem - there's an array of endpoints used for setting up the USB device, with .endpoint = UE_ADDR_ANY, however they're also being setup with the same endpoint configured in multiple transfer configs. Eg, a NIC with 3 or 4 bulk TX endpoints will configure the BK and BE endpoints with the same physical endpoint ID. This also leads to timed out transfers. My /guess/ was that the firmware isn't happy with one or both of the above, and so I solved both. * drop the USB transfer timeout to 1 second, not 5 seconds - that way we'll either get a 1 second traffic pause and USB transfer failure, or a 5 second device timeout. Having both the TX timeout and the USB transfer timeout made recovery from a USB transfer timeout (without a NIC reset) almost impossible. * enforce one transfer per endpoint; * separate pending/active buffer tracking per endpoint; * each endpoint now has its own TX callback to make sure the queue / end point ID is known; * and only frames from a given endpoint pending queue is going into the active queue and into that endpoint. * Finally, create a local wme2qid array and populate it with the endpoint mapping that ensures unique physical endpoint use. Locally tested: * rtl8812AU, 11n STA mode * rtl8192EU, 11n STA mode (with diffs to fix the channel config / power timeouts.) Differential Revision: https://reviews.freebsd.org/D47522 --- sys/dev/rtwn/if_rtwnvar.h | 2 +- sys/dev/rtwn/usb/rtwn_usb_attach.c | 26 ++ sys/dev/rtwn/usb/rtwn_usb_ep.c | 23 ++--- sys/dev/rtwn/usb/rtwn_usb_tx.c | 100 ++--- sys/dev/rtwn/usb/rtwn_usb_tx.h | 5 +- sys/dev/rtwn/usb/rtwn_usb_var.h| 12 +++-- 6 files changed, 129 insertions(+), 39 deletions(-) diff --git a/sys/dev/rtwn/if_rtwnvar.h b/sys/dev/rtwn/if_rtwnvar.h index 6a44b7b73902..f4c6d7ee64b4 100644 --- a/sys/dev/rtwn/if_rtwnvar.h +++ b/sys/dev/rtwn/if_rtwnvar.h @@ -32,7 +32,7 @@ #define RTWN_MACID_VALID 0x8000 #define RTWN_MACID_LIMIT 128 -#define RTWN_TX_TIMEOUT5000/* ms */ +#define RTWN_TX_TIMEOUT1000/* ms */ #define RTWN_MAX_EPOUT 4 #define RTWN_PORT_COUNT2 diff --git a/sys/dev/rtwn/usb/rtwn_usb_attach.c b/sys/dev/rtwn/usb/rtwn_usb_attach.c index 71798ffc14f9..4958939a768a 100644 --- a/sys/dev/rtwn/usb/rtwn_usb_attach.c +++ b/sys/dev/rtwn/usb/rtwn_usb_attach.c @@ -156,10 +156,12 @@ rtwn_usb_alloc_tx_list(struct rtwn_softc *sc) if (error != 0) return (error); - STAILQ_INIT(&uc->uc_tx_active); - STAILQ_INIT(&uc->uc_tx_inactive); - STAILQ_INIT(&uc->uc_tx_pending); + for (i = RTWN_BULK_TX_FIRST; i < RTWN_BULK_EP_COUNT; i++) { + STAILQ_INIT(&uc->uc_tx_active[i]); + STAILQ_INIT(&uc->uc_tx_pending[i]); + } + STAILQ_INIT(&uc->uc_tx_inactive); for (i = 0; i < RTWN_USB_TX_LIST_COUNT; i++) STAILQ_INSERT_HEAD(&uc->uc_tx_inactive, &uc->uc_tx[i], next); @@ -207,23 +209,29 @@ static void rtwn_usb_free_tx_list(struct rtwn_softc *sc) { struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc); + int i; r
git: 1375790a15b1 - main - net80211: add IEEE80211_IS_QOS_NULL()
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=1375790a15b122518b779b111c18ee2da5702728 commit 1375790a15b122518b779b111c18ee2da5702728 Author: Adrian Chadd AuthorDate: 2024-11-17 06:06:11 + Commit: Adrian Chadd CommitDate: 2024-11-19 04:50:17 + net80211: add IEEE80211_IS_QOS_NULL() This will be useful when fixing up the sequence number generation and checks, as the rules around how sequence numbers are generated have been clarified in 802.11-2016 and later. QoS-NULL frames are explicitly marked as "any sequence number". But for now, just create a macro and use it in the one place it's currently being used as a check - ath(4). * Add IEEE80211_IS_QOS_NULL(). * Change the "will this frame go into the TX block-ack window" check in the ath(4) transmit path. Note this changes the check to be more specific, but both paths already had previous checks to ensure they're QoS data frames. Locally tested: * ath(4), AR9380, STA mode w/ AMPDU TX/RX enabled and negotiated Differential Revision: https://reviews.freebsd.org/D47645 --- sys/dev/ath/if_ath_tx.c | 4 ++-- sys/net80211/ieee80211.h | 10 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sys/dev/ath/if_ath_tx.c b/sys/dev/ath/if_ath_tx.c index 1ec23972f283..1559b66a7c7d 100644 --- a/sys/dev/ath/if_ath_tx.c +++ b/sys/dev/ath/if_ath_tx.c @@ -2050,7 +2050,7 @@ ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni, */ if (IEEE80211_QOS_HAS_SEQ(wh) && (! IEEE80211_IS_MULTICAST(wh->i_addr1)) && - (subtype != IEEE80211_FC0_SUBTYPE_QOS_NULL)) { + (! IEEE80211_IS_QOS_NULL(wh))) { bf->bf_state.bfs_dobaw = 1; } } @@ -2991,7 +2991,7 @@ ath_tx_tid_seqno_assign(struct ath_softc *sc, struct ieee80211_node *ni, * RX side. */ subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; - if (subtype == IEEE80211_FC0_SUBTYPE_QOS_NULL) { + if (IEEE80211_IS_QOS_NULL(wh)) { /* XXX no locking for this TID? This is a bit of a problem. */ seqno = ni->ni_txseqs[IEEE80211_NONQOS_TID]; INCR(ni->ni_txseqs[IEEE80211_NONQOS_TID], IEEE80211_SEQ_RANGE); diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h index eb83d0a40a33..e62b8c16d68f 100644 --- a/sys/net80211/ieee80211.h +++ b/sys/net80211/ieee80211.h @@ -274,6 +274,16 @@ struct ieee80211_qosframe_addr4 { IEEE80211_FC0_TYPE_DATA, \ IEEE80211_FC0_SUBTYPE_QOS_DATA)) +/* + * Return true if this frame is a QoS NULL data frame. + */ +#defineIEEE80211_IS_QOS_NULL(wh) \ + (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh,\ +IEEE80211_FC0_VERSION_0, \ +IEEE80211_FC0_TYPE_DATA, \ +IEEE80211_FC0_SUBTYPE_QOS_NULL)) + + #defineIEEE80211_FC1_DIR_MASK 0x03 #defineIEEE80211_FC1_DIR_NODS 0x00/* STA->STA */ #defineIEEE80211_FC1_DIR_TODS 0x01/* STA->AP */
git: 842a2c1ad396 - main - uath: flush data/commands to the firmware before changing channel / state
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=842a2c1ad39637e91547bf725e8b4ce8773c5935 commit 842a2c1ad39637e91547bf725e8b4ce8773c5935 Author: Adrian Chadd AuthorDate: 2024-11-18 05:12:10 + Commit: Adrian Chadd CommitDate: 2024-11-19 04:50:41 + uath: flush data/commands to the firmware before changing channel / state The driver wasn't stable - it would start fine, but during scan it would eventually hang and no further command endpoint transfers would complete. After adding some debugging and looking at the logs I noticed that things went sideways once a /data/ frame was sent. The channel change config happened between the data frame being sent and being completed. My guess is that the firmware doesn't like a channel change and reset whilst there's pending data frames. Checking the Linux driver I found that it was doing a flush before a channel change, and we're doing it afterwards. This acts like a fence around ensuring scheduled TX work has completed. In net80211 the transmit path and the control path aren't serialised, so it's very often the case that ioctls, state changes, etc occur whilst in parallel there are frame transmits being scheduled. This seems to happen more frequently on a more recent, high core (8) machine with XHCI. I remember testing this driver years ago on single and dual core CPU laptops with no problems. So, add some flushes - before a channel change, and during a transition to AUTH when the BSS config is being programmed into the firmware. These two fences seem enough to reliably associate as a 2GHz and 5GHz STA. Note that this isn't entirely blocking all newly queued transmit work from occuring until after the NIC has finished configuration. That will need some further investigation. Locally tested: * Wistron NuWeb AR5523 dual-band NIC, STA mode, 2/5GHz Differential Revision: https://reviews.freebsd.org/D47655 --- sys/dev/usb/wlan/if_uath.c | 4 1 file changed, 4 insertions(+) diff --git a/sys/dev/usb/wlan/if_uath.c b/sys/dev/usb/wlan/if_uath.c index 580022f5a0c5..32e3c0325c6e 100644 --- a/sys/dev/usb/wlan/if_uath.c +++ b/sys/dev/usb/wlan/if_uath.c @@ -1831,6 +1831,8 @@ uath_set_channel(struct ieee80211com *ic) UATH_UNLOCK(sc); return; } + /* flush data & control requests into the target */ + (void)uath_flush(sc); (void)uath_switch_channel(sc, ic->ic_curchan); UATH_UNLOCK(sc); } @@ -2015,6 +2017,8 @@ uath_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) break; case IEEE80211_S_AUTH: + /* flush data & control requests into the target */ + (void)uath_flush(sc); /* XXX good place? set RTS threshold */ uath_config(sc, CFG_USER_RTS_THRESHOLD, vap->iv_rtsthreshold); /* XXX bad place */
git: 7098b90152dd - main - usb: fix the ID for the dual-band Wistron AR5523 USB NIC
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=7098b90152dddcaf10c43ff31a8f1f3a952267d5 commit 7098b90152dddcaf10c43ff31a8f1f3a952267d5 Author: Adrian Chadd AuthorDate: 2024-11-18 05:10:32 + Commit: Adrian Chadd CommitDate: 2024-11-19 04:50:24 + usb: fix the ID for the dual-band Wistron AR5523 USB NIC Use the correct ID, as I have one of these NICs. Add the previous one back in case it's out there in the wild. @emaste did a bit of a dig into the product numbers. @sam did change the ID from 0x0828 -> 082a in a commit a long while back. It's worth reading the code review for further details. However, I do have one of these NICs and I verified that it indeed has the given ID, and with some follow-up work to fix some race conditions, it works fine in 2GHz 11bg and 5GHz 11a operation. Differential Revision: https://reviews.freebsd.org/D47654 Obtained from: Linux, drivers/net/wireless/ath/ar5523/ar5523.c --- sys/dev/usb/usbdevs| 3 ++- sys/dev/usb/wlan/if_uath.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs index a368cf84d9d5..50968a2c80cf 100644 --- a/sys/dev/usb/usbdevs +++ b/sys/dev/usb/usbdevs @@ -5025,7 +5025,8 @@ product WISTRONNEWEB UR055G 0x0711 UR055G product WISTRONNEWEB O8494 0x0804 ORiNOCO 802.11n product WISTRONNEWEB AR5523_1 0x0826 AR5523 product WISTRONNEWEB AR5523_1_NF 0x0827 AR5523 (no firmware) -product WISTRONNEWEB AR5523_2 0x082a AR5523 +product WISTRONNEWEB AR5523_2 0x0828 AR5523 +product WISTRONNEWEB AR5523_2_ALT 0x082a AR5523 product WISTRONNEWEB AR5523_2_NF 0x0829 AR5523 (no firmware) /* Xerox products */ diff --git a/sys/dev/usb/wlan/if_uath.c b/sys/dev/usb/wlan/if_uath.c index e78003bc250a..580022f5a0c5 100644 --- a/sys/dev/usb/wlan/if_uath.c +++ b/sys/dev/usb/wlan/if_uath.c @@ -183,6 +183,7 @@ static const STRUCT_USB_HOST_ID uath_devs[] = { UATH_DEV(UMEDIA,AR5523_2), UATH_DEV(WISTRONNEWEB, AR5523_1), UATH_DEV(WISTRONNEWEB, AR5523_2), + UATH_DEV(WISTRONNEWEB, AR5523_2_ALT), UATH_DEV(ZCOM, AR5523) #undef UATH_DEV };
git: c249cc3822dc - main - net80211: migrate FC0_TYPE_MASK / FC0_SUBTYPE_MASK frame type checks to macros
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=c249cc3822dc002288700ee206cf28c0c6031449 commit c249cc3822dc002288700ee206cf28c0c6031449 Author: Adrian Chadd AuthorDate: 2024-11-09 21:44:50 + Commit: Adrian Chadd CommitDate: 2024-11-17 17:53:04 + net80211: migrate FC0_TYPE_MASK / FC0_SUBTYPE_MASK frame type checks to macros * Add macros for the management and control frame type checks that I've come across in the drivers. * Delete some now old code (eg ath's ieee80211_is_action()) as there's now a macro for it. Local testing: * not yet, I have a lot of wifi devices to find and test against Differential Revision: https://reviews.freebsd.org/D47500 --- sys/dev/ath/if_ath_tx.c| 24 ++-- sys/dev/ipw/if_ipw.c | 2 +- sys/dev/iwn/if_iwn.c | 4 +--- sys/dev/malo/if_malo.c | 12 +++- sys/dev/mwl/if_mwl.c | 7 ++- sys/dev/otus/if_otus.c | 3 +-- sys/dev/ral/rt2560.c | 5 + sys/dev/ral/rt2661.c | 4 +--- sys/dev/ral/rt2860.c | 8 ++-- sys/dev/usb/wlan/if_rum.c | 4 +--- sys/dev/usb/wlan/if_run.c | 4 +--- sys/dev/usb/wlan/if_upgt.c | 3 +-- sys/dev/usb/wlan/if_ural.c | 5 + sys/dev/usb/wlan/if_urtw.c | 7 ++- sys/dev/usb/wlan/if_zyd.c | 4 +--- sys/net80211/ieee80211.h | 36 16 files changed, 57 insertions(+), 75 deletions(-) diff --git a/sys/dev/ath/if_ath_tx.c b/sys/dev/ath/if_ath_tx.c index 69d0b5c00848..1ec23972f283 100644 --- a/sys/dev/ath/if_ath_tx.c +++ b/sys/dev/ath/if_ath_tx.c @@ -1133,8 +1133,7 @@ ath_tx_calc_duration(struct ath_softc *sc, struct ath_buf *bf) * Calculate duration. This logically belongs in the 802.11 * layer but it lacks sufficient information to calculate it. */ - if ((flags & HAL_TXDESC_NOACK) == 0 && - (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) != IEEE80211_FC0_TYPE_CTL) { + if ((flags & HAL_TXDESC_NOACK) == 0 && !IEEE80211_IS_CTL(wh)) { u_int16_t dur; if (shortPreamble) dur = rt->info[rix].spAckDuration; @@ -2577,25 +2576,6 @@ badbad: * It's a dirty hack, but someone's gotta do it. */ -/* - * XXX doesn't belong here! - */ -static int -ieee80211_is_action(struct ieee80211_frame *wh) -{ - /* Type: Management frame? */ - if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) != - IEEE80211_FC0_TYPE_MGT) - return 0; - - /* Subtype: Action frame? */ - if ((wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) != - IEEE80211_FC0_SUBTYPE_ACTION) - return 0; - - return 1; -} - /* * Return an alternate TID for ADDBA request frames. * @@ -2612,7 +2592,7 @@ ath_tx_action_frame_override_queue(struct ath_softc *sc, uint16_t baparamset; /* Not action frame? Bail */ - if (! ieee80211_is_action(wh)) + if (! IEEE80211_IS_MGMT_ACTION(wh)) return 0; /* XXX Not needed for frames we send? */ diff --git a/sys/dev/ipw/if_ipw.c b/sys/dev/ipw/if_ipw.c index 051f046d26ad..68662f378933 100644 --- a/sys/dev/ipw/if_ipw.c +++ b/sys/dev/ipw/if_ipw.c @@ -1119,7 +1119,7 @@ ipw_fix_channel(struct ipw_softc *sc, struct mbuf *m) wh = mtod(m, struct ieee80211_frame *); - if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) != IEEE80211_FC0_TYPE_MGT) + if (!IEEE80211_IS_MGMT(wh)) return; subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index d2d44d93f948..50d50fdc473c 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -4624,9 +4624,7 @@ iwn_tx_data(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni) IEEE80211_QOS_ACKPOLICY_NOACK) flags |= IWN_TX_NEED_ACK; } - if ((wh->i_fc[0] & - (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == - (IEEE80211_FC0_TYPE_CTL | IEEE80211_FC0_SUBTYPE_BAR)) + if (IEEE80211_IS_CTL_BAR(wh)) flags |= IWN_TX_IMM_BA; /* Cannot happen yet. */ if (wh->i_fc[1] & IEEE80211_FC1_MORE_FRAG) diff --git a/sys/dev/malo/if_malo.c b/sys/dev/malo/if_malo.c index 56310085ef5f..52419f377bb6 100644 --- a/sys/dev/malo/if_malo.c +++ b/sys/dev/malo/if_malo.c @@ -94,13 +94,9 @@ enum { MALO_DEBUG_FW = 0x8000, /* firmware */ MALO_DEBUG_ANY = 0x }; -#defineIS_BEACON(wh) \ - ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK | \ - IEEE80211_FC0_SUBTYPE_MASK)) == \ -(IEEE80211_FC0_TYPE_MGT|IEEE80211_FC0_
git: 3d0d43d25ac6 - main - net80211: remove IEEE80211_FC0_QOSDATA
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=3d0d43d25ac6e4a6157447e3b7307e1b44275b08 commit 3d0d43d25ac6e4a6157447e3b7307e1b44275b08 Author: Adrian Chadd AuthorDate: 2024-11-10 04:12:57 + Commit: Adrian Chadd CommitDate: 2024-11-17 17:53:16 + net80211: remove IEEE80211_FC0_QOSDATA This is unused by anything in the tree; anything using it should be instead using one of the frame type macros. Differential Revision: https://reviews.freebsd.org/D47503 --- sys/net80211/ieee80211.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h index e9147e028385..eb83d0a40a33 100644 --- a/sys/net80211/ieee80211.h +++ b/sys/net80211/ieee80211.h @@ -255,9 +255,6 @@ struct ieee80211_qosframe_addr4 { /* Data frame types */ -#defineIEEE80211_FC0_QOSDATA \ - (IEEE80211_FC0_TYPE_DATA|IEEE80211_FC0_SUBTYPE_QOS_DATA|IEEE80211_FC0_VERSION_0) - /* * Return true if the frame is any of the QOS frame types, not just * data frames. Matching on the IEEE80211_FC0_SUBTYPE_QOS_ANY bit
git: 3d54d9e364f8 - main - ath: use the new net80211 methods for AMPDU density/limit, short-GI
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=3d54d9e364f88117fa9f7126ef0184c6da5069fc commit 3d54d9e364f88117fa9f7126ef0184c6da5069fc Author: Adrian Chadd AuthorDate: 2024-11-25 23:02:26 + Commit: Adrian Chadd CommitDate: 2024-12-03 05:31:05 + ath: use the new net80211 methods for AMPDU density/limit, short-GI Now that net80211 has this code, just leverage it instead of rolling our own. Differential Revision: https://reviews.freebsd.org/D47748 Reviewed by:bz --- sys/dev/ath/if_ath_tx_ht.c | 38 +++--- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/sys/dev/ath/if_ath_tx_ht.c b/sys/dev/ath/if_ath_tx_ht.c index ca69d4558d76..9558b7c9e696 100644 --- a/sys/dev/ath/if_ath_tx_ht.c +++ b/sys/dev/ath/if_ath_tx_ht.c @@ -222,7 +222,6 @@ void ath_tx_rate_fill_rcflags(struct ath_softc *sc, struct ath_buf *bf) { struct ieee80211_node *ni = bf->bf_node; - struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; const HAL_RATE_TABLE *rt = sc->sc_currates; struct ath_rc_series *rc = bf->bf_state.bfs_rc; @@ -297,17 +296,13 @@ ath_tx_rate_fill_rcflags(struct ath_softc *sc, struct ath_buf *bf) * we are always "out" by some amount. */ if (ni->ni_chw == 40 && - ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI40 && - ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40 && - vap->iv_flags_ht & IEEE80211_FHT_SHORTGI40 && + ieee80211_ht_check_tx_shortgi_40(ni) && (bf->bf_flags & ATH_BUF_TOA_PROBE) == 0) { rc[i].flags |= ATH_RC_SGI_FLAG; } if (ni->ni_chw == 20 && - ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI20 && - ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20 && - vap->iv_flags_ht & IEEE80211_FHT_SHORTGI20 && + ieee80211_ht_check_tx_shortgi_20(ni) && (bf->bf_flags & ATH_BUF_TOA_PROBE) == 0) { rc[i].flags |= ATH_RC_SGI_FLAG; } @@ -406,7 +401,6 @@ ath_compute_num_delims(struct ath_softc *sc, struct ath_buf *first_bf, { const HAL_RATE_TABLE *rt = sc->sc_currates; struct ieee80211_node *ni = first_bf->bf_node; - struct ieee80211vap *vap = ni->ni_vap; int ndelim, mindelim = 0; int mpdudensity;/* in 1/100'th of a microsecond */ int peer_mpdudensity; /* net80211 value */ @@ -418,17 +412,7 @@ ath_compute_num_delims(struct ath_softc *sc, struct ath_buf *first_bf, /* * Get the advertised density from the node. */ - peer_mpdudensity = - _IEEE80211_MASKSHIFT(ni->ni_htparam, IEEE80211_HTCAP_MPDUDENSITY); - - /* -* vap->iv_ampdu_density is a net80211 value, rather than the actual -* density. Larger values are longer A-MPDU density spacing values, -* and we want to obey larger configured / negotiated density values -* per station if we get it. -*/ - if (vap->iv_ampdu_density > peer_mpdudensity) - peer_mpdudensity = vap->iv_ampdu_density; + peer_mpdudensity = ieee80211_ht_get_node_ampdu_density(ni); /* * Convert the A-MPDU density net80211 value to a 1/100 microsecond @@ -563,8 +547,6 @@ static int ath_get_aggr_limit(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_buf *bf) { - struct ieee80211vap *vap = ni->ni_vap; - int amin = ATH_AGGR_MAXSIZE; int i; @@ -572,15 +554,9 @@ ath_get_aggr_limit(struct ath_softc *sc, struct ieee80211_node *ni, if (sc->sc_aggr_limit > 0 && sc->sc_aggr_limit < ATH_AGGR_MAXSIZE) amin = sc->sc_aggr_limit; - /* Check the vap configured transmit limit */ - amin = MIN(amin, ath_rx_ampdu_to_byte(vap->iv_ampdu_limit)); - - /* -* Check the HTCAP field for the maximum size the node has -* negotiated. If it's smaller than what we have, cap it there. -*/ - amin = MIN(amin, ath_rx_ampdu_to_byte( - _IEEE80211_MASKSHIFT(ni->ni_htparam, IEEE80211_HTCAP_MAXRXAMPDU))); + /* Check the vap and node configured transmit limit */ + amin = MIN(amin, + ath_rx_ampdu_to_byte(ieee80211_ht_get_node_ampdu_limit(ni))); for (i = 0; i < ATH_RC_NUM; i++) { if (bf->bf_state.bfs_rc[i].tries == 0) @@ -593,7 +5
git: 3f62f8ef5e40 - main - iwn: use ieee80211_ht_check_tx_shortgi_20() and ieee80211_ht_check_tx_shortgi_40()
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=3f62f8ef5e4001ba7a2a9324e10a508eea15b68c commit 3f62f8ef5e4001ba7a2a9324e10a508eea15b68c Author: Adrian Chadd AuthorDate: 2024-11-25 23:13:32 + Commit: Adrian Chadd CommitDate: 2024-12-03 05:31:39 + iwn: use ieee80211_ht_check_tx_shortgi_20() and ieee80211_ht_check_tx_shortgi_40() Use the new net80211 routines to check the node width and the local / node flags. This should be "more" correct than the previous code. Differential Revision: https://reviews.freebsd.org/D47750 Reviewed by:bz --- sys/dev/iwn/if_iwn.c | 15 +-- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index 50d50fdc473c..db3eb37ced9e 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -2812,23 +2812,18 @@ iwn_rate_to_plcp(struct iwn_softc *sc, struct ieee80211_node *ni, */ plcp = IEEE80211_RV(rate) | IWN_RFLAG_MCS; - /* -* XXX the following should only occur if both -* the local configuration _and_ the remote node -* advertise these capabilities. Thus this code -* may need fixing! -*/ - /* * Set the channel width and guard interval. +* +* Take into account the local configuration and +* the node/peer advertised abilities. */ if (IEEE80211_IS_CHAN_HT40(ni->ni_chan)) { plcp |= IWN_RFLAG_HT40; - if (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40) + if (ieee80211_ht_check_tx_shortgi_40(ni)) plcp |= IWN_RFLAG_SGI; - } else if (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20) { + } else if (ieee80211_ht_check_tx_shortgi_20(ni)) plcp |= IWN_RFLAG_SGI; - } /* * Ensure the selected rate matches the link quality
git: c6b44f64c330 - main - net80211: add helper functions for determining HT transmit parameters
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=c6b44f64c33010501aee2fd99016aeca54a09a1e commit c6b44f64c33010501aee2fd99016aeca54a09a1e Author: Adrian Chadd AuthorDate: 2024-11-25 23:00:24 + Commit: Adrian Chadd CommitDate: 2024-12-03 05:30:45 + net80211: add helper functions for determining HT transmit parameters This adds helper functions to determine a variety of HT related transmit parameters: * AMPDU density and size; * short-GI for 20 and 40MHz; * Whether 40MHz transmit is allowed; * Whether HT rates have been negotiated for transmit. It should be done here rather than drivers having to re-invent the wheel each time. This is doubly important for AP modes where each node will hvae different supported features and this needs to be used when assembling transmit frames / configuring transmit parameters. Differential Revision: https://reviews.freebsd.org/D47747 Reviewed by:bz --- sys/net80211/ieee80211_ht.c | 140 sys/net80211/ieee80211_ht.h | 6 ++ 2 files changed, 146 insertions(+) diff --git a/sys/net80211/ieee80211_ht.c b/sys/net80211/ieee80211_ht.c index 28c329ce3d32..1f97b7b9927a 100644 --- a/sys/net80211/ieee80211_ht.c +++ b/sys/net80211/ieee80211_ht.c @@ -3604,3 +3604,143 @@ ieee80211_add_htinfo_vendor(uint8_t *frm, struct ieee80211_node *ni) frm[5] = BCM_OUI_HTINFO; return ieee80211_add_htinfo_body(frm + 6, ni); } + +/* + * Get the HT density for the given 802.11n node. + * + * Take into account the density advertised from the peer. + * Larger values are longer A-MPDU density spacing values, and + * we want to obey them per station if we get them. + */ +int +ieee80211_ht_get_node_ampdu_density(const struct ieee80211_node *ni) +{ + struct ieee80211vap *vap; + int peer_mpdudensity; + + vap = ni->ni_vap; + peer_mpdudensity = + _IEEE80211_MASKSHIFT(ni->ni_htparam, IEEE80211_HTCAP_MPDUDENSITY); + if (vap->iv_ampdu_density > peer_mpdudensity) + peer_mpdudensity = vap->iv_ampdu_density; + return (peer_mpdudensity); +} + +/* + * Get the transmit A-MPDU limit for the given 802.11n node. + * + * Take into account the limit advertised from the peer. + * Smaller values indicate smaller maximum A-MPDU sizes, and + * should be used when forming an A-MPDU to the given peer. + */ +int +ieee80211_ht_get_node_ampdu_limit(const struct ieee80211_node *ni) +{ + struct ieee80211vap *vap; + int peer_mpdulimit; + + vap = ni->ni_vap; + peer_mpdulimit = + _IEEE80211_MASKSHIFT(ni->ni_htparam, IEEE80211_HTCAP_MAXRXAMPDU); + + return (MIN(vap->iv_ampdu_limit, peer_mpdulimit)); +} + +/* + * Return true if short-GI is available when transmitting to + * the given node at 20MHz. + * + * Ensure it's configured and available in the VAP / driver as + * well as the node. + */ +bool +ieee80211_ht_check_tx_shortgi_20(const struct ieee80211_node *ni) +{ + const struct ieee80211vap *vap; + const struct ieee80211com *ic; + + if (! ieee80211_ht_check_tx_ht(ni)) + return (false); + + vap = ni->ni_vap; + ic = ni->ni_ic; + + return ((ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI20) && + (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20) && + (vap->iv_flags_ht & IEEE80211_FHT_SHORTGI20)); +} + +/* + * Return true if short-GI is available when transmitting to + * the given node at 40MHz. + * + * Ensure it's configured and available in the VAP / driver as + * well as the node and BSS. + */ +bool +ieee80211_ht_check_tx_shortgi_40(const struct ieee80211_node *ni) +{ + const struct ieee80211vap *vap; + const struct ieee80211com *ic; + + if (! ieee80211_ht_check_tx_ht40(ni)) + return (false); + + vap = ni->ni_vap; + ic = ni->ni_ic; + + return ((ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI40) && + (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40) && + (vap->iv_flags_ht & IEEE80211_FHT_SHORTGI40)); +} + +/* + * Return true if HT rates can be used for the given node. + * + * There are some situations seen in the wild, wild past where + * HT APs would announce HT but no HT rates. + */ +bool +ieee80211_ht_check_tx_ht(const struct ieee80211_node *ni) +{ + const struct ieee80211vap *vap; + const struct ieee80211_channel *bss_chan; + + if (ni == NULL || ni->ni_chan == IEEE80211_CHAN_ANYC || + ni->ni_vap == NULL || ni->ni_vap->iv_bss == NULL) + return (false); + + vap = ni->ni_vap; + bss_chan = vap->iv_bss->ni_chan; + + if (bss_chan == IEEE80211_CHAN_ANYC) + return (false); + + if (IEEE80211_IS_CHAN_H
git: 2014462da5b3 - main - amrr: remove duplicate logic, use ieee80211_ht_check_tx_ht()
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=2014462da5b3e630cdbf687d918bbfc0c3a344a4 commit 2014462da5b3e630cdbf687d918bbfc0c3a344a4 Author: Adrian Chadd AuthorDate: 2024-11-26 01:40:12 + Commit: Adrian Chadd CommitDate: 2024-12-03 05:32:08 + amrr: remove duplicate logic, use ieee80211_ht_check_tx_ht() This uses the new net80211 helper function to indicate that nodes can actually receive transmitted HT rates. Differential Revision: https://reviews.freebsd.org/D47754 Reviewed by:bz --- sys/net80211/ieee80211_amrr.c | 37 + 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/sys/net80211/ieee80211_amrr.c b/sys/net80211/ieee80211_amrr.c index 461554d75ea1..386a3de92a74 100644 --- a/sys/net80211/ieee80211_amrr.c +++ b/sys/net80211/ieee80211_amrr.c @@ -138,25 +138,6 @@ amrr_deinit(struct ieee80211vap *vap) nrefs--;/* XXX locking */ } -/* - * Return whether 11n rates are possible. - * - * Some 11n devices may return HT information but no HT rates. - * Thus, we shouldn't treat them as an 11n node. - */ -static int -amrr_node_is_11n(struct ieee80211_node *ni) -{ - - if (ni->ni_chan == NULL) - return (0); - if (ni->ni_chan == IEEE80211_CHAN_ANYC) - return (0); - if (IEEE80211_IS_CHAN_HT(ni->ni_chan) && ni->ni_htrates.rs_nrates == 0) - return (0); - return (IEEE80211_IS_CHAN_HT(ni->ni_chan)); -} - static void amrr_node_init(struct ieee80211_node *ni) { @@ -189,7 +170,7 @@ amrr_node_init(struct ieee80211_node *ni) amn->amn_success_threshold = amrr->amrr_min_success_threshold; /* 11n or not? Pick the right rateset */ - if (amrr_node_is_11n(ni)) { + if (ieee80211_ht_check_tx_ht(ni)) { /* XXX ew */ IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, "%s: 11n node", __func__); @@ -204,7 +185,7 @@ amrr_node_init(struct ieee80211_node *ni) rate = rs->rs_rates[0]; /* XXX clear the basic rate flag if it's not 11n */ - if (! amrr_node_is_11n(ni)) + if (! ieee80211_ht_check_tx_ht(ni)) rate &= IEEE80211_RATE_VAL; /* pick initial rate from the rateset - HT or otherwise */ @@ -213,7 +194,7 @@ amrr_node_init(struct ieee80211_node *ni) amn->amn_rix--) { /* legacy - anything < 36mbit, stop searching */ /* 11n - stop at MCS4 */ - if (amrr_node_is_11n(ni)) { + if (ieee80211_ht_check_tx_ht(ni)) { if ((rs->rs_rates[amn->amn_rix] & 0x1f) < 4) break; } else if ((rs->rs_rates[amn->amn_rix] & IEEE80211_RATE_VAL) <= 72) @@ -222,7 +203,7 @@ amrr_node_init(struct ieee80211_node *ni) rate = rs->rs_rates[amn->amn_rix] & IEEE80211_RATE_VAL; /* if the rate is an 11n rate, ensure the MCS bit is set */ - if (amrr_node_is_11n(ni)) + if (ieee80211_ht_check_tx_ht(ni)) rate |= IEEE80211_RATE_MCS; /* Assign initial rate from the rateset */ @@ -234,7 +215,7 @@ amrr_node_init(struct ieee80211_node *ni) IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, "AMRR: nrates=%d, initial rate %s%d", rs->rs_nrates, - amrr_node_is_11n(ni) ? "MCS " : "", + ieee80211_ht_check_tx_ht(ni) ? "MCS " : "", rate & IEEE80211_RATE_VAL); } @@ -254,7 +235,7 @@ amrr_update(struct ieee80211_amrr *amrr, struct ieee80211_amrr_node *amn, KASSERT(is_enough(amn), ("txcnt %d", amn->amn_txcnt)); /* 11n or not? Pick the right rateset */ - if (amrr_node_is_11n(ni)) { + if (ieee80211_ht_check_tx_ht(ni)) { /* XXX ew */ rs = (struct ieee80211_rateset *) &ni->ni_htrates; } else { @@ -347,7 +328,7 @@ amrr_rate(struct ieee80211_node *ni, void *arg __unused, uint32_t iarg __unused) amrr = amn->amn_amrr; /* 11n or not? Pick the right rateset */ - if (amrr_node_is_11n(ni)) { + if (ieee80211_ht_check_tx_ht(ni)) { /* XXX ew */ rs = (struct ieee80211_rateset *) &ni->ni_htrates; } else { @@ -360,7 +341,7 @@ amrr_rate(struct ieee80211_node *ni, void *arg __unused, uint32_t iarg __unused) /* update public rate */ ni->ni_txrate = rs->rs_rates[rix]; /* XXX strip basic rate flag from txrate, if non-11n */ - if (amrr_node_is_11n(ni)) + if (ieee80211_ht_check_tx_ht(ni)) ni->ni_
git: 057db5b227d0 - main - iwn: use ieee80211_ht_check_tx_ht()
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=057db5b227d0e1c1d14c7dbc67c6613e328d1735 commit 057db5b227d0e1c1d14c7dbc67c6613e328d1735 Author: Adrian Chadd AuthorDate: 2024-11-26 01:50:50 + Commit: Adrian Chadd CommitDate: 2024-12-03 05:32:26 + iwn: use ieee80211_ht_check_tx_ht() ieee80211_ht_check_tx_ht() now implements the "is this a HT node with actual HT rates I can transmit to." Differential Revision: https://reviews.freebsd.org/D47755 Reviewed by:bz --- sys/dev/iwn/if_iwn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index db3eb37ced9e..b887ebf842e1 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -4480,7 +4480,7 @@ iwn_tx_rate_to_linkq_offset(struct iwn_softc *sc, struct ieee80211_node *ni, /* * Figure out if we're using 11n or not here. */ - if (IEEE80211_IS_CHAN_HT(ni->ni_chan) && ni->ni_htrates.rs_nrates > 0) + if (ieee80211_ht_check_tx_ht(ni)) is_11n = 1; else is_11n = 0; @@ -5358,7 +5358,7 @@ iwn_set_link_quality(struct iwn_softc *sc, struct ieee80211_node *ni) * 11n _and_ we have some 11n rates, or don't * try. */ - if (IEEE80211_IS_CHAN_HT(ni->ni_chan) && ni->ni_htrates.rs_nrates > 0) { + if (ieee80211_ht_check_tx_ht(ni)) { rs = (struct ieee80211_rateset *) &ni->ni_htrates; is_11n = 1; } else {
git: 81aef988acc7 - main - rtwn: remove the conditional compilation around the sc_ht40 option.
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=81aef988acc7b48e7943831cb4b4087895e108bc commit 81aef988acc7b48e7943831cb4b4087895e108bc Author: Adrian Chadd AuthorDate: 2024-12-02 05:11:02 + Commit: Adrian Chadd CommitDate: 2024-12-05 07:27:26 + rtwn: remove the conditional compilation around the sc_ht40 option. This option stems from a bunch of issues a long time ago where HT40 support on some NICs is unstable - likely because we're not setting up the RF/baseband correctly. In any case, it doesn't need to be conditionally compiled anymore. Leave it in, leave it off by default, and various chipset initialisation paths can decide whether to enable it themselves. Reviewed by:emaste --- sys/dev/rtwn/if_rtwn.c| 2 -- sys/dev/rtwn/if_rtwnvar.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/sys/dev/rtwn/if_rtwn.c b/sys/dev/rtwn/if_rtwn.c index df18dc54ed3f..e452448976dd 100644 --- a/sys/dev/rtwn/if_rtwn.c +++ b/sys/dev/rtwn/if_rtwn.c @@ -326,12 +326,10 @@ rtwn_sysctlattach(struct rtwn_softc *sc) struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev); -#if 1 sc->sc_ht40 = 0; SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "ht40", CTLFLAG_RDTUN, &sc->sc_ht40, sc->sc_ht40, "Enable 40 MHz mode support"); -#endif #ifdef RTWN_DEBUG SYSCTL_ADD_U32(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, diff --git a/sys/dev/rtwn/if_rtwnvar.h b/sys/dev/rtwn/if_rtwnvar.h index f4c6d7ee64b4..3d4db0a37a9e 100644 --- a/sys/dev/rtwn/if_rtwnvar.h +++ b/sys/dev/rtwn/if_rtwnvar.h @@ -171,9 +171,7 @@ struct rtwn_softc { struct mbufqsc_snd; device_tsc_dev; -#if 1 int sc_ht40; -#endif uint32_tsc_debug; int sc_hwcrypto; int sc_ratectl_sysctl;
git: fcb5e8d0c19a - main - rtwn: don't do 64 bit TSF extension by default
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=fcb5e8d0c19ac21515ab3047d39a76b32d835cec commit fcb5e8d0c19ac21515ab3047d39a76b32d835cec Author: Adrian Chadd AuthorDate: 2024-12-02 05:22:45 + Commit: Adrian Chadd CommitDate: 2024-12-05 07:27:46 + rtwn: don't do 64 bit TSF extension by default The TSF64 extension involves at least 3 reads from TSF registers (R92C_TSFTR(0), R92C_TSFTR(1), R92C_TSFTR(2)) which are 4 byte control transfers. They take up valuable USB link time. It's likely much less expensive for PCIe adapters. At some point it may be worthwhile enabling it by default just for those. With this disabled, the only USB traffic that I see during normal data operation are bulk TX/RX data transfers for 802.11 packets, and on NICs w/ net80211 rate control, the control register space read/writes for TX completion. (And that will also need addressing.) This is the difference between 15mbit TCP RX and 30mbit TCP RX on the 11n NICs, and around 40 to 50mbit TCP RX on the 11ac NICs in HT40 and VHT80. Locally tested: * RTL8188EU, STA mode * RTL8192CU, STA mode * RTL8192EU, STA mode * RTL8811AU, STA mode * RTL8821AU, STA mode Differential Revision: https://reviews.freebsd.org/D47861 --- sys/dev/rtwn/if_rtwn.c| 5 + sys/dev/rtwn/if_rtwn_rx.c | 14 -- sys/dev/rtwn/if_rtwnvar.h | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sys/dev/rtwn/if_rtwn.c b/sys/dev/rtwn/if_rtwn.c index e452448976dd..3d0dce516f84 100644 --- a/sys/dev/rtwn/if_rtwn.c +++ b/sys/dev/rtwn/if_rtwn.c @@ -331,6 +331,11 @@ rtwn_sysctlattach(struct rtwn_softc *sc) "ht40", CTLFLAG_RDTUN, &sc->sc_ht40, sc->sc_ht40, "Enable 40 MHz mode support"); + sc->sc_ena_tsf64 = 0; + SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "ena_tsf64", CTLFLAG_RWTUN, &sc->sc_ena_tsf64, + sc->sc_ena_tsf64, "Enable/disable per-packet TSF64 reporting"); + #ifdef RTWN_DEBUG SYSCTL_ADD_U32(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "debug", CTLFLAG_RWTUN, &sc->sc_debug, sc->sc_debug, diff --git a/sys/dev/rtwn/if_rtwn_rx.c b/sys/dev/rtwn/if_rtwn_rx.c index ebfb8e67ec6d..58cd53b01e63 100644 --- a/sys/dev/rtwn/if_rtwn_rx.c +++ b/sys/dev/rtwn/if_rtwn_rx.c @@ -285,8 +285,18 @@ rtwn_rx_common(struct rtwn_softc *sc, struct mbuf *m, void *desc) rxs.c_pktflags |= IEEE80211_RX_F_FAIL_FCSCRC; rxs.r_flags |= IEEE80211_R_TSF_START; /* XXX undocumented */ - rxs.r_flags |= IEEE80211_R_TSF64; - rxs.c_rx_tsf = rtwn_extend_rx_tsf(sc, stat); + + /* +* Doing the TSF64 extension on USB is expensive, especially +* if it's being done on every MPDU in an AMPDU burst. +*/ + if (sc->sc_ena_tsf64) { + rxs.r_flags |= IEEE80211_R_TSF64; + rxs.c_rx_tsf = rtwn_extend_rx_tsf(sc, stat); + } else { + rxs.r_flags |= IEEE80211_R_TSF32; + rxs.c_rx_tsf = le32toh(stat->tsf_low); + } /* Get RSSI from PHY status descriptor. */ is_cck = (rxs.c_pktflags & IEEE80211_RX_F_CCK) != 0; diff --git a/sys/dev/rtwn/if_rtwnvar.h b/sys/dev/rtwn/if_rtwnvar.h index 3d4db0a37a9e..d4458384dbd7 100644 --- a/sys/dev/rtwn/if_rtwnvar.h +++ b/sys/dev/rtwn/if_rtwnvar.h @@ -172,6 +172,7 @@ struct rtwn_softc { device_tsc_dev; int sc_ht40; + int sc_ena_tsf64; uint32_tsc_debug; int sc_hwcrypto; int sc_ratectl_sysctl;
git: d76247e801de - main - rtwn: enable FCS in the recive config to work around truncated frames
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=d76247e801dec95600a068fa1bb09f4f57e00031 commit d76247e801dec95600a068fa1bb09f4f57e00031 Author: Adrian Chadd AuthorDate: 2024-11-27 00:59:15 + Commit: Adrian Chadd CommitDate: 2024-12-05 07:27:03 + rtwn: enable FCS in the recive config to work around truncated frames I noticed that on RTL8812AU/RTL8821AU receiving VHT frames that I'd occasionally see frames missing the last 4 bytes. I can easily reproduce it with a ping sweep and fast (10ms) between frames. There's also a report of an earlier NIC (RTL8188EU) doing the same thing with HT frames but not with OFDM (11g) frames. After a bunch of poking, it turns out a driver where things DID work properly for the other report kept FCS enabled, and trimmed it from the frame before pushing it up to the network layer. I did the same and it also worked fine. The other solution was to disable PHYSTATUS notifications, but then we'd get no per packet RX notifications (RX rate, RSSI, etc.) Locally tested: * RTL8192EU, STA mode (HT) * RTL8812AU, STA mode (HT, VHT) * RTL8821AU, STA mode (HT, VHT) Differential Revision: https://reviews.freebsd.org/D47775 --- sys/dev/rtwn/if_rtwn_rx.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sys/dev/rtwn/if_rtwn_rx.c b/sys/dev/rtwn/if_rtwn_rx.c index 762472eca440..ebfb8e67ec6d 100644 --- a/sys/dev/rtwn/if_rtwn_rx.c +++ b/sys/dev/rtwn/if_rtwn_rx.c @@ -318,6 +318,10 @@ rtwn_rx_common(struct rtwn_softc *sc, struct mbuf *m, void *desc) /* Drop PHY descriptor. */ m_adj(m, infosz + shift); + /* If APPFCS, drop FCS */ + if (sc->rcr & R92C_RCR_APPFCS) + m_adj(m, -IEEE80211_CRC_LEN); + return (ni); } @@ -456,6 +460,15 @@ rtwn_rxfilter_init(struct rtwn_softc *sc) R92C_RCR_HTC_LOC_CTRL | R92C_RCR_APP_PHYSTS | R92C_RCR_APP_ICV | R92C_RCR_APP_MIC; + /* +* Add FCS, to work around occasional 4 byte truncation +* with some frames. This is more problematic on RTL8812/ +* RTL8821 because they're also doing L3/L4 checksum offload +* and hardware encryption, so both are tagged as "passed" +* before the frame is truncated. +*/ + sc->rcr |= R92C_RCR_APPFCS; + /* Update dynamic Rx filter parts. */ rtwn_rxfilter_update(sc); } @@ -487,7 +500,7 @@ rtwn_set_promisc(struct rtwn_softc *sc) RTWN_ASSERT_LOCKED(sc); mask_all = R92C_RCR_ACF | R92C_RCR_ADF | R92C_RCR_AMF | R92C_RCR_AAP; - mask_min = R92C_RCR_APM; + mask_min = R92C_RCR_APM | R92C_RCR_APPFCS; if (sc->bcn_vaps == 0) mask_min |= R92C_RCR_CBSSID_BCN;
git: 77e64f45c478 - main - rtwn: use ieee80211_ht_get_node_ampdu_density(), fix programming MAX_AGG
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=77e64f45c47827987b84a2e5bf3e9f6a2a52bda8 commit 77e64f45c47827987b84a2e5bf3e9f6a2a52bda8 Author: Adrian Chadd AuthorDate: 2024-11-26 16:59:11 + Commit: Adrian Chadd CommitDate: 2024-12-05 07:26:35 + rtwn: use ieee80211_ht_get_node_ampdu_density(), fix programming MAX_AGG * use ieee80211_ht_get_node_ampdu_density() now instead of the vap->iv_ampdu_density, so the correct density is used in AP/IBSS/mesh modes. * MAX_AGG controls how many frames are to be sent in an A-MPDU. It maps to ((MAX_AGG * 2) + 1) == npackets. 0x1f (31) means 64 packets. So, instead of hard-coding 0x1f, use the negotiated block-ack window size. Differential Revision: https://reviews.freebsd.org/D47766 --- sys/dev/rtwn/rtl8192c/r92c_tx.c | 26 -- sys/dev/rtwn/rtl8812a/r12a_tx.c | 26 -- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/sys/dev/rtwn/rtl8192c/r92c_tx.c b/sys/dev/rtwn/rtl8192c/r92c_tx.c index b8c26d861a14..a3e92e1b7ebb 100644 --- a/sys/dev/rtwn/rtl8192c/r92c_tx.c +++ b/sys/dev/rtwn/rtl8192c/r92c_tx.c @@ -221,6 +221,28 @@ r92c_tx_setup_macid(void *buf, int id) txd->txdw4 &= ~htole32(R92C_TXDW4_RTS_SHORT); } +static int +r92c_calculate_tx_agg_window(struct rtwn_softc *sc, +const struct ieee80211_node *ni, int tid) +{ + const struct ieee80211_tx_ampdu *tap; + int wnd; + + tap = &ni->ni_tx_ampdu[tid]; + + /* +* BAW is (MAX_AGG * 2) + 1, hence the /2 here. +* Ensure we don't send 0 or more than 64. +*/ + wnd = tap->txa_wnd / 2; + if (wnd == 0) + wnd = 1; + else if (wnd > 0x1f) + wnd = 0x1f; + + return (wnd); +} + void r92c_fill_tx_desc(struct rtwn_softc *sc, struct ieee80211_node *ni, struct mbuf *m, void *buf, uint8_t ridx, int maxretry) @@ -276,9 +298,9 @@ r92c_fill_tx_desc(struct rtwn_softc *sc, struct ieee80211_node *ni, (m->m_flags & M_AMPDU_MPDU) != 0); if (m->m_flags & M_AMPDU_MPDU) { txd->txdw2 |= htole32(SM(R92C_TXDW2_AMPDU_DEN, - vap->iv_ampdu_density)); + ieee80211_ht_get_node_ampdu_density(ni))); txd->txdw6 |= htole32(SM(R92C_TXDW6_MAX_AGG, - 0x1f)); /* XXX */ + r92c_calculate_tx_agg_window(sc, ni, tid))); } if (sc->sc_ratectl == RTWN_RATECTL_NET80211) { txd->txdw2 |= htole32(R92C_TXDW2_CCX_RPT); diff --git a/sys/dev/rtwn/rtl8812a/r12a_tx.c b/sys/dev/rtwn/rtl8812a/r12a_tx.c index 8cee2a16fbd5..6102a0567e74 100644 --- a/sys/dev/rtwn/rtl8812a/r12a_tx.c +++ b/sys/dev/rtwn/rtl8812a/r12a_tx.c @@ -229,6 +229,28 @@ r12a_tx_set_ldpc(struct rtwn_softc *sc, struct r12a_tx_desc *txd, txd->txdw5 |= htole32(R12A_TXDW5_DATA_LDPC); } +static int +r12a_calculate_tx_agg_window(struct rtwn_softc *sc, +const struct ieee80211_node *ni, int tid) +{ + const struct ieee80211_tx_ampdu *tap; + int wnd; + + tap = &ni->ni_tx_ampdu[tid]; + + /* +* BAW is (MAX_AGG * 2) + 1, hence the /2 here. +* Ensure we don't send 0 or more than 64. +*/ + wnd = tap->txa_wnd / 2; + if (wnd == 0) + wnd = 1; + else if (wnd > 0x1f) + wnd = 0x1f; + + return (wnd); +} + void r12a_fill_tx_desc(struct rtwn_softc *sc, struct ieee80211_node *ni, struct mbuf *m, void *buf, uint8_t ridx, int maxretry) @@ -280,9 +302,9 @@ r12a_fill_tx_desc(struct rtwn_softc *sc, struct ieee80211_node *ni, if (m->m_flags & M_AMPDU_MPDU) { txd->txdw2 |= htole32(R12A_TXDW2_AGGEN); txd->txdw2 |= htole32(SM(R12A_TXDW2_AMPDU_DEN, - vap->iv_ampdu_density)); + ieee80211_ht_get_node_ampdu_density(ni))); txd->txdw3 |= htole32(SM(R12A_TXDW3_MAX_AGG, - 0x1f)); /* XXX */ + r12a_calculate_tx_agg_window(sc, ni, tid))); } else txd->txdw2 |= htole32(R12A_TXDW2_AGGBK);
git: 05c3851b20e0 - main - rtwn: enable receiving AMSDU in AMPDU
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=05c3851b20e0c9036f8252fa3056df23d72369bb commit 05c3851b20e0c9036f8252fa3056df23d72369bb Author: Adrian Chadd AuthorDate: 2024-11-27 04:39:09 + Commit: Adrian Chadd CommitDate: 2024-12-05 07:27:12 + rtwn: enable receiving AMSDU in AMPDU All of the supported NICs should support this. Locally tested: * RTL8192CU, STA mode * RTL8192EU, STA mode * RTL8821AU, STA mode * RTL8812AU, STA mode Differential Revision: https://reviews.freebsd.org/D47776 --- sys/dev/rtwn/if_rtwn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/dev/rtwn/if_rtwn.c b/sys/dev/rtwn/if_rtwn.c index 4334d5700e51..df18dc54ed3f 100644 --- a/sys/dev/rtwn/if_rtwn.c +++ b/sys/dev/rtwn/if_rtwn.c @@ -247,6 +247,7 @@ rtwn_attach(struct rtwn_softc *sc) | IEEE80211_HTCAP_SMPS_OFF /* SM PS mode disabled */ /* s/w capabilities */ | IEEE80211_HTC_HT /* HT operation */ + | IEEE80211_HTC_RX_AMSDU_AMPDU /* A-MSDU in A-MPDU */ | IEEE80211_HTC_AMPDU /* A-MPDU tx */ | IEEE80211_HTC_AMSDU /* A-MSDU tx */ ;
git: 6749f059a586 - main - rtwn: use ieee80211_ht_check_tx_shortgi_20() and ieee80211_ht_check_tx_shortgi_40()
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=6749f059a586ff62f2909134c4f4599c82fabc5e commit 6749f059a586ff62f2909134c4f4599c82fabc5e Author: Adrian Chadd AuthorDate: 2024-11-25 23:20:42 + Commit: Adrian Chadd CommitDate: 2024-12-03 22:46:46 + rtwn: use ieee80211_ht_check_tx_shortgi_20() and ieee80211_ht_check_tx_shortgi_40() Use the new net80211 routines rather than rolling our own. (The first version of this diff landed a previous version of what was reviewed, so this brings it up to what was finally accepted in the review.) Differential Revision: https://reviews.freebsd.org/D47751 Reviewed by:bz --- sys/dev/rtwn/rtl8192c/r92c_tx.c | 20 ++-- sys/dev/rtwn/rtl8812a/r12a_tx.c | 20 ++-- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/sys/dev/rtwn/rtl8192c/r92c_tx.c b/sys/dev/rtwn/rtl8192c/r92c_tx.c index 5c8b2e114727..b8c26d861a14 100644 --- a/sys/dev/rtwn/rtl8192c/r92c_tx.c +++ b/sys/dev/rtwn/rtl8192c/r92c_tx.c @@ -172,12 +172,20 @@ r92c_tx_set_sgi(struct rtwn_softc *sc, void *buf, struct ieee80211_node *ni) { struct r92c_tx_desc *txd = (struct r92c_tx_desc *)buf; - if (IEEE80211_IS_CHAN_HT40(ni->ni_chan) - && ieee80211_ht_check_tx_shortgi_40(ni)) - txd->txdw5 |= htole32(R92C_TXDW5_SGI); - else if (IEEE80211_IS_CHAN_HT20(ni->ni_chan) - && ieee80211_ht_check_tx_shortgi_20(ni)) - txd->txdw5 |= htole32(R92C_TXDW5_SGI); + /* +* Only enable short-GI if we're transmitting in that +* width to that node. +* +* Specifically, do not enable shortgi for 20MHz if +* we're attempting to transmit at 40MHz. +*/ + if (ieee80211_ht_check_tx_ht40(ni)) { + if (ieee80211_ht_check_tx_shortgi_40(ni)) + txd->txdw5 |= htole32(R92C_TXDW5_SGI); + } else if (ieee80211_ht_check_tx_ht(ni)) { + if (ieee80211_ht_check_tx_shortgi_20(ni)) + txd->txdw5 |= htole32(R92C_TXDW5_SGI); + } } void diff --git a/sys/dev/rtwn/rtl8812a/r12a_tx.c b/sys/dev/rtwn/rtl8812a/r12a_tx.c index 7a8a7d3679b1..8cee2a16fbd5 100644 --- a/sys/dev/rtwn/rtl8812a/r12a_tx.c +++ b/sys/dev/rtwn/rtl8812a/r12a_tx.c @@ -202,12 +202,20 @@ r12a_tx_set_sgi(struct rtwn_softc *sc, void *buf, struct ieee80211_node *ni) /* TODO: VHT 20/40/80 checks */ - if (IEEE80211_IS_CHAN_HT40(ni->ni_chan) - && ieee80211_ht_check_tx_shortgi_40(ni)) - txd->txdw5 |= htole32(R12A_TXDW5_DATA_SHORT); - else if (IEEE80211_IS_CHAN_HT20(ni->ni_chan) - && ieee80211_ht_check_tx_shortgi_20(ni)) - txd->txdw5 |= htole32(R12A_TXDW5_DATA_SHORT); + /* +* Only enable short-GI if we're transmitting in that +* width to that node. +* +* Specifically, do not enable shortgi for 20MHz if +* we're attempting to transmit at 40MHz. +*/ + if (ieee80211_ht_check_tx_ht40(ni)) { + if (ieee80211_ht_check_tx_shortgi_40(ni)) + txd->txdw5 |= htole32(R12A_TXDW5_DATA_SHORT); + } else if (ieee80211_ht_check_tx_ht(ni)) { + if (ieee80211_ht_check_tx_shortgi_20(ni)) + txd->txdw5 |= htole32(R12A_TXDW5_DATA_SHORT); + } } static void
git: e1eff81ea99c - main - rtwn: use ieee80211_ht_check_tx_shortgi_20() and ieee80211_ht_check_tx_shortgi_40()
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=e1eff81ea99c1000ad74436a54c54ec9e777282a commit e1eff81ea99c1000ad74436a54c54ec9e777282a Author: Adrian Chadd AuthorDate: 2024-11-25 23:20:42 + Commit: Adrian Chadd CommitDate: 2024-12-03 22:10:49 + rtwn: use ieee80211_ht_check_tx_shortgi_20() and ieee80211_ht_check_tx_shortgi_40() Use the new net80211 routines rather than rolling our own. Differential Revision: https://reviews.freebsd.org/D47751 Reviewed by: bz --- sys/dev/rtwn/rtl8192c/r92c_tx.c | 11 --- sys/dev/rtwn/rtl8812a/r12a_tx.c | 13 ++--- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/sys/dev/rtwn/rtl8192c/r92c_tx.c b/sys/dev/rtwn/rtl8192c/r92c_tx.c index 15beca776b61..5c8b2e114727 100644 --- a/sys/dev/rtwn/rtl8192c/r92c_tx.c +++ b/sys/dev/rtwn/rtl8192c/r92c_tx.c @@ -171,15 +171,12 @@ static void r92c_tx_set_sgi(struct rtwn_softc *sc, void *buf, struct ieee80211_node *ni) { struct r92c_tx_desc *txd = (struct r92c_tx_desc *)buf; - struct ieee80211vap *vap = ni->ni_vap; - if ((vap->iv_flags_ht & IEEE80211_FHT_SHORTGI20) && /* HT20 */ - (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20)) + if (IEEE80211_IS_CHAN_HT40(ni->ni_chan) + && ieee80211_ht_check_tx_shortgi_40(ni)) txd->txdw5 |= htole32(R92C_TXDW5_SGI); - else if (ni->ni_chan != IEEE80211_CHAN_ANYC && /* HT40 */ - IEEE80211_IS_CHAN_HT40(ni->ni_chan) && - (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40) && - (vap->iv_flags_ht & IEEE80211_FHT_SHORTGI40)) + else if (IEEE80211_IS_CHAN_HT20(ni->ni_chan) + && ieee80211_ht_check_tx_shortgi_20(ni)) txd->txdw5 |= htole32(R92C_TXDW5_SGI); } diff --git a/sys/dev/rtwn/rtl8812a/r12a_tx.c b/sys/dev/rtwn/rtl8812a/r12a_tx.c index 9e0d8e85c0cf..7a8a7d3679b1 100644 --- a/sys/dev/rtwn/rtl8812a/r12a_tx.c +++ b/sys/dev/rtwn/rtl8812a/r12a_tx.c @@ -199,15 +199,14 @@ static void r12a_tx_set_sgi(struct rtwn_softc *sc, void *buf, struct ieee80211_node *ni) { struct r12a_tx_desc *txd = (struct r12a_tx_desc *)buf; - struct ieee80211vap *vap = ni->ni_vap; - if ((vap->iv_flags_ht & IEEE80211_FHT_SHORTGI20) && /* HT20 */ - (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20)) + /* TODO: VHT 20/40/80 checks */ + + if (IEEE80211_IS_CHAN_HT40(ni->ni_chan) + && ieee80211_ht_check_tx_shortgi_40(ni)) txd->txdw5 |= htole32(R12A_TXDW5_DATA_SHORT); - else if (ni->ni_chan != IEEE80211_CHAN_ANYC && /* HT40 */ - IEEE80211_IS_CHAN_HT40(ni->ni_chan) && - (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40) && - (vap->iv_flags_ht & IEEE80211_FHT_SHORTGI40)) + else if (IEEE80211_IS_CHAN_HT20(ni->ni_chan) + && ieee80211_ht_check_tx_shortgi_20(ni)) txd->txdw5 |= htole32(R12A_TXDW5_DATA_SHORT); }
git: 791170aaf7ef - main - rtwn: make sure RCR_APPFCS stays set in monitor mode / mode changes.
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=791170aaf7efb4e053ccbf537d80a43e8a81d1e4 commit 791170aaf7efb4e053ccbf537d80a43e8a81d1e4 Author: Adrian Chadd AuthorDate: 2024-12-16 20:09:56 + Commit: Adrian Chadd CommitDate: 2024-12-28 01:46:38 + rtwn: make sure RCR_APPFCS stays set in monitor mode / mode changes. My previous commit meant that APPFCS wasn't enabled during monitor mode and likely other corner cases. Ensure it stays on at all times. This, amusingly, fixes monitor mode in RTL8812AU/RTL8821AU - without it, I don't see HT/VHT frames in monitor mode but I can still receive them in normal STA mode. Differential Revision: https://reviews.freebsd.org/D48112 --- sys/dev/rtwn/if_rtwn_rx.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/dev/rtwn/if_rtwn_rx.c b/sys/dev/rtwn/if_rtwn_rx.c index b1465dd80ee7..e5ddc7a3cb97 100644 --- a/sys/dev/rtwn/if_rtwn_rx.c +++ b/sys/dev/rtwn/if_rtwn_rx.c @@ -532,7 +532,7 @@ rtwn_set_promisc(struct rtwn_softc *sc) RTWN_ASSERT_LOCKED(sc); mask_all = R92C_RCR_ACF | R92C_RCR_ADF | R92C_RCR_AMF | R92C_RCR_AAP; - mask_min = R92C_RCR_APM | R92C_RCR_APPFCS; + mask_min = R92C_RCR_APM; if (sc->bcn_vaps == 0) mask_min |= R92C_RCR_CBSSID_BCN; @@ -551,5 +551,12 @@ rtwn_set_promisc(struct rtwn_softc *sc) sc->rcr &= ~mask_min; sc->rcr |= mask_all; } + + /* +* Add FCS, to work around occasional 4 byte truncation. +* See the previous comment above R92C_RCR_APPFCS. +*/ + sc->rcr |= R92C_RCR_APPFCS; + rtwn_rxfilter_set(sc); }
git: 64ecfc27dbd4 - main - rtwn: add forcerate flag to TX descriptor setup
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=64ecfc27dbd486ed764f9696b6e56f88e34ee8a1 commit 64ecfc27dbd486ed764f9696b6e56f88e34ee8a1 Author: Adrian Chadd AuthorDate: 2024-12-16 01:28:30 + Commit: Adrian Chadd CommitDate: 2025-01-03 01:24:01 + rtwn: add forcerate flag to TX descriptor setup When doing firmware rate control there will be situations where the rate being passed in needs to actually override the rate control selection. So add a flag to the descriptor setup path to indicate that indeed this particular rate should be forced, rather than rely on the firmware rate control. This is currently a no-op as firmware rate control isn't working in-tree, but it is working for me locally with other changes. Without this, there's no way to force low rates for management, DHCP traffic, and to allow fixed rate via "ifconfig wlanX ucastrate Y" to function. Locally tested: * RTL8192CU, STA mode (firmware and driver/net80211 rate control) Differential Revision: https://reviews.freebsd.org/D48100 Reviewed by:bz, gavin --- sys/dev/rtwn/if_rtwn_tx.c | 14 +- sys/dev/rtwn/if_rtwnvar.h | 6 +++--- sys/dev/rtwn/rtl8192c/r92c.h| 2 +- sys/dev/rtwn/rtl8192c/r92c_tx.c | 2 +- sys/dev/rtwn/rtl8812a/r12a.h| 2 +- sys/dev/rtwn/rtl8812a/r12a_tx.c | 2 +- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/sys/dev/rtwn/if_rtwn_tx.c b/sys/dev/rtwn/if_rtwn_tx.c index bf45d14f7edc..c59d1de1dea8 100644 --- a/sys/dev/rtwn/if_rtwn_tx.c +++ b/sys/dev/rtwn/if_rtwn_tx.c @@ -117,6 +117,7 @@ rtwn_tx_data(struct rtwn_softc *sc, struct ieee80211_node *ni, struct rtwn_tx_desc_common *txd; struct rtwn_tx_buf buf; uint8_t rate, ridx, type; + bool force_rate = false; u_int cipher; int ismcast; @@ -129,13 +130,16 @@ rtwn_tx_data(struct rtwn_softc *sc, struct ieee80211_node *ni, /* Choose a TX rate index. */ if (type == IEEE80211_FC0_TYPE_MGT || type == IEEE80211_FC0_TYPE_CTL || - (m->m_flags & M_EAPOL) != 0) + (m->m_flags & M_EAPOL) != 0) { rate = tp->mgmtrate; - else if (ismcast) + force_rate = true; + } else if (ismcast) { + force_rate = true; rate = tp->mcastrate; - else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) + } else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) { + force_rate = true; rate = tp->ucastrate; - else { + } else { if (sc->sc_ratectl == RTWN_RATECTL_NET80211) { /* XXX pass pktlen */ (void) ieee80211_ratectl_rate(ni, NULL, 0); @@ -172,7 +176,7 @@ rtwn_tx_data(struct rtwn_softc *sc, struct ieee80211_node *ni, memset(txd, 0, sc->txdesc_len); txd->txdw1 = htole32(SM(RTWN_TXDW1_CIPHER, rtwn_get_cipher(cipher))); - rtwn_fill_tx_desc(sc, ni, m, txd, ridx, tp->maxretry); + rtwn_fill_tx_desc(sc, ni, m, txd, ridx, force_rate, tp->maxretry); if (ieee80211_radiotap_active_vap(vap)) { struct rtwn_tx_radiotap_header *tap = &sc->sc_txtap; diff --git a/sys/dev/rtwn/if_rtwnvar.h b/sys/dev/rtwn/if_rtwnvar.h index 3913526f8c3c..fa4b6d0a5df7 100644 --- a/sys/dev/rtwn/if_rtwnvar.h +++ b/sys/dev/rtwn/if_rtwnvar.h @@ -319,7 +319,7 @@ struct rtwn_softc { void(*sc_detach_private)(struct rtwn_softc *); void(*sc_fill_tx_desc)(struct rtwn_softc *, struct ieee80211_node *, struct mbuf *, - void *, uint8_t, int); + void *, uint8_t, bool, int); void(*sc_fill_tx_desc_raw)(struct rtwn_softc *, struct ieee80211_node *, struct mbuf *, void *, const struct ieee80211_bpf_params *); @@ -527,9 +527,9 @@ voidrtwn_suspend(struct rtwn_softc *); #define rtwn_detach_private(_sc) \ (((_sc)->sc_detach_private)((_sc))) #define rtwn_fill_tx_desc(_sc, _ni, _m, \ - _buf, _ridx, _maxretry) \ + _buf, _ridx, _force, _maxretry) \ (((_sc)->sc_fill_tx_desc)((_sc), (_ni), \ - (_m), (_buf), (_ridx), (_maxretry))) + (_m), (_buf), (_ridx), (_force), (_maxretry))) #define rtwn_fill_tx_desc_raw(_sc, _ni, _m, \ _buf, _params) \ (((_sc)->sc_fill_tx_desc_raw)((_sc), (_ni), \ diff --git a/sys/dev/rtwn/rtl8192c/r92c.h b/sys/dev/rtwn/rtl8192c/r92c.h index a7091be66f64..cab7393caf39 100644 --- a/sys/dev/rtwn/rtl8192c/r92c.h +++ b/sys/dev/rtwn/rtl8192c/r92c.h @@ -117,7 +117,7 @@ voidr92c_tx_enable_ampdu(void *, int); void r92c_tx_setup_hwseq(void *); void r92c_tx
git: 4fad98b5c8d7 - main - rtwn: remove SEQ_SEL, replace with a QOS bit
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=4fad98b5c8d77c771c2dd14e3d4ce517b4bb92d9 commit 4fad98b5c8d77c771c2dd14e3d4ce517b4bb92d9 Author: Adrian Chadd AuthorDate: 2024-12-15 18:11:57 + Commit: Adrian Chadd CommitDate: 2024-12-31 01:35:13 + rtwn: remove SEQ_SEL, replace with a QOS bit I've reviewed all of the linux vendor and upstream drivers. This SEQ_SEL field isn't a mask and doesn't ever look like it it was; instead this bit is set to tag QoS data frames. In fact, it effectively was set to 0 for STA frames and potentially 1 for broadcast/multicast frames as the STA macid of 0 and broadcast/ multicast macid of 1 maps to that. In AP modes it would be tagged based on bit 0. So, bring it in line with the vendor and linux drivers. Locally tested: * RTL8192CU, STA, hostap * RTL8188EU, STA * RTL8192EU, STA Differential Revision: https://reviews.freebsd.org/D48092 --- sys/dev/rtwn/rtl8192c/r92c_beacon.c | 1 - sys/dev/rtwn/rtl8192c/r92c_tx.c | 12 ++-- sys/dev/rtwn/rtl8192c/r92c_tx_desc.h | 3 +-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/sys/dev/rtwn/rtl8192c/r92c_beacon.c b/sys/dev/rtwn/rtl8192c/r92c_beacon.c index 8084d5b69438..4646b9317c2f 100644 --- a/sys/dev/rtwn/rtl8192c/r92c_beacon.c +++ b/sys/dev/rtwn/rtl8192c/r92c_beacon.c @@ -64,7 +64,6 @@ r92c_beacon_init(struct rtwn_softc *sc, void *buf, int id) rtwn_r92c_tx_setup_macid(sc, buf, id); txd->txdw4 |= htole32(R92C_TXDW4_DRVRATE); - txd->txdw4 |= htole32(SM(R92C_TXDW4_SEQ_SEL, id)); txd->txdw4 |= htole32(SM(R92C_TXDW4_PORT_ID, id)); txd->txdw5 |= htole32(SM(R92C_TXDW5_DATARATE, RTWN_RIDX_CCK1)); } diff --git a/sys/dev/rtwn/rtl8192c/r92c_tx.c b/sys/dev/rtwn/rtl8192c/r92c_tx.c index 313f79e216e6..c60081fc675c 100644 --- a/sys/dev/rtwn/rtl8192c/r92c_tx.c +++ b/sys/dev/rtwn/rtl8192c/r92c_tx.c @@ -272,7 +272,13 @@ r92c_fill_tx_desc(struct rtwn_softc *sc, struct ieee80211_node *ni, if (ismcast) txd->flags0 |= R92C_FLAGS0_BMCAST; + if (IEEE80211_IS_QOSDATA(wh)) + txd->txdw4 |= htole32(R92C_TXDW4_QOS); + if (!ismcast) { + struct rtwn_node *un = RTWN_NODE(ni); + macid = un->id; + /* Unicast frame, check if an ACK is expected. */ if (!qos || (qos & IEEE80211_QOS_ACKPOLICY) != IEEE80211_QOS_ACKPOLICY_NOACK) { @@ -281,9 +287,6 @@ r92c_fill_tx_desc(struct rtwn_softc *sc, struct ieee80211_node *ni, maxretry)); } - struct rtwn_node *un = RTWN_NODE(ni); - macid = un->id; - if (type == IEEE80211_FC0_TYPE_DATA) { qsel = tid % RTWN_MAX_TID; @@ -348,7 +351,6 @@ r92c_fill_tx_desc(struct rtwn_softc *sc, struct ieee80211_node *ni, if (!hasqos) { /* Use HW sequence numbering for non-QoS frames. */ rtwn_r92c_tx_setup_hwseq(sc, txd); - txd->txdw4 |= htole32(SM(R92C_TXDW4_SEQ_SEL, uvp->id)); } else { uint16_t seqno; @@ -409,7 +411,6 @@ r92c_fill_tx_desc_raw(struct rtwn_softc *sc, struct ieee80211_node *ni, if (!IEEE80211_QOS_HAS_SEQ(wh)) { /* Use HW sequence numbering for non-QoS frames. */ rtwn_r92c_tx_setup_hwseq(sc, txd); - txd->txdw4 |= htole32(SM(R92C_TXDW4_SEQ_SEL, uvp->id)); } else { /* Set sequence number. */ txd->txdseq |= htole16(M_SEQNO_GET(m) % IEEE80211_SEQ_RANGE); @@ -438,7 +439,6 @@ r92c_fill_tx_desc_null(struct rtwn_softc *sc, void *buf, int is11b, if (!qos) { rtwn_r92c_tx_setup_hwseq(sc, txd); - txd->txdw4 |= htole32(SM(R92C_TXDW4_SEQ_SEL, id)); } } diff --git a/sys/dev/rtwn/rtl8192c/r92c_tx_desc.h b/sys/dev/rtwn/rtl8192c/r92c_tx_desc.h index 6e546c3da236..33edb975f062 100644 --- a/sys/dev/rtwn/rtl8192c/r92c_tx_desc.h +++ b/sys/dev/rtwn/rtl8192c/r92c_tx_desc.h @@ -69,8 +69,7 @@ struct r92c_tx_desc { uint32_ttxdw4; #define R92C_TXDW4_RTSRATE_M 0x001f #define R92C_TXDW4_RTSRATE_S 0 -#define R92C_TXDW4_SEQ_SEL_M 0x0040 -#define R92C_TXDW4_SEQ_SEL_S 6 +#define R92C_TXDW4_QOS 0x0040 /* BIT(6) for 8188cu/8192cu/8723au */ #define R92C_TXDW4_HWSEQ_EN0x0080 #define R92C_TXDW4_DRVRATE 0x0100 #define R92C_TXDW4_CTS2SELF0x0800
Re: git: 0f1bf1c22a0c - main - umb: Introduce the USB umb(4) network driver
On Fri, 31 Jan 2025 at 15:31, Bjoern A. Zeeb wrote: > On Mon, 20 Jan 2025, Adrian Chadd wrote: > > > The branch main has been updated by adrian: > > > > URL: > https://cgit.FreeBSD.org/src/commit/?id=0f1bf1c22a0c97e84a4db19197a75952487aa20b > > > > commit 0f1bf1c22a0c97e84a4db19197a75952487aa20b > > Author: Adrian Chadd > > AuthorDate: 2025-01-20 23:46:15 + > > Commit: Adrian Chadd > > CommitDate: 2025-01-20 23:46:15 + > > > >umb: Introduce the USB umb(4) network driver > > Still breaks at least: > amd64 MINIMAL kernel failed, check _.amd64.MINIMAL for details > amd64 MINIMALUP kernel failed, check _.amd64.MINIMALUP for details > It wasn't broken when it landed, I did a universe pass. -- >>> Kernel build for MINIMAL completed on Tue Jan 21 08:18:12 UTC 2025 -- >>> Kernel(s) MINIMAL built in 892 seconds, ncpu: 32, make -j16 -- I'll go update the tree and start again.
git: b71805e991fb - main - rtwn: add APIs for setting transmit power
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=b71805e991fb955005640bdec81618e37d3af47c commit b71805e991fb955005640bdec81618e37d3af47c Author: Adrian Chadd AuthorDate: 2024-12-07 16:32:04 + Commit: Adrian Chadd CommitDate: 2024-12-18 23:45:24 + 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 --- sys/dev/rtwn/if_rtwn.c | 9 + sys/dev/rtwn/if_rtwn_nop.h | 6 ++ sys/dev/rtwn/if_rtwnvar.h| 4 sys/dev/rtwn/rtl8188e/pci/r88ee_attach.c | 1 + sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c | 1 + sys/dev/rtwn/rtl8192c/pci/r92ce_attach.c | 1 + sys/dev/rtwn/rtl8192c/usb/r92cu_attach.c | 1 + sys/dev/rtwn/rtl8192e/usb/r92eu_attach.c | 1 + sys/dev/rtwn/rtl8812a/usb/r12au_attach.c | 1 + sys/dev/rtwn/rtl8821a/usb/r21au_attach.c | 1 + 10 files changed, 26 insertions(+) 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 @@ voidrtwn_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(str