Commit 6d1ba32c authored by Ahmad Masri's avatar Ahmad Masri Committed by Kalle Valo

wil6210: accessing 802.3 addresses via utility functions

Rearrange the code by having functions to access 802.3 header
members, source and destination addresses.
Signed-off-by: default avatarAhmad Masri <amasri@codeaurora.org>
Signed-off-by: default avatarMaya Erez <merez@codeaurora.org>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent bf0353a6
...@@ -383,7 +383,6 @@ static int wil_rx_get_cid_by_skb(struct wil6210_priv *wil, struct sk_buff *skb) ...@@ -383,7 +383,6 @@ static int wil_rx_get_cid_by_skb(struct wil6210_priv *wil, struct sk_buff *skb)
*/ */
int cid = wil_rxdesc_cid(d); int cid = wil_rxdesc_cid(d);
unsigned int snaplen = wil_rx_snaplen(); unsigned int snaplen = wil_rx_snaplen();
struct ethhdr *eth;
struct ieee80211_hdr_3addr *hdr; struct ieee80211_hdr_3addr *hdr;
int i; int i;
unsigned char *ta; unsigned char *ta;
...@@ -401,8 +400,7 @@ static int wil_rx_get_cid_by_skb(struct wil6210_priv *wil, struct sk_buff *skb) ...@@ -401,8 +400,7 @@ static int wil_rx_get_cid_by_skb(struct wil6210_priv *wil, struct sk_buff *skb)
skb->len); skb->len);
return -ENOENT; return -ENOENT;
} }
eth = (void *)skb->data; ta = wil_skb_get_sa(skb);
ta = eth->h_source;
} else { } else {
if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
wil_err_ratelimited(wil, "Short frame, len = %d\n", wil_err_ratelimited(wil, "Short frame, len = %d\n",
...@@ -739,11 +737,11 @@ void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev) ...@@ -739,11 +737,11 @@ void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev)
unsigned int len = skb->len; unsigned int len = skb->len;
int cid; int cid;
int security; int security;
struct ethhdr *eth = (void *)skb->data; u8 *sa, *da = wil_skb_get_da(skb);
/* here looking for DA, not A1, thus Rxdesc's 'mcast' indication /* here looking for DA, not A1, thus Rxdesc's 'mcast' indication
* is not suitable, need to look at data * is not suitable, need to look at data
*/ */
int mcast = is_multicast_ether_addr(eth->h_dest); int mcast = is_multicast_ether_addr(da);
struct wil_net_stats *stats; struct wil_net_stats *stats;
struct sk_buff *xmit_skb = NULL; struct sk_buff *xmit_skb = NULL;
static const char * const gro_res_str[] = { static const char * const gro_res_str[] = {
...@@ -774,7 +772,8 @@ void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev) ...@@ -774,7 +772,8 @@ void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev)
} }
if (wdev->iftype == NL80211_IFTYPE_STATION) { if (wdev->iftype == NL80211_IFTYPE_STATION) {
if (mcast && ether_addr_equal(eth->h_source, ndev->dev_addr)) { sa = wil_skb_get_sa(skb);
if (mcast && ether_addr_equal(sa, ndev->dev_addr)) {
/* mcast packet looped back to us */ /* mcast packet looped back to us */
rc = GRO_DROP; rc = GRO_DROP;
dev_kfree_skb(skb); dev_kfree_skb(skb);
...@@ -787,8 +786,7 @@ void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev) ...@@ -787,8 +786,7 @@ void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev)
*/ */
xmit_skb = skb_copy(skb, GFP_ATOMIC); xmit_skb = skb_copy(skb, GFP_ATOMIC);
} else { } else {
int xmit_cid = wil_find_cid(wil, vif->mid, int xmit_cid = wil_find_cid(wil, vif->mid, da);
eth->h_dest);
if (xmit_cid >= 0) { if (xmit_cid >= 0) {
/* The destination station is associated to /* The destination station is associated to
...@@ -1239,11 +1237,12 @@ static struct wil_ring *wil_find_tx_ucast(struct wil6210_priv *wil, ...@@ -1239,11 +1237,12 @@ static struct wil_ring *wil_find_tx_ucast(struct wil6210_priv *wil,
struct wil6210_vif *vif, struct wil6210_vif *vif,
struct sk_buff *skb) struct sk_buff *skb)
{ {
int i; int i, cid;
struct ethhdr *eth = (void *)skb->data; const u8 *da = wil_skb_get_da(skb);
int cid = wil_find_cid(wil, vif->mid, eth->h_dest);
int min_ring_id = wil_get_min_tx_ring_id(wil); int min_ring_id = wil_get_min_tx_ring_id(wil);
cid = wil_find_cid(wil, vif->mid, da);
if (cid < 0 || cid >= max_assoc_sta) if (cid < 0 || cid >= max_assoc_sta)
return NULL; return NULL;
...@@ -1257,7 +1256,7 @@ static struct wil_ring *wil_find_tx_ucast(struct wil6210_priv *wil, ...@@ -1257,7 +1256,7 @@ static struct wil_ring *wil_find_tx_ucast(struct wil6210_priv *wil,
struct wil_ring_tx_data *txdata = &wil->ring_tx_data[i]; struct wil_ring_tx_data *txdata = &wil->ring_tx_data[i];
wil_dbg_txrx(wil, "find_tx_ucast: (%pM) -> [%d]\n", wil_dbg_txrx(wil, "find_tx_ucast: (%pM) -> [%d]\n",
eth->h_dest, i); da, i);
if (v->va && txdata->enabled) { if (v->va && txdata->enabled) {
return v; return v;
} else { } else {
...@@ -1348,10 +1347,10 @@ static struct wil_ring *wil_find_tx_bcast_1(struct wil6210_priv *wil, ...@@ -1348,10 +1347,10 @@ static struct wil_ring *wil_find_tx_bcast_1(struct wil6210_priv *wil,
static void wil_set_da_for_vring(struct wil6210_priv *wil, static void wil_set_da_for_vring(struct wil6210_priv *wil,
struct sk_buff *skb, int vring_index) struct sk_buff *skb, int vring_index)
{ {
struct ethhdr *eth = (void *)skb->data; u8 *da = wil_skb_get_da(skb);
int cid = wil->ring2cid_tid[vring_index][0]; int cid = wil->ring2cid_tid[vring_index][0];
ether_addr_copy(eth->h_dest, wil->sta[cid].addr); ether_addr_copy(da, wil->sta[cid].addr);
} }
static struct wil_ring *wil_find_tx_bcast_2(struct wil6210_priv *wil, static struct wil_ring *wil_find_tx_bcast_2(struct wil6210_priv *wil,
...@@ -1362,8 +1361,7 @@ static struct wil_ring *wil_find_tx_bcast_2(struct wil6210_priv *wil, ...@@ -1362,8 +1361,7 @@ static struct wil_ring *wil_find_tx_bcast_2(struct wil6210_priv *wil,
struct sk_buff *skb2; struct sk_buff *skb2;
int i; int i;
u8 cid; u8 cid;
struct ethhdr *eth = (void *)skb->data; const u8 *src = wil_skb_get_sa(skb);
char *src = eth->h_source;
struct wil_ring_tx_data *txdata, *txdata2; struct wil_ring_tx_data *txdata, *txdata2;
int min_ring_id = wil_get_min_tx_ring_id(wil); int min_ring_id = wil_get_min_tx_ring_id(wil);
...@@ -2121,8 +2119,8 @@ netdev_tx_t wil_start_xmit(struct sk_buff *skb, struct net_device *ndev) ...@@ -2121,8 +2119,8 @@ netdev_tx_t wil_start_xmit(struct sk_buff *skb, struct net_device *ndev)
{ {
struct wil6210_vif *vif = ndev_to_vif(ndev); struct wil6210_vif *vif = ndev_to_vif(ndev);
struct wil6210_priv *wil = vif_to_wil(vif); struct wil6210_priv *wil = vif_to_wil(vif);
struct ethhdr *eth = (void *)skb->data; const u8 *da = wil_skb_get_da(skb);
bool bcast = is_multicast_ether_addr(eth->h_dest); bool bcast = is_multicast_ether_addr(da);
struct wil_ring *ring; struct wil_ring *ring;
static bool pr_once_fw; static bool pr_once_fw;
int rc; int rc;
...@@ -2169,7 +2167,7 @@ netdev_tx_t wil_start_xmit(struct sk_buff *skb, struct net_device *ndev) ...@@ -2169,7 +2167,7 @@ netdev_tx_t wil_start_xmit(struct sk_buff *skb, struct net_device *ndev)
ring = wil_find_tx_ucast(wil, vif, skb); ring = wil_find_tx_ucast(wil, vif, skb);
} }
if (unlikely(!ring)) { if (unlikely(!ring)) {
wil_dbg_txrx(wil, "No Tx RING found for %pM\n", eth->h_dest); wil_dbg_txrx(wil, "No Tx RING found for %pM\n", da);
goto drop; goto drop;
} }
/* set up vring entry */ /* set up vring entry */
......
...@@ -567,11 +567,25 @@ static inline int wil_ring_is_full(struct wil_ring *ring) ...@@ -567,11 +567,25 @@ static inline int wil_ring_is_full(struct wil_ring *ring)
return wil_ring_next_tail(ring) == ring->swhead; return wil_ring_next_tail(ring) == ring->swhead;
} }
static inline bool wil_need_txstat(struct sk_buff *skb) static inline u8 *wil_skb_get_da(struct sk_buff *skb)
{
struct ethhdr *eth = (void *)skb->data;
return eth->h_dest;
}
static inline u8 *wil_skb_get_sa(struct sk_buff *skb)
{ {
struct ethhdr *eth = (void *)skb->data; struct ethhdr *eth = (void *)skb->data;
return is_unicast_ether_addr(eth->h_dest) && skb->sk && return eth->h_source;
}
static inline bool wil_need_txstat(struct sk_buff *skb)
{
const u8 *da = wil_skb_get_da(skb);
return is_unicast_ether_addr(da) && skb->sk &&
(skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS); (skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS);
} }
......
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