From owner-svn-src-all@freebsd.org Sat Mar 9 12:54:16 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 94E0015250A2; Sat, 9 Mar 2019 12:54:16 +0000 (UTC) (envelope-from avos@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3805B86222; Sat, 9 Mar 2019 12:54:16 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 26AC3B83F; Sat, 9 Mar 2019 12:54:16 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x29CsGqW030269; Sat, 9 Mar 2019 12:54:16 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x29CsDEC030258; Sat, 9 Mar 2019 12:54:13 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201903091254.x29CsDEC030258@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sat, 9 Mar 2019 12:54:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r344969 - in stable: 11/sys/dev/malo 11/sys/dev/mwl 11/sys/dev/usb/wlan 11/sys/net80211 12/sys/dev/malo 12/sys/dev/mwl 12/sys/dev/usb/wlan 12/sys/net80211 X-SVN-Group: stable-12 X-SVN-Commit-Author: avos X-SVN-Commit-Paths: in stable: 11/sys/dev/malo 11/sys/dev/mwl 11/sys/dev/usb/wlan 11/sys/net80211 12/sys/dev/malo 12/sys/dev/mwl 12/sys/dev/usb/wlan 12/sys/net80211 X-SVN-Commit-Revision: 344969 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3805B86222 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.970,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Mar 2019 12:54:16 -0000 Author: avos Date: Sat Mar 9 12:54:10 2019 New Revision: 344969 URL: https://svnweb.freebsd.org/changeset/base/344969 Log: MFC r343990: net80211: hide casts for 'i_seq' field offset calculation inside ieee80211_getqos() and reuse it in various places. Modified: stable/12/sys/dev/malo/if_malo.c stable/12/sys/dev/mwl/if_mwl.c stable/12/sys/dev/usb/wlan/if_run.c stable/12/sys/net80211/ieee80211_adhoc.c stable/12/sys/net80211/ieee80211_hostap.c stable/12/sys/net80211/ieee80211_ht.c stable/12/sys/net80211/ieee80211_mesh.c stable/12/sys/net80211/ieee80211_output.c stable/12/sys/net80211/ieee80211_proto.h stable/12/sys/net80211/ieee80211_sta.c stable/12/sys/net80211/ieee80211_wds.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/dev/malo/if_malo.c stable/11/sys/dev/mwl/if_mwl.c stable/11/sys/dev/usb/wlan/if_run.c stable/11/sys/net80211/ieee80211_adhoc.c stable/11/sys/net80211/ieee80211_hostap.c stable/11/sys/net80211/ieee80211_ht.c stable/11/sys/net80211/ieee80211_mesh.c stable/11/sys/net80211/ieee80211_output.c stable/11/sys/net80211/ieee80211_proto.h stable/11/sys/net80211/ieee80211_sta.c stable/11/sys/net80211/ieee80211_wds.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/dev/malo/if_malo.c ============================================================================== --- stable/12/sys/dev/malo/if_malo.c Sat Mar 9 12:44:05 2019 (r344968) +++ stable/12/sys/dev/malo/if_malo.c Sat Mar 9 12:54:10 2019 (r344969) @@ -1051,13 +1051,9 @@ malo_tx_start(struct malo_softc *sc, struct ieee80211_ copyhdrlen = hdrlen = ieee80211_anyhdrsize(wh); pktlen = m0->m_pkthdr.len; if (IEEE80211_QOS_HAS_SEQ(wh)) { - if (IEEE80211_IS_DSTODS(wh)) { - qos = *(uint16_t *) - (((struct ieee80211_qosframe_addr4 *) wh)->i_qos); + qos = *(uint16_t *)ieee80211_getqos(wh); + if (IEEE80211_IS_DSTODS(wh)) copyhdrlen -= sizeof(qos); - } else - qos = *(uint16_t *) - (((struct ieee80211_qosframe *) wh)->i_qos); } else qos = 0; @@ -1952,7 +1948,6 @@ malo_rx_proc(void *arg, int npending) struct malo_rxdesc *ds; struct mbuf *m, *mnew; struct ieee80211_qosframe *wh; - struct ieee80211_qosframe_addr4 *wh4; struct ieee80211_node *ni; int off, len, hdrlen, pktlen, rssi, ntodo; uint8_t *data, status; @@ -2062,15 +2057,8 @@ malo_rx_proc(void *arg, int npending) /* NB: don't need to do this sometimes but ... */ /* XXX special case so we can memcpy after m_devget? */ ovbcopy(data + sizeof(uint16_t), wh, hdrlen); - if (IEEE80211_QOS_HAS_SEQ(wh)) { - if (IEEE80211_IS_DSTODS(wh)) { - wh4 = mtod(m, - struct ieee80211_qosframe_addr4*); - *(uint16_t *)wh4->i_qos = ds->qosctrl; - } else { - *(uint16_t *)wh->i_qos = ds->qosctrl; - } - } + if (IEEE80211_QOS_HAS_SEQ(wh)) + *(uint16_t *)ieee80211_getqos(wh) = ds->qosctrl; if (ieee80211_radiotap_active(ic)) { sc->malo_rx_th.wr_flags = 0; sc->malo_rx_th.wr_rate = ds->rate; Modified: stable/12/sys/dev/mwl/if_mwl.c ============================================================================== --- stable/12/sys/dev/mwl/if_mwl.c Sat Mar 9 12:44:05 2019 (r344968) +++ stable/12/sys/dev/mwl/if_mwl.c Sat Mar 9 12:54:10 2019 (r344969) @@ -2614,7 +2614,6 @@ mwl_rx_proc(void *arg, int npending) struct mwl_rxdesc *ds; struct mbuf *m; struct ieee80211_qosframe *wh; - struct ieee80211_qosframe_addr4 *wh4; struct ieee80211_node *ni; struct mwl_node *mn; int off, len, hdrlen, pktlen, rssi, ntodo; @@ -2761,15 +2760,8 @@ mwl_rx_proc(void *arg, int npending) /* NB: don't need to do this sometimes but ... */ /* XXX special case so we can memcpy after m_devget? */ ovbcopy(data + sizeof(uint16_t), wh, hdrlen); - if (IEEE80211_QOS_HAS_SEQ(wh)) { - if (IEEE80211_IS_DSTODS(wh)) { - wh4 = mtod(m, - struct ieee80211_qosframe_addr4*); - *(uint16_t *)wh4->i_qos = ds->QosCtrl; - } else { - *(uint16_t *)wh->i_qos = ds->QosCtrl; - } - } + if (IEEE80211_QOS_HAS_SEQ(wh)) + *(uint16_t *)ieee80211_getqos(wh) = ds->QosCtrl; /* * The f/w strips WEP header but doesn't clear * the WEP bit; mark the packet with M_WEP so @@ -3100,13 +3092,9 @@ mwl_tx_start(struct mwl_softc *sc, struct ieee80211_no copyhdrlen = hdrlen; pktlen = m0->m_pkthdr.len; if (IEEE80211_QOS_HAS_SEQ(wh)) { - if (IEEE80211_IS_DSTODS(wh)) { - qos = *(uint16_t *) - (((struct ieee80211_qosframe_addr4 *) wh)->i_qos); + qos = *(uint16_t *)ieee80211_getqos(wh); + if (IEEE80211_IS_DSTODS(wh)) copyhdrlen -= sizeof(qos); - } else - qos = *(uint16_t *) - (((struct ieee80211_qosframe *) wh)->i_qos); } else qos = 0; Modified: stable/12/sys/dev/usb/wlan/if_run.c ============================================================================== --- stable/12/sys/dev/usb/wlan/if_run.c Sat Mar 9 12:44:05 2019 (r344968) +++ stable/12/sys/dev/usb/wlan/if_run.c Sat Mar 9 12:54:10 2019 (r344969) @@ -3369,11 +3369,7 @@ run_tx(struct run_softc *sc, struct mbuf *m, struct ie if ((hasqos = IEEE80211_QOS_HAS_SEQ(wh))) { uint8_t *frm; - if(IEEE80211_HAS_ADDR4(wh)) - frm = ((struct ieee80211_qosframe_addr4 *)wh)->i_qos; - else - frm =((struct ieee80211_qosframe *)wh)->i_qos; - + frm = ieee80211_getqos(wh); qos = le16toh(*(const uint16_t *)frm); tid = qos & IEEE80211_QOS_TID; qid = TID_TO_WME_AC(tid); Modified: stable/12/sys/net80211/ieee80211_adhoc.c ============================================================================== --- stable/12/sys/net80211/ieee80211_adhoc.c Sat Mar 9 12:44:05 2019 (r344968) +++ stable/12/sys/net80211/ieee80211_adhoc.c Sat Mar 9 12:54:10 2019 (r344969) @@ -522,11 +522,9 @@ adhoc_input(struct ieee80211_node *ni, struct mbuf *m, /* * Save QoS bits for use below--before we strip the header. */ - if (subtype == IEEE80211_FC0_SUBTYPE_QOS) { - qos = (dir == IEEE80211_FC1_DIR_DSTODS) ? - ((struct ieee80211_qosframe_addr4 *)wh)->i_qos[0] : - ((struct ieee80211_qosframe *)wh)->i_qos[0]; - } else + if (subtype == IEEE80211_FC0_SUBTYPE_QOS) + qos = ieee80211_getqos(wh)[0]; + else qos = 0; /* Modified: stable/12/sys/net80211/ieee80211_hostap.c ============================================================================== --- stable/12/sys/net80211/ieee80211_hostap.c Sat Mar 9 12:44:05 2019 (r344968) +++ stable/12/sys/net80211/ieee80211_hostap.c Sat Mar 9 12:54:10 2019 (r344969) @@ -708,11 +708,9 @@ hostap_input(struct ieee80211_node *ni, struct mbuf *m /* * Save QoS bits for use below--before we strip the header. */ - if (subtype == IEEE80211_FC0_SUBTYPE_QOS) { - qos = (dir == IEEE80211_FC1_DIR_DSTODS) ? - ((struct ieee80211_qosframe_addr4 *)wh)->i_qos[0] : - ((struct ieee80211_qosframe *)wh)->i_qos[0]; - } else + if (subtype == IEEE80211_FC0_SUBTYPE_QOS) + qos = ieee80211_getqos(wh)[0]; + else qos = 0; /* Modified: stable/12/sys/net80211/ieee80211_ht.c ============================================================================== --- stable/12/sys/net80211/ieee80211_ht.c Sat Mar 9 12:44:05 2019 (r344968) +++ stable/12/sys/net80211/ieee80211_ht.c Sat Mar 9 12:54:10 2019 (r344969) @@ -886,10 +886,7 @@ ieee80211_ampdu_reorder(struct ieee80211_node *ni, str if (IEEE80211_IS_MULTICAST(wh->i_addr1)) return PROCESS; - if (IEEE80211_IS_DSTODS(wh)) - tid = ((struct ieee80211_qosframe_addr4 *)wh)->i_qos[0]; - else - tid = wh->i_qos[0]; + tid = ieee80211_getqos(wh)[0]; tid &= IEEE80211_QOS_TID; rap = &ni->ni_rx_ampdu[tid]; if ((rap->rxa_flags & IEEE80211_AGGR_XCHGPEND) == 0) { Modified: stable/12/sys/net80211/ieee80211_mesh.c ============================================================================== --- stable/12/sys/net80211/ieee80211_mesh.c Sat Mar 9 12:44:05 2019 (r344968) +++ stable/12/sys/net80211/ieee80211_mesh.c Sat Mar 9 12:54:10 2019 (r344969) @@ -1655,12 +1655,7 @@ mesh_input(struct ieee80211_node *ni, struct mbuf *m, * in the Mesh Control field and a 3 address qos frame * is used. */ - if (IEEE80211_IS_DSTODS(wh)) - *(uint16_t *)qos = *(uint16_t *) - ((struct ieee80211_qosframe_addr4 *)wh)->i_qos; - else - *(uint16_t *)qos = *(uint16_t *) - ((struct ieee80211_qosframe *)wh)->i_qos; + *(uint16_t *)qos = *(uint16_t *)ieee80211_getqos(wh); /* * NB: The mesh STA sets the Mesh Control Present Modified: stable/12/sys/net80211/ieee80211_output.c ============================================================================== --- stable/12/sys/net80211/ieee80211_output.c Sat Mar 9 12:44:05 2019 (r344968) +++ stable/12/sys/net80211/ieee80211_output.c Sat Mar 9 12:54:10 2019 (r344969) @@ -1948,14 +1948,8 @@ ieee80211_fragment(struct ieee80211vap *vap, struct mb whf = mtod(m, struct ieee80211_frame *); memcpy(whf, wh, hdrsize); #ifdef IEEE80211_SUPPORT_MESH - if (vap->iv_opmode == IEEE80211_M_MBSS) { - if (IEEE80211_IS_DSTODS(wh)) - ((struct ieee80211_qosframe_addr4 *) - whf)->i_qos[1] &= ~IEEE80211_QOS_MC; - else - ((struct ieee80211_qosframe *) - whf)->i_qos[1] &= ~IEEE80211_QOS_MC; - } + if (vap->iv_opmode == IEEE80211_M_MBSS) + ieee80211_getqos(wh)[1] &= ~IEEE80211_QOS_MC; #endif *(uint16_t *)&whf->i_seq[0] |= htole16( (fragno & IEEE80211_SEQ_FRAG_MASK) << Modified: stable/12/sys/net80211/ieee80211_proto.h ============================================================================== --- stable/12/sys/net80211/ieee80211_proto.h Sat Mar 9 12:44:05 2019 (r344968) +++ stable/12/sys/net80211/ieee80211_proto.h Sat Mar 9 12:54:10 2019 (r344969) @@ -303,6 +303,22 @@ void ieee80211_wme_ic_getparams(struct ieee80211com *i int ieee80211_wme_vap_ac_is_noack(struct ieee80211vap *vap, int ac); /* + * Return pointer to the QoS field from a Qos frame. + */ +static __inline uint8_t * +ieee80211_getqos(void *data) +{ + struct ieee80211_frame *wh = data; + + KASSERT(IEEE80211_QOS_HAS_SEQ(wh), ("QoS field is absent!")); + + if (IEEE80211_IS_DSTODS(wh)) + return (((struct ieee80211_qosframe_addr4 *)wh)->i_qos); + else + return (((struct ieee80211_qosframe *)wh)->i_qos); +} + +/* * Return the WME TID from a QoS frame. If no TID * is present return the index for the "non-QoS" entry. */ Modified: stable/12/sys/net80211/ieee80211_sta.c ============================================================================== --- stable/12/sys/net80211/ieee80211_sta.c Sat Mar 9 12:44:05 2019 (r344968) +++ stable/12/sys/net80211/ieee80211_sta.c Sat Mar 9 12:54:10 2019 (r344969) @@ -786,11 +786,9 @@ sta_input(struct ieee80211_node *ni, struct mbuf *m, /* * Save QoS bits for use below--before we strip the header. */ - if (subtype == IEEE80211_FC0_SUBTYPE_QOS) { - qos = (dir == IEEE80211_FC1_DIR_DSTODS) ? - ((struct ieee80211_qosframe_addr4 *)wh)->i_qos[0] : - ((struct ieee80211_qosframe *)wh)->i_qos[0]; - } else + if (subtype == IEEE80211_FC0_SUBTYPE_QOS) + qos = ieee80211_getqos(wh)[0]; + else qos = 0; /* Modified: stable/12/sys/net80211/ieee80211_wds.c ============================================================================== --- stable/12/sys/net80211/ieee80211_wds.c Sat Mar 9 12:44:05 2019 (r344968) +++ stable/12/sys/net80211/ieee80211_wds.c Sat Mar 9 12:54:10 2019 (r344969) @@ -583,11 +583,9 @@ wds_input(struct ieee80211_node *ni, struct mbuf *m, /* * Save QoS bits for use below--before we strip the header. */ - if (subtype == IEEE80211_FC0_SUBTYPE_QOS) { - qos = (dir == IEEE80211_FC1_DIR_DSTODS) ? - ((struct ieee80211_qosframe_addr4 *)wh)->i_qos[0] : - ((struct ieee80211_qosframe *)wh)->i_qos[0]; - } else + if (subtype == IEEE80211_FC0_SUBTYPE_QOS) + qos = ieee80211_getqos(wh)[0]; + else qos = 0; /*