Commit c8a16c68 authored by Christian Lamparter's avatar Christian Lamparter Committed by John W. Linville

carl9170: common error path for bad frames

This patch replaces several identical frame drop
paths with a single shared rx frame error handler.
Signed-off-by: default avatarChristian Lamparter <chunkeey@googlemail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 12eec2cc
...@@ -598,18 +598,14 @@ static void carl9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len) ...@@ -598,18 +598,14 @@ static void carl9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len)
if (!IS_STARTED(ar)) if (!IS_STARTED(ar))
return; return;
if (unlikely(len < sizeof(*mac))) { if (unlikely(len < sizeof(*mac)))
ar->rx_dropped++; goto drop;
return;
}
mpdu_len = len - sizeof(*mac); mpdu_len = len - sizeof(*mac);
mac = (void *)(buf + mpdu_len); mac = (void *)(buf + mpdu_len);
if (unlikely(mac->error & AR9170_RX_ERROR_FATAL)) { if (unlikely(mac->error & AR9170_RX_ERROR_FATAL))
ar->rx_dropped++; goto drop;
return;
}
switch (mac->status & AR9170_RX_STATUS_MPDU) { switch (mac->status & AR9170_RX_STATUS_MPDU) {
case AR9170_RX_STATUS_MPDU_FIRST: case AR9170_RX_STATUS_MPDU_FIRST:
...@@ -638,8 +634,7 @@ static void carl9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len) ...@@ -638,8 +634,7 @@ static void carl9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len)
"is clipped.\n"); "is clipped.\n");
} }
ar->rx_dropped++; goto drop;
return;
} }
break; break;
...@@ -659,8 +654,7 @@ static void carl9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len) ...@@ -659,8 +654,7 @@ static void carl9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len)
"is clipped.\n"); "is clipped.\n");
} }
ar->rx_dropped++; goto drop;
return;
} }
case AR9170_RX_STATUS_MPDU_MIDDLE: case AR9170_RX_STATUS_MPDU_MIDDLE:
...@@ -672,8 +666,7 @@ static void carl9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len) ...@@ -672,8 +666,7 @@ static void carl9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len)
wiphy_err(ar->hw->wiphy, "rx stream does not start " wiphy_err(ar->hw->wiphy, "rx stream does not start "
"with a first_mpdu frame tag.\n"); "with a first_mpdu frame tag.\n");
ar->rx_dropped++; goto drop;
return;
} }
head = &ar->rx_plcp; head = &ar->rx_plcp;
...@@ -696,16 +689,12 @@ static void carl9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len) ...@@ -696,16 +689,12 @@ static void carl9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len)
} }
/* FC + DU + RA + FCS */ /* FC + DU + RA + FCS */
if (unlikely(mpdu_len < (2 + 2 + 6 + FCS_LEN))) { if (unlikely(mpdu_len < (2 + 2 + ETH_ALEN + FCS_LEN)))
ar->rx_dropped++; goto drop;
return;
}
memset(&status, 0, sizeof(status)); memset(&status, 0, sizeof(status));
if (unlikely(carl9170_rx_mac_status(ar, head, mac, &status))) { if (unlikely(carl9170_rx_mac_status(ar, head, mac, &status)))
ar->rx_dropped++; goto drop;
return;
}
if (phy) if (phy)
carl9170_rx_phy_status(ar, phy, &status); carl9170_rx_phy_status(ar, phy, &status);
...@@ -713,12 +702,15 @@ static void carl9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len) ...@@ -713,12 +702,15 @@ static void carl9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len)
carl9170_ps_beacon(ar, buf, mpdu_len); carl9170_ps_beacon(ar, buf, mpdu_len);
skb = carl9170_rx_copy_data(buf, mpdu_len); skb = carl9170_rx_copy_data(buf, mpdu_len);
if (likely(skb)) { if (!skb)
memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status)); goto drop;
ieee80211_rx(ar->hw, skb);
} else { memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status));
ar->rx_dropped++; ieee80211_rx(ar->hw, skb);
} return;
drop:
ar->rx_dropped++;
} }
static void carl9170_rx_untie_cmds(struct ar9170 *ar, const u8 *respbuf, static void carl9170_rx_untie_cmds(struct ar9170 *ar, const u8 *respbuf,
......
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