From nobody Mon Feb 19 08:07:50 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TdZsL4lQVz5B2s5; Mon, 19 Feb 2024 08:07:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TdZsL3Tczz4K80; Mon, 19 Feb 2024 08:07:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708330070; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wof61PzbTtoyrZ84qMYmRSMOugP82pTgO0Mbh2wPJvg=; b=F8LFRbxOG4mrzL88Ywzq817XynN4RO5BSAFg3f5FF3Ks1zJPcdCIlFR5YSaTrVNbiWFMq+ MKC/j2bm4tjLXCnUZmPspWfUb0ncrO7yw+ysOPKygerxP1Pq2DKNc7FBmM4Z5FIjoyn82l COAR71ekfsq8NkbfBe7RWFWqvBo7sxeN6nw68KnEkjnN7mw6+empa8mr/iqS5ozKdGwx4p ko8yAnAaQkG2tcMx4MVdVoEpJvwsRXMVOTWd22k5yEIi+baIqluCBzvLUz+7Npuc5+e7XN 3p3Ng0cajV73DrPI95lR4jQIUOEjbOh8XiwtJ2qi/oLyP9x9RFBvKtylSjt6IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708330070; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wof61PzbTtoyrZ84qMYmRSMOugP82pTgO0Mbh2wPJvg=; b=abOcKCffUjIME+iRvkKzjgSEBcSwBkqIE5x1Yk9yfo+W81iOSdtVjmYdjK4FAII/nYShXa Ed+6a2vDD73i0Bwnho4et4EmY7BnNAyhcbRJB5Q1EVdnWFbqkWToUPsDz4B4A9MpdZrb2G Z+Qn44/VyE4TOkbIxSyUU558zMWSbaPaQvvWoR+RrGNomGNZ8VnbyQodrU7ZnYqFfODQm3 dSKIscIR3LA7m8ujcyg6gA0tnLNTpx5OxDra00lUV4KTt23f3dMvgWrPGHfSvUmSS4pA0Q CtxXZjMPWZP8gdPAEV3/ritdi5oPRlWlL5A+KbrPSNDIwxgXqzwzochM/3c2YQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708330070; a=rsa-sha256; cv=none; b=MrIY2RPfL/goHTB082Eo4N72Di5lBl6tLHYhVH2E533SvD69MJZpSPlH14tB48QJujzyOP 86VQ96fCqVq1iMlxrjUHxXithqsx/wUTDZROf2eIPVOIZcuB/txzGf6c0bSjJt97PcDb09 dT7Zkbi+pUTn3wwTnUE7b0cU25jz4ZbRVD3SIU43/cvx6uantruhOPXGdehoiO7SYHPqEf o8cZML7UGFQaTOfQEM5sheWnk41onWElFg1hSoRRDTUYtnTQ9wjrx9moR32T8dkvAGUyvc mozLUYSnqfNLN5k0eF5T1wKPvg6Yc8xxUDB6xsUSNAifeUTRYGFC9fT39QwEmg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TdZsL2ZtCzRGf; Mon, 19 Feb 2024 08:07:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41J87ofn015873; Mon, 19 Feb 2024 08:07:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41J87oJp015870; Mon, 19 Feb 2024 08:07:50 GMT (envelope-from git) Date: Mon, 19 Feb 2024 08:07:50 GMT Message-Id: <202402190807.41J87oJp015870@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 9d5aef293d90 - stable/13 - net80211: adjust more VHT structures/fields List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9d5aef293d90de29adffed908ce391d799b1dae4 Auto-Submitted: auto-generated The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=9d5aef293d90de29adffed908ce391d799b1dae4 commit 9d5aef293d90de29adffed908ce391d799b1dae4 Author: Bjoern A. Zeeb AuthorDate: 2023-12-02 20:40:51 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-02-19 08:02:00 +0000 net80211: adjust more VHT structures/fields Replace ieee80211_ie_vhtcap with ieee80211_vht_cap and ieee80211_ie_vht_operation with ieee80211_vht_operation. The "ie" version has the two bytes type/length at the beginning which we did not actually use as such (the one place doing did just as unused extra work). Using the non-"ie" versions allows us to re-use them on shared code. Using an enum helps us to not accidentally get unsuppored or unhandled values tough we cannot use it in the struct as we need to ensure the field width. ieee80211_vht_operation is guarded by _KERNEL/WANT_NET80211. While the header is supposed to be exported to user land historically, software such as wpa bring their own structure definitions. For in-tree usage it is only ifconfig which really cares (at least for now). Sponsored by: The FreeBSD Foundation Reviewed by: adrian (earlier), cc Differential Revision: https://reviews.freebsd.org/D42901 (cherry picked from commit e85eb4c8d7bd8051c351a6fc6982a8b3bcfdbb2d) --- sbin/ifconfig/ifieee80211.c | 32 ++++++++++++++++++++++++-------- sys/net80211/ieee80211.h | 38 +++++++++++++++++--------------------- sys/net80211/ieee80211_hostap.c | 4 ++-- sys/net80211/ieee80211_input.c | 4 ++-- sys/net80211/ieee80211_output.c | 16 ++++++++-------- sys/net80211/ieee80211_vht.c | 23 ++++++----------------- sys/net80211/ieee80211_vht.h | 4 ++-- 7 files changed, 61 insertions(+), 60 deletions(-) diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c index bf54e7b6de70..0271fded95ba 100644 --- a/sbin/ifconfig/ifieee80211.c +++ b/sbin/ifconfig/ifieee80211.c @@ -70,6 +70,7 @@ #include #include +#define WANT_NET80211 1 #include #include #include @@ -2780,10 +2781,18 @@ printvhtcap(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) { printf("%s", tag); if (verbose) { - const struct ieee80211_ie_vhtcap *vhtcap = - (const struct ieee80211_ie_vhtcap *) ie; - uint32_t vhtcap_info = LE_READ_4(&vhtcap->vht_cap_info); + const struct ieee80211_vht_cap *vhtcap; + uint32_t vhtcap_info; + /* Check that the the right size. */ + if (ie[1] != sizeof(*vhtcap)) { + printf(""); + return; + } + /* Skip Element ID and Length. */ + vhtcap = (const struct ieee80211_vht_cap *)(ie + 2); + + vhtcap_info = LE_READ_4(&vhtcap->vht_cap_info); printf("supp_mcs.rx_mcs_map)); @@ -2803,13 +2812,20 @@ printvhtinfo(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) { printf("%s", tag); if (verbose) { - const struct ieee80211_ie_vht_operation *vhtinfo = - (const struct ieee80211_ie_vht_operation *) ie; + const struct ieee80211_vht_operation *vhtinfo; + + /* Check that the the right size. */ + if (ie[1] != sizeof(*vhtinfo)) { + printf(""); + return; + } + /* Skip Element ID and Length. */ + vhtinfo = (const struct ieee80211_vht_operation *)(ie + 2); - printf("", + printf("", vhtinfo->chan_width, - vhtinfo->center_freq_seg1_idx, - vhtinfo->center_freq_seg2_idx, + vhtinfo->center_freq_seq0_idx, + vhtinfo->center_freq_seq1_idx, LE_READ_2(&vhtinfo->basic_mcs_set)); } } diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h index cd69f72f5c51..e6533705811e 100644 --- a/sys/net80211/ieee80211.h +++ b/sys/net80211/ieee80211.h @@ -866,29 +866,25 @@ struct ieee80211_vht_cap { struct ieee80211_vht_mcs_info supp_mcs; } __packed; -/* VHT capabilities element: 802.11ac-2013 8.4.2.160 */ -struct ieee80211_ie_vhtcap { - uint8_t ie; - uint8_t len; - uint32_t vht_cap_info; - struct ieee80211_vht_mcs_info supp_mcs; -} __packed; - -/* VHT operation mode subfields - 802.11ac-2013 Table 8.183x */ -#define IEEE80211_VHT_CHANWIDTH_USE_HT 0 /* Use HT IE for chw */ -#define IEEE80211_VHT_CHANWIDTH_80MHZ 1 /* 80MHz */ -#define IEEE80211_VHT_CHANWIDTH_160MHZ 2 /* 160MHz */ -#define IEEE80211_VHT_CHANWIDTH_80P80MHZ 3 /* 80+80MHz */ +/* 802.11ac-2013, Table 8-183x-VHT Operation Information subfields */ +enum ieee80211_vht_chanwidth { + IEEE80211_VHT_CHANWIDTH_USE_HT = 0, /* 20 MHz or 40 MHz */ + IEEE80211_VHT_CHANWIDTH_80MHZ = 1, /* 80MHz */ + IEEE80211_VHT_CHANWIDTH_160MHZ = 2, /* 160MHz */ + IEEE80211_VHT_CHANWIDTH_80P80MHZ = 3, /* 80+80MHz */ + /* 4..255 reserved. */ +}; -/* VHT operation IE - 802.11ac-2013 8.4.2.161 */ -struct ieee80211_ie_vht_operation { - uint8_t ie; - uint8_t len; - uint8_t chan_width; - uint8_t center_freq_seg1_idx; - uint8_t center_freq_seg2_idx; - uint16_t basic_mcs_set; +/* The name conflicts with the same structure in wpa. Only ifconfig needs this. */ +#if defined(_KERNEL) || defined(WANT_NET80211) +/* 802.11ac-2013 8.4.2.161 VHT Operation element */ +struct ieee80211_vht_operation { + uint8_t chan_width; /* enum ieee80211_vht_chanwidth */ + uint8_t center_freq_seq0_idx; /* 20/40/80/160 - VHT chan1 */ + uint8_t center_freq_seq1_idx; /* 80+80 - VHT chan2 */ + uint16_t basic_mcs_set; /* Basic VHT-MCS and NSS Set */ } __packed; +#endif /* 802.11ac VHT Capabilities */ #define IEEE80211_VHTCAP_MAX_MPDU_LENGTH_3895 0x00000000 diff --git a/sys/net80211/ieee80211_hostap.c b/sys/net80211/ieee80211_hostap.c index d80d658317ed..2f6317d9d8de 100644 --- a/sys/net80211/ieee80211_hostap.c +++ b/sys/net80211/ieee80211_hostap.c @@ -2124,12 +2124,12 @@ hostap_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0, /* Validate VHT IEs */ if (vhtcap != NULL) { IEEE80211_VERIFY_LENGTH(vhtcap[1], - sizeof(struct ieee80211_ie_vhtcap) - 2, + sizeof(struct ieee80211_vht_cap), return); } if (vhtinfo != NULL) { IEEE80211_VERIFY_LENGTH(vhtinfo[1], - sizeof(struct ieee80211_ie_vht_operation) - 2, + sizeof(struct ieee80211_vht_operation), return); } diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c index 492a3038c971..a1db4a50c2ce 100644 --- a/sys/net80211/ieee80211_input.c +++ b/sys/net80211/ieee80211_input.c @@ -769,12 +769,12 @@ ieee80211_parse_beacon(struct ieee80211_node *ni, struct mbuf *m, /* Process VHT IEs */ if (scan->vhtcap != NULL) { IEEE80211_VERIFY_LENGTH(scan->vhtcap[1], - sizeof(struct ieee80211_ie_vhtcap) - 2, + sizeof(struct ieee80211_vht_cap), scan->vhtcap = NULL); } if (scan->vhtopmode != NULL) { IEEE80211_VERIFY_LENGTH(scan->vhtopmode[1], - sizeof(struct ieee80211_ie_vht_operation) - 2, + sizeof(struct ieee80211_vht_operation), scan->vhtopmode = NULL); } diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c index 288f0c7da2c8..2819114651d5 100644 --- a/sys/net80211/ieee80211_output.c +++ b/sys/net80211/ieee80211_output.c @@ -2455,7 +2455,7 @@ ieee80211_probereq_ie_len(struct ieee80211vap *vap, struct ieee80211com *ic) sizeof(struct ieee80211_ie_htcap) : 0) #ifdef notyet + sizeof(struct ieee80211_ie_htinfo) /* XXX not needed? */ - + sizeof(struct ieee80211_ie_vhtcap) + + 2 + sizeof(struct ieee80211_vht_cap) #endif + ((vap->iv_flags & IEEE80211_F_WPA1 && vap->iv_wpa_ie != NULL) ? vap->iv_wpa_ie[1] : 0) @@ -2820,7 +2820,7 @@ ieee80211_send_mgmt(struct ieee80211_node *ni, int type, int arg) + 2 + 26 + sizeof(struct ieee80211_wme_info) + sizeof(struct ieee80211_ie_htcap) - + sizeof(struct ieee80211_ie_vhtcap) + + 2 + sizeof(struct ieee80211_vht_cap) + 4 + sizeof(struct ieee80211_ie_htcap) #ifdef IEEE80211_SUPPORT_SUPERG + sizeof(struct ieee80211_ath_ie) @@ -2953,8 +2953,8 @@ ieee80211_send_mgmt(struct ieee80211_node *ni, int type, int arg) + 2 + (IEEE80211_RATE_MAXSIZE - IEEE80211_RATE_SIZE) + sizeof(struct ieee80211_ie_htcap) + 4 + sizeof(struct ieee80211_ie_htinfo) + 4 - + sizeof(struct ieee80211_ie_vhtcap) - + sizeof(struct ieee80211_ie_vht_operation) + + 2 + sizeof(struct ieee80211_vht_cap) + + 2 + sizeof(struct ieee80211_vht_operation) + sizeof(struct ieee80211_wme_param) #ifdef IEEE80211_SUPPORT_SUPERG + sizeof(struct ieee80211_ath_ie) @@ -3112,8 +3112,8 @@ ieee80211_alloc_proberesp(struct ieee80211_node *bss, int legacy) + sizeof(struct ieee80211_wme_param) + 4 + sizeof(struct ieee80211_ie_htcap) + 4 + sizeof(struct ieee80211_ie_htinfo) - + sizeof(struct ieee80211_ie_vhtcap) - + sizeof(struct ieee80211_ie_vht_operation) + + 2 + sizeof(struct ieee80211_vht_cap) + + 2 + sizeof(struct ieee80211_vht_operation) #ifdef IEEE80211_SUPPORT_SUPERG + sizeof(struct ieee80211_ath_ie) #endif @@ -3727,8 +3727,8 @@ ieee80211_beacon_alloc(struct ieee80211_node *ni) /* XXX conditional? */ + 4+2*sizeof(struct ieee80211_ie_htcap)/* HT caps */ + 4+2*sizeof(struct ieee80211_ie_htinfo)/* HT info */ - + sizeof(struct ieee80211_ie_vhtcap)/* VHT caps */ - + sizeof(struct ieee80211_ie_vht_operation)/* VHT info */ + + 2 + sizeof(struct ieee80211_vht_cap)/* VHT caps */ + + 2 + sizeof(struct ieee80211_vht_operation)/* VHT info */ + (vap->iv_caps & IEEE80211_C_WME ? /* WME */ sizeof(struct ieee80211_wme_param) : 0) #ifdef IEEE80211_SUPPORT_SUPERG diff --git a/sys/net80211/ieee80211_vht.c b/sys/net80211/ieee80211_vht.c index 1561255be101..77a36a395d5c 100644 --- a/sys/net80211/ieee80211_vht.c +++ b/sys/net80211/ieee80211_vht.c @@ -342,7 +342,7 @@ ieee80211_vht_node_leave(struct ieee80211_node *ni) */ void ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, - struct ieee80211_ie_vhtcap *vhtcap, int opmode) + struct ieee80211_vht_cap *vhtcap, int opmode) { struct ieee80211vap *vap = ni->ni_vap; // struct ieee80211com *ic = vap->iv_ic; @@ -350,9 +350,6 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, uint32_t new_vhtcap; int i; - vhtcap->ie = IEEE80211_ELEMID_VHT_CAP; - vhtcap->len = sizeof(struct ieee80211_ie_vhtcap) - 2; - /* * Capabilities - it depends on whether we are a station * or not. @@ -680,19 +677,12 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, uint8_t * ieee80211_add_vhtcap(uint8_t *frm, struct ieee80211_node *ni) { - struct ieee80211_ie_vhtcap vhtcap; - int opmode; - - opmode = 0; - if (ni->ni_vap->iv_opmode == IEEE80211_M_STA) - opmode = 1; - - ieee80211_vht_get_vhtcap_ie(ni, &vhtcap, opmode); + struct ieee80211_vht_cap vhtcap; - memset(frm, '\0', sizeof(struct ieee80211_ie_vhtcap)); + ieee80211_vht_get_vhtcap_ie(ni, &vhtcap, 1); frm[0] = IEEE80211_ELEMID_VHT_CAP; - frm[1] = sizeof(struct ieee80211_ie_vhtcap) - 2; + frm[1] = sizeof(vhtcap); frm += 2; /* 32-bit VHT capability */ @@ -775,10 +765,9 @@ ieee80211_vht_get_chwidth_ie(struct ieee80211_channel *c) uint8_t * ieee80211_add_vhtinfo(uint8_t *frm, struct ieee80211_node *ni) { - memset(frm, '\0', sizeof(struct ieee80211_ie_vht_operation)); frm[0] = IEEE80211_ELEMID_VHT_OPMODE; - frm[1] = sizeof(struct ieee80211_ie_vht_operation) - 2; + frm[1] = sizeof(struct ieee80211_vht_operation); frm += 2; /* 8-bit chanwidth */ @@ -886,7 +875,7 @@ ieee80211_vht_adjust_channel(struct ieee80211com *ic, */ void ieee80211_vht_get_vhtinfo_ie(struct ieee80211_node *ni, - struct ieee80211_ie_vht_operation *vhtop, int opmode) + struct ieee80211_vht_operation *vhtop, int opmode) { printf("%s: called; TODO!\n", __func__); } diff --git a/sys/net80211/ieee80211_vht.h b/sys/net80211/ieee80211_vht.h index 756c2e367485..f2d1706ea0f2 100644 --- a/sys/net80211/ieee80211_vht.h +++ b/sys/net80211/ieee80211_vht.h @@ -61,8 +61,8 @@ struct ieee80211_channel * struct ieee80211_channel *, int); void ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, - struct ieee80211_ie_vhtcap *, int); + struct ieee80211_vht_cap *, int); void ieee80211_vht_get_vhtinfo_ie(struct ieee80211_node *ni, - struct ieee80211_ie_vht_operation *, int); + struct ieee80211_vht_operation *, int); #endif /* _NET80211_IEEE80211_VHT_H_ */