staging: rtl8723bs: replace private 802.11 header macros with generic helpers
cover staging: rtl8723bs: replace private 802.11 header macros with generic helpers
The rtl8723bs driver has its own set of macros and inline functions in wifi.h for working with 802.11 frame headers. They access the header through hardcoded byte offsets and pointer casts, and they duplicate struct ieee80211_hdr and the helpers in <linux/ieee80211.h> that mac80211, cfg80211 and other wireless drivers already use.
This series switches the driver over to the generic versions and deletes the private ones from wifi.h. Each patch converts one group of macros and removes their definitions once nothing uses them anymore, so the driver builds after every patch.
Patches 1 to 3 convert header address access and the Frame Control flag checks and updates.
Patches 4 and 5 convert the frame type and subtype checks. Single comparisons use the ieee80211_is_*() helpers, and switch statements mask frame_control with IEEE80211_FCTL_* and use IEEE80211_STYPE_* case labels, the same way mac80211 does.
Patch 6 removes an unused struct member. Its initialisers were the last users of a few private subtype constants that have no generic equivalent.
Patch 7 converts the frame subtype setter and removes the private WIFI_* frame type enum.
Patches 8 and 9 convert the Sequence Control, Duration/ID and QoS Control fields.
Patch 10 replaces the driver's destination and source address helpers with ieee80211_get_DA() and ieee80211_get_SA().
None of this should change behaviour. In the few places where a generic helper checks more than the code it replaces, or where the old macro kept bits that a plain assignment would overwrite, the commit message explains why the result is the same.
Compile tested with W=1 after each patch, and checked with checkpatch and smatch. I don't have a device with this chip, so it has not been tested on hardware.
Rishik Yechuri (10):
staging: rtl8723bs: use struct ieee80211_hdr for header addresses
staging: rtl8723bs: use ieee80211_has_*() to test frame control flags
staging: rtl8723bs: set frame control flags with IEEE80211_FCTL_*
masks
staging: rtl8723bs: use ieee80211_is_*() for frame type tests
staging: rtl8723bs: use IEEE80211_FCTL_* masks for frame type dispatch
staging: rtl8723bs: remove unused num member from struct mlme_handler
staging: rtl8723bs: use IEEE80211_FTYPE_* and IEEE80211_STYPE_* values
staging: rtl8723bs: use struct ieee80211_hdr for seq_ctrl and
duration_id
staging: rtl8723bs: use IEEE80211_QOS_CTL_* masks for QoS control
staging: rtl8723bs: use ieee80211_get_DA() and ieee80211_get_SA()
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 254 ++++++++--------- drivers/staging/rtl8723bs/core/rtw_recv.c | 134 ++++----- drivers/staging/rtl8723bs/core/rtw_security.c | 41 +-- .../staging/rtl8723bs/core/rtw_wlan_util.c | 7 +- drivers/staging/rtl8723bs/core/rtw_xmit.c | 75 +++--- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 42 +-- .../staging/rtl8723bs/hal/rtl8723bs_recv.c | 9 +- .../staging/rtl8723bs/hal/rtl8723bs_xmit.c | 3 +- .../staging/rtl8723bs/include/rtw_mlme_ext.h | 1 - drivers/staging/rtl8723bs/include/wifi.h | 255 +----------------- .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 19 +- 11 files changed, 319 insertions(+), 521 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/10 staging: rtl8723bs: use struct ieee80211_hdr for header addresses
The driver defines GetAddr1Ptr() through GetAddr4Ptr() in wifi.h to obtain pointers to the address fields of an IEEE 802.11 header by adding hardcoded byte offsets to the frame buffer. This duplicates struct ieee80211_hdr from <linux/ieee80211.h>, which describes the same layout and is used throughout the wireless subsystem.
Replace each use of these macros with the corresponding addr1..addr4 member of struct ieee80211_hdr, and remove the macro definitions. Several functions in rtw_mlme_ext.c already access the header through struct ieee80211_hdr. This makes the remaining call sites consistent with them.
Include <linux/ieee80211.h> directly in wifi.h, since the inline helpers there now depend on struct ieee80211_hdr.
This is the first step towards replacing the driver's private 802.11 header macros with the generic helpers provided by the kernel.
No functional change intended.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 87 +++++++++++-------- drivers/staging/rtl8723bs/core/rtw_recv.c | 46 +++++----- .../staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723bs/include/wifi.h | 43 +++++---- .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 +- 5 files changed, 100 insertions(+), 81 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +50 -37
@@ -415,11 +415,12 @@ void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext)static void _mgt_dispatcher (struct adapter *padapter,struct mlme_handler *ptable,union recv_frame *precv_frame) {u8 *pframe = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;if (ptable->func) {/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ -if (memcmp (GetAddr1Ptr (pframe),myid (&padapter->eeprompriv),ETH_ALEN ) && - !is_broadcast_ether_addr (GetAddr1Ptr (pframe))) +if (memcmp (hdr->addr1,myid (&padapter->eeprompriv),ETH_ALEN ) && + !is_broadcast_ether_addr (hdr->addr1))return ; ptable->func (padapter, precv_frame);
@@ -432,14 +433,15 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame)struct mlme_handler *ptable;struct mlme_priv *pmlmepriv = &padapter->mlmepriv;u8 *pframe = precv_frame->u.hdr.rx_data; -struct sta_info *psta =rtw_get_stainfo (&padapter->stapriv,GetAddr2Ptr (pframe)); +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe; +struct sta_info *psta =rtw_get_stainfo (&padapter->stapriv, hdr->addr2);if (GetFrameType (pframe) !=WIFI_MGT_TYPE )return ;/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ -if (memcmp (GetAddr1Ptr (pframe),myid (&padapter->eeprompriv),ETH_ALEN ) && - !is_broadcast_ether_addr (GetAddr1Ptr (pframe))) { +if (memcmp (hdr->addr1,myid (&padapter->eeprompriv),ETH_ALEN ) && + !is_broadcast_ether_addr (hdr->addr1)) {return ; }
@@ -554,6 +556,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)struct mlme_priv *pmlmepriv = &padapter->mlmepriv;struct sta_priv *pstapriv = &padapter->stapriv;u8 *pframe = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;uint len = precv_frame->u.hdr.len;struct wlan_bssid_ex *pbss;int ret = _SUCCESS;
@@ -574,7 +577,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)return _SUCCESS; } -if (!memcmp (GetAddr3Ptr (pframe),get_my_bssid (&pmlmeinfo->network),ETH_ALEN )) { +if (!memcmp (hdr->addr3,get_my_bssid (&pmlmeinfo->network),ETH_ALEN )) {if (pmlmeinfo->state &WIFI_FW_AUTH_NULL ) {/* we should update current network before auth, or some IE is wrong */ pbss =kmalloc_obj (*pbss,GFP_ATOMIC );
@@ -610,7 +613,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)if (((pmlmeinfo->state &0x03 ) ==WIFI_FW_STATION_STATE ) && (pmlmeinfo->state &WIFI_FW_ASSOC_SUCCESS )) { - psta =rtw_get_stainfo (pstapriv,GetAddr2Ptr (pframe)); + psta =rtw_get_stainfo (pstapriv, hdr->addr2);if (psta) { ret =rtw_check_bcn_info (padapter, pframe, len);if (!ret) {
@@ -628,7 +631,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)adaptive_early_32k (pmlmeext, pframe, len); } }else if ((pmlmeinfo->state &0x03 ) ==WIFI_FW_ADHOC_STATE ) { - psta =rtw_get_stainfo (pstapriv,GetAddr2Ptr (pframe)); + psta =rtw_get_stainfo (pstapriv, hdr->addr2);if (psta) {/* update WMM, ERP in the beacon */ /* todo: the timer is used instead of the number of the beacon received */
@@ -650,7 +653,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)update_TSF (pmlmeext, pframe, len);/* report sta add event */ -report_add_sta_event (padapter,GetAddr2Ptr (pframe), cam_idx); +report_add_sta_event (padapter, hdr->addr2, cam_idx); } } }
@@ -673,6 +676,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;u8 *pframe = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;uint len = precv_frame->u.hdr.len;u8 offset =0 ;
@@ -682,7 +686,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)if (len <WLAN_HDR_A3_LEN )return _FAIL; - sa =GetAddr2Ptr (pframe); + sa = hdr->addr2; auth_mode = psecuritypriv->dot11_auth_algrthm;
@@ -930,6 +934,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)struct wlan_bssid_ex *cur = &(pmlmeinfo->network);struct sta_priv *pstapriv = &padapter->stapriv;u8 *pframe = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;uint pkt_len = precv_frame->u.hdr.len;if ((pmlmeinfo->state &0x03 ) !=WIFI_FW_AP_STATE )
@@ -944,7 +949,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)if (pkt_len <sizeof (struct ieee80211_hdr_3addr ) + ie_offset)return _FAIL; - pstat =rtw_get_stainfo (pstapriv,GetAddr2Ptr (pframe)); + pstat =rtw_get_stainfo (pstapriv, hdr->addr2);if (!pstat) { status =WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA ; goto asoc_class2_error;
@@ -1302,7 +1307,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) asoc_class2_error: -issue_deauth (padapter,GetAddr2Ptr (pframe), status); +issue_deauth (padapter, hdr->addr2, status);return _FAIL;
@@ -1418,10 +1423,11 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;u8 *pframe = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;int ignore_received_deauth =0 ;/* check A3 */ -if (memcmp (GetAddr3Ptr (pframe),get_my_bssid (&pmlmeinfo->network),ETH_ALEN )) +if (memcmp (hdr->addr3,get_my_bssid (&pmlmeinfo->network),ETH_ALEN ))return _SUCCESS; reason =le16_to_cpu (*(__le16 *)(pframe +WLAN_HDR_A3_LEN ));
@@ -1432,9 +1438,9 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)netdev_dbg (padapter->pnetdev,"ap recv deauth reason code(%d) sta:%pM\n" , reason, -GetAddr2Ptr (pframe)); + hdr->addr2); - psta =rtw_get_stainfo (pstapriv,GetAddr2Ptr (pframe)); + psta =rtw_get_stainfo (pstapriv, hdr->addr2);if (psta) {u8 updated = false;
@@ -1470,11 +1476,11 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)netdev_dbg (padapter->pnetdev,"sta recv deauth reason code(%d) sta:%pM, ignore = %d\n" , - reason,GetAddr3Ptr (pframe), + reason, hdr->addr3, ignore_received_deauth);if (ignore_received_deauth ==0 ) -receive_disconnect (padapter,GetAddr3Ptr (pframe), reason); +receive_disconnect (padapter, hdr->addr3, reason); pmlmepriv->link_detect_info.busy_traffic = false;return _SUCCESS;
@@ -1487,9 +1493,10 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame)struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;u8 *pframe = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;/* check A3 */ -if (memcmp (GetAddr3Ptr (pframe),get_my_bssid (&pmlmeinfo->network),ETH_ALEN )) +if (memcmp (hdr->addr3,get_my_bssid (&pmlmeinfo->network),ETH_ALEN ))return _SUCCESS; reason =le16_to_cpu (*(__le16 *)(pframe +WLAN_HDR_A3_LEN ));
@@ -1500,9 +1507,9 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame)netdev_dbg (padapter->pnetdev,"ap recv disassoc reason code(%d) sta:%pM\n" , - reason,GetAddr2Ptr (pframe)); + reason, hdr->addr2); - psta =rtw_get_stainfo (pstapriv,GetAddr2Ptr (pframe)); + psta =rtw_get_stainfo (pstapriv, hdr->addr2);if (psta) {u8 updated = false;
@@ -1521,9 +1528,9 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame) }netdev_dbg (padapter->pnetdev,"sta recv disassoc reason code(%d) sta:%pM\n" , - reason,GetAddr3Ptr (pframe)); + reason, hdr->addr3); -receive_disconnect (padapter,GetAddr3Ptr (pframe), reason); +receive_disconnect (padapter, hdr->addr3, reason); pmlmepriv->link_detect_info.busy_traffic = false;return _SUCCESS;
@@ -1539,11 +1546,12 @@ unsigned int on_action_spct(struct adapter *padapter, union recv_frame *precv_frstruct sta_info *psta =NULL ;struct sta_priv *pstapriv = &padapter->stapriv;u8 *pframe = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;u8 *frame_body = (u8 *)(pframe +sizeof (struct ieee80211_hdr_3addr ));u8 category;u8 action; - psta =rtw_get_stainfo (pstapriv,GetAddr2Ptr (pframe)); + psta =rtw_get_stainfo (pstapriv, hdr->addr2);if (!psta) goto exit;
@@ -1579,17 +1587,18 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_frastruct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;u8 *pframe = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;struct sta_priv *pstapriv = &padapter->stapriv;/* check RA matches or not */ -if (memcmp (myid (&(padapter->eeprompriv)),GetAddr1Ptr (pframe),ETH_ALEN ))/* for if1, sta/ap mode */ +if (memcmp (myid (&(padapter->eeprompriv)), hdr->addr1,ETH_ALEN ))/* for if1, sta/ap mode */ return _SUCCESS;if ((pmlmeinfo->state &0x03 ) !=WIFI_FW_AP_STATE )if (!(pmlmeinfo->state &WIFI_FW_ASSOC_SUCCESS ))return _SUCCESS; - addr =GetAddr2Ptr (pframe); + addr = hdr->addr2; psta =rtw_get_stainfo (pstapriv, addr);if (!psta)
@@ -1742,11 +1751,12 @@ unsigned int on_action_public(struct adapter *padapter, union recv_frame *precv_ {unsigned int ret = _FAIL;u8 *pframe = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;u8 *frame_body = pframe +sizeof (struct ieee80211_hdr_3addr );u8 category, action;/* check RA matches or not */ -if (memcmp (myid (&(padapter->eeprompriv)),GetAddr1Ptr (pframe),ETH_ALEN )) +if (memcmp (myid (&(padapter->eeprompriv)), hdr->addr1,ETH_ALEN )) goto exit; category = frame_body[0 ];
@@ -1770,11 +1780,12 @@ unsigned int on_action_public(struct adapter *padapter, union recv_frame *precv_unsigned int OnAction_ht (struct adapter *padapter,union recv_frame *precv_frame) {u8 *pframe = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;u8 *frame_body = pframe +sizeof (struct ieee80211_hdr_3addr );u8 category, action;/* check RA matches or not */ -if (memcmp (myid (&(padapter->eeprompriv)),GetAddr1Ptr (pframe),ETH_ALEN )) +if (memcmp (myid (&(padapter->eeprompriv)), hdr->addr1,ETH_ALEN )) goto exit; category = frame_body[0 ];
@@ -1797,13 +1808,14 @@ unsigned int OnAction_ht(struct adapter *padapter, union recv_frame *precv_frameunsigned int OnAction_sa_query (struct adapter *padapter,union recv_frame *precv_frame) {u8 *pframe = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);unsigned short tid;switch (pframe[WLAN_HDR_A3_LEN +1 ]) {case 0 :/* SA Query req */ memcpy (&tid, &pframe[WLAN_HDR_A3_LEN +2 ],sizeof (unsigned short )); -issue_action_SA_Query (padapter,GetAddr2Ptr (pframe),1 , tid); +issue_action_SA_Query (padapter, hdr->addr2,1 , tid);break ;case 1 :/* SA Query rsp */
@@ -1924,13 +1936,13 @@ void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattrivoid update_mgntframe_attrib_addr (struct adapter *padapter,struct xmit_frame *pmgntframe) { -u8 *pframe; +struct ieee80211_hdr *hdr;struct pkt_attrib *pattrib = &pmgntframe->attrib; - pframe = (u8 *)(pmgntframe->buf_addr) +TXDESC_OFFSET ; + hdr = (struct ieee80211_hdr *)(pmgntframe->buf_addr +TXDESC_OFFSET ); -memcpy (pattrib->ra,GetAddr1Ptr (pframe),ETH_ALEN ); -memcpy (pattrib->ta,GetAddr2Ptr (pframe),ETH_ALEN ); +memcpy (pattrib->ra, hdr->addr1,ETH_ALEN ); +memcpy (pattrib->ta, hdr->addr2,ETH_ALEN ); }void dump_mgntframe (struct adapter *padapter,struct xmit_frame *pmgntframe)
@@ -2609,9 +2621,9 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i fctrl = &(pwlanhdr->frame_control); *(fctrl) =0 ; -memcpy (GetAddr1Ptr (pwlanhdr), pstat->hwaddr,ETH_ALEN ); -memcpy (GetAddr2Ptr (pwlanhdr),myid (&(padapter->eeprompriv)),ETH_ALEN ); -memcpy (GetAddr3Ptr (pwlanhdr),get_my_bssid (&(pmlmeinfo->network)),ETH_ALEN ); +memcpy (pwlanhdr->addr1, pstat->hwaddr,ETH_ALEN ); +memcpy (pwlanhdr->addr2,myid (&(padapter->eeprompriv)),ETH_ALEN ); +memcpy (pwlanhdr->addr3,get_my_bssid (&(pmlmeinfo->network)),ETH_ALEN );SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++;
@@ -3744,6 +3756,7 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, stru8 *p;u16 val16, subtype;u8 *pframe = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;u32 packet_len = precv_frame->u.hdr.len;u8 ie_offset;struct registry_priv *pregistrypriv = &padapter->registrypriv;
@@ -3854,10 +3867,10 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, strif (val16 &BIT (0 )) { bssid->infrastructure_mode =NL80211_IFTYPE_STATION ; -memcpy (bssid->mac_address,GetAddr2Ptr (pframe),ETH_ALEN ); +memcpy (bssid->mac_address, hdr->addr2,ETH_ALEN ); }else { bssid->infrastructure_mode =NL80211_IFTYPE_ADHOC ; -memcpy (bssid->mac_address,GetAddr3Ptr (pframe),ETH_ALEN ); +memcpy (bssid->mac_address, hdr->addr3,ETH_ALEN ); }if (val16 &BIT (4 ))
drivers/staging/rtl8723bs/core/rtw_recv.c +26 -20
140 lines not on this page · raw message
drivers/staging/rtl8723bs/core/rtw_wlan_util.c +1 -1
@@ -1082,7 +1082,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)int group_cipher =0 , pairwise_cipher =0 , is_8021x =0 ;unsigned char *pbuf;u32 wpa_ielen =0 ; -u8 *pbssid =GetAddr3Ptr (pframe); +u8 *pbssid = ((struct ieee80211_hdr *)pframe)->addr3;struct HT_info_element *pht_info =NULL ;struct ieee80211_ht_cap *pht_cap =NULL ;u32 bcn_channel;
drivers/staging/rtl8723bs/include/wifi.h +21 -22
116 lines not on this page · raw message
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +2 -1
@@ -1908,7 +1908,8 @@ void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, u8 *pmgmt_frame, sinfo.filled =0 ; sinfo.assoc_req_ies = pmgmt_frame +WLAN_HDR_A3_LEN + ie_offset; sinfo.assoc_req_ies_len = frame_len -WLAN_HDR_A3_LEN - ie_offset; -cfg80211_new_sta (wdev,GetAddr2Ptr (pmgmt_frame), &sinfo,GFP_ATOMIC ); +cfg80211_new_sta (wdev, ((struct ieee80211_hdr *)pmgmt_frame)->addr2, + &sinfo,GFP_ATOMIC ); } }
Signature · 1 line
2.43.0
PATCH 2/10 staging: rtl8723bs: use ieee80211_has_*() to test frame control flags
In reply to Rishik YechuriThe driver defines GetToDs(), GetFrDs(), get_tofr_ds(), GetMFrag(), GetRetry(), GetPwrMgt(), GetMData(), GetPrivacy() and GetOrder() in wifi.h to test individual bits of the IEEE 802.11 Frame Control field. Each macro casts the frame buffer to __le16 and masks a single bit. <linux/ieee80211.h> provides equivalent helpers that operate on the frame_control member of struct ieee80211_hdr and test the same bits.
Replace each use of these macros with the corresponding helper:
GetToDs() -> ieee80211_has_tods() GetFrDs() -> ieee80211_has_fromds() GetMFrag() -> ieee80211_has_morefrags() GetRetry() -> ieee80211_has_retry() GetPwrMgt() -> ieee80211_has_pm() GetMData() -> ieee80211_has_moredata()
GetPrivacy() -> ieee80211_has_protected()
GetOrder() -> ieee80211_has_order()
Open code get_tofr_ds() using ieee80211_has_tods() and ieee80211_has_fromds(), and remove the macro definitions. Also remove GetOrderBit(), which has no users.
No functional change intended.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 10 +++--- drivers/staging/rtl8723bs/core/rtw_recv.c | 19 +++++++----- drivers/staging/rtl8723bs/include/wifi.h | 31 ++++--------------- 3 files changed, 23 insertions(+), 37 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +6 -4
@@ -455,7 +455,7 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) ptable += index;if (psta) { -if (GetRetry (pframe)) { +if (ieee80211_has_retry (hdr->frame_control)) {if (precv_frame->u.hdr.attrib.seq_num == psta->rx_mgmt_frame_seq_num) {/* drop the duplicate management frame */ return ;
@@ -690,7 +690,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) auth_mode = psecuritypriv->dot11_auth_algrthm; -if (GetPrivacy (pframe)) { +if (ieee80211_has_protected (hdr->frame_control)) {u8 *iv;struct rx_pkt_attrib *prxattrib = &(precv_frame->u.hdr.attrib);
@@ -849,6 +849,7 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_framstruct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;u8 *pframe = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;uint pkt_len = precv_frame->u.hdr.len;/* check A1 matches or not */
@@ -858,7 +859,7 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_framif (!(pmlmeinfo->state &WIFI_FW_AUTH_STATE ))return _SUCCESS; - offset = (GetPrivacy (pframe)) ?4 :0 ; + offset = (ieee80211_has_protected (hdr->frame_control)) ?4 :0 ; seq =le16_to_cpu (*(__le16 *)((SIZE_PTR )pframe +WLAN_HDR_A3_LEN + offset +2 )); status =le16_to_cpu (*(__le16 *)((SIZE_PTR )pframe +WLAN_HDR_A3_LEN + offset +4 ));
@@ -1673,10 +1674,11 @@ static s32 rtw_action_public_decache(union recv_frame *recv_frame, s32 token)struct adapter *adapter = recv_frame->u.hdr.adapter;struct mlme_ext_priv *mlmeext = &(adapter->mlmeextpriv);u8 *frame = recv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)frame;u16 seq_ctrl = ((recv_frame->u.hdr.attrib.seq_num &0xffff ) <<4 ) | (recv_frame->u.hdr.attrib.frag_num &0xf ); -if (GetRetry (frame)) { +if (ieee80211_has_retry (hdr->frame_control)) {if (token >=0 ) {if ((seq_ctrl == mlmeext->action_public_rxseq) && (token == mlmeext->action_public_dialog_token))
drivers/staging/rtl8723bs/core/rtw_recv.c +11 -8
@@ -566,13 +566,14 @@ static void process_pwrbit_data(struct adapter *padapter, union recv_frame *prec {unsigned char pwrbit;u8 *ptr = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)ptr;struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;struct sta_priv *pstapriv = &padapter->stapriv;struct sta_info *psta =NULL ; psta =rtw_get_stainfo (pstapriv, pattrib->src); - pwrbit =GetPwrMgt (ptr); + pwrbit =ieee80211_has_pm (hdr->frame_control);if (psta) {if (pwrbit) {
@@ -1248,7 +1249,7 @@ static signed int validate_recv_data_frame(struct adapter *adapter, union recv_fstruct security_priv *psecuritypriv = &adapter->securitypriv;signed int ret = _SUCCESS; - bretry =GetRetry (ptr); + bretry =ieee80211_has_retry (hdr->frame_control); pda =get_da (ptr); psa =get_sa (ptr); pbssid =get_hdr_bssid (ptr);
@@ -1435,6 +1436,7 @@ static signed int validate_recv_frame(struct adapter *adapter, union recv_framestruct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;u8 *ptr = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)ptr;u8 ver = (unsigned char ) (*ptr) &0x3 ;/* add version chk */
@@ -1446,16 +1448,17 @@ static signed int validate_recv_frame(struct adapter *adapter, union recv_frame type =GetFrameType (ptr); subtype =GetFrameSubType (ptr);/* bit(7)~bit(2) */ - pattrib->to_fr_ds =get_tofr_ds (ptr); + pattrib->to_fr_ds = (ieee80211_has_tods (hdr->frame_control) <<1 ) | +ieee80211_has_fromds (hdr->frame_control); pattrib->frag_num =GetFragNum (ptr); pattrib->seq_num =GetSequence (ptr); - pattrib->pw_save =GetPwrMgt (ptr); - pattrib->mfrag =GetMFrag (ptr); - pattrib->mdata =GetMData (ptr); - pattrib->privacy =GetPrivacy (ptr); - pattrib->order =GetOrder (ptr); + pattrib->pw_save =ieee80211_has_pm (hdr->frame_control); + pattrib->mfrag =ieee80211_has_morefrags (hdr->frame_control); + pattrib->mdata =ieee80211_has_moredata (hdr->frame_control); + pattrib->privacy =ieee80211_has_protected (hdr->frame_control); + pattrib->order =ieee80211_has_order (hdr->frame_control);switch (type) {case WIFI_MGT_TYPE :/* mgnt */
drivers/staging/rtl8723bs/include/wifi.h +6 -25
@@ -75,53 +75,33 @@ enum {#define SetToDs (pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(_TO_DS_)) -#define GetToDs (pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_TO_DS_)) != 0) -#define SetFrDs (pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_)) -#define GetFrDs (pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_FROM_DS_)) != 0) - -#define get_tofr_ds (pframe) ((GetToDs(pframe) << 1) | GetFrDs(pframe)) -#define SetMFrag (pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_)) -#define GetMFrag (pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_FRAG_)) != 0) -#define ClearMFrag (pbuf) \ (*(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_))) -#define GetRetry (pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_RETRY_)) != 0) -#define ClearRetry (pbuf) \ (*(__le16 *)(pbuf) &= (~cpu_to_le16(_RETRY_)))#define SetPwrMgt (pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(_PWRMGT_)) -#define GetPwrMgt (pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_PWRMGT_)) != 0) -#define ClearPwrMgt (pbuf) \ (*(__le16 *)(pbuf) &= (~cpu_to_le16(_PWRMGT_)))#define SetMData (pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(_MORE_DATA_)) -#define GetMData (pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_DATA_)) != 0) -#define ClearMData (pbuf) \ (*(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_)))#define SetPrivacy (pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_)) -#define GetPrivacy (pbuf) \ - (((*(__le16 *)(pbuf)) & cpu_to_le16(_PRIVACY_)) != 0) - -#define GetOrder (pbuf) \ - (((*(__le16 *)(pbuf)) & cpu_to_le16(_ORDER_)) != 0) -#define GetFrameType (pbuf) \ (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(3) | BIT(2)))
@@ -204,7 +184,8 @@ static inline unsigned char *get_da(unsigned char *pframe) {struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;unsigned char *da; -unsigned int to_fr_ds = (GetToDs (pframe) <<1 ) |GetFrDs (pframe); +unsigned int to_fr_ds = (ieee80211_has_tods (hdr->frame_control) <<1 ) | +ieee80211_has_fromds (hdr->frame_control);switch (to_fr_ds) {case 0x00 :/* ToDs = 0, FromDs = 0 */
@@ -228,7 +209,8 @@ static inline unsigned char *get_sa(unsigned char *pframe) {struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;unsigned char *sa; -unsigned int to_fr_ds = (GetToDs (pframe) <<1 ) |GetFrDs (pframe); +unsigned int to_fr_ds = (ieee80211_has_tods (hdr->frame_control) <<1 ) | +ieee80211_has_fromds (hdr->frame_control);switch (to_fr_ds) {case 0x00 :/* ToDs = 0, FromDs = 0 */
@@ -252,7 +234,8 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe) {struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;unsigned char *sa =NULL ; -unsigned int to_fr_ds = (GetToDs (pframe) <<1 ) |GetFrDs (pframe); +unsigned int to_fr_ds = (ieee80211_has_tods (hdr->frame_control) <<1 ) | +ieee80211_has_fromds (hdr->frame_control);switch (to_fr_ds) {case 0x00 :/* ToDs = 0, FromDs = 0 */
@@ -317,8 +300,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe)/*----------------------------------------------------------------------------- Below is the definition for 802.11n ------------------------------------------------------------------------------*/ -#define GetOrderBit (pbuf) (((*(unsigned short *)(pbuf)) & cpu_to_le16(_ORDER_)) != 0) -#define ACT_CAT_VENDOR 0x7F/* 127 */ /**
Signature · 1 line
2.43.0
PATCH 3/10 staging: rtl8723bs: set frame control flags with IEEE80211_FCTL_* masks
In reply to Rishik YechuriThe driver defines SetToDs(), SetFrDs(), SetMFrag(), ClearMFrag(), ClearRetry(), SetPwrMgt(), ClearPwrMgt(), SetMData(), ClearMData() and SetPrivacy() in wifi.h to set and clear bits of the IEEE 802.11 Frame Control field, using private _TO_DS_ through _ORDER_ bit definitions that duplicate the IEEE80211_FCTL_* constants in <linux/ieee80211.h>.
Replace each use of these macros by operating on the frame_control member directly with the corresponding IEEE80211_FCTL_* mask, as is done elsewhere in the wireless subsystem.
In rtw_xmitframe_coalesce(), the header pointer is updated on each iteration of the fragmentation loop, since mem_start advances to a new fragment each time.
When constructing the BIP additional authentication data, mask the Retry, Power Management and More Data bits in a local copy of the Frame Control field before copying it into the buffer. This matches bip_aad() in net/mac80211/wpa.c.
Remove the macro definitions and the private bit definitions, which no longer have any users. Also remove the mem_start variable from rtw_mgmt_xmitframe_coalesce(), as its only use was the SetPrivacy() call.
No functional change intended.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 12 +++--- drivers/staging/rtl8723bs/core/rtw_security.c | 9 +++-- drivers/staging/rtl8723bs/core/rtw_xmit.c | 29 +++++++------- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 12 +++--- drivers/staging/rtl8723bs/include/wifi.h | 39 ------------------- 5 files changed, 33 insertions(+), 68 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +6 -6
@@ -2573,7 +2573,7 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned shortif ((pmlmeinfo->auth_seq ==3 ) && (pmlmeinfo->state &WIFI_FW_AUTH_STATE ) && (use_shared_key ==1 )) { pframe =rtw_set_ie (pframe,WLAN_EID_CHALLENGE ,128 , pmlmeinfo->chg_txt, &(pattrib->pktlen)); -SetPrivacy (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_PROTECTED ); pattrib->hdrlen =sizeof (struct ieee80211_hdr_3addr );
@@ -2926,12 +2926,12 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da, *(fctrl) =0 ;if ((pmlmeinfo->state &0x03 ) ==WIFI_FW_AP_STATE ) -SetFrDs (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_FROMDS );else if ((pmlmeinfo->state &0x03 ) ==WIFI_FW_STATION_STATE ) -SetToDs (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_TODS );if (power_mode) -SetPwrMgt (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_PM );memcpy (pwlanhdr->addr1, da,ETH_ALEN );memcpy (pwlanhdr->addr2,myid (&(padapter->eeprompriv)),ETH_ALEN );
@@ -3068,9 +3068,9 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, *(fctrl) =0 ;if ((pmlmeinfo->state &0x03 ) ==WIFI_FW_AP_STATE ) -SetFrDs (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_FROMDS );else if ((pmlmeinfo->state &0x03 ) ==WIFI_FW_STATION_STATE ) -SetToDs (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_TODS ); qc = (unsigned short *)(pframe + pattrib->hdrlen -2 );
drivers/staging/rtl8723bs/core/rtw_security.c +5 -4
@@ -1277,6 +1277,7 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe)u8 mic[16 ];struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;__le16 le_tmp; +__le16 mask_fc;__le64 le_tmp64 =0 ; ori_len = pattrib->pkt_len -WLAN_HDR_A3_LEN +BIP_AAD_SIZE ;
@@ -1320,10 +1321,10 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe)memset (p +2 + len -8 ,0 ,8 );/* conscruct AAD, copy frame control field */ -memcpy (BIP_AAD , &pwlanhdr->frame_control,2 ); -ClearRetry (BIP_AAD ); -ClearPwrMgt (BIP_AAD ); -ClearMData (BIP_AAD ); + mask_fc = pwlanhdr->frame_control; + mask_fc &= ~cpu_to_le16 (IEEE80211_FCTL_RETRY |IEEE80211_FCTL_PM | +IEEE80211_FCTL_MOREDATA ); +memcpy (BIP_AAD , &mask_fc,2 );/* conscruct AAD, copy address 1 to address 3 */ memcpy (BIP_AAD +2 , &pwlanhdr->addrs,sizeof (pwlanhdr->addrs));
drivers/staging/rtl8723bs/core/rtw_xmit.c +16 -13
@@ -921,7 +921,7 @@ int rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr {/* 1.Data transfer to AP */ /* 2.Arp pkt will relayed by AP */ -SetToDs (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_TODS );memcpy (pwlanhdr->addr1,get_bssid (pmlmepriv),ETH_ALEN );memcpy (pwlanhdr->addr2, pattrib->src,ETH_ALEN );memcpy (pwlanhdr->addr3, pattrib->dst,ETH_ALEN );
@@ -930,7 +930,7 @@ int rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattrif (pqospriv->qos_option) qos_option = true; }else if (check_fwstate (pmlmepriv,WIFI_AP_STATE )) { -SetFrDs (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_FROMDS );memcpy (pwlanhdr->addr1, pattrib->dst,ETH_ALEN );memcpy (pwlanhdr->addr2,get_bssid (pmlmepriv),ETH_ALEN );memcpy (pwlanhdr->addr3, pattrib->src,ETH_ALEN );
@@ -950,10 +950,10 @@ int rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr }if (pattrib->mdata) -SetMData (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_MOREDATA );if (pattrib->encrypt) -SetPrivacy (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_PROTECTED );if (qos_option) { qc = (unsigned short *)(hdr + pattrib->hdrlen -2 );
@@ -1069,6 +1069,7 @@ int rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, structSIZE_PTR addr;u8 *pframe, *mem_start; +struct ieee80211_hdr *hdr;u8 hw_hdr_offset;struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
@@ -1106,8 +1107,9 @@ int rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct mpdu_len = frg_len; pframe = mem_start; + hdr = (struct ieee80211_hdr *)mem_start; -SetMFrag (mem_start); + hdr->frame_control |=cpu_to_le16 (IEEE80211_FCTL_MOREFRAGS ); pframe += pattrib->hdrlen; mpdu_len -= pattrib->hdrlen;
@@ -1157,7 +1159,7 @@ int rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct ((pattrib->bswenc) ? pattrib->icv_len :0 ) + mem_sz; -ClearMFrag (mem_start); + hdr->frame_control &= ~cpu_to_le16 (IEEE80211_FCTL_MOREFRAGS );break ; }
@@ -1185,7 +1187,7 @@ int rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct/* broadcast or multicast management pkt use BIP, unicast management pkt use CCMP encryption */ int rtw_mgmt_xmitframe_coalesce (struct adapter *padapter,struct sk_buff *pkt,struct xmit_frame *pxmitframe) { -u8 *pframe, *mem_start =NULL , *tmp_buf =NULL ; +u8 *pframe, *tmp_buf =NULL ;u8 subtype;struct sta_info *psta =NULL ;struct pkt_attrib *pattrib = &pxmitframe->attrib;
@@ -1196,10 +1198,11 @@ int rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, sstruct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;struct mlme_priv *pmlmepriv = &padapter->mlmepriv;struct ieee80211_hdr *pwlanhdr; +__le16 mask_fc;u8 MME [_MME_IE_LENGTH_];u32 ori_len; - mem_start = pframe = (u8 *)(pxmitframe->buf_addr) +TXDESC_OFFSET ; + pframe = (u8 *)(pxmitframe->buf_addr) +TXDESC_OFFSET ; pwlanhdr = (struct ieee80211_hdr *)pframe; ori_len =BIP_AAD_SIZE + pattrib->pktlen;
@@ -1249,10 +1252,10 @@ int rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, s frame_body_len = pattrib->pktlen -sizeof (struct ieee80211_hdr_3addr );/* conscruct AAD, copy frame control field */ -memcpy (BIP_AAD , &pwlanhdr->frame_control,2 ); -ClearRetry (BIP_AAD ); -ClearPwrMgt (BIP_AAD ); -ClearMData (BIP_AAD ); + mask_fc = pwlanhdr->frame_control; + mask_fc &= ~cpu_to_le16 (IEEE80211_FCTL_RETRY |IEEE80211_FCTL_PM | +IEEE80211_FCTL_MOREDATA ); +memcpy (BIP_AAD , &mask_fc,2 );/* conscruct AAD, copy address 1 to address 3 */ memcpy (BIP_AAD +2 , &pwlanhdr->addrs,sizeof (pwlanhdr->addrs));/* copy management fram body */
@@ -1329,7 +1332,7 @@ int rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, s pattrib->last_txcmdsz = pattrib->pktlen;/* set protected bit must be before SW encrypt */ -SetPrivacy (mem_start); + pwlanhdr->frame_control |=cpu_to_le16 (IEEE80211_FCTL_PROTECTED );/* software encrypt */ xmitframe_swencrypt (padapter, pxmitframe); }
drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +6 -6
@@ -192,7 +192,7 @@ static void ConstructPSPoll(struct adapter *padapter, u8 *pframe, u32 *pLength)/* Frame control. */ fctrl = &pwlanhdr->frame_control; *(fctrl) =0 ; -SetPwrMgt (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_PM );SetFrameSubType (pframe,WIFI_PSPOLL );/* AID. */
@@ -229,17 +229,17 @@ static void ConstructNullFunctionData(struct adapter *padapter, fctrl = &pwlanhdr->frame_control; *(fctrl) =0 ;if (bForcePowerSave) -SetPwrMgt (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_PM );switch (cur_network->network.infrastructure_mode) {case NL80211_IFTYPE_STATION : -SetToDs (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_TODS );ether_addr_copy (pwlanhdr->addr1,get_my_bssid (&(pmlmeinfo->network)));ether_addr_copy (pwlanhdr->addr2,myid (&(padapter->eeprompriv)));ether_addr_copy (pwlanhdr->addr3, StaAddr);break ;case NL80211_IFTYPE_AP : -SetFrDs (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_FROMDS );ether_addr_copy (pwlanhdr->addr1, StaAddr);ether_addr_copy (pwlanhdr->addr2,get_my_bssid (&(pmlmeinfo->network)));ether_addr_copy (pwlanhdr->addr3,myid (&(padapter->eeprompriv)));
@@ -732,9 +732,9 @@ static void ConstructBtNullFunctionData(struct adapter *padapter, fctrl = &pwlanhdr->frame_control; *fctrl =0 ;if (bForcePowerSave) -SetPwrMgt (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_PM ); -SetFrDs (fctrl); + *fctrl |=cpu_to_le16 (IEEE80211_FCTL_FROMDS );ether_addr_copy (pwlanhdr->addr1, StaAddr);ether_addr_copy (pwlanhdr->addr2,myid (&padapter->eeprompriv));ether_addr_copy (pwlanhdr->addr3,myid (&padapter->eeprompriv));
drivers/staging/rtl8723bs/include/wifi.h +0 -39
@@ -63,45 +63,6 @@ enum { WIFI_QOS_DATA_NULL = (BIT(6) | WIFI_QOS_DATA_TYPE), }; -#define _TO_DS_ BIT(8) -#define _FROM_DS_ BIT(9) -#define _MORE_FRAG_ BIT(10) -#define _RETRY_ BIT(11) -#define _PWRMGT_ BIT(12) -#define _MORE_DATA_ BIT(13) -#define _PRIVACY_ BIT(14) -#define _ORDER_ BIT(15) - -#define SetToDs (pbuf) \ - (*(__le16 *)(pbuf) |= cpu_to_le16(_TO_DS_)) - -#define SetFrDs (pbuf) \ - (*(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_)) - -#define SetMFrag (pbuf) \ - (*(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_)) - -#define ClearMFrag (pbuf) \ - (*(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_))) - -#define ClearRetry (pbuf) \ - (*(__le16 *)(pbuf) &= (~cpu_to_le16(_RETRY_))) - -#define SetPwrMgt (pbuf) \ - (*(__le16 *)(pbuf) |= cpu_to_le16(_PWRMGT_)) - -#define ClearPwrMgt (pbuf) \ - (*(__le16 *)(pbuf) &= (~cpu_to_le16(_PWRMGT_))) - -#define SetMData (pbuf) \ - (*(__le16 *)(pbuf) |= cpu_to_le16(_MORE_DATA_)) - -#define ClearMData (pbuf) \ - (*(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_))) - -#define SetPrivacy (pbuf) \ - (*(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_)) -#define GetFrameType (pbuf) \ (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(3) | BIT(2)))
Signature · 1 line
2.43.0
PATCH 4/10 staging: rtl8723bs: use ieee80211_is_*() for frame type tests
In reply to Rishik YechuriSeveral functions test whether a received or transmitted frame is of one particular type or subtype by comparing the result of GetFrameType() or GetFrameSubType() against the driver's WIFI_* constants. <linux/ieee80211.h> provides ieee80211_is_*() helpers that perform the same tests on the frame_control member of struct ieee80211_hdr.
Replace these single comparisons with the corresponding helpers:
GetFrameType() == WIFI_MGT_TYPE -> ieee80211_is_mgmt() GetFrameType() == WIFI_CTRL_TYPE -> ieee80211_is_ctl() GetFrameType() == WIFI_DATA_TYPE -> ieee80211_is_data() GetFrameSubType() == WIFI_BEACON -> ieee80211_is_beacon() GetFrameSubType() == WIFI_PSPOLL -> ieee80211_is_pspoll()
GetFrameSubType() == WIFI_ASSOCREQ -> ieee80211_is_assoc_req()
GetFrameSubType() == WIFI_DEAUTH -> ieee80211_is_deauth()
GetFrameSubType() == WIFI_DISASSOC -> ieee80211_is_disassoc()
The QoS data test in sta2ap_data_frame() is replaced with ieee80211_is_data_qos(). The helper additionally checks that the frame type is data, which is always the case on this path since the frame has already been classified as a data frame by validate_recv_frame().
Remove IsFrameTypeCtrl(), whose only caller is converted by this change.
The remaining users of GetFrameType() and GetFrameSubType() are converted separately.
No functional change intended.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723bs/core/rtw_recv.c | 11 ++++++----- drivers/staging/rtl8723bs/core/rtw_xmit.c | 3 ++- drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c | 5 +++-- drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 3 ++- drivers/staging/rtl8723bs/include/wifi.h | 5 ----- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 6 +++--- 7 files changed, 17 insertions(+), 18 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +1 -1
@@ -436,7 +436,7 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame)struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;struct sta_info *psta =rtw_get_stainfo (&padapter->stapriv, hdr->addr2); -if (GetFrameType (pframe) !=WIFI_MGT_TYPE ) +if (!ieee80211_is_mgmt (hdr->frame_control))return ;/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
drivers/staging/rtl8723bs/core/rtw_recv.c +6 -5
@@ -859,6 +859,7 @@ static signed int sta2ap_data_frame(struct adapter *adapter, union recv_frame *p struct sta_info **psta) {u8 *ptr = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)ptr;struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;struct sta_priv *pstapriv = &adapter->stapriv;struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
@@ -882,7 +883,7 @@ static signed int sta2ap_data_frame(struct adapter *adapter, union recv_frame *pprocess_pwrbit_data (adapter, precv_frame); -if ((GetFrameSubType (ptr) &WIFI_QOS_DATA_TYPE ) ==WIFI_QOS_DATA_TYPE ) +if (ieee80211_is_data_qos (hdr->frame_control))process_wmmps_data (adapter, precv_frame);if (GetFrameSubType (ptr) &BIT (6 )) {
@@ -915,7 +916,7 @@ static signed int validate_recv_ctrl_frame(struct adapter *padapter, union recv_struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;struct sta_info *psta =NULL ; -if (GetFrameType (pframe) !=WIFI_CTRL_TYPE ) +if (!ieee80211_is_ctl (hdr->frame_control))return _FAIL;/* receive the frames that ra(a1) is my address */
@@ -930,7 +931,7 @@ static signed int validate_recv_ctrl_frame(struct adapter *padapter, union recv_ psta->sta_stats.rx_ctrl_pkts++;/* only handle ps-poll */ -if (GetFrameSubType (pframe) ==WIFI_PSPOLL ) { +if (ieee80211_is_pspoll (hdr->frame_control)) {u16 aid;u8 wmmps_ac =0 ;
@@ -1128,9 +1129,9 @@ static union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union re psta_addr = pfhdr->attrib.ta; psta =rtw_get_stainfo (pstapriv, psta_addr);if (!psta) { -u8 type =GetFrameType (pfhdr->rx_data); +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pfhdr->rx_data; -if (type !=WIFI_DATA_TYPE ) { +if (!ieee80211_is_data (hdr->frame_control)) { psta =rtw_get_bcmc_stainfo (padapter); pdefrag_q = &psta->sta_recvpriv.defrag_q; }else {
drivers/staging/rtl8723bs/core/rtw_xmit.c +2 -1
@@ -1231,7 +1231,8 @@ int rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, smemset (MME ,0 ,18 );/* other types doesn't need the BIP */ -if (GetFrameSubType (pframe) !=WIFI_DEAUTH &&GetFrameSubType (pframe) !=WIFI_DISASSOC ) +if (!ieee80211_is_deauth (pwlanhdr->frame_control) && + !ieee80211_is_disassoc (pwlanhdr->frame_control)) goto xmitframe_coalesce_fail; MGMT_body = pframe +sizeof (struct ieee80211_hdr_3addr );
drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c +3 -2
@@ -82,6 +82,7 @@ static void update_recvframe_phyinfo(union recv_frame *precvframe, (struct odm_phy_info *)(&pattrib->phy_info);u8 *wlanhdr = precvframe->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)wlanhdr;u8 *my_bssid;u8 *rx_bssid;u8 *rx_ra;
@@ -101,7 +102,7 @@ static void update_recvframe_phyinfo(union recv_frame *precvframe, my_bssid =get_bssid (&padapter->mlmepriv); rx_bssid =get_hdr_bssid (wlanhdr); - pkt_info.bssid_match = ((!IsFrameTypeCtrl (wlanhdr)) && + pkt_info.bssid_match = (!ieee80211_is_ctl (hdr->frame_control) && !pattrib->icv_err && !pattrib->crc_err &ðer_addr_equal (rx_bssid, my_bssid));
@@ -111,7 +112,7 @@ static void update_recvframe_phyinfo(union recv_frame *precvframe,ether_addr_equal (rx_ra, my_hwaddr); pkt_info.is_beacon = pkt_info.bssid_match && - (GetFrameSubType (wlanhdr) ==WIFI_BEACON ); +ieee80211_is_beacon (hdr->frame_control); sa =get_ta (wlanhdr);
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +2 -1
@@ -426,6 +426,7 @@ s32 rtl8723bs_mgnt_xmit(struct xmit_priv *pxmitpriv = &padapter->xmitpriv;struct dvobj_priv *pdvobjpriv =adapter_to_dvobj (padapter);u8 *pframe = (u8 *)(pmgntframe->buf_addr) +TXDESC_OFFSET ; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;u8 txdesc_size =TXDESC_SIZE ;rtl8723b_update_txdesc (pmgntframe, pmgntframe->buf_addr);
@@ -441,7 +442,7 @@ s32 rtl8723bs_mgnt_xmit( pxmitbuf->priv_data =NULL ; -if (GetFrameSubType (pframe) ==WIFI_BEACON ) {/* dump beacon directly */ +if (ieee80211_is_beacon (hdr->frame_control)) {/* dump beacon directly */ ret =rtw_write_port (padapter, pdvobjpriv->Queue2Pipe[pxmitbuf->ff_hwaddr], pxmitbuf->len, (u8 *)pxmitbuf);if (ret != _SUCCESS)rtw_sctx_done_err (&pxmitbuf->sctx,RTW_SCTX_DONE_WRITE_PORT_ERR );
drivers/staging/rtl8723bs/include/wifi.h +0 -5
@@ -216,11 +216,6 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe)return sa; } -static inline int IsFrameTypeCtrl (unsigned char *pframe) -{ -return GetFrameType (pframe) ==WIFI_CTRL_TYPE ; -} -/*----------------------------------------------------------------------------- Below is for the security related definition ------------------------------------------------------------------------------*/
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +3 -3
@@ -1897,10 +1897,11 @@ void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, u8 *pmgmt_frame,struct wireless_dev *wdev = padapter->rtw_wdev; { +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pmgmt_frame;struct station_info sinfo = {};u8 ie_offset; -if (GetFrameSubType (pmgmt_frame) ==WIFI_ASSOCREQ ) +if (ieee80211_is_assoc_req (hdr->frame_control)) ie_offset = _ASOCREQ_IE_OFFSET_;else /* WIFI_REASSOCREQ */ ie_offset = _REASOCREQ_IE_OFFSET_;
@@ -1908,8 +1909,7 @@ void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, u8 *pmgmt_frame, sinfo.filled =0 ; sinfo.assoc_req_ies = pmgmt_frame +WLAN_HDR_A3_LEN + ie_offset; sinfo.assoc_req_ies_len = frame_len -WLAN_HDR_A3_LEN - ie_offset; -cfg80211_new_sta (wdev, ((struct ieee80211_hdr *)pmgmt_frame)->addr2, - &sinfo,GFP_ATOMIC ); +cfg80211_new_sta (wdev, hdr->addr2, &sinfo,GFP_ATOMIC ); } }
Signature · 1 line
2.43.0
PATCH 5/10 staging: rtl8723bs: use IEEE80211_FCTL_* masks for frame type dispatch
In reply to Rishik YechuriThe remaining users of GetFrameType() and GetFrameSubType() switch on the frame type or subtype, store it for several later comparisons, or derive values from its individual bits. Convert them to operate on the frame_control member of struct ieee80211_hdr.
Switch statements now mask frame_control with IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE and use cpu_to_le16(IEEE80211_FTYPE_*) or cpu_to_le16(IEEE80211_STYPE_*) case labels, as is done in mac80211.
Where the subtype was stored in a local variable and compared against several values, store the frame_control value instead and use the ieee80211_is_*() helpers.
The test for the absence of a data payload in ap2sta_data_frame() and sta2ap_data_frame() is replaced with ieee80211_is_data_present(), and the QoS test in validate_recv_frame() with ieee80211_is_data_qos(). Both helpers additionally check that the frame type is data, which is always the case on these paths.
In aes_cipher(), aes_decipher() and rtw_check_bcn_info(), the type and subtype are kept as integer values and are now derived using the IEEE80211_FCTL_* masks and compared against IEEE80211_FTYPE_* and IEEE80211_STYPE_* values, which are numerically identical to the WIFI_* values they replace.
Remove the GetFrameType() and GetFrameSubType() macros, which no longer have any users.
No functional change intended.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 35 ++++++++-------- drivers/staging/rtl8723bs/core/rtw_recv.c | 40 +++++++++---------- drivers/staging/rtl8723bs/core/rtw_security.c | 32 ++++++++------- .../staging/rtl8723bs/core/rtw_wlan_util.c | 7 ++-- drivers/staging/rtl8723bs/core/rtw_xmit.c | 20 +++++----- drivers/staging/rtl8723bs/include/wifi.h | 6 --- 6 files changed, 65 insertions(+), 75 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +16 -19
@@ -447,7 +447,7 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) ptable = mlme_sta_tbl; - index =GetFrameSubType (pframe) >>4 ; + index = (le16_to_cpu (hdr->frame_control) &IEEE80211_FCTL_STYPE ) >>4 ;if (index >=ARRAY_SIZE (mlme_sta_tbl))return ;
@@ -464,24 +464,24 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) psta->rx_mgmt_frame_seq_num = precv_frame->u.hdr.attrib.seq_num; } -switch (GetFrameSubType (pframe)) { -case WIFI_AUTH : +switch (hdr->frame_control &cpu_to_le16 (IEEE80211_FCTL_STYPE )) { +case cpu_to_le16 (IEEE80211_STYPE_AUTH ):if (check_fwstate (pmlmepriv,WIFI_AP_STATE )) ptable->func = &OnAuth;else ptable->func = &OnAuthClient; fallthrough; -case WIFI_ASSOCREQ : -case WIFI_REASSOCREQ : +case cpu_to_le16 (IEEE80211_STYPE_ASSOC_REQ ): +case cpu_to_le16 (IEEE80211_STYPE_REASSOC_REQ ):_mgt_dispatcher (padapter, ptable, precv_frame);break ; -case WIFI_PROBEREQ : +case cpu_to_le16 (IEEE80211_STYPE_PROBE_REQ ):_mgt_dispatcher (padapter, ptable, precv_frame);break ; -case WIFI_BEACON : +case cpu_to_le16 (IEEE80211_STYPE_BEACON ):_mgt_dispatcher (padapter, ptable, precv_frame);break ; -case WIFI_ACTION : +case cpu_to_le16 (IEEE80211_STYPE_ACTION ):_mgt_dispatcher (padapter, ptable, precv_frame);break ;default :
@@ -927,7 +927,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)unsigned char supportRate[16 ];int support_rate_num;unsigned short status =WLAN_STATUS_SUCCESS ; -unsigned short frame_type, ie_offset =0 ; +unsigned short ie_offset =0 ;struct mlme_priv *pmlmepriv = &padapter->mlmepriv;struct security_priv *psecuritypriv = &padapter->securitypriv;struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
@@ -941,8 +941,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)if ((pmlmeinfo->state &0x03 ) !=WIFI_FW_AP_STATE )return _FAIL; - frame_type =GetFrameSubType (pframe); -if (frame_type ==WIFI_ASSOCREQ ) +if (ieee80211_is_assoc_req (hdr->frame_control)) ie_offset = _ASOCREQ_IE_OFFSET_;else /* WIFI_REASSOCREQ */ ie_offset = _REASOCREQ_IE_OFFSET_;
@@ -1286,7 +1285,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)sta_info_update (padapter, pstat);/* 2 issue assoc rsp before notify station join event. */ -if (frame_type ==WIFI_ASSOCREQ ) +if (ieee80211_is_assoc_req (hdr->frame_control))issue_asocrsp (padapter, status, pstat,WIFI_ASSOCRSP );else issue_asocrsp (padapter, status, pstat,WIFI_REASSOCRSP );
@@ -1315,7 +1314,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) OnAssocReqFail: pstat->aid =0 ; -if (frame_type ==WIFI_ASSOCREQ ) +if (ieee80211_is_assoc_req (hdr->frame_control))issue_asocrsp (padapter, status, pstat,WIFI_ASSOCRSP );else issue_asocrsp (padapter, status, pstat,WIFI_REASSOCRSP );
@@ -3756,7 +3755,7 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, strint i;u32 len;u8 *p; -u16 val16, subtype; +u16 val16;u8 *pframe = precv_frame->u.hdr.rx_data;struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;u32 packet_len = precv_frame->u.hdr.len;
@@ -3773,17 +3772,15 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, strmemset (bssid,0 ,sizeof (struct wlan_bssid_ex )); - subtype =GetFrameSubType (pframe); - -if (subtype ==WIFI_BEACON ) { +if (ieee80211_is_beacon (hdr->frame_control)) { bssid->reserved[0 ] =1 ; ie_offset = _BEACON_IE_OFFSET_; }else {/* FIXME : more type */ -if (subtype ==WIFI_PROBERSP ) { +if (ieee80211_is_probe_resp (hdr->frame_control)) { ie_offset = _PROBERSP_IE_OFFSET_; bssid->reserved[0 ] =3 ; - }else if (subtype ==WIFI_PROBEREQ ) { + }else if (ieee80211_is_probe_req (hdr->frame_control)) { ie_offset = _PROBEREQ_IE_OFFSET_; bssid->reserved[0 ] =2 ; }else {
drivers/staging/rtl8723bs/core/rtw_recv.c +18 -22
@@ -806,7 +806,7 @@ static signed int ap2sta_data_frame(struct adapter *adapter, union recv_frame *p goto exit; } -if (GetFrameSubType (ptr) &BIT (6 )) { +if (!ieee80211_is_data_present (hdr->frame_control)) {/* No data, will not indicate to upper layer, temporarily count it here */ count_rx_stats (adapter, precv_frame, *psta); ret =RTW_RX_HANDLED ;
@@ -886,7 +886,7 @@ static signed int sta2ap_data_frame(struct adapter *adapter, union recv_frame *pif (ieee80211_is_data_qos (hdr->frame_control))process_wmmps_data (adapter, precv_frame); -if (GetFrameSubType (ptr) &BIT (6 )) { +if (!ieee80211_is_data_present (hdr->frame_control)) {/* No data, will not indicate to upper layer, temporarily count it here */ count_rx_stats (adapter, precv_frame, *psta); ret =RTW_RX_HANDLED ;
@@ -1214,14 +1214,14 @@ static signed int validate_recv_mgnt_frame(struct adapter *padapter, union recv_ psta->sta_stats.rx_mgnt_pkts++; -switch (GetFrameSubType (precv_frame->u.hdr.rx_data)) { -case WIFI_BEACON : +switch (hdr->frame_control &cpu_to_le16 (IEEE80211_FCTL_STYPE )) { +case cpu_to_le16 (IEEE80211_STYPE_BEACON ): psta->sta_stats.rx_beacon_pkts++;break ; -case WIFI_PROBEREQ : +case cpu_to_le16 (IEEE80211_STYPE_PROBE_REQ ): psta->sta_stats.rx_probereq_pkts++;break ; -case WIFI_PROBERSP : +case cpu_to_le16 (IEEE80211_STYPE_PROBE_RESP ):if (!memcmp (padapter->eeprompriv.mac_addr, hdr->addr1,ETH_ALEN )) psta->sta_stats.rx_probersp_pkts++; else if (is_broadcast_ether_addr(hdr->addr1) ||
@@ -1352,16 +1352,17 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_framestruct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;u8 *ptr = precv_frame->u.hdr.rx_data;struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)ptr; -u8 subtype; +__le16 fc; - subtype =GetFrameSubType (ptr);/* bit(7)~bit(2) */ + fc = hdr->frame_control;/* only support station mode */ if (check_fwstate (pmlmepriv,WIFI_STATION_STATE ) &&check_fwstate (pmlmepriv, _FW_LINKED) && adapter->securitypriv.binstallBIPkey) {/* unicast management frame decrypt */ if (pattrib->privacy && !(is_multicast_ether_addr (hdr->addr1)) && - (subtype ==WIFI_DEAUTH || subtype ==WIFI_DISASSOC || subtype ==WIFI_ACTION )) { + (ieee80211_is_deauth (fc) ||ieee80211_is_disassoc (fc) || +ieee80211_is_action (fc))) {u8 *mgmt_DATA;u32 data_len =0 ;
@@ -1390,7 +1391,7 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame pattrib->pkt_len = pattrib->pkt_len - pattrib->iv_len - pattrib->icv_len;kfree (mgmt_DATA); }else if (is_multicast_ether_addr (hdr->addr1) && - (subtype ==WIFI_DEAUTH || subtype ==WIFI_DISASSOC )) { + (ieee80211_is_deauth (fc) ||ieee80211_is_disassoc (fc))) {signed int BIP_ret = _SUCCESS;/* verify BIP MME IE of broadcast/multicast de-auth/disassoc packet */ BIP_ret =rtw_BIP_verify (adapter, (u8 *)precv_frame);
@@ -1402,7 +1403,7 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame goto validate_80211w_fail; } }else {/* 802.11w protect */ -if (subtype ==WIFI_ACTION ) { +if (ieee80211_is_action (fc)) {/* according 802.11-2012 standard, these five types are not robust types */ if (ptr[WLAN_HDR_A3_LEN] != RTW_WLAN_CATEGORY_PUBLIC && ptr[WLAN_HDR_A3_LEN] != RTW_WLAN_CATEGORY_HT &&
@@ -1411,7 +1412,7 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame ptr[WLAN_HDR_A3_LEN] != RTW_WLAN_CATEGORY_P2P) { goto validate_80211w_fail; } - }else if (subtype ==WIFI_DEAUTH || subtype ==WIFI_DISASSOC ) { + }else if (ieee80211_is_deauth (fc) ||ieee80211_is_disassoc (fc)) {/* issue sa query request */ issue_action_SA_Query (adapter,NULL ,0 ,0 ); goto validate_80211w_fail;
@@ -1430,8 +1431,6 @@ static signed int validate_recv_frame(struct adapter *adapter, union recv_frame/* then call check if rx seq/frag. duplicated. */ -u8 type; -u8 subtype;signed int retval = _SUCCESS;struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
@@ -1446,9 +1445,6 @@ static signed int validate_recv_frame(struct adapter *adapter, union recv_frame goto exit; } - type =GetFrameType (ptr); - subtype =GetFrameSubType (ptr);/* bit(7)~bit(2) */ - pattrib->to_fr_ds = (ieee80211_has_tods (hdr->frame_control) <<1 ) |ieee80211_has_fromds (hdr->frame_control);
@@ -1461,8 +1457,8 @@ static signed int validate_recv_frame(struct adapter *adapter, union recv_frame pattrib->privacy =ieee80211_has_protected (hdr->frame_control); pattrib->order =ieee80211_has_order (hdr->frame_control); -switch (type) { -case WIFI_MGT_TYPE :/* mgnt */ +switch (hdr->frame_control &cpu_to_le16 (IEEE80211_FCTL_FTYPE )) { +case cpu_to_le16 (IEEE80211_FTYPE_MGMT ):/* mgnt */ if (validate_80211w_mgmt (adapter, precv_frame) == _FAIL) { retval = _FAIL;break ;
@@ -1471,12 +1467,12 @@ static signed int validate_recv_frame(struct adapter *adapter, union recv_frame retval =validate_recv_mgnt_frame (adapter, precv_frame); retval = _FAIL;/* only data frame return _SUCCESS */ break ; -case WIFI_CTRL_TYPE :/* ctrl */ +case cpu_to_le16 (IEEE80211_FTYPE_CTL ):/* ctrl */ retval =validate_recv_ctrl_frame (adapter, precv_frame); retval = _FAIL;/* only data frame return _SUCCESS */ break ; -case WIFI_DATA_TYPE :/* data */ - pattrib->qos = (subtype &BIT (7 )) ?1 :0 ; +case cpu_to_le16 (IEEE80211_FTYPE_DATA ):/* data */ + pattrib->qos =ieee80211_is_data_qos (hdr->frame_control); retval =validate_recv_data_frame (adapter, precv_frame);if (retval == _FAIL) {struct recv_priv *precvpriv = &adapter->recvpriv;
drivers/staging/rtl8723bs/core/rtw_security.c +17 -15
@@ -649,7 +649,7 @@ static void construct_mic_iv(u8 *mic_iv, mic_iv[1 ] =0x00 ;/* 802.11w management frame should set management bit(4) */ -if (frtype ==WIFI_MGT_TYPE ) +if (frtype ==IEEE80211_FTYPE_MGMT ) mic_iv[1 ] |=BIT (4 );for (i =2 ; i <8 ; i++)
@@ -675,7 +675,7 @@ static void construct_mic_header1(u8 *mic_header1, mic_header1[1 ] = (u8)((header_length -2 ) %256 );/* 802.11w management frame don't AND subtype bits 4, 5, 6 of frame control field */ -if (frtype ==WIFI_MGT_TYPE ) +if (frtype ==IEEE80211_FTYPE_MGMT ) mic_header1[2 ] = mpdu[0 ];else mic_header1[2 ] = mpdu[0 ] &0xcf ;/* Mute CF poll & CF ack bits */
@@ -767,7 +767,7 @@ static void construct_ctr_preload(u8 *ctr_preload, ctr_preload[1 ] = mpdu[24 ] &0x0f ;/* 802.11w management frame should set management bit(4) */ -if (frtype ==WIFI_MGT_TYPE ) +if (frtype ==IEEE80211_FTYPE_MGMT ) ctr_preload[1 ] |=BIT (4 );/* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */
@@ -800,8 +800,9 @@ static signed int aes_cipher(u8 *key, u16 hdrlen,u8 aes_out[16 ] = {};u8 padded_buffer[16 ] = {};u8 mic[8 ]; -u8 frtype =GetFrameType (pframe); -u8 frsubtype =GetFrameSubType (pframe); +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe; +u8 frtype =le16_to_cpu (hdr->frame_control) &IEEE80211_FCTL_FTYPE ; +u8 frsubtype =le16_to_cpu (hdr->frame_control) &IEEE80211_FCTL_STYPE ; frsubtype = frsubtype >>4 ;
@@ -810,14 +811,14 @@ static signed int aes_cipher(u8 *key, u16 hdrlen,else a4_exists = true; -if (((frtype | frsubtype) ==WIFI_DATA_CFACK ) || - ((frtype | frsubtype) ==WIFI_DATA_CFPOLL ) || - ((frtype | frsubtype) ==WIFI_DATA_CFACKPOLL )) { +if (((frtype | frsubtype) == (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_DATA_CFACK )) || + ((frtype | frsubtype) == (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_DATA_CFPOLL )) || + ((frtype | frsubtype) == (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_DATA_CFACKPOLL ))) { qc_exists = true;if (hdrlen !=WLAN_HDR_A3_QOS_LEN ) hdrlen +=2 ; - } else if ((frtype == WIFI_DATA) && + } else if ((frtype == IEEE80211_FTYPE_DATA) && ((frsubtype == 0x08) || (frsubtype == 0x09) || (frsubtype == 0x0a) ||
@@ -1005,8 +1006,9 @@ static signed int aes_decipher(u8 *key, u8 hdrlen,u8 padded_buffer[16 ] = {};u8 mic[8 ]; -u8 frtype =GetFrameType (pframe); -u8 frsubtype =GetFrameSubType (pframe); +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe; +u8 frtype =le16_to_cpu (hdr->frame_control) &IEEE80211_FCTL_FTYPE ; +u8 frsubtype =le16_to_cpu (hdr->frame_control) &IEEE80211_FCTL_STYPE ; frsubtype = frsubtype >>4 ;
@@ -1028,14 +1030,14 @@ static signed int aes_decipher(u8 *key, u8 hdrlen,else a4_exists = true; -if (((frtype | frsubtype) ==WIFI_DATA_CFACK ) || - ((frtype | frsubtype) ==WIFI_DATA_CFPOLL ) || - ((frtype | frsubtype) ==WIFI_DATA_CFACKPOLL )) { +if (((frtype | frsubtype) == (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_DATA_CFACK )) || + ((frtype | frsubtype) == (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_DATA_CFPOLL )) || + ((frtype | frsubtype) == (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_DATA_CFACKPOLL ))) { qc_exists = true;if (hdrlen !=WLAN_HDR_A3_QOS_LEN ) hdrlen +=2 ; - } else if ((frtype == WIFI_DATA) && + } else if ((frtype == IEEE80211_FTYPE_DATA) && ((frsubtype == 0x08) || (frsubtype == 0x09) || (frsubtype == 0x0a) ||
drivers/staging/rtl8723bs/core/rtw_wlan_util.c +4 -3
@@ -1082,7 +1082,8 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)int group_cipher =0 , pairwise_cipher =0 , is_8021x =0 ;unsigned char *pbuf;u32 wpa_ielen =0 ; -u8 *pbssid = ((struct ieee80211_hdr *)pframe)->addr3; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe; +u8 *pbssid = hdr->addr3;struct HT_info_element *pht_info =NULL ;struct ieee80211_ht_cap *pht_cap =NULL ;u32 bcn_channel;
@@ -1111,9 +1112,9 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) pmlmepriv->NumOfBcnInfoChkFail =0 ; } - subtype =GetFrameSubType (pframe) >>4 ; + subtype = (le16_to_cpu (hdr->frame_control) &IEEE80211_FCTL_STYPE ) >>4 ; -if (subtype ==WIFI_BEACON ) +if (subtype ==IEEE80211_STYPE_BEACON ) bssid->reserved[0 ] =1 ; bssid->length =sizeof (struct wlan_bssid_ex ) -MAX_IE_SZ + len;
drivers/staging/rtl8723bs/core/rtw_xmit.c +10 -10
@@ -1188,7 +1188,7 @@ int rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, structint rtw_mgmt_xmitframe_coalesce (struct adapter *padapter,struct sk_buff *pkt,struct xmit_frame *pxmitframe) {u8 *pframe, *tmp_buf =NULL ; -u8 subtype; +__le16 fc;struct sta_info *psta =NULL ;struct pkt_attrib *pattrib = &pxmitframe->attrib;s32 bmcst =is_multicast_ether_addr (pattrib->ra);
@@ -1212,7 +1212,7 @@ int rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, sreturn -ENOMEM ; tmp_buf =BIP_AAD ; - subtype =GetFrameSubType (pframe);/* bit(7)~bit(2) */ + fc = pwlanhdr->frame_control;spin_lock_bh (&padapter->security_key_mutex);/* only support station mode */
@@ -1270,8 +1270,8 @@ int rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, smemcpy (pframe -8 , mic,8 ); }else {/* unicast mgmt frame TX */ /* start to encrypt mgmt frame */ -if (subtype ==WIFI_DEAUTH || subtype ==WIFI_DISASSOC || - subtype ==WIFI_REASSOCREQ || subtype ==WIFI_ACTION ) { +if (ieee80211_is_deauth (fc) ||ieee80211_is_disassoc (fc) || +ieee80211_is_reassoc_req (fc) ||ieee80211_is_action (fc)) {if (pattrib->psta) psta = pattrib->psta;else
@@ -1284,7 +1284,7 @@ int rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, s goto xmitframe_coalesce_fail;/* according 802.11-2012 standard, these five types are not robust types */ - if (subtype == WIFI_ACTION && + if (ieee80211_is_action(fc) && (pframe[WLAN_HDR_A3_LEN] == RTW_WLAN_CATEGORY_PUBLIC || pframe[WLAN_HDR_A3_LEN] == RTW_WLAN_CATEGORY_HT || pframe[WLAN_HDR_A3_LEN] == RTW_WLAN_CATEGORY_UNPROTECTED_WNM ||
@@ -2440,7 +2440,7 @@ struct xmit_buf *dequeue_pending_xmitbuf_under_survey(struct xmit_priv *pxmitpriif (!list_empty (&pqueue->queue)) {struct list_head *plist, *phead; -u8 type; +struct ieee80211_hdr *hdr; phead =get_list_head (pqueue); plist = phead;
@@ -2451,11 +2451,11 @@ struct xmit_buf *dequeue_pending_xmitbuf_under_survey(struct xmit_priv *pxmitpri pxmitbuf = container_of(plist, struct xmit_buf, list); - type =GetFrameSubType (pxmitbuf->pbuf +TXDESC_OFFSET ); + hdr = (struct ieee80211_hdr *)(pxmitbuf->pbuf +TXDESC_OFFSET ); -if ((type ==WIFI_PROBEREQ ) || - (type ==WIFI_DATA_NULL ) || - (type ==WIFI_QOS_DATA_NULL )) { +if (ieee80211_is_probe_req (hdr->frame_control) || +ieee80211_is_nullfunc (hdr->frame_control) || +ieee80211_is_qos_nullfunc (hdr->frame_control)) {list_del_init (&pxmitbuf->list);break ; }
drivers/staging/rtl8723bs/include/wifi.h +0 -6
@@ -63,18 +63,12 @@ enum { WIFI_QOS_DATA_NULL = (BIT(6) | WIFI_QOS_DATA_TYPE), }; -#define GetFrameType (pbuf) \ - (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(3) | BIT(2))) -#define SetFrameType (pbuf, type) \ do { \ *(unsigned short *)(pbuf) &= cpu_to_le16(~(BIT(3) | BIT(2))); \ *(unsigned short *)(pbuf) |= cpu_to_le16(type); \ } while (0) -#define GetFrameSubType (pbuf) (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(7) |\ - BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2))) -#define SetFrameSubType (pbuf, type) \ do { \ *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | \
Signature · 1 line
2.43.0
PATCH 6/10 staging: rtl8723bs: remove unused num member from struct mlme_handler
In reply to Rishik YechuriThe num member of struct mlme_handler is initialised in mlme_sta_tbl[] with the WIFI_* subtype constants but is never read. The table is indexed directly by the frame subtype in mgt_dispatcher(), and only the func member of each entry is used.
Remove the member and its initialisers. This drops the last references to several WIFI_* constants that have no equivalent in <linux/ieee80211.h>, such as WIFI_ACTION_NOACK, so that the private frame type definitions can be removed in a later change.
No functional change intended.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 30 +++++++++---------- .../staging/rtl8723bs/include/rtw_mlme_ext.h | 1 - 2 files changed, 15 insertions(+), 16 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +15 -15
@@ -12,23 +12,23 @@#include <linux/unaligned.h> static struct mlme_handler mlme_sta_tbl[] = { - {WIFI_ASSOCREQ ,"OnAssocReq" , &OnAssocReq}, - {WIFI_ASSOCRSP ,"OnAssocRsp" , &OnAssocRsp}, - {WIFI_REASSOCREQ ,"OnReAssocReq" , &OnAssocReq}, - {WIFI_REASSOCRSP ,"OnReAssocRsp" , &OnAssocRsp}, - {WIFI_PROBEREQ ,"OnProbeReq" , &OnProbeReq}, - {WIFI_PROBERSP ,"OnProbeRsp" , &OnProbeRsp}, + {"OnAssocReq" , &OnAssocReq}, + {"OnAssocRsp" , &OnAssocRsp}, + {"OnReAssocReq" , &OnAssocReq}, + {"OnReAssocRsp" , &OnAssocRsp}, + {"OnProbeReq" , &OnProbeReq}, + {"OnProbeRsp" , &OnProbeRsp},/* below 2 are reserved */ - {0 ,"DoReserved" , &DoReserved}, - {0 ,"DoReserved" , &DoReserved}, - {WIFI_BEACON ,"OnBeacon" , &OnBeacon}, - {WIFI_ATIM ,"OnATIM" , &OnAtim}, - {WIFI_DISASSOC ,"OnDisassoc" , &OnDisassoc}, - {WIFI_AUTH ,"OnAuth" , &OnAuthClient}, - {WIFI_DEAUTH ,"OnDeAuth" , &OnDeAuth}, - {WIFI_ACTION ,"OnAction" , &OnAction}, - {WIFI_ACTION_NOACK ,"OnActionNoAck" , &OnAction}, + {"DoReserved" , &DoReserved}, + {"DoReserved" , &DoReserved}, + {"OnBeacon" , &OnBeacon}, + {"OnATIM" , &OnAtim}, + {"OnDisassoc" , &OnDisassoc}, + {"OnAuth" , &OnAuthClient}, + {"OnDeAuth" , &OnDeAuth}, + {"OnAction" , &OnAction}, + {"OnActionNoAck" , &OnAction}, };static struct action_handler OnAction_tbl[] = {
drivers/staging/rtl8723bs/include/rtw_mlme_ext.h +0 -1
@@ -205,7 +205,6 @@ enum { };struct mlme_handler { -unsigned int num;char *str;unsigned int (*func)(struct adapter *padapter,union recv_frame *precv_frame); };
Signature · 1 line
2.43.0
PATCH 7/10 staging: rtl8723bs: use IEEE80211_FTYPE_* and IEEE80211_STYPE_* values
In reply to Rishik YechuriThe driver sets the type and subtype of transmitted frames with SetFrameSubType() using its private WIFI_* enumeration, which encodes the same values as the IEEE80211_FTYPE_* and IEEE80211_STYPE_* constants in <linux/ieee80211.h>.
Replace each SetFrameSubType() call with an OR of the corresponding IEEE80211_FTYPE_* and IEEE80211_STYPE_* values into frame_control. At every call site the Frame Control field has already been cleared, so the type and subtype bits are zero and the OR is equivalent to the clear and set performed by the macro. Flags that some callers set before the subtype, such as Power Management and From DS, are preserved as before.
Convert the values stored in pattrib->subtype and passed to issue_asocrsp() to the kernel definitions as well. They are numerically identical to the WIFI_* values they replace.
Remove SetFrameSubType(), the unused SetFrameType(), and the WIFI_* frame type and subtype enumerations, which no longer have any users. Update comments that referred to the removed constants.
No functional change intended.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 36 ++++++------ drivers/staging/rtl8723bs/core/rtw_xmit.c | 8 +-- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 12 ++-- drivers/staging/rtl8723bs/include/wifi.h | 58 ------------------- .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 8 +-- 5 files changed, 32 insertions(+), 90 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +18 -18
@@ -943,7 +943,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)if (ieee80211_is_assoc_req (hdr->frame_control)) ie_offset = _ASOCREQ_IE_OFFSET_; -else /* WIFI_REASSOCREQ */ +else /* reassociation request */ ie_offset = _REASOCREQ_IE_OFFSET_;if (pkt_len <sizeof (struct ieee80211_hdr_3addr ) + ie_offset)
@@ -1286,9 +1286,9 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)/* 2 issue assoc rsp before notify station join event. */ if (ieee80211_is_assoc_req (hdr->frame_control)) -issue_asocrsp (padapter, status, pstat,WIFI_ASSOCRSP ); +issue_asocrsp (padapter, status, pstat,IEEE80211_STYPE_ASSOC_RESP );else -issue_asocrsp (padapter, status, pstat,WIFI_REASSOCRSP ); +issue_asocrsp (padapter, status, pstat,IEEE80211_STYPE_REASSOC_RESP );spin_lock_bh (&pstat->lock);kfree (pstat->passoc_req);
@@ -1315,9 +1315,9 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) pstat->aid =0 ;if (ieee80211_is_assoc_req (hdr->frame_control)) -issue_asocrsp (padapter, status, pstat,WIFI_ASSOCRSP ); +issue_asocrsp (padapter, status, pstat,IEEE80211_STYPE_ASSOC_RESP );else -issue_asocrsp (padapter, status, pstat,WIFI_REASSOCRSP ); +issue_asocrsp (padapter, status, pstat,IEEE80211_STYPE_REASSOC_RESP );return _FAIL; }
@@ -2083,7 +2083,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms)memcpy (pwlanhdr->addr3,get_my_bssid (cur_network),ETH_ALEN );SetSeqNum (pwlanhdr,0 /*pmlmeext->mgnt_seq*/ ); -SetFrameSubType (pframe,WIFI_BEACON ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_BEACON ); pframe +=sizeof (struct ieee80211_hdr_3addr ); pattrib->pktlen =sizeof (struct ieee80211_hdr_3addr );
@@ -2235,7 +2235,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2pSetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; -SetFrameSubType (fctrl,WIFI_PROBERSP ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_PROBE_RESP ); pattrib->hdrlen =sizeof (struct ieee80211_hdr_3addr ); pattrib->pktlen = pattrib->hdrlen;
@@ -2432,7 +2432,7 @@ static void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *psSetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; -SetFrameSubType (pframe,WIFI_PROBEREQ ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_PROBE_REQ ); pframe +=sizeof (struct ieee80211_hdr_3addr ); pattrib->pktlen =sizeof (struct ieee80211_hdr_3addr );
@@ -2499,7 +2499,7 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned shortSetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; -SetFrameSubType (pframe,WIFI_AUTH ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_AUTH ); pframe +=sizeof (struct ieee80211_hdr_3addr ); pattrib->pktlen =sizeof (struct ieee80211_hdr_3addr );
@@ -2628,8 +2628,8 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_iSetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; -if ((pkt_type ==WIFI_ASSOCRSP ) || (pkt_type ==WIFI_REASSOCRSP )) { -SetFrameSubType (pwlanhdr, pkt_type); +if (pkt_type ==IEEE80211_STYPE_ASSOC_RESP || pkt_type ==IEEE80211_STYPE_REASSOC_RESP ) { + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT | pkt_type); }else {rtw_free_xmitbuf (pxmitpriv, pmgntframe->pxmitbuf);rtw_free_xmitframe (pxmitpriv, pmgntframe);
@@ -2755,7 +2755,7 @@ void issue_assocreq(struct adapter *padapter)SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; -SetFrameSubType (pframe,WIFI_ASSOCREQ ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ASSOC_REQ ); pframe +=sizeof (struct ieee80211_hdr_3addr ); pattrib->pktlen =sizeof (struct ieee80211_hdr_3addr );
@@ -2938,7 +2938,7 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da,SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; -SetFrameSubType (pframe,WIFI_DATA_NULL ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_NULLFUNC ); pframe +=sizeof (struct ieee80211_hdr_3addr ); pattrib->pktlen =sizeof (struct ieee80211_hdr_3addr );
@@ -3085,7 +3085,7 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da,SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; -SetFrameSubType (pframe,WIFI_QOS_DATA_NULL ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_QOS_NULLFUNC ); pframe +=sizeof (struct ieee80211_qos_hdr ); pattrib->pktlen =sizeof (struct ieee80211_qos_hdr );
@@ -3177,7 +3177,7 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da,SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; -SetFrameSubType (pframe,WIFI_DEAUTH ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_DEAUTH ); pframe +=sizeof (struct ieee80211_hdr_3addr ); pattrib->pktlen =sizeof (struct ieee80211_hdr_3addr );
@@ -3271,7 +3271,7 @@ void issue_action_SA_Query(struct adapter *padapter, unsigned char *raddr, unsigSetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; -SetFrameSubType (pframe,WIFI_ACTION ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ACTION ); pframe +=sizeof (struct ieee80211_hdr_3addr ); pattrib->pktlen =sizeof (struct ieee80211_hdr_3addr );
@@ -3344,7 +3344,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned chSetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; -SetFrameSubType (pframe,WIFI_ACTION ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ACTION ); pframe +=sizeof (struct ieee80211_hdr_3addr ); pattrib->pktlen =sizeof (struct ieee80211_hdr_3addr );
@@ -3498,7 +3498,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter)SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; -SetFrameSubType (pframe,WIFI_ACTION ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ACTION ); pframe +=sizeof (struct ieee80211_hdr_3addr ); pattrib->pktlen =sizeof (struct ieee80211_hdr_3addr );
drivers/staging/rtl8723bs/core/rtw_xmit.c +4 -4
@@ -650,7 +650,7 @@ static int set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) } pattrib->priority = UserPriority; pattrib->hdrlen =WLAN_HDR_A3_QOS_LEN ; - pattrib->subtype =WIFI_QOS_DATA_TYPE ; + pattrib->subtype =IEEE80211_FTYPE_DATA |IEEE80211_STYPE_QOS_DATA ;return 0 ; }
@@ -774,7 +774,7 @@ static int update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p pattrib->pkt_hdrlen =ETH_HLEN ;/* pattrib->ether_type == 0x8100) ? (14 + 4): 14; vlan tag */ pattrib->hdrlen =WLAN_HDR_A3_LEN ; - pattrib->subtype =WIFI_DATA_TYPE ; + pattrib->subtype =IEEE80211_FTYPE_DATA |IEEE80211_STYPE_DATA ; pattrib->priority =0 ;if (check_fwstate (pmlmepriv,WIFI_AP_STATE |WIFI_ADHOC_STATE |WIFI_ADHOC_MASTER_STATE )) {
@@ -914,9 +914,9 @@ int rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattrmemset (hdr,0 ,WLANHDR_OFFSET ); -SetFrameSubType (fctrl, pattrib->subtype); + *fctrl |=cpu_to_le16 (pattrib->subtype); -if (pattrib->subtype &WIFI_DATA_TYPE ) { +if (pattrib->subtype &IEEE80211_FTYPE_DATA ) {if (check_fwstate (pmlmepriv,WIFI_STATION_STATE )) { {/* 1.Data transfer to AP */
drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +6 -6
@@ -116,7 +116,7 @@ static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength)ether_addr_copy (pwlanhdr->addr3,get_my_bssid (cur_network));SetSeqNum (pwlanhdr,0 ); -SetFrameSubType (pframe,WIFI_BEACON ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_BEACON ); pframe +=sizeof (struct ieee80211_hdr_3addr ); pktlen =sizeof (struct ieee80211_hdr_3addr );
@@ -193,7 +193,7 @@ static void ConstructPSPoll(struct adapter *padapter, u8 *pframe, u32 *pLength) fctrl = &pwlanhdr->frame_control; *(fctrl) =0 ; *fctrl |=cpu_to_le16 (IEEE80211_FCTL_PM ); -SetFrameSubType (pframe,WIFI_PSPOLL ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_CTL |IEEE80211_STYPE_PSPOLL );/* AID. */ SetDuration (pframe, (pmlmeinfo->aid |0xc000 ));
@@ -257,7 +257,7 @@ static void ConstructNullFunctionData(struct adapter *padapter,if (bQoS) {struct ieee80211_qos_hdr *pwlanqoshdr; -SetFrameSubType (pframe,WIFI_QOS_DATA_NULL ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_QOS_NULLFUNC ); pwlanqoshdr = (struct ieee80211_qos_hdr *)pframe;SetPriority (&pwlanqoshdr->qos_ctrl,AC );
@@ -265,7 +265,7 @@ static void ConstructNullFunctionData(struct adapter *padapter, pktlen =sizeof (struct ieee80211_qos_hdr ); }else { -SetFrameSubType (pframe,WIFI_DATA_NULL ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_NULLFUNC ); pktlen =sizeof (struct ieee80211_hdr_3addr ); }
@@ -745,7 +745,7 @@ static void ConstructBtNullFunctionData(struct adapter *padapter,if (bQoS) {struct ieee80211_qos_hdr *pwlanqoshdr; -SetFrameSubType (pframe,WIFI_QOS_DATA_NULL ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_QOS_NULLFUNC ); pwlanqoshdr = (struct ieee80211_qos_hdr *)pframe;SetPriority (&pwlanqoshdr->qos_ctrl,AC );
@@ -753,7 +753,7 @@ static void ConstructBtNullFunctionData(struct adapter *padapter, pktlen =sizeof (struct ieee80211_qos_hdr ); }else { -SetFrameSubType (pframe,WIFI_DATA_NULL ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_NULLFUNC ); pktlen =sizeof (struct ieee80211_hdr_3addr ); }
drivers/staging/rtl8723bs/include/wifi.h +0 -58
64 lines not on this page · raw message
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +4 -4
@@ -283,12 +283,12 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wlSetSeqNum (pwlanhdr,0 /*pmlmeext->mgnt_seq*/ ); -if (pnetwork->network.reserved[0 ] ==1 ) {/* WIFI_BEACON */ +if (pnetwork->network.reserved[0 ] ==1 ) {/* beacon */ eth_broadcast_addr (pwlanhdr->addr1); -SetFrameSubType (pbuf,WIFI_BEACON ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_BEACON ); }else {memcpy (pwlanhdr->addr1,myid (&padapter->eeprompriv),ETH_ALEN ); -SetFrameSubType (pbuf,WIFI_PROBERSP ); + *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_PROBE_RESP ); }memcpy (pwlanhdr->addr2, pnetwork->network.mac_address,ETH_ALEN );
@@ -1903,7 +1903,7 @@ void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, u8 *pmgmt_frame,if (ieee80211_is_assoc_req (hdr->frame_control)) ie_offset = _ASOCREQ_IE_OFFSET_; -else /* WIFI_REASSOCREQ */ +else /* reassociation request */ ie_offset = _REASOCREQ_IE_OFFSET_; sinfo.filled =0 ;
Signature · 1 line
2.43.0
PATCH 8/10 staging: rtl8723bs: use struct ieee80211_hdr for seq_ctrl and duration_id
In reply to Rishik YechuriThe driver reads and writes the Sequence Control and Duration/ID fields of IEEE 802.11 headers with the SetSeqNum(), GetSequence(), GetFragNum(), SetDuration() and GetAid() macros, which access the frame buffer at hardcoded byte offsets. struct ieee80211_hdr provides the seq_ctrl and duration_id members for these fields, and <linux/ieee80211.h> provides IEEE80211_SCTL_* masks and helpers to convert between sequence numbers and the Sequence Control field.
Replace GetSequence() with ieee80211_get_sn(), GetFragNum() with a mask of seq_ctrl with IEEE80211_SCTL_FRAG, and SetDuration() and GetAid() with accesses to duration_id.
SetSeqNum() updates the sequence number while preserving the fragment number. Where the header has just been cleared, replace it with an assignment of IEEE80211_SN_TO_SEQ() to seq_ctrl. The reserved page frames built in rtl8723b_cmd.c are written into a buffer that is not cleared between uses. Those callers set a sequence number of zero, so replace them with a mask that clears the sequence number and keeps the fragment number, as SetSeqNum() did.
Remove these macros and the unused SetFragNum().
No functional change intended.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 24 ++++++++--------- drivers/staging/rtl8723bs/core/rtw_recv.c | 6 ++--- drivers/staging/rtl8723bs/core/rtw_xmit.c | 3 ++- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 10 +++---- drivers/staging/rtl8723bs/include/wifi.h | 26 ------------------- .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 6 ++--- 6 files changed, 25 insertions(+), 50 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +12 -12
@@ -2082,7 +2082,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms)memcpy (pwlanhdr->addr2,myid (&(padapter->eeprompriv)),ETH_ALEN );memcpy (pwlanhdr->addr3,get_my_bssid (cur_network),ETH_ALEN ); -SetSeqNum (pwlanhdr,0 /*pmlmeext->mgnt_seq*/ ); + pwlanhdr->seq_ctrl =0 ; *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_BEACON ); pframe +=sizeof (struct ieee80211_hdr_3addr );
@@ -2233,7 +2233,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2pmemcpy (pwlanhdr->addr2, mac,ETH_ALEN );memcpy (pwlanhdr->addr3, bssid,ETH_ALEN ); -SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl =cpu_to_le16 (IEEE80211_SN_TO_SEQ (pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_PROBE_RESP );
@@ -2430,7 +2430,7 @@ static void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *psmemcpy (pwlanhdr->addr2, mac,ETH_ALEN ); -SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl =cpu_to_le16 (IEEE80211_SN_TO_SEQ (pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_PROBE_REQ );
@@ -2497,7 +2497,7 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short fctrl = &(pwlanhdr->frame_control); *(fctrl) =0 ; -SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl =cpu_to_le16 (IEEE80211_SN_TO_SEQ (pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_AUTH );
@@ -2626,7 +2626,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_imemcpy (pwlanhdr->addr2,myid (&(padapter->eeprompriv)),ETH_ALEN );memcpy (pwlanhdr->addr3,get_my_bssid (&(pmlmeinfo->network)),ETH_ALEN ); -SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl =cpu_to_le16 (IEEE80211_SN_TO_SEQ (pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++;if (pkt_type ==IEEE80211_STYPE_ASSOC_RESP || pkt_type ==IEEE80211_STYPE_REASSOC_RESP ) { *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT | pkt_type);
@@ -2753,7 +2753,7 @@ void issue_assocreq(struct adapter *padapter)memcpy (pwlanhdr->addr2,myid (&(padapter->eeprompriv)),ETH_ALEN );memcpy (pwlanhdr->addr3,get_my_bssid (&(pmlmeinfo->network)),ETH_ALEN ); -SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl =cpu_to_le16 (IEEE80211_SN_TO_SEQ (pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ASSOC_REQ );
@@ -2936,7 +2936,7 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da,memcpy (pwlanhdr->addr2,myid (&(padapter->eeprompriv)),ETH_ALEN );memcpy (pwlanhdr->addr3,get_my_bssid (&(pmlmeinfo->network)),ETH_ALEN ); -SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl =cpu_to_le16 (IEEE80211_SN_TO_SEQ (pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_NULLFUNC );
@@ -3083,7 +3083,7 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da,memcpy (pwlanhdr->addr2,myid (&(padapter->eeprompriv)),ETH_ALEN );memcpy (pwlanhdr->addr3,get_my_bssid (&(pmlmeinfo->network)),ETH_ALEN ); -SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl =cpu_to_le16 (IEEE80211_SN_TO_SEQ (pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_QOS_NULLFUNC );
@@ -3175,7 +3175,7 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da,memcpy (pwlanhdr->addr2,myid (&(padapter->eeprompriv)),ETH_ALEN );memcpy (pwlanhdr->addr3,get_my_bssid (&(pmlmeinfo->network)),ETH_ALEN ); -SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl =cpu_to_le16 (IEEE80211_SN_TO_SEQ (pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_DEAUTH );
@@ -3269,7 +3269,7 @@ void issue_action_SA_Query(struct adapter *padapter, unsigned char *raddr, unsigmemcpy (pwlanhdr->addr2,myid (&(padapter->eeprompriv)),ETH_ALEN );memcpy (pwlanhdr->addr3,get_my_bssid (&(pmlmeinfo->network)),ETH_ALEN ); -SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl =cpu_to_le16 (IEEE80211_SN_TO_SEQ (pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ACTION );
@@ -3342,7 +3342,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned chmemcpy (pwlanhdr->addr2,myid (&(padapter->eeprompriv)),ETH_ALEN );memcpy (pwlanhdr->addr3,get_my_bssid (&(pmlmeinfo->network)),ETH_ALEN ); -SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl =cpu_to_le16 (IEEE80211_SN_TO_SEQ (pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ACTION );
@@ -3496,7 +3496,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter)memcpy (pwlanhdr->addr2,myid (&(padapter->eeprompriv)),ETH_ALEN );memcpy (pwlanhdr->addr3,get_my_bssid (&(pmlmeinfo->network)),ETH_ALEN ); -SetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl =cpu_to_le16 (IEEE80211_SN_TO_SEQ (pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ACTION );
drivers/staging/rtl8723bs/core/rtw_recv.c +3 -3
@@ -935,7 +935,7 @@ static signed int validate_recv_ctrl_frame(struct adapter *padapter, union recv_u16 aid;u8 wmmps_ac =0 ; - aid =GetAid (pframe); + aid =le16_to_cpu (hdr->duration_id) &0x3fff ;if (psta->aid != aid)return _FAIL;
@@ -1448,8 +1448,8 @@ static signed int validate_recv_frame(struct adapter *adapter, union recv_frame pattrib->to_fr_ds = (ieee80211_has_tods (hdr->frame_control) <<1 ) |ieee80211_has_fromds (hdr->frame_control); - pattrib->frag_num =GetFragNum (ptr); - pattrib->seq_num =GetSequence (ptr); + pattrib->frag_num =le16_to_cpu (hdr->seq_ctrl) &IEEE80211_SCTL_FRAG ; + pattrib->seq_num =ieee80211_get_sn (hdr); pattrib->pw_save =ieee80211_has_pm (hdr->frame_control); pattrib->mfrag =ieee80211_has_morefrags (hdr->frame_control);
drivers/staging/rtl8723bs/core/rtw_xmit.c +2 -1
@@ -987,7 +987,8 @@ int rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr psta->sta_xmitpriv.txseq_tid[pattrib->priority] %=4096u ; pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority]; -SetSeqNum (hdr, pattrib->seqnum); + pwlanhdr->seq_ctrl = +cpu_to_le16 (IEEE80211_SN_TO_SEQ (pattrib->seqnum));/* check if enable ampdu */ if (pattrib->ht_en && psta->htpriv.ampdu_enable)
drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +5 -5
@@ -115,7 +115,7 @@ static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength)ether_addr_copy (pwlanhdr->addr2,myid (&padapter->eeprompriv));ether_addr_copy (pwlanhdr->addr3,get_my_bssid (cur_network)); -SetSeqNum (pwlanhdr,0 ); + pwlanhdr->seq_ctrl &=cpu_to_le16 (IEEE80211_SCTL_FRAG ); *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_BEACON ); pframe +=sizeof (struct ieee80211_hdr_3addr );
@@ -196,7 +196,7 @@ static void ConstructPSPoll(struct adapter *padapter, u8 *pframe, u32 *pLength) *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_CTL |IEEE80211_STYPE_PSPOLL );/* AID. */ -SetDuration (pframe, (pmlmeinfo->aid |0xc000 )); + pwlanhdr->duration_id =cpu_to_le16 (pmlmeinfo->aid |0xc000 );/* BSSID. */ ether_addr_copy (pwlanhdr->addr1,get_my_bssid (&pmlmeinfo->network));
@@ -252,7 +252,7 @@ static void ConstructNullFunctionData(struct adapter *padapter,break ; } -SetSeqNum (pwlanhdr,0 ); + pwlanhdr->seq_ctrl &=cpu_to_le16 (IEEE80211_SCTL_FRAG );if (bQoS) {struct ieee80211_qos_hdr *pwlanqoshdr;
@@ -739,8 +739,8 @@ static void ConstructBtNullFunctionData(struct adapter *padapter,ether_addr_copy (pwlanhdr->addr2,myid (&padapter->eeprompriv));ether_addr_copy (pwlanhdr->addr3,myid (&padapter->eeprompriv)); -SetDuration (pwlanhdr,0 ); -SetSeqNum (pwlanhdr,0 ); + pwlanhdr->duration_id =0 ; + pwlanhdr->seq_ctrl &=cpu_to_le16 (IEEE80211_SCTL_FRAG );if (bQoS) {struct ieee80211_qos_hdr *pwlanqoshdr;
drivers/staging/rtl8723bs/include/wifi.h +0 -26
@@ -18,30 +18,6 @@/* This test verifies the WLAN NIC can update the NAV through sending the CTS with large duration. */ #define WiFiNavUpperUs 30000/* 30 ms */ -#define GetSequence (pbuf) \ - (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 22)) >> 4) - -#define GetFragNum (pbuf) \ - (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 22)) & 0x0f) - -#define SetFragNum (pbuf, num) \ - do { \ - *(unsigned short *)((size_t)(pbuf) + 22) = \ - ((*(unsigned short *)((size_t)(pbuf) + 22)) & \ - le16_to_cpu(~(0x000f))) | \ - cpu_to_le16(0x0f & (num)); \ - } while (0) - -#define SetSeqNum (pbuf, num) \ - do { \ - *(__le16 *)((size_t)(pbuf) + 22) = \ - ((*(__le16 *)((size_t)(pbuf) + 22)) & cpu_to_le16((unsigned short)0x000f)) | \ - cpu_to_le16((unsigned short)(0xfff0 & (num << 4))); \ - } while (0) - -#define SetDuration (pbuf, dur) \ - (*(__le16 *)((size_t)(pbuf) + 2) = cpu_to_le16(0xffff & (dur))) -#define SetPriority (pbuf, tid) \ (*(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf))
@@ -57,8 +33,6 @@#define GetAMsdu (pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 7) & 0x1) -#define GetAid (pbuf) (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 2)) & 0x3fff) -static inline unsigned char *rtl8723bs_get_ra (unsigned char *pframe) {struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +3 -3
@@ -281,7 +281,7 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl fctrl = &pwlanhdr->frame_control; *(fctrl) =0 ; -SetSeqNum (pwlanhdr,0 /*pmlmeext->mgnt_seq*/ ); + pwlanhdr->seq_ctrl =0 ;if (pnetwork->network.reserved[0 ] ==1 ) {/* beacon */ eth_broadcast_addr (pwlanhdr->addr1);
@@ -2074,7 +2074,7 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc pwlanhdr = (struct ieee80211_hdr *)pframe;/* update seq number */ - pmlmeext->mgnt_seq =GetSequence (pwlanhdr); + pmlmeext->mgnt_seq =ieee80211_get_sn (pwlanhdr); pattrib->seqnum = pmlmeext->mgnt_seq; pmlmeext->mgnt_seq++;
@@ -2480,7 +2480,7 @@ static int _cfg80211_rtw_mgmt_tx(struct adapter *padapter, u8 tx_ch, const u8 *b pwlanhdr = (struct ieee80211_hdr *)pframe;/* update seq number */ - pmlmeext->mgnt_seq =GetSequence (pwlanhdr); + pmlmeext->mgnt_seq =ieee80211_get_sn (pwlanhdr); pattrib->seqnum = pmlmeext->mgnt_seq; pmlmeext->mgnt_seq++;
Signature · 1 line
2.43.0
PATCH 9/10 staging: rtl8723bs: use IEEE80211_QOS_CTL_* masks for QoS control
In reply to Rishik YechuriThe driver reads and writes the QoS Control field with the SetPriority(), GetPriority(), SetEOSP(), SetAckpolicy(), GetAckpolicy() and GetAMsdu() macros, which shift and mask the field by hand. <linux/ieee80211.h> defines IEEE80211_QOS_CTL_* masks for the TID, EOSP, Ack Policy and A-MSDU Present subfields.
On transmit, set the subfields with le16_encode_bits() and the corresponding masks, and declare the QoS Control pointers as __le16 to match the byte order of the field. le16_encode_bits() masks the value to the width of the subfield, as the macros did.
On receive, locate the field with ieee80211_get_qos_ctl() instead of a fixed offset of 24 bytes, and extract the subfields with u8_get_bits(). Frames with four addresses are rejected by validate_recv_data_frame() before the QoS Control field is parsed, so the helper always returns the same offset as before.
Remove the macro definitions, which no longer have any users.
No functional change intended.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 10 +++++----- drivers/staging/rtl8723bs/core/rtw_recv.c | 8 +++++--- drivers/staging/rtl8723bs/core/rtw_xmit.c | 12 +++++++----- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 8 ++++---- drivers/staging/rtl8723bs/include/wifi.h | 15 --------------- 5 files changed, 21 insertions(+), 32 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +5 -5
@@ -3039,7 +3039,7 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da,unsigned char *pframe;struct ieee80211_hdr *pwlanhdr;__le16 *fctrl; -u16 *qc; +__le16 *qc;struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
@@ -3071,13 +3071,13 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da,else if ((pmlmeinfo->state &0x03 ) ==WIFI_FW_STATION_STATE ) *fctrl |=cpu_to_le16 (IEEE80211_FCTL_TODS ); - qc = (unsigned short *)(pframe + pattrib->hdrlen -2 ); + qc = (__le16 *)(pframe + pattrib->hdrlen -2 ); -SetPriority (qc, tid); + *qc |=le16_encode_bits (tid,IEEE80211_QOS_CTL_TID_MASK ); -SetEOSP (qc, pattrib->eosp); + *qc |=le16_encode_bits (pattrib->eosp,IEEE80211_QOS_CTL_EOSP ); -SetAckpolicy (qc, pattrib->ack_policy); + *qc |=le16_encode_bits (pattrib->ack_policy,IEEE80211_QOS_CTL_ACK_POLICY_MASK );memcpy (pwlanhdr->addr1, da,ETH_ALEN );memcpy (pwlanhdr->addr2,myid (&(padapter->eeprompriv)),ETH_ALEN );
drivers/staging/rtl8723bs/core/rtw_recv.c +5 -3
@@ -1309,9 +1309,11 @@ static signed int validate_recv_data_frame(struct adapter *adapter, union recv_f pattrib->ack_policy =0 ;/* parsing QC field */ if (pattrib->qos ==1 ) { - pattrib->priority =GetPriority ((ptr +24 )); - pattrib->ack_policy =GetAckpolicy ((ptr +24 )); - pattrib->amsdu =GetAMsdu ((ptr +24 )); +u8 *qc =ieee80211_get_qos_ctl (hdr); + + pattrib->priority =u8_get_bits (*qc,IEEE80211_QOS_CTL_TID_MASK ); + pattrib->ack_policy =u8_get_bits (*qc,IEEE80211_QOS_CTL_ACK_POLICY_MASK ); + pattrib->amsdu =u8_get_bits (*qc,IEEE80211_QOS_CTL_A_MSDU_PRESENT ); pattrib->hdrlen = pattrib->to_fr_ds ==3 ?32 :26 ;if (pattrib->priority !=0 && pattrib->priority !=3 )
drivers/staging/rtl8723bs/core/rtw_xmit.c +7 -5
@@ -904,7 +904,7 @@ static void xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmint rtw_make_wlanhdr (struct adapter *padapter,u8 *hdr,struct pkt_attrib *pattrib) { -u16 *qc; +__le16 *qc;struct ieee80211_hdr *pwlanhdr = (struct ieee80211_hdr *)hdr;struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -956,14 +956,16 @@ int rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr *fctrl |=cpu_to_le16 (IEEE80211_FCTL_PROTECTED );if (qos_option) { - qc = (unsigned short *)(hdr + pattrib->hdrlen -2 ); + qc = (__le16 *)(hdr + pattrib->hdrlen -2 );if (pattrib->priority) -SetPriority (qc, pattrib->priority); + *qc |=le16_encode_bits (pattrib->priority, +IEEE80211_QOS_CTL_TID_MASK ); -SetEOSP (qc, pattrib->eosp); + *qc |=le16_encode_bits (pattrib->eosp,IEEE80211_QOS_CTL_EOSP ); -SetAckpolicy (qc, pattrib->ack_policy); + *qc |=le16_encode_bits (pattrib->ack_policy, +IEEE80211_QOS_CTL_ACK_POLICY_MASK ); }/* TODO: fill HT Control Field */
drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +4 -4
@@ -260,8 +260,8 @@ static void ConstructNullFunctionData(struct adapter *padapter, *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_QOS_NULLFUNC ); pwlanqoshdr = (struct ieee80211_qos_hdr *)pframe; -SetPriority (&pwlanqoshdr->qos_ctrl,AC ); -SetEOSP (&pwlanqoshdr->qos_ctrl, bEosp); + pwlanqoshdr->qos_ctrl |=le16_encode_bits (AC ,IEEE80211_QOS_CTL_TID_MASK ); + pwlanqoshdr->qos_ctrl |=le16_encode_bits (bEosp,IEEE80211_QOS_CTL_EOSP ); pktlen =sizeof (struct ieee80211_qos_hdr ); }else {
@@ -748,8 +748,8 @@ static void ConstructBtNullFunctionData(struct adapter *padapter, *fctrl |=cpu_to_le16 (IEEE80211_FTYPE_DATA |IEEE80211_STYPE_QOS_NULLFUNC ); pwlanqoshdr = (struct ieee80211_qos_hdr *)pframe; -SetPriority (&pwlanqoshdr->qos_ctrl,AC ); -SetEOSP (&pwlanqoshdr->qos_ctrl, bEosp); + pwlanqoshdr->qos_ctrl |=le16_encode_bits (AC ,IEEE80211_QOS_CTL_TID_MASK ); + pwlanqoshdr->qos_ctrl |=le16_encode_bits (bEosp,IEEE80211_QOS_CTL_EOSP ); pktlen =sizeof (struct ieee80211_qos_hdr ); }else {
drivers/staging/rtl8723bs/include/wifi.h +0 -15
@@ -18,21 +18,6 @@/* This test verifies the WLAN NIC can update the NAV through sending the CTS with large duration. */ #define WiFiNavUpperUs 30000/* 30 ms */ -#define SetPriority (pbuf, tid) \ - (*(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf)) - -#define GetPriority (pbuf) ((le16_to_cpu(*(__le16 *)(pbuf))) & 0xf) - -#define SetEOSP (pbuf, eosp) \ - (*(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4)) - -#define SetAckpolicy (pbuf, ack) \ - (*(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5)) - -#define GetAckpolicy (pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 5) & 0x3) - -#define GetAMsdu (pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 7) & 0x1) -static inline unsigned char *rtl8723bs_get_ra (unsigned char *pframe) {struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
Signature · 1 line
2.43.0
PATCH 10/10 staging: rtl8723bs: use ieee80211_get_DA() and ieee80211_get_SA()
In reply to Rishik Yechuriget_da() and get_sa() in wifi.h select the destination and source address of a frame according to the To DS and From DS bits. They duplicate ieee80211_get_DA() and ieee80211_get_SA() from <linux/ieee80211.h>, which return the same address for every combination of these bits.
rtl8723bs_get_ra() and get_ta() only return the addr1 and addr2 members of the header.
Replace get_da() and get_sa() with the generic helpers, replace rtl8723bs_get_ra() and get_ta() with direct accesses to addr1 and addr2, and remove the four functions.
No functional change intended.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 8 ++- drivers/staging/rtl8723bs/core/rtw_recv.c | 4 +- .../staging/rtl8723bs/hal/rtl8723bs_recv.c | 4 +- drivers/staging/rtl8723bs/include/wifi.h | 68 ------------------- 4 files changed, 9 insertions(+), 75 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +5 -3
@@ -501,6 +501,7 @@ unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame)struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;struct wlan_bssid_ex *cur = &pmlmeinfo->network;u8 *pframe = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;uint len = precv_frame->u.hdr.len;u8 is_valid_p2p_probereq = false;
@@ -529,7 +530,7 @@ unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame)if ((check_fwstate (pmlmepriv, _FW_LINKED) && pmlmepriv->cur_network.join_res) ||check_fwstate (pmlmepriv,WIFI_ADHOC_MASTER_STATE )) -issue_probersp (padapter,get_sa (pframe), is_valid_p2p_probereq); +issue_probersp (padapter,ieee80211_get_SA (hdr), is_valid_p2p_probereq); }return _SUCCESS;
@@ -853,7 +854,7 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_framuint pkt_len = precv_frame->u.hdr.len;/* check A1 matches or not */ -if (memcmp (myid (&(padapter->eeprompriv)),get_da (pframe),ETH_ALEN )) +if (memcmp (myid (&(padapter->eeprompriv)),ieee80211_get_DA (hdr),ETH_ALEN ))return _SUCCESS;if (!(pmlmeinfo->state &WIFI_FW_AUTH_STATE ))
@@ -1332,10 +1333,11 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame)struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;u8 *pframe = precv_frame->u.hdr.rx_data; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;uint pkt_len = precv_frame->u.hdr.len;/* check A1 matches or not */ -if (memcmp (myid (&(padapter->eeprompriv)),get_da (pframe),ETH_ALEN )) +if (memcmp (myid (&(padapter->eeprompriv)),ieee80211_get_DA (hdr),ETH_ALEN ))return _SUCCESS;if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS |WIFI_FW_ASSOC_STATE )))
drivers/staging/rtl8723bs/core/rtw_recv.c +2 -2
@@ -1251,8 +1251,8 @@ static signed int validate_recv_data_frame(struct adapter *adapter, union recv_fsigned int ret = _SUCCESS; bretry =ieee80211_has_retry (hdr->frame_control); - pda =get_da (ptr); - psa =get_sa (ptr); + pda =ieee80211_get_DA (hdr); + psa =ieee80211_get_SA (hdr); pbssid =get_hdr_bssid (ptr);if (!pbssid) {
drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c +2 -2
@@ -106,7 +106,7 @@ static void update_recvframe_phyinfo(union recv_frame *precvframe, !pattrib->icv_err && !pattrib->crc_err && ether_addr_equal(rx_bssid, my_bssid)); - rx_ra =rtl8723bs_get_ra (wlanhdr); + rx_ra = hdr->addr1; my_hwaddr =myid (&padapter->eeprompriv); pkt_info.to_self = pkt_info.bssid_match &ðer_addr_equal (rx_ra, my_hwaddr);
@@ -114,7 +114,7 @@ static void update_recvframe_phyinfo(union recv_frame *precvframe, pkt_info.is_beacon = pkt_info.bssid_match &&ieee80211_is_beacon (hdr->frame_control); - sa =get_ta (wlanhdr); + sa = hdr->addr2; pkt_info.station_id =0xFF ;
drivers/staging/rtl8723bs/include/wifi.h +0 -68
74 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerQuoted 32 lines · Rishik Yechuri
The rtl8723bs driver has its own set of macros and inline functions in
wifi.hfor working with 802.11 frame headers. They access the header through hardcoded byte offsets and pointer casts, and they duplicate structieee80211_hdrand the helpers in <linux/ieee80211.h> that mac80211, cfg80211 and other wireless drivers already use.This series switches the driver over to the generic versions and deletes the private ones from
wifi.h. Each patch converts one group of macros and removes their definitions once nothing uses them anymore, so the driver builds after every patch.Patches 1 to 3 convert header address access and the Frame Control flag checks and updates.
Patches 4 and 5 convert the frame type and subtype checks. Single comparisons use the ieee80211_is_*() helpers, and switch statements mask
frame_controlwith IEEE80211_FCTL_* and use IEEE80211_STYPE_* case labels, the same way mac80211 does.Patch 6 removes an unused struct member. Its initialisers were the last users of a few private subtype constants that have no generic equivalent.
Patch 7 converts the frame subtype setter and removes the private WIFI_* frame type enum.
Patches 8 and 9 convert the Sequence Control, Duration/ID and QoS Control fields.
Patch 10 replaces the driver's destination and source address helpers with
ieee80211_get_DA()andieee80211_get_SA().
Quoted 8 lines
None of this should change behaviour. In the few places where a generic helper checks more than the code it replaces, or where the old macro kept bits that a plain assignment would overwrite, the commit message explains why the result is the same.
Compile tested with W=1 after each patch, and checked with checkpatch and smatch. I don't have a device with this chip, so it has not been tested on hardware.
Did you forget the assisted-by tag for this series or did you really do this "by hand"?
thanks,
greg k-h
I forgot to add the assisted-by tag to the series. I wrote the series with some help from claude. Should I resend the series with updated tags?
Quoted 49 lines · Greg Kroah-Hartman
Quoted 32 lines · Rishik Yechuri
The rtl8723bs driver has its own set of macros and inline functions in
wifi.hfor working with 802.11 frame headers. They access the header through hardcoded byte offsets and pointer casts, and they duplicate structieee80211_hdrand the helpers in <linux/ieee80211.h> that mac80211, cfg80211 and other wireless drivers already use.This series switches the driver over to the generic versions and deletes the private ones from
wifi.h. Each patch converts one group of macros and removes their definitions once nothing uses them anymore, so the driver builds after every patch.Patches 1 to 3 convert header address access and the Frame Control flag checks and updates.
Patches 4 and 5 convert the frame type and subtype checks. Single comparisons use the ieee80211_is_*() helpers, and switch statements mask
frame_controlwith IEEE80211_FCTL_* and use IEEE80211_STYPE_* case labels, the same way mac80211 does.Patch 6 removes an unused struct member. Its initialisers were the last users of a few private subtype constants that have no generic equivalent.
Patch 7 converts the frame subtype setter and removes the private WIFI_* frame type enum.
Patches 8 and 9 convert the Sequence Control, Duration/ID and QoS Control fields.
Patch 10 replaces the driver's destination and source address helpers with
ieee80211_get_DA()andieee80211_get_SA().Quoted 8 lines
None of this should change behaviour. In the few places where a generic helper checks more than the code it replaces, or where the old macro kept bits that a plain assignment would overwrite, the commit message explains why the result is the same.
Compile tested with W=1 after each patch, and checked with checkpatch and smatch. I don't have a device with this chip, so it has not been tested on hardware.
Did you forget the assisted-by tag for this series or did you really do this "by hand"?
thanks,
greg k-h
Greg Kroah-Hartman
maintainerQuoted 3 lines · Rishik
I forgot to add the assisted-by tag to the series. I wrote the series with some help from claude. Should I resend the series with updated tags?
Please rebase on the latest kernel release and see what happens :)
Just saw that the driver was removed.
Quoted 7 lines · Greg Kroah-Hartman
Quoted 3 lines · Rishik
I forgot to add the assisted-by tag to the series. I wrote the series with some help from claude. Should I resend the series with updated tags?
Please rebase on the latest kernel release and see what happens :)