[PATCH 1/4] brcm80211: use proper ieee80211 routines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



removed the following defines as a side effect:
- FC_SUBTYPE_ANY_QOS
- FC_KIND_MASK
- FC_PROBE_REQ
- FC_PROBE_RESP
- FC_BEACON
- FC_PS_POLL
- FC_RTS
- FC_CTS

Signed-off-by: Stanislav Fomichev <kernel@xxxxxxxxxxx>
---
 drivers/staging/brcm80211/brcmsmac/wlc_ampdu.c    |    5 +-
 drivers/staging/brcm80211/brcmsmac/wlc_mac80211.c |   77 +++++++++------------
 drivers/staging/brcm80211/include/proto/802.11.h  |   11 ---
 3 files changed, 37 insertions(+), 56 deletions(-)

diff --git a/drivers/staging/brcm80211/brcmsmac/wlc_ampdu.c b/drivers/staging/brcm80211/brcmsmac/wlc_ampdu.c
index 4f9d4de..bedf4b2 100644
--- a/drivers/staging/brcm80211/brcmsmac/wlc_ampdu.c
+++ b/drivers/staging/brcm80211/brcmsmac/wlc_ampdu.c
@@ -637,11 +637,12 @@ wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi,
 			mcl |= TXC_STARTMSDU;
 			rts = (struct ieee80211_rts *)&txh->rts_frame;
 			fc = le16_to_cpu(rts->frame_control);
-			if ((fc & FC_KIND_MASK) == FC_RTS) {
+
+			if (ieee80211_is_rts(rts->frame_control)) {
 				mcl |= TXC_SENDRTS;
 				use_rts = true;
 			}
-			if ((fc & FC_KIND_MASK) == FC_CTS) {
+			if (ieee80211_is_cts(rts->frame_control)) {
 				mcl |= TXC_SENDCTS;
 				use_cts = true;
 			}
diff --git a/drivers/staging/brcm80211/brcmsmac/wlc_mac80211.c b/drivers/staging/brcm80211/brcmsmac/wlc_mac80211.c
index 464e421..94a5fa4 100644
--- a/drivers/staging/brcm80211/brcmsmac/wlc_mac80211.c
+++ b/drivers/staging/brcm80211/brcmsmac/wlc_mac80211.c
@@ -5208,15 +5208,12 @@ wlc_sendpkt_mac80211(struct wlc_info *wlc, struct sk_buff *sdu,
 	void *pkt;
 	struct scb *scb = &global_scb;
 	struct ieee80211_hdr *d11_header = (struct ieee80211_hdr *)(sdu->data);
-	u16 type, fc;
 
 	ASSERT(sdu);
 
-	fc = le16_to_cpu(d11_header->frame_control);
-	type = (fc & IEEE80211_FCTL_FTYPE);
-
 	/* 802.11 standard requires management traffic to go at highest priority */
-	prio = (type == IEEE80211_FTYPE_DATA ? sdu->priority : MAXPRIO);
+	prio = ieee80211_is_data(d11_header->frame_control) ? sdu->priority :
+		MAXPRIO;
 	fifo = prio2fifo[prio];
 
 	ASSERT((uint) skb_headroom(sdu) >= TXOFF);
@@ -5750,7 +5747,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
 	u8 *plcp, plcp_fallback[D11_PHY_HDR_LEN];
 	struct osl_info *osh;
 	int len, phylen, rts_phylen;
-	u16 fc, type, frameid, mch, phyctl, xfts, mainrates;
+	u16 frameid, mch, phyctl, xfts, mainrates;
 	u16 seq = 0, mcl = 0, status = 0;
 	ratespec_t rspec[2] = { WLC_RATE_1M, WLC_RATE_1M }, rts_rspec[2] = {
 	WLC_RATE_1M, WLC_RATE_1M};
@@ -5789,11 +5786,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
 
 	/* locate 802.11 MAC header */
 	h = (struct ieee80211_hdr *)(p->data);
-	fc = le16_to_cpu(h->frame_control);
-	type = (fc & IEEE80211_FCTL_FTYPE);
-
-	qos = (type == IEEE80211_FTYPE_DATA &&
-	       FC_SUBTYPE_ANY_QOS(fc));
+	qos = ieee80211_is_data_qos(h->frame_control);
 
 	/* compute length of frame in bytes for use in PLCP computations */
 	len = pkttotlen(osh, p);
@@ -5845,7 +5838,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
 	frameid |= queue & TXFID_QUEUE_MASK;
 
 	/* set the ignpmq bit for all pkts tx'd in PS mode and for beacons */
-	if (SCB_PS(scb) || ((fc & FC_KIND_MASK) == FC_BEACON))
+	if (SCB_PS(scb) || ieee80211_is_beacon(h->frame_control))
 		mcl |= TXC_IGNOREPMQ;
 
 	ASSERT(hw->max_rates <= IEEE80211_TX_MAX_RATES);
@@ -6051,7 +6044,8 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
 	txrate[1]->count = 0;
 
 	/* (2) PROTECTION, may change rspec */
-	if ((ieee80211_is_data(fc) || ieee80211_is_mgmt(fc)) &&
+	if ((ieee80211_is_data(h->frame_control) ||
+	    ieee80211_is_mgmt(h->frame_control)) &&
 	    (phylen > wlc->RTSThresh) && !is_multicast_ether_addr(h->addr1))
 		use_rts = true;
 
@@ -6073,7 +6067,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
 	    plcp[0];
 
 	/* DUR field for main rate */
-	if ((fc != FC_PS_POLL) &&
+	if (!ieee80211_is_pspoll(h->frame_control) &&
 	    !is_multicast_ether_addr(h->addr1) && !use_rifs) {
 		durid =
 		    wlc_compute_frame_dur(wlc, rspec[0], preamble_type[0],
@@ -6090,7 +6084,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
 	}
 
 	/* DUR field for fallback rate */
-	if (fc == FC_PS_POLL)
+	if (ieee80211_is_pspoll(h->frame_control))
 		txh->FragDurFallback = h->duration_id;
 	else if (is_multicast_ether_addr(h->addr1) || use_rifs)
 		txh->FragDurFallback = 0;
@@ -6221,10 +6215,14 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
 		txh->RTSDurFallback = cpu_to_le16(durid);
 
 		if (use_cts) {
-			rts->frame_control = cpu_to_le16(FC_CTS);
+			rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL |
+							 IEEE80211_STYPE_CTS);
+
 			memcpy(&rts->ra, &h->addr2, ETH_ALEN);
 		} else {
-			rts->frame_control = cpu_to_le16((u16) FC_RTS);
+			rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL |
+							 IEEE80211_STYPE_RTS);
+
 			memcpy(&rts->ra, &h->addr1, 2 * ETH_ALEN);
 		}
 
@@ -6600,7 +6598,6 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
 	uint totlen, supr_status;
 	bool lastframe;
 	struct ieee80211_hdr *h;
-	u16 fc;
 	u16 mcl;
 	struct ieee80211_tx_info *tx_info;
 	struct ieee80211_tx_rate *txrate;
@@ -6655,7 +6652,6 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
 
 	tx_info = IEEE80211_SKB_CB(p);
 	h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN);
-	fc = le16_to_cpu(h->frame_control);
 
 	scb = (struct scb *)tx_info->control.sta->drv_priv;
 
@@ -6684,7 +6680,7 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
 	tx_rts_count =
 	    (txs->status & TX_STATUS_RTS_RTX_MASK) >> TX_STATUS_RTS_RTX_SHIFT;
 
-	lastframe = (fc & IEEE80211_FCTL_MOREFRAGS) == 0;
+	lastframe = ieee80211_has_morefrags(h->frame_control);
 
 	if (!lastframe) {
 		WL_ERROR("Not last frame!\n");
@@ -7053,7 +7049,6 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
 	d11rxhdr_t *rxh;
 	struct ieee80211_hdr *h;
 	struct osl_info *osh;
-	u16 fc;
 	uint len;
 	bool is_amsdu;
 
@@ -7105,9 +7100,7 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
 	}
 
 	/* check received pkt has at least frame control field */
-	if (len >= D11_PHY_HDR_LEN + sizeof(h->frame_control)) {
-		fc = le16_to_cpu(h->frame_control);
-	} else {
+	if (len < D11_PHY_HDR_LEN + sizeof(h->frame_control)) {
 		wlc->pub->_cnt->rxrunt++;
 		goto toss;
 	}
@@ -7117,8 +7110,9 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
 	/* explicitly test bad src address to avoid sending bad deauth */
 	if (!is_amsdu) {
 		/* CTS and ACK CTL frames are w/o a2 */
-		if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA ||
-		    (fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) {
+
+		if (ieee80211_is_data(h->frame_control) ||
+		    ieee80211_is_mgmt(h->frame_control)) {
 			if ((is_zero_ether_addr(h->addr2) ||
 			     is_multicast_ether_addr(h->addr2))) {
 				WL_ERROR("wl%d: %s: dropping a frame with "
@@ -7132,10 +7126,8 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
 	}
 
 	/* due to sheer numbers, toss out probe reqs for now */
-	if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) {
-		if ((fc & FC_KIND_MASK) == FC_PROBE_REQ)
-			goto toss;
-	}
+	if (ieee80211_is_probe_req(h->frame_control))
+		goto toss;
 
 	if (is_amsdu) {
 		WL_ERROR("%s: is_amsdu causing toss\n", __func__);
@@ -7688,7 +7680,7 @@ wlc_compute_bcntsfoff(struct wlc_info *wlc, ratespec_t rspec,
  *	and included up to, but not including, the 4 byte FCS.
  */
 static void
-wlc_bcn_prb_template(struct wlc_info *wlc, uint type, ratespec_t bcn_rspec,
+wlc_bcn_prb_template(struct wlc_info *wlc, u16 type, ratespec_t bcn_rspec,
 		     wlc_bsscfg_t *cfg, u16 *buf, int *len)
 {
 	static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255};
@@ -7697,9 +7689,10 @@ wlc_bcn_prb_template(struct wlc_info *wlc, uint type, ratespec_t bcn_rspec,
 	int hdr_len, body_len;
 
 	ASSERT(*len >= 142);
-	ASSERT(type == FC_BEACON || type == FC_PROBE_RESP);
+	ASSERT(type == IEEE80211_STYPE_BEACON ||
+	       type == IEEE80211_STYPE_PROBE_RESP);
 
-	if (MBSS_BCN_ENAB(cfg) && type == FC_BEACON)
+	if (MBSS_BCN_ENAB(cfg) && type == IEEE80211_STYPE_BEACON)
 		hdr_len = DOT11_MAC_HDR_LEN;
 	else
 		hdr_len = D11_PHY_HDR_LEN + DOT11_MAC_HDR_LEN;
@@ -7713,7 +7706,7 @@ wlc_bcn_prb_template(struct wlc_info *wlc, uint type, ratespec_t bcn_rspec,
 	plcp = (cck_phy_hdr_t *) buf;
 
 	/* PLCP for Probe Response frames are filled in from core's rate table */
-	if (type == FC_BEACON && !MBSS_BCN_ENAB(cfg)) {
+	if (type == IEEE80211_STYPE_BEACON && !MBSS_BCN_ENAB(cfg)) {
 		/* fill in PLCP */
 		wlc_compute_plcp(wlc, bcn_rspec,
 				 (DOT11_MAC_HDR_LEN + body_len + FCS_LEN),
@@ -7725,17 +7718,17 @@ wlc_bcn_prb_template(struct wlc_info *wlc, uint type, ratespec_t bcn_rspec,
 	if (!SOFTBCN_ENAB(cfg))
 		wlc_beacon_phytxctl_txant_upd(wlc, bcn_rspec);
 
-	if (MBSS_BCN_ENAB(cfg) && type == FC_BEACON)
+	if (MBSS_BCN_ENAB(cfg) && type == IEEE80211_STYPE_BEACON)
 		h = (struct ieee80211_mgmt *)&plcp[0];
 	else
 		h = (struct ieee80211_mgmt *)&plcp[1];
 
 	/* fill in 802.11 header */
-	h->frame_control = cpu_to_le16((u16) type);
+	h->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | type);
 
 	/* DUR is 0 for multicast bcn, or filled in by MAC for prb resp */
 	/* A1 filled in by MAC for prb resp, broadcast for bcn */
-	if (type == FC_BEACON)
+	if (type == IEEE80211_STYPE_BEACON)
 		memcpy(&h->da, &ether_bcast, ETH_ALEN);
 	memcpy(&h->sa, &cfg->cur_etheraddr, ETH_ALEN);
 	memcpy(&h->bssid, &cfg->BSSID, ETH_ALEN);
@@ -7799,8 +7792,8 @@ void wlc_bss_update_beacon(struct wlc_info *wlc, wlc_bsscfg_t *cfg)
 			true));
 
 		/* update the template and ucode shm */
-		wlc_bcn_prb_template(wlc, FC_BEACON, wlc->bcn_rspec, cfg, bcn,
-				     &len);
+		wlc_bcn_prb_template(wlc, IEEE80211_STYPE_BEACON,
+				     wlc->bcn_rspec, cfg, bcn, &len);
 		wlc_write_hw_bcntemplates(wlc, bcn, len, false);
 	}
 }
@@ -7859,8 +7852,8 @@ wlc_bss_update_probe_resp(struct wlc_info *wlc, wlc_bsscfg_t *cfg, bool suspend)
 	if (!MBSS_PRB_ENAB(cfg)) {
 
 		/* create the probe response template */
-		wlc_bcn_prb_template(wlc, FC_PROBE_RESP, 0, cfg, prb_resp,
-				     &len);
+		wlc_bcn_prb_template(wlc, IEEE80211_STYPE_PROBE_RESP, 0, cfg,
+				     prb_resp, &len);
 
 		if (suspend)
 			wlc_suspend_mac_and_wait(wlc);
@@ -7898,7 +7891,6 @@ int wlc_prep_pdu(struct wlc_info *wlc, struct sk_buff *pdu, uint *fifop)
 	d11txh_t *txh;
 	struct ieee80211_hdr *h;
 	struct scb *scb;
-	u16 fc;
 
 	osh = wlc->osh;
 
@@ -7907,7 +7899,6 @@ int wlc_prep_pdu(struct wlc_info *wlc, struct sk_buff *pdu, uint *fifop)
 	ASSERT(txh);
 	h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN);
 	ASSERT(h);
-	fc = le16_to_cpu(h->frame_control);
 
 	/* get the pkt queue info. This was put at wlc_sendctl or wlc_send for PDU */
 	fifo = le16_to_cpu(txh->TxFrameID) & TXFID_QUEUE_MASK;
diff --git a/drivers/staging/brcm80211/include/proto/802.11.h b/drivers/staging/brcm80211/include/proto/802.11.h
index 8ca674e..3c09d8d 100644
--- a/drivers/staging/brcm80211/include/proto/802.11.h
+++ b/drivers/staging/brcm80211/include/proto/802.11.h
@@ -121,17 +121,6 @@ typedef struct wme_param_ie wme_param_ie_t;
 #define SEQNUM_MAX		0x1000
 #define FRAGNUM_MASK		0xF
 
-#define FC_SUBTYPE_ANY_QOS(s)	((((fc) & IEEE80211_FCTL_STYPE & (1<<7))) != 0)
-
-#define FC_KIND_MASK		(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)
-
-#define FC_PROBE_REQ	(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ)
-#define FC_PROBE_RESP	(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP)
-#define FC_BEACON	(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON)
-#define FC_PS_POLL	(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL)
-#define FC_RTS		(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS)
-#define FC_CTS		(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS)
-
 #define TLV_LEN_OFF		1
 #define TLV_HDR_LEN		2
 #define TLV_BODY_OFF		2
-- 
1.7.1

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux