Commit e3fbf8d2 authored by Michal Kazior's avatar Michal Kazior Committed by Kalle Valo

ath10k: cleanup RX decap handling

Simplify decapping code and make it easier to
understand.
Signed-off-by: default avatarMichal Kazior <michal.kazior@tieto.com>
Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
parent 26d1e9c2
...@@ -669,11 +669,16 @@ static void ath10k_htt_rx_amsdu(struct ath10k_htt *htt, ...@@ -669,11 +669,16 @@ static void ath10k_htt_rx_amsdu(struct ath10k_htt *htt,
switch (fmt) { switch (fmt) {
case RX_MSDU_DECAP_RAW: case RX_MSDU_DECAP_RAW:
/* remove trailing FCS */
skb_trim(skb, skb->len - FCS_LEN); skb_trim(skb, skb->len - FCS_LEN);
break; break;
case RX_MSDU_DECAP_NATIVE_WIFI: case RX_MSDU_DECAP_NATIVE_WIFI:
/* nothing to do */
break; break;
case RX_MSDU_DECAP_ETHERNET2_DIX: case RX_MSDU_DECAP_ETHERNET2_DIX:
/* strip ethernet header and insert decapped 802.11
* header, amsdu subframe header and rfc1042 header */
len = 0; len = 0;
len += sizeof(struct rfc1042_hdr); len += sizeof(struct rfc1042_hdr);
len += sizeof(struct amsdu_subframe_hdr); len += sizeof(struct amsdu_subframe_hdr);
...@@ -683,6 +688,8 @@ static void ath10k_htt_rx_amsdu(struct ath10k_htt *htt, ...@@ -683,6 +688,8 @@ static void ath10k_htt_rx_amsdu(struct ath10k_htt *htt,
memcpy(skb_push(skb, hdr_len), hdr, hdr_len); memcpy(skb_push(skb, hdr_len), hdr, hdr_len);
break; break;
case RX_MSDU_DECAP_8023_SNAP_LLC: case RX_MSDU_DECAP_8023_SNAP_LLC:
/* insert decapped 802.11 header making a singly
* A-MSDU */
memcpy(skb_push(skb, hdr_len), hdr, hdr_len); memcpy(skb_push(skb, hdr_len), hdr, hdr_len);
break; break;
} }
...@@ -706,6 +713,8 @@ static void ath10k_htt_rx_msdu(struct ath10k_htt *htt, struct htt_rx_info *info) ...@@ -706,6 +713,8 @@ static void ath10k_htt_rx_msdu(struct ath10k_htt *htt, struct htt_rx_info *info)
struct ieee80211_hdr *hdr; struct ieee80211_hdr *hdr;
enum rx_msdu_decap_format fmt; enum rx_msdu_decap_format fmt;
enum htt_rx_mpdu_encrypt_type enctype; enum htt_rx_mpdu_encrypt_type enctype;
int hdr_len;
void *rfc1042;
/* This shouldn't happen. If it does than it may be a FW bug. */ /* This shouldn't happen. If it does than it may be a FW bug. */
if (skb->next) { if (skb->next) {
...@@ -719,46 +728,39 @@ static void ath10k_htt_rx_msdu(struct ath10k_htt *htt, struct htt_rx_info *info) ...@@ -719,46 +728,39 @@ static void ath10k_htt_rx_msdu(struct ath10k_htt *htt, struct htt_rx_info *info)
RX_MSDU_START_INFO1_DECAP_FORMAT); RX_MSDU_START_INFO1_DECAP_FORMAT);
enctype = MS(__le32_to_cpu(rxd->mpdu_start.info0), enctype = MS(__le32_to_cpu(rxd->mpdu_start.info0),
RX_MPDU_START_INFO0_ENCRYPT_TYPE); RX_MPDU_START_INFO0_ENCRYPT_TYPE);
hdr = (void *)skb->data - RX_HTT_HDR_STATUS_LEN; hdr = (struct ieee80211_hdr *)rxd->rx_hdr_status;
hdr_len = ieee80211_hdrlen(hdr->frame_control);
skb->ip_summed = ath10k_htt_rx_get_csum_state(skb); skb->ip_summed = ath10k_htt_rx_get_csum_state(skb);
switch (fmt) { switch (fmt) {
case RX_MSDU_DECAP_RAW: case RX_MSDU_DECAP_RAW:
/* remove trailing FCS */ /* remove trailing FCS */
skb_trim(skb, skb->len - 4); skb_trim(skb, skb->len - FCS_LEN);
break; break;
case RX_MSDU_DECAP_NATIVE_WIFI: case RX_MSDU_DECAP_NATIVE_WIFI:
/* nothing to do here */ /* nothing to do here */
break; break;
case RX_MSDU_DECAP_ETHERNET2_DIX: case RX_MSDU_DECAP_ETHERNET2_DIX:
/* macaddr[6] + macaddr[6] + ethertype[2] */ /* strip ethernet header and insert decapped 802.11 header and
skb_pull(skb, 6 + 6 + 2); * rfc1042 header */
break;
case RX_MSDU_DECAP_8023_SNAP_LLC:
/* macaddr[6] + macaddr[6] + len[2] */
/* we don't need this for non-A-MSDU */
skb_pull(skb, 6 + 6 + 2);
break;
}
if (fmt == RX_MSDU_DECAP_ETHERNET2_DIX) {
void *llc;
int llclen;
llclen = 8; rfc1042 = hdr;
llc = hdr; rfc1042 += roundup(hdr_len, 4);
llc += roundup(ieee80211_hdrlen(hdr->frame_control), 4); rfc1042 += roundup(ath10k_htt_rx_crypto_param_len(enctype), 4);
llc += roundup(ath10k_htt_rx_crypto_param_len(enctype), 4);
skb_push(skb, llclen); skb_pull(skb, sizeof(struct ethhdr));
memcpy(skb->data, llc, llclen); memcpy(skb_push(skb, sizeof(struct rfc1042_hdr)),
} rfc1042, sizeof(struct rfc1042_hdr));
memcpy(skb_push(skb, hdr_len), hdr, hdr_len);
break;
case RX_MSDU_DECAP_8023_SNAP_LLC:
/* remove A-MSDU subframe header and insert
* decapped 802.11 header. rfc1042 header is already there */
if (fmt >= RX_MSDU_DECAP_ETHERNET2_DIX) { skb_pull(skb, sizeof(struct amsdu_subframe_hdr));
int len = ieee80211_hdrlen(hdr->frame_control); memcpy(skb_push(skb, hdr_len), hdr, hdr_len);
skb_push(skb, len); break;
memcpy(skb->data, hdr, len);
} }
info->skb = skb; info->skb = skb;
......
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