Commit 2aaeaaff authored by Aiman Najjar's avatar Aiman Najjar Committed by Greg Kroah-Hartman

staging: rtl8712: code improvements to make_wlanhdr

1. Refactor make_wlanhdr to improve code style.
2. Use ether_addr_copy instead of memcpy to copy addresses.
Suggested-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarAiman Najjar <aiman.najjar@hurranet.com>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/275773a0379e4a03839cd832d2ed952fd7bfee48.1585508171.git.aiman.najjar@hurranet.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f476c590
...@@ -477,75 +477,72 @@ static int make_wlanhdr(struct _adapter *padapter, u8 *hdr, ...@@ -477,75 +477,72 @@ static int make_wlanhdr(struct _adapter *padapter, u8 *hdr,
struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct qos_priv *pqospriv = &pmlmepriv->qospriv; struct qos_priv *pqospriv = &pmlmepriv->qospriv;
__le16 *fctrl = &pwlanhdr->frame_ctl; __le16 *fctrl = &pwlanhdr->frame_ctl;
u8 *bssid;
memset(hdr, 0, WLANHDR_OFFSET); memset(hdr, 0, WLANHDR_OFFSET);
SetFrameSubType(fctrl, pattrib->subtype); SetFrameSubType(fctrl, pattrib->subtype);
if (pattrib->subtype & WIFI_DATA_TYPE) { if (!(pattrib->subtype & WIFI_DATA_TYPE))
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { return 0;
/* to_ds = 1, fr_ds = 0; */
SetToDs(fctrl);
memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv),
ETH_ALEN);
memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN);
memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN);
} else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
/* to_ds = 0, fr_ds = 1; */
SetFrDs(fctrl);
memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN);
memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv),
ETH_ALEN);
memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN);
} else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ||
check_fwstate(pmlmepriv,
WIFI_ADHOC_MASTER_STATE)) {
memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN);
memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN);
memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv),
ETH_ALEN);
} else if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) {
memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN);
memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN);
memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv),
ETH_ALEN);
} else {
return -EINVAL;
}
if (pattrib->encrypt) bssid = get_bssid(pmlmepriv);
SetPrivacy(fctrl);
if (pqospriv->qos_option) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
qc = (unsigned short *)(hdr + pattrib->hdrlen - 2); /* to_ds = 1, fr_ds = 0; */
if (pattrib->priority) SetToDs(fctrl);
SetPriority(qc, pattrib->priority); ether_addr_copy(pwlanhdr->addr1, bssid);
SetAckpolicy(qc, pattrib->ack_policy); ether_addr_copy(pwlanhdr->addr2, pattrib->src);
} ether_addr_copy(pwlanhdr->addr3, pattrib->dst);
/* TODO: fill HT Control Field */ } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
/* Update Seq Num will be handled by f/w */ /* to_ds = 0, fr_ds = 1; */
{ SetFrDs(fctrl);
struct sta_info *psta; ether_addr_copy(pwlanhdr->addr1, pattrib->dst);
bool bmcst = is_multicast_ether_addr(pattrib->ra); ether_addr_copy(pwlanhdr->addr2, bssid);
ether_addr_copy(pwlanhdr->addr3, pattrib->src);
if (pattrib->psta) { } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ||
psta = pattrib->psta; check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
} else { ether_addr_copy(pwlanhdr->addr1, pattrib->dst);
if (bmcst) ether_addr_copy(pwlanhdr->addr2, pattrib->src);
psta = r8712_get_bcmc_stainfo(padapter); ether_addr_copy(pwlanhdr->addr3, bssid);
else } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) {
psta = ether_addr_copy(pwlanhdr->addr1, pattrib->dst);
r8712_get_stainfo(&padapter->stapriv, ether_addr_copy(pwlanhdr->addr2, pattrib->src);
pattrib->ra); ether_addr_copy(pwlanhdr->addr3, bssid);
} } else {
if (psta) { return -EINVAL;
psta->sta_xmitpriv.txseq_tid }
[pattrib->priority]++;
psta->sta_xmitpriv.txseq_tid[pattrib->priority] if (pattrib->encrypt)
&= 0xFFF; SetPrivacy(fctrl);
pattrib->seqnum = psta->sta_xmitpriv. if (pqospriv->qos_option) {
txseq_tid[pattrib->priority]; qc = (unsigned short *)(hdr + pattrib->hdrlen - 2);
SetSeqNum(hdr, pattrib->seqnum); if (pattrib->priority)
} SetPriority(qc, pattrib->priority);
SetAckpolicy(qc, pattrib->ack_policy);
}
/* TODO: fill HT Control Field */
/* Update Seq Num will be handled by f/w */
{
struct sta_info *psta;
bool bmcst = is_multicast_ether_addr(pattrib->ra);
if (pattrib->psta)
psta = pattrib->psta;
else if (bmcst)
psta = r8712_get_bcmc_stainfo(padapter);
else
psta = r8712_get_stainfo(&padapter->stapriv,
pattrib->ra);
if (psta) {
u16 *txtid = psta->sta_xmitpriv.txseq_tid;
txtid[pattrib->priority]++;
txtid[pattrib->priority] &= 0xFFF;
pattrib->seqnum = txtid[pattrib->priority];
SetSeqNum(hdr, pattrib->seqnum);
} }
} }
return 0; return 0;
} }
......
...@@ -115,7 +115,7 @@ struct pkt_attrib { ...@@ -115,7 +115,7 @@ struct pkt_attrib {
u8 icv_len; u8 icv_len;
unsigned char iv[8]; unsigned char iv[8];
unsigned char icv[8]; unsigned char icv[8];
u8 dst[ETH_ALEN]; u8 dst[ETH_ALEN] __aligned(2); /* for ether_addr_copy */
u8 src[ETH_ALEN]; u8 src[ETH_ALEN];
u8 ta[ETH_ALEN]; u8 ta[ETH_ALEN];
u8 ra[ETH_ALEN]; u8 ra[ETH_ALEN];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment