staging: r8188eu: use is_multicast_ether_addr instead of IS_MCAST
cover staging: r8188eu: use is_multicast_ether_addr instead of IS_MCAST
This series replaces most uses of the custom IS_MCAST macro with is_multicast_ether_addr. The goal is to get rid of IS_MCAST. There is only one usage left in rtw_sta_mgt.c, but that one needs more effort to verify that the buffers are properly aligned, so I left it as is for now.
Michael Straube (8):
staging: r8188eu: ensure proper alignment for eth address buffers
staging: r8188eu: use is_multicast_ether_addr in core/rtw_mlme.c
staging: r8188eu: use is_multicast_ether_addr in core/rtw_mp.c
staging: r8188eu: use is_multicast_ether_addr in core/rtw_recv.c
staging: r8188eu: use is_multicast_ether_addr in core/rtw_security.c
staging: r8188eu: use is_multicast_ether_addr in core/rtw_xmit.c
staging: r8188eu: use is_multicast_ether_addr in hal/rtl8188eu_xmit.c
staging: r8188eu: use is_multicast_ether_addr in os_dep/recv_linux.c
drivers/staging/r8188eu/core/rtw_mlme.c | 4 ++-- drivers/staging/r8188eu/core/rtw_mp.c | 4 ++-- drivers/staging/r8188eu/core/rtw_recv.c | 20 ++++++++++---------- drivers/staging/r8188eu/core/rtw_security.c | 8 ++++---- drivers/staging/r8188eu/core/rtw_xmit.c | 15 ++++++--------- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 3 +-- drivers/staging/r8188eu/include/rtw_recv.h | 10 +++++----- drivers/staging/r8188eu/include/rtw_xmit.h | 8 ++++---- drivers/staging/r8188eu/os_dep/recv_linux.c | 2 +- 9 files changed, 35 insertions(+), 39 deletions(-)
Signature · 1 line
2.32.0
PATCH 1/8 staging: r8188eu: ensure proper alignment for eth address buffers
Add __aligned(2) to eth address buffers in structs rx_pkt_attrib and pkt_attrib to ensure proper alignment for usage with functions from <linux/etherdevice.h>
--- drivers/staging/r8188eu/include/rtw_recv.h | 10 +++++----- drivers/staging/r8188eu/include/rtw_xmit.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/staging/r8188eu/include/rtw_recv.h +5 -5
@@ -109,11 +109,11 @@ struct rx_pkt_attrib {u16 eth_type; -u8 dst[ETH_ALEN ]; -u8 src[ETH_ALEN ]; -u8 ta[ETH_ALEN ]; -u8 ra[ETH_ALEN ]; -u8 bssid[ETH_ALEN ]; +u8 dst[ETH_ALEN ]__aligned(2) ; +u8 src[ETH_ALEN ]__aligned(2) ; +u8 ta[ETH_ALEN ]__aligned(2) ; +u8 ra[ETH_ALEN ]__aligned(2) ; +u8 bssid[ETH_ALEN ]__aligned(2) ;u8 ack_policy;
drivers/staging/r8188eu/include/rtw_xmit.h +4 -4
@@ -122,10 +122,10 @@ struct pkt_attrib {u8 ack_policy;u8 mac_id;u8 vcs_mode;/* virtual carrier sense method */ -u8 dst[ETH_ALEN ]; -u8 src[ETH_ALEN ]; -u8 ta[ETH_ALEN ]; -u8 ra[ETH_ALEN ]; +u8 dst[ETH_ALEN ]__aligned(2) ; +u8 src[ETH_ALEN ]__aligned(2) ; +u8 ta[ETH_ALEN ]__aligned(2) ; +u8 ra[ETH_ALEN ]__aligned(2) ;u8 key_idx;u8 qos_en;u8 ht_en;
Signature · 1 line
2.32.0
PATCH 2/8 staging: r8188eu: use is_multicast_ether_addr in core/rtw_mlme.c
In reply to Michael StraubeUse is_multicast_ether_addr instead of custom macro IS_MCAST, the buffer is properly aligned.
--- drivers/staging/r8188eu/core/rtw_mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme.c +2 -2
@@ -2121,9 +2121,9 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfrstruct sta_info *psta =NULL ;struct ht_priv *phtpriv;struct pkt_attrib *pattrib = &pxmitframe->attrib; -s32 bmcst =IS_MCAST (pattrib->ra); -if (bmcst || (padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod <100 )) +if (is_multicast_ether_addr (pattrib->ra) || + padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod <100 )return ; priority = pattrib->priority;
Signature · 1 line
2.32.0
PATCH 3/8 staging: r8188eu: use is_multicast_ether_addr in core/rtw_mp.c
In reply to Michael StraubeUse is_multicast_ether_addr instead of custom macro IS_MCAST, the buffer is properly aligned.
--- drivers/staging/r8188eu/core/rtw_mp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/r8188eu/core/rtw_mp.c +2 -2
@@ -635,7 +635,7 @@ void SetPacketTx(struct adapter *padapter)struct tx_desc *desc;struct rtw_ieee80211_hdr *hdr;u8 payload; -s32 bmcast; +bool bmcast;struct pkt_attrib *pattrib;struct mp_priv *pmp_priv;
@@ -651,7 +651,7 @@ void SetPacketTx(struct adapter *padapter)memcpy (pattrib->src, padapter->eeprompriv.mac_addr,ETH_ALEN );memcpy (pattrib->ta, pattrib->src,ETH_ALEN );memcpy (pattrib->ra, pattrib->dst,ETH_ALEN ); - bmcast =IS_MCAST (pattrib->ra); + bmcast =is_multicast_ether_addr (pattrib->ra);if (bmcast) { pattrib->mac_id =1 ; pattrib->psta =rtw_get_bcmc_stainfo (padapter);
Signature · 1 line
2.32.0
PATCH 4/8 staging: r8188eu: use is_multicast_ether_addr in core/rtw_recv.c
In reply to Michael StraubeUse is_multicast_ether_addr instead of custom macro IS_MCAST, all buffers are properly aligned.
--- drivers/staging/r8188eu/core/rtw_recv.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/staging/r8188eu/core/rtw_recv.c +10 -10
@@ -330,7 +330,7 @@ static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvfrif (prxattrib->encrypt == _TKIP_) {/* calculate mic code */ if (stainfo) { -if (IS_MCAST (prxattrib->ra)) { +if (is_multicast_ether_addr (prxattrib->ra)) { mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0 ];if (!psecuritypriv) {
@@ -361,11 +361,11 @@ static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvfrif (bmic_err) {/* double check key_index for some timing issue , */ /* cannot compare with psecuritypriv->dot118021XGrpKeyid also cause timing issue */ -if (IS_MCAST (prxattrib->ra) && prxattrib->key_index != pmlmeinfo->key_index) +if (is_multicast_ether_addr (prxattrib->ra) && prxattrib->key_index != pmlmeinfo->key_index) brpt_micerror = false;if ((prxattrib->bdecrypted) && (brpt_micerror)) { -rtw_handle_tkip_mic_err (adapter, (u8 )IS_MCAST (prxattrib->ra)); +rtw_handle_tkip_mic_err (adapter, (u8 )is_multicast_ether_addr (prxattrib->ra));DBG_88E (" mic error :prxattrib->bdecrypted=%d\n" , prxattrib->bdecrypted); }else {DBG_88E (" mic error :prxattrib->bdecrypted=%d\n" , prxattrib->bdecrypted);
@@ -373,7 +373,7 @@ static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvfr res = _FAIL; }else {/* mic checked ok */ -if ((!psecuritypriv->bcheck_grpkey) && (IS_MCAST (prxattrib->ra))) +if (!psecuritypriv->bcheck_grpkey &&is_multicast_ether_addr (prxattrib->ra)) psecuritypriv->bcheck_grpkey = true; } }
@@ -618,7 +618,7 @@ static void count_rx_stats(struct adapter *padapter, struct recv_frame *prframe, padapter->mlmepriv.LinkDetectInfo.NumRxOkInPeriod++; -if (!is_broadcast_ether_addr (pattrib->dst) && !IS_MCAST (pattrib->dst)) +if (!is_broadcast_ether_addr (pattrib->dst) && !is_multicast_ether_addr (pattrib->dst)) padapter->mlmepriv.LinkDetectInfo.NumRxUnicastOkInPeriod++;if (sta)
@@ -650,7 +650,7 @@ int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame,u8 *mybssid =get_bssid (pmlmepriv);u8 *myhwaddr =myid (&adapter->eeprompriv);u8 *sta_addr =NULL ; -int bmcast =IS_MCAST (pattrib->dst); +bool bmcast =is_multicast_ether_addr (pattrib->dst);if (check_fwstate (pmlmepriv,WIFI_ADHOC_STATE ) ||check_fwstate (pmlmepriv,WIFI_ADHOC_MASTER_STATE )) {
@@ -683,7 +683,7 @@ int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame, }else if (check_fwstate (pmlmepriv,WIFI_AP_STATE )) {if (bmcast) {/* For AP mode, if DA == MCAST, then BSSID should be also MCAST */ -if (!IS_MCAST (pattrib->bssid)) { +if (!is_multicast_ether_addr (pattrib->bssid)) { ret = _FAIL; goto exit; }
@@ -739,7 +739,7 @@ static int ap2sta_data_frame(struct mlme_priv *pmlmepriv = &adapter->mlmepriv;u8 *mybssid =get_bssid (pmlmepriv);u8 *myhwaddr =myid (&adapter->eeprompriv); -int bmcast =IS_MCAST (pattrib->dst); +bool bmcast =is_multicast_ether_addr (pattrib->dst); if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && (check_fwstate(pmlmepriv, _FW_LINKED) ||
@@ -1136,7 +1136,7 @@ static int validate_recv_data_frame(struct adapter *adapter, }if (pattrib->privacy) { -GET_ENCRY_ALGO (psecuritypriv, psta, pattrib->encrypt,IS_MCAST (pattrib->ra)); +GET_ENCRY_ALGO (psecuritypriv, psta, pattrib->encrypt,is_multicast_ether_addr (pattrib->ra));SET_ICE_IV_LEN (pattrib->iv_len, pattrib->icv_len, pattrib->encrypt); }else {
@@ -1957,7 +1957,7 @@ static int recv_func(struct adapter *padapter, struct recv_frame *rframe)if (ret == _SUCCESS) {/* check if need to enqueue into uc_swdec_pending_queue*/ if (check_fwstate (mlmepriv,WIFI_STATION_STATE ) && - !IS_MCAST (prxattrib->ra) && prxattrib->encrypt >0 && + !is_multicast_ether_addr (prxattrib->ra) && prxattrib->encrypt >0 && (prxattrib->bdecrypted ==0 || psecuritypriv->sw_decrypt) && psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPAPSK && !psecuritypriv->busetkipkey) {
Signature · 1 line
2.32.0
PATCH 5/8 staging: r8188eu: use is_multicast_ether_addr in core/rtw_security.c
In reply to Michael StraubeUse is_multicast_ether_addr instead of custom macro IS_MCAST, all buffers are properly aligned.
--- drivers/staging/r8188eu/core/rtw_security.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/r8188eu/core/rtw_security.c +4 -4
@@ -538,7 +538,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) stainfo =rtw_get_stainfo (&padapter->stapriv, &pattrib->ra[0 ]);if (stainfo) { -if (IS_MCAST (pattrib->ra)) +if (is_multicast_ether_addr (pattrib->ra)) prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;else prwskey = &stainfo->dot118021x_UncstKey.skey[0 ];
@@ -608,7 +608,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)if (prxattrib->encrypt == _TKIP_) { stainfo =rtw_get_stainfo (&padapter->stapriv, &prxattrib->ta[0 ]);if (stainfo) { -if (IS_MCAST (prxattrib->ra)) { +if (is_multicast_ether_addr (prxattrib->ra)) {if (!psecuritypriv->binstallGrpkey) { res = _FAIL;DBG_88E ("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n" , __func__);
@@ -1188,7 +1188,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) stainfo =rtw_get_stainfo (&padapter->stapriv, &pattrib->ra[0 ]);if (stainfo) { -if (IS_MCAST (pattrib->ra)) +if (is_multicast_ether_addr (pattrib->ra)) prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;else prwskey = &stainfo->dot118021x_UncstKey.skey[0 ];
@@ -1421,7 +1421,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)if (prxattrib->encrypt == _AES_) { stainfo =rtw_get_stainfo (&padapter->stapriv, &prxattrib->ta[0 ]);if (stainfo) { -if (IS_MCAST (prxattrib->ra)) { +if (is_multicast_ether_addr (prxattrib->ra)) {/* in concurrent we should use sw descrypt in group key, so we remove this message */ if (!psecuritypriv->binstallGrpkey) { res = _FAIL;
Signature · 1 line
2.32.0
PATCH 6/8 staging: r8188eu: use is_multicast_ether_addr in core/rtw_xmit.c
In reply to Michael StraubeUse is_multicast_ether_addr instead of custom macro IS_MCAST, all buffers are properly aligned.
--- drivers/staging/r8188eu/core/rtw_xmit.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/staging/r8188eu/core/rtw_xmit.c +6 -9
@@ -411,7 +411,7 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct pstruct sta_info *psta =NULL ;struct ethhdr etherhdr; -int bmcast; +bool bmcast;struct sta_priv *pstapriv = &padapter->stapriv;struct security_priv *psecuritypriv = &padapter->securitypriv;struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -472,7 +472,7 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct pif ((pattrib->ether_type ==0x0806 ) || (pattrib->ether_type ==0x888e ) || (pattrib->dhcp_pkt ==1 ))rtw_lps_ctrl_wk_cmd (padapter,LPS_CTRL_SPECIAL_PACKET ,1 ); - bmcast =IS_MCAST (pattrib->ra); + bmcast =is_multicast_ether_addr (pattrib->ra);/* get sta_info */ if (bmcast) {
@@ -597,7 +597,6 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfrstruct xmit_priv *pxmitpriv = &padapter->xmitpriv;u8 priority[4 ] = {0x0 ,0x0 ,0x0 ,0x0 };u8 hw_hdr_offset =0 ; -int bmcst =IS_MCAST (pattrib->ra);if (pattrib->psta) stainfo = pattrib->psta;
@@ -615,7 +614,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr pframe = pxmitframe->buf_addr + hw_hdr_offset; -if (bmcst) { +if (is_multicast_ether_addr (pattrib->ra)) {if (!memcmp (psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key,16 ))return _FAIL;/* start to calculate the mic code */
@@ -715,12 +714,10 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattrstruct sta_info *psta; -int bmcst =IS_MCAST (pattrib->ra); -if (pattrib->psta) { psta = pattrib->psta; }else { -if (bmcst) { +if (is_multicast_ether_addr (pattrib->ra)) { psta =rtw_get_bcmc_stainfo (padapter); }else { psta =rtw_get_stainfo (&padapter->stapriv, pattrib->ra);
@@ -907,7 +904,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, structstruct xmit_priv *pxmitpriv = &padapter->xmitpriv;struct pkt_attrib *pattrib = &pxmitframe->attrib;u8 *pbuf_start; -s32 bmcst =IS_MCAST (pattrib->ra); +bool bmcst =is_multicast_ether_addr (pattrib->ra);s32 res = _SUCCESS;if (!pkt)
@@ -1801,7 +1798,7 @@ int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frastruct sta_priv *pstapriv = &padapter->stapriv;struct pkt_attrib *pattrib = &pxmitframe->attrib;struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -int bmcst =IS_MCAST (pattrib->ra); +bool bmcst =is_multicast_ether_addr (pattrib->ra);if (!check_fwstate (pmlmepriv,WIFI_AP_STATE ))return ret;
Signature · 1 line
2.32.0
PATCH 7/8 staging: r8188eu: use is_multicast_ether_addr in hal/rtl8188eu_xmit.c
In reply to Michael StraubeUse is_multicast_ether_addr instead of custom macro IS_MCAST, the buffer is properly aligned.
--- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/r8188eu/hal/rtl8188eu_xmit.c +1 -2
@@ -167,7 +167,6 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bagstruct tx_desc *ptxdesc = (struct tx_desc *)pmem;struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv;struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; -int bmcst =IS_MCAST (pattrib->ra);if (adapt->registrypriv.mp_mode ==0 ) {if ((!bagg_pkt) && (urb_zero_packet_chk (adapt, sz) ==0 )) {
@@ -186,7 +185,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag ptxdesc->txdw0 |=cpu_to_le32 (((offset) <<OFFSET_SHT ) &0x00ff0000 );/* 32 bytes for TX Desc */ -if (bmcst) +if (is_multicast_ether_addr (pattrib->ra)) ptxdesc->txdw0 |=cpu_to_le32 (BMC );if (adapt->registrypriv.mp_mode ==0 ) {
Signature · 1 line
2.32.0
PATCH 8/8 staging: r8188eu: use is_multicast_ether_addr in os_dep/recv_linux.c
In reply to Michael StraubeUse is_multicast_ether_addr instead of custom macro IS_MCAST, the buffer is properly aligned.
--- drivers/staging/r8188eu/os_dep/recv_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/r8188eu/os_dep/recv_linux.c +1 -1
@@ -132,7 +132,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter,struct sta_info *psta =NULL ;struct sta_priv *pstapriv = &padapter->stapriv;struct rx_pkt_attrib *pattrib = &precv_frame->attrib; -int bmcast =IS_MCAST (pattrib->dst); +bool bmcast =is_multicast_ether_addr (pattrib->dst);if (memcmp (pattrib->dst,myid (&padapter->eeprompriv),ETH_ALEN )) {
Signature · 1 line
2.32.0
Quoted 28 lines · Michael Straube
This series replaces most uses of the custom
IS_MCASTmacro withis_multicast_ether_addr. The goal is to get rid ofIS_MCAST. There is only one usage left inrtw_sta_mgt.c, but that one needs more effort to verify that the buffers are properly aligned, so I left it as is for now.Michael Straube (8):
staging: r8188eu: ensure proper alignment for eth address buffers
staging: r8188eu: useis_multicast_ether_addrincore/rtw_mlme.c
staging: r8188eu: useis_multicast_ether_addrincore/rtw_mp.c
staging: r8188eu: useis_multicast_ether_addrincore/rtw_recv.c
staging: r8188eu: useis_multicast_ether_addrincore/rtw_security.c
staging: r8188eu: useis_multicast_ether_addrincore/rtw_xmit.c
staging: r8188eu: useis_multicast_ether_addrinhal/rtl8188eu_xmit.c
staging: r8188eu: useis_multicast_ether_addrinos_dep/recv_linux.cdrivers/staging/r8188eu/core/rtw_mlme.c | 4 ++-- drivers/staging/r8188eu/core/rtw_mp.c | 4 ++-- drivers/staging/r8188eu/core/rtw_recv.c | 20 ++++++++++---------- drivers/staging/r8188eu/core/rtw_security.c | 8 ++++---- drivers/staging/r8188eu/core/rtw_xmit.c | 15 ++++++--------- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 3 +-- drivers/staging/r8188eu/include/rtw_recv.h | 10 +++++----- drivers/staging/r8188eu/include/rtw_xmit.h | 8 ++++---- drivers/staging/r8188eu/os_dep/recv_linux.c | 2 +- 9 files changed, 35 insertions(+), 39 deletions(-)
Quoted 3 lines
--
2.32.0
Dear Michael,
Based on my limited knowledge, looks good to me. Also I built and runtime tested it with my N10-Nano, driver works well still. Many thanks.
For whole series:
Regards,
Phil