From nobody Sun Nov 17 18:00:20 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 4Xrz7S1Ncyz5dChx; Sun, 17 Nov 2024 18:00:20 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xrz7S1DGYz4k4b; Sun, 17 Nov 2024 18:00:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731866420; 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=LFg7ivz7j7JUXrRZ5N+ekXapA26rwYemCwzge3AZlYA=; b=v4WC/F4rwg8Fh4WdE9OcMEPB4MfkfsJrLrx+o/B8gc1zj/isddDuKC5j8voQsKLbt77OBY QmVhQst+I4k564i2fwO7O9mP5p8nURRTwVR0FNP8sUGH3HWVvP/LfttQ3F2DpDoZK6fr7m 0Nljr7YnCFVUmiYHCEx+KdrxWV6cexyOf8y6Z+Rvhd+RLL7bFbjqmxJ1TTwit5JLOmsY5g f65hY+6Th2ypcbdh1TwApltbelcMLmWEL6aT1TVCw2KfdqUc0qH40+3YRMnk7CMzY4eGEl bd25LA5XHq6Hm5eV2tXF9mqk7lqnwMaGINPIBRv8+9/R8zZ6qOUq9s42iscELw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731866420; 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=LFg7ivz7j7JUXrRZ5N+ekXapA26rwYemCwzge3AZlYA=; b=uqcvQl7mOX7ZQK3UXoX1vA/am2ptsXqm5pA8XfF/VKgwSKTld1j44/canJxpCcqLnNZ4YU QGlCin3A+hOh/sNOT/sHJx6LNMbgg6Rps0tDq1IbPOgAmghqrHHuD59l5UUhbZ7yNcVLKo of+iDtOMlrnNxQxdibNmw/4E42q1qslwyP8NK7NM5726jG6JudujhlFGCmmr0T/o7p5Bdj n8O2m1jN1j3qj79Lz525CZxIxFsCsb9wpMBYTB5ZPpEjDF/lu6lCZASfcRFkQJ7vrl1fka oGelVrl1sUydq2v2agIUAI5PZzgLeC7t15/ldyPzERSQp8FpMaqbyPCE6P14gw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731866420; a=rsa-sha256; cv=none; b=RvxR8FVShkiLgNR7ZdQtzTUYRSFFeVStr/eLpU78FNckTsctmoF4g3hzTCkay9dJ0Y9VlW kv0HeB3cn0vK3m4Pz6KcGqcpaM/74o2gvoAxqDISaqyarfs03TY321tHK/wJFEe51kpKAI oEGjJezsGlQE1Dvx6VVb8MW+U4LYkBTtLe1nG+Pd5qCz1sUoT9of1uhRU6J628x9LjOpN8 AACm5hX1zXHCnDPHx/JFG48B49JalGrkWMZ1xPvUvMGWGl8Z2JIfc1ZMoBpKAZeKFm2IV9 koT8x4enc7qk70wXiU6SpSI2FcG5/CWo77vYPEEKYzsJFZzJVh4X4OMgmQHucg== 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 4Xrz7S0rF9z12Ny; Sun, 17 Nov 2024 18:00:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4AHI0K9l070667; Sun, 17 Nov 2024 18:00:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AHI0K6p070664; Sun, 17 Nov 2024 18:00:20 GMT (envelope-from git) Date: Sun, 17 Nov 2024 18:00:20 GMT Message-Id: <202411171800.4AHI0K6p070664@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: c249cc3822dc - main - net80211: migrate FC0_TYPE_MASK / FC0_SUBTYPE_MASK frame type checks to macros 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c249cc3822dc002288700ee206cf28c0c6031449 Auto-Submitted: auto-generated 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 +0000 Commit: Adrian Chadd CommitDate: 2024-11-17 17:53:04 +0000 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 = 0x00008000, /* firmware */ MALO_DEBUG_ANY = 0xffffffff }; -#define IS_BEACON(wh) \ - ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK | \ - IEEE80211_FC0_SUBTYPE_MASK)) == \ - (IEEE80211_FC0_TYPE_MGT|IEEE80211_FC0_SUBTYPE_BEACON)) #define IFF_DUMPPKTS_RECV(sc, wh) \ (((sc->malo_debug & MALO_DEBUG_RECV) && \ - ((sc->malo_debug & MALO_DEBUG_RECV_ALL) || !IS_BEACON(wh)))) + ((sc->malo_debug & MALO_DEBUG_RECV_ALL) || !IEEE80211_IS_MGMT_BEACON(wh)))) #define IFF_DUMPPKTS_XMIT(sc) \ (sc->malo_debug & MALO_DEBUG_XMIT) #define DPRINTF(sc, m, fmt, ...) do { \ @@ -1025,8 +1021,6 @@ static int malo_tx_start(struct malo_softc *sc, struct ieee80211_node *ni, struct malo_txbuf *bf, struct mbuf *m0) { -#define IS_DATA_FRAME(wh) \ - ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK)) == IEEE80211_FC0_TYPE_DATA) int error, iswep; int hdrlen, pktlen; struct ieee80211_frame *wh; @@ -1150,7 +1144,7 @@ malo_tx_start(struct malo_softc *sc, struct ieee80211_node *ni, ds->pktptr = htole32(bf->bf_segs[0].ds_addr); ds->pktlen = htole16(bf->bf_segs[0].ds_len); /* NB: pPhysNext setup once, don't touch */ - ds->datarate = IS_DATA_FRAME(wh) ? 1 : 0; + ds->datarate = IEEE80211_IS_DATA(wh) ? 1 : 0; ds->sap_pktinfo = 0; ds->format = 0; @@ -1183,7 +1177,7 @@ malo_tx_start(struct malo_softc *sc, struct ieee80211_node *ni, #endif MALO_TXQ_LOCK(txq); - if (!IS_DATA_FRAME(wh)) + if (!IEEE80211_IS_DATA(wh)) ds->status |= htole32(1); ds->status |= htole32(MALO_TXD_STATUS_FW_OWNED); STAILQ_INSERT_TAIL(&txq->active, bf, bf_list); diff --git a/sys/dev/mwl/if_mwl.c b/sys/dev/mwl/if_mwl.c index 49b8b3279c7f..f396ef7256f4 100644 --- a/sys/dev/mwl/if_mwl.c +++ b/sys/dev/mwl/if_mwl.c @@ -226,12 +226,9 @@ enum { MWL_DEBUG_AMPDU = 0x00004000, /* BA stream handling */ MWL_DEBUG_ANY = 0xffffffff }; -#define IS_BEACON(wh) \ - ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK|IEEE80211_FC0_SUBTYPE_MASK)) == \ - (IEEE80211_FC0_TYPE_MGT|IEEE80211_FC0_SUBTYPE_BEACON)) #define IFF_DUMPPKTS_RECV(sc, wh) \ ((sc->sc_debug & MWL_DEBUG_RECV) && \ - ((sc->sc_debug & MWL_DEBUG_RECV_ALL) || !IS_BEACON(wh))) + ((sc->sc_debug & MWL_DEBUG_RECV_ALL) || !IEEE80211_IS_MGMT_BEACON(wh))) #define IFF_DUMPPKTS_XMIT(sc) \ (sc->sc_debug & MWL_DEBUG_XMIT) @@ -2553,7 +2550,7 @@ mwl_anyhdrsize(const void *data) { const struct ieee80211_frame *wh = data; - if ((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL) { + if (IEEE80211_IS_CTL(wh)) { switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) { case IEEE80211_FC0_SUBTYPE_CTS: case IEEE80211_FC0_SUBTYPE_ACK: diff --git a/sys/dev/otus/if_otus.c b/sys/dev/otus/if_otus.c index dbb913d83ae8..a620a400bfd6 100644 --- a/sys/dev/otus/if_otus.c +++ b/sys/dev/otus/if_otus.c @@ -1686,8 +1686,7 @@ otus_sub_rxeof(struct otus_softc *sc, uint8_t *buf, int len, struct mbufq *rxq) * with invalid frame control values here. Just toss them * rather than letting net80211 get angry and log. */ - if ((wh->i_fc[0] & IEEE80211_FC0_VERSION_MASK) != - IEEE80211_FC0_VERSION_0) { + if (!IEEE80211_IS_FC0_CHECK_VER(wh, IEEE80211_FC0_VERSION_0)) { OTUS_DPRINTF(sc, OTUS_DEBUG_RXDONE, "%s: invalid 802.11 fc version (firmware bug?)\n", __func__); diff --git a/sys/dev/ral/rt2560.c b/sys/dev/ral/rt2560.c index d7cafe1994c9..aaae1245a9a1 100644 --- a/sys/dev/ral/rt2560.c +++ b/sys/dev/ral/rt2560.c @@ -1558,10 +1558,7 @@ rt2560_tx_mgt(struct rt2560_softc *sc, struct mbuf *m0, *(uint16_t *)wh->i_dur = htole16(dur); /* tell hardware to add timestamp for probe responses */ - if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == - IEEE80211_FC0_TYPE_MGT && - (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == - IEEE80211_FC0_SUBTYPE_PROBE_RESP) + if (IEEE80211_IS_MGMT_PROBE_RESP(wh)) flags |= RT2560_TX_TIMESTAMP; } diff --git a/sys/dev/ral/rt2661.c b/sys/dev/ral/rt2661.c index 1194ef12189f..4912e1106fa6 100644 --- a/sys/dev/ral/rt2661.c +++ b/sys/dev/ral/rt2661.c @@ -1326,9 +1326,7 @@ rt2661_tx_mgt(struct rt2661_softc *sc, struct mbuf *m0, *(uint16_t *)wh->i_dur = htole16(dur); /* tell hardware to add timestamp in probe responses */ - if ((wh->i_fc[0] & - (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == - (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP)) + if (IEEE80211_IS_MGMT_PROBE_RESP(wh)) flags |= RT2661_TX_TIMESTAMP; } diff --git a/sys/dev/ral/rt2860.c b/sys/dev/ral/rt2860.c index ab5b32b4e026..e928de084bcb 100644 --- a/sys/dev/ral/rt2860.c +++ b/sys/dev/ral/rt2860.c @@ -1559,9 +1559,7 @@ rt2860_tx(struct rt2860_softc *sc, struct mbuf *m, struct ieee80211_node *ni) *(uint16_t *)wh->i_dur = htole16(dur); } /* ask MAC to insert timestamp into probe responses */ - if ((wh->i_fc[0] & - (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == - (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP)) + if (IEEE80211_IS_MGMT_PROBE_RESP(wh)) /* NOTE: beacons do not pass through tx_data() */ txwi->flags |= RT2860_TX_TS; @@ -1802,9 +1800,7 @@ rt2860_tx_raw(struct rt2860_softc *sc, struct mbuf *m, *(uint16_t *)wh->i_dur = htole16(dur); } /* ask MAC to insert timestamp into probe responses */ - if ((wh->i_fc[0] & - (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == - (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP)) + if (IEEE80211_IS_MGMT_PROBE_RESP(wh)) /* NOTE: beacons do not pass through tx_data() */ txwi->flags |= RT2860_TX_TS; diff --git a/sys/dev/usb/wlan/if_rum.c b/sys/dev/usb/wlan/if_rum.c index edf92e2222b4..fc83409543ec 100644 --- a/sys/dev/usb/wlan/if_rum.c +++ b/sys/dev/usb/wlan/if_rum.c @@ -1526,9 +1526,7 @@ rum_tx_mgt(struct rum_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) USETW(wh->i_dur, dur); /* tell hardware to add timestamp for probe responses */ - if (type == IEEE80211_FC0_TYPE_MGT && - (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == - IEEE80211_FC0_SUBTYPE_PROBE_RESP) + if (IEEE80211_IS_MGMT_PROBE_RESP(wh)) flags |= RT2573_TX_TIMESTAMP; } diff --git a/sys/dev/usb/wlan/if_run.c b/sys/dev/usb/wlan/if_run.c index e2ea78f78b13..e709ceff8849 100644 --- a/sys/dev/usb/wlan/if_run.c +++ b/sys/dev/usb/wlan/if_run.c @@ -3595,9 +3595,7 @@ run_tx_mgt(struct run_softc *sc, struct mbuf *m, struct ieee80211_node *ni) wh = mtod(m, struct ieee80211_frame *); /* tell hardware to add timestamp for probe responses */ - if ((wh->i_fc[0] & - (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == - (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP)) + if (IEEE80211_IS_MGMT_PROBE_RESP(wh)) wflags |= RT2860_TX_TS; else if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { xflags |= RT2860_TX_ACK; diff --git a/sys/dev/usb/wlan/if_upgt.c b/sys/dev/usb/wlan/if_upgt.c index 55d231e2c655..642631ae34b7 100644 --- a/sys/dev/usb/wlan/if_upgt.c +++ b/sys/dev/usb/wlan/if_upgt.c @@ -2139,8 +2139,7 @@ upgt_tx_start(struct upgt_softc *sc, struct mbuf *m, struct ieee80211_node *ni, mem->addr = htole32(data->addr); txdesc = (struct upgt_lmac_tx_desc *)(mem + 1); - if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == - IEEE80211_FC0_TYPE_MGT) { + if (IEEE80211_IS_MGMT(wh)) { /* mgmt frames */ txdesc->header1.flags = UPGT_H1_FLAGS_TX_MGMT; /* always send mgmt frames at lowest rate (DS1) */ diff --git a/sys/dev/usb/wlan/if_ural.c b/sys/dev/usb/wlan/if_ural.c index 1acae6d84b53..6e01592da44f 100644 --- a/sys/dev/usb/wlan/if_ural.c +++ b/sys/dev/usb/wlan/if_ural.c @@ -1097,10 +1097,7 @@ ural_tx_mgt(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) USETW(wh->i_dur, dur); /* tell hardware to add timestamp for probe responses */ - if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == - IEEE80211_FC0_TYPE_MGT && - (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == - IEEE80211_FC0_SUBTYPE_PROBE_RESP) + if (IEEE80211_IS_MGMT_PROBE_RESP(wh)) flags |= RAL_TX_TIMESTAMP; } diff --git a/sys/dev/usb/wlan/if_urtw.c b/sys/dev/usb/wlan/if_urtw.c index d08a3237e9b2..1a7a1eba4758 100644 --- a/sys/dev/usb/wlan/if_urtw.c +++ b/sys/dev/usb/wlan/if_urtw.c @@ -1724,8 +1724,7 @@ urtw_tx_start(struct urtw_softc *sc, struct ieee80211_node *ni, struct mbuf *m0, ieee80211_radiotap_tx(vap, m0); } - if (type == IEEE80211_FC0_TYPE_MGT || - type == IEEE80211_FC0_TYPE_CTL || + if (IEEE80211_IS_MGMT(wh) || IEEE80211_IS_CTL(wh) || (m0->m_flags & M_EAPOL) != 0) { rate = tp->mgmtrate; } else { @@ -1803,9 +1802,7 @@ urtw_tx_start(struct urtw_softc *sc, struct ieee80211_node *ni, struct mbuf *m0, } tx->flag = htole32(flags); tx->txdur = txdur; - if (type == IEEE80211_FC0_TYPE_MGT && - (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == - IEEE80211_FC0_SUBTYPE_PROBE_RESP) + if (IEEE80211_IS_MGMT_PROBE_RESP(wh)) tx->retry = 1; else tx->retry = URTW_TX_MAXRETRY; diff --git a/sys/dev/usb/wlan/if_zyd.c b/sys/dev/usb/wlan/if_zyd.c index a4dc6b972c96..76e7d4312040 100644 --- a/sys/dev/usb/wlan/if_zyd.c +++ b/sys/dev/usb/wlan/if_zyd.c @@ -2505,9 +2505,7 @@ zyd_tx_start(struct zyd_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) } } else desc->flags |= ZYD_TX_FLAG_MULTICAST; - if ((wh->i_fc[0] & - (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == - (IEEE80211_FC0_TYPE_CTL | IEEE80211_FC0_SUBTYPE_PS_POLL)) + if (IEEE80211_IS_CTL_PS_POLL(wh)) desc->flags |= ZYD_TX_FLAG_TYPE(ZYD_TX_TYPE_PS_POLL); /* actual transmit length (XXX why +10?) */ diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h index a2d6b3040032..e9147e028385 100644 --- a/sys/net80211/ieee80211.h +++ b/sys/net80211/ieee80211.h @@ -219,6 +219,42 @@ struct ieee80211_qosframe_addr4 { (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \ IEEE80211_FC0_TYPE_EXT)) +/* Management frame types */ + +#define IEEE80211_IS_MGMT_BEACON(wh) \ + (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \ + IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_MGT, \ + IEEE80211_FC0_SUBTYPE_BEACON)) + +#define IEEE80211_IS_MGMT_PROBE_RESP(wh) \ + (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \ + IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_MGT, \ + IEEE80211_FC0_SUBTYPE_PROBE_RESP)) + +#define IEEE80211_IS_MGMT_ACTION(wh) \ + (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \ + IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_MGT, \ + IEEE80211_FC0_SUBTYPE_ACTION)) + +/* Control frame types */ + +#define IEEE80211_IS_CTL_PS_POLL(wh) \ + (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \ + IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_CTL, \ + IEEE80211_FC0_SUBTYPE_PS_POLL)) + +#define IEEE80211_IS_CTL_BAR(wh) \ + (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \ + IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_CTL, \ + IEEE80211_FC0_SUBTYPE_BAR)) + +/* Data frame types */ + #define IEEE80211_FC0_QOSDATA \ (IEEE80211_FC0_TYPE_DATA|IEEE80211_FC0_SUBTYPE_QOS_DATA|IEEE80211_FC0_VERSION_0)