diff options
author | Michal Kazior <michal.kazior@tieto.com> | 2013-09-26 03:12:23 -0400 |
---|---|---|
committer | Kalle Valo <kvalo@qca.qualcomm.com> | 2013-09-26 03:12:23 -0400 |
commit | e3fbf8d22a7ba109d1542c50c063acc23ef818ff (patch) | |
tree | d66afda1cff88cebfe0159b0e3b101691c3ee2f3 /drivers/net/wireless/ath/ath10k/htt_rx.c | |
parent | 26d1e9c2610c36689d48f7167ddc007e970d5489 (diff) |
ath10k: cleanup RX decap handling
Simplify decapping code and make it easier to
understand.
Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath10k/htt_rx.c')
-rw-r--r-- | drivers/net/wireless/ath/ath10k/htt_rx.c | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index 617df96e4ffd..cdb4e6da7cc2 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c | |||
@@ -669,11 +669,16 @@ static void ath10k_htt_rx_amsdu(struct ath10k_htt *htt, | |||
669 | 669 | ||
670 | switch (fmt) { | 670 | switch (fmt) { |
671 | case RX_MSDU_DECAP_RAW: | 671 | case RX_MSDU_DECAP_RAW: |
672 | /* remove trailing FCS */ | ||
672 | skb_trim(skb, skb->len - FCS_LEN); | 673 | skb_trim(skb, skb->len - FCS_LEN); |
673 | break; | 674 | break; |
674 | case RX_MSDU_DECAP_NATIVE_WIFI: | 675 | case RX_MSDU_DECAP_NATIVE_WIFI: |
676 | /* nothing to do */ | ||
675 | break; | 677 | break; |
676 | case RX_MSDU_DECAP_ETHERNET2_DIX: | 678 | case RX_MSDU_DECAP_ETHERNET2_DIX: |
679 | /* strip ethernet header and insert decapped 802.11 | ||
680 | * header, amsdu subframe header and rfc1042 header */ | ||
681 | |||
677 | len = 0; | 682 | len = 0; |
678 | len += sizeof(struct rfc1042_hdr); | 683 | len += sizeof(struct rfc1042_hdr); |
679 | len += sizeof(struct amsdu_subframe_hdr); | 684 | len += sizeof(struct amsdu_subframe_hdr); |
@@ -683,6 +688,8 @@ static void ath10k_htt_rx_amsdu(struct ath10k_htt *htt, | |||
683 | memcpy(skb_push(skb, hdr_len), hdr, hdr_len); | 688 | memcpy(skb_push(skb, hdr_len), hdr, hdr_len); |
684 | break; | 689 | break; |
685 | case RX_MSDU_DECAP_8023_SNAP_LLC: | 690 | case RX_MSDU_DECAP_8023_SNAP_LLC: |
691 | /* insert decapped 802.11 header making a singly | ||
692 | * A-MSDU */ | ||
686 | memcpy(skb_push(skb, hdr_len), hdr, hdr_len); | 693 | memcpy(skb_push(skb, hdr_len), hdr, hdr_len); |
687 | break; | 694 | break; |
688 | } | 695 | } |
@@ -706,6 +713,8 @@ static void ath10k_htt_rx_msdu(struct ath10k_htt *htt, struct htt_rx_info *info) | |||
706 | struct ieee80211_hdr *hdr; | 713 | struct ieee80211_hdr *hdr; |
707 | enum rx_msdu_decap_format fmt; | 714 | enum rx_msdu_decap_format fmt; |
708 | enum htt_rx_mpdu_encrypt_type enctype; | 715 | enum htt_rx_mpdu_encrypt_type enctype; |
716 | int hdr_len; | ||
717 | void *rfc1042; | ||
709 | 718 | ||
710 | /* This shouldn't happen. If it does than it may be a FW bug. */ | 719 | /* This shouldn't happen. If it does than it may be a FW bug. */ |
711 | if (skb->next) { | 720 | if (skb->next) { |
@@ -719,46 +728,39 @@ static void ath10k_htt_rx_msdu(struct ath10k_htt *htt, struct htt_rx_info *info) | |||
719 | RX_MSDU_START_INFO1_DECAP_FORMAT); | 728 | RX_MSDU_START_INFO1_DECAP_FORMAT); |
720 | enctype = MS(__le32_to_cpu(rxd->mpdu_start.info0), | 729 | enctype = MS(__le32_to_cpu(rxd->mpdu_start.info0), |
721 | RX_MPDU_START_INFO0_ENCRYPT_TYPE); | 730 | RX_MPDU_START_INFO0_ENCRYPT_TYPE); |
722 | hdr = (void *)skb->data - RX_HTT_HDR_STATUS_LEN; | 731 | hdr = (struct ieee80211_hdr *)rxd->rx_hdr_status; |
732 | hdr_len = ieee80211_hdrlen(hdr->frame_control); | ||
723 | 733 | ||
724 | skb->ip_summed = ath10k_htt_rx_get_csum_state(skb); | 734 | skb->ip_summed = ath10k_htt_rx_get_csum_state(skb); |
725 | 735 | ||
726 | switch (fmt) { | 736 | switch (fmt) { |
727 | case RX_MSDU_DECAP_RAW: | 737 | case RX_MSDU_DECAP_RAW: |
728 | /* remove trailing FCS */ | 738 | /* remove trailing FCS */ |
729 | skb_trim(skb, skb->len - 4); | 739 | skb_trim(skb, skb->len - FCS_LEN); |
730 | break; | 740 | break; |
731 | case RX_MSDU_DECAP_NATIVE_WIFI: | 741 | case RX_MSDU_DECAP_NATIVE_WIFI: |
732 | /* nothing to do here */ | 742 | /* nothing to do here */ |
733 | break; | 743 | break; |
734 | case RX_MSDU_DECAP_ETHERNET2_DIX: | 744 | case RX_MSDU_DECAP_ETHERNET2_DIX: |
735 | /* macaddr[6] + macaddr[6] + ethertype[2] */ | 745 | /* strip ethernet header and insert decapped 802.11 header and |
736 | skb_pull(skb, 6 + 6 + 2); | 746 | * rfc1042 header */ |
737 | break; | ||
738 | case RX_MSDU_DECAP_8023_SNAP_LLC: | ||
739 | /* macaddr[6] + macaddr[6] + len[2] */ | ||
740 | /* we don't need this for non-A-MSDU */ | ||
741 | skb_pull(skb, 6 + 6 + 2); | ||
742 | break; | ||
743 | } | ||
744 | |||
745 | if (fmt == RX_MSDU_DECAP_ETHERNET2_DIX) { | ||
746 | void *llc; | ||
747 | int llclen; | ||
748 | 747 | ||
749 | llclen = 8; | 748 | rfc1042 = hdr; |
750 | llc = hdr; | 749 | rfc1042 += roundup(hdr_len, 4); |
751 | llc += roundup(ieee80211_hdrlen(hdr->frame_control), 4); | 750 | rfc1042 += roundup(ath10k_htt_rx_crypto_param_len(enctype), 4); |
752 | llc += roundup(ath10k_htt_rx_crypto_param_len(enctype), 4); | ||
753 | 751 | ||
754 | skb_push(skb, llclen); | 752 | skb_pull(skb, sizeof(struct ethhdr)); |
755 | memcpy(skb->data, llc, llclen); | 753 | memcpy(skb_push(skb, sizeof(struct rfc1042_hdr)), |
756 | } | 754 | rfc1042, sizeof(struct rfc1042_hdr)); |
755 | memcpy(skb_push(skb, hdr_len), hdr, hdr_len); | ||
756 | break; | ||
757 | case RX_MSDU_DECAP_8023_SNAP_LLC: | ||
758 | /* remove A-MSDU subframe header and insert | ||
759 | * decapped 802.11 header. rfc1042 header is already there */ | ||
757 | 760 | ||
758 | if (fmt >= RX_MSDU_DECAP_ETHERNET2_DIX) { | 761 | skb_pull(skb, sizeof(struct amsdu_subframe_hdr)); |
759 | int len = ieee80211_hdrlen(hdr->frame_control); | 762 | memcpy(skb_push(skb, hdr_len), hdr, hdr_len); |
760 | skb_push(skb, len); | 763 | break; |
761 | memcpy(skb->data, hdr, len); | ||
762 | } | 764 | } |
763 | 765 | ||
764 | info->skb = skb; | 766 | info->skb = skb; |