Release 4.7 drivers/net/wireless/marvell/libertas/rx.c
/*
* This file contains the handling of RX in wlan driver.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/etherdevice.h>
#include <linux/hardirq.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/export.h>
#include <net/cfg80211.h>
#include "defs.h"
#include "host.h"
#include "radiotap.h"
#include "decl.h"
#include "dev.h"
#include "mesh.h"
struct eth803hdr {
u8 dest_addr[6];
u8 src_addr[6];
u16 h803_len;
}
__packed;
struct rfc1042hdr {
u8 llc_dsap;
u8 llc_ssap;
u8 llc_ctrl;
u8 snap_oui[3];
u16 snap_type;
}
__packed;
struct rxpackethdr {
struct eth803hdr eth803_hdr;
struct rfc1042hdr rfc1042_hdr;
}
__packed;
struct rx80211packethdr {
struct rxpd rx_pd;
void *eth80211_hdr;
}
__packed;
static int process_rxed_802_11_packet(struct lbs_private *priv,
struct sk_buff *skb);
/**
* lbs_process_rxed_packet - processes received packet and forwards it
* to kernel/upper layer
*
* @priv: A pointer to &struct lbs_private
* @skb: A pointer to skb which includes the received packet
* returns: 0 or -1
*/
int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb)
{
int ret = 0;
struct net_device *dev = priv->dev;
struct rxpackethdr *p_rx_pkt;
struct rxpd *p_rx_pd;
int hdrchop;
struct ethhdr *p_ethhdr;
static const u8 rfc1042_eth_hdr[] = {
0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00
};
lbs_deb_enter(LBS_DEB_RX);
BUG_ON(!skb);
skb->ip_summed = CHECKSUM_NONE;
if (priv->wdev->iftype == NL80211_IFTYPE_MONITOR) {
ret = process_rxed_802_11_packet(priv, skb);
goto done;
}
p_rx_pd = (struct rxpd *) skb->data;
p_rx_pkt = (struct rxpackethdr *) ((u8 *)p_rx_pd +
le32_to_cpu(p_rx_pd->pkt_ptr));
dev = lbs_mesh_set_dev(priv, dev, p_rx_pd);
lbs_deb_hex(LBS_DEB_RX, "RX Data: Before chop rxpd", skb->data,
min_t(unsigned int, skb->len, 100));
if (skb->len < (ETH_HLEN + 8 + sizeof(struct rxpd))) {
lbs_deb_rx("rx err: frame received with bad length\n");
dev->stats.rx_length_errors++;
ret = -EINVAL;
dev_kfree_skb(skb);
goto done;
}
lbs_deb_rx("rx data: skb->len - pkt_ptr = %d-%zd = %zd\n",
skb->len, (size_t)le32_to_cpu(p_rx_pd->pkt_ptr),
skb->len - (size_t)le32_to_cpu(p_rx_pd->pkt_ptr));
lbs_deb_hex(LBS_DEB_RX, "RX Data: Dest", p_rx_pkt->eth803_hdr.dest_addr,
sizeof(p_rx_pkt->eth803_hdr.dest_addr));
lbs_deb_hex(LBS_DEB_RX, "RX Data: Src", p_rx_pkt->eth803_hdr.src_addr,
sizeof(p_rx_pkt->eth803_hdr.src_addr));
if (memcmp(&p_rx_pkt->rfc1042_hdr,
rfc1042_eth_hdr, sizeof(rfc1042_eth_hdr)) == 0) {
/*
* Replace the 803 header and rfc1042 header (llc/snap) with an
* EthernetII header, keep the src/dst and snap_type (ethertype)
*
* The firmware only passes up SNAP frames converting
* all RX Data from 802.11 to 802.2/LLC/SNAP frames.
*
* To create the Ethernet II, just move the src, dst address right
* before the snap_type.
*/
p_ethhdr = (struct ethhdr *)
((u8 *) &p_rx_pkt->eth803_hdr
+ sizeof(p_rx_pkt->eth803_hdr) + sizeof(p_rx_pkt->rfc1042_hdr)
- sizeof(p_rx_pkt->eth803_hdr.dest_addr)
- sizeof(p_rx_pkt->eth803_hdr.src_addr)
- sizeof(p_rx_pkt->rfc1042_hdr.snap_type));
memcpy(p_ethhdr->h_source, p_rx_pkt->eth803_hdr.src_addr,
sizeof(p_ethhdr->h_source));
memcpy(p_ethhdr->h_dest, p_rx_pkt->eth803_hdr.dest_addr,
sizeof(p_ethhdr->h_dest));
/* Chop off the rxpd + the excess memory from the 802.2/llc/snap header
* that was removed
*/
hdrchop = (u8 *)p_ethhdr - (u8 *)p_rx_pd;
} else {
lbs_deb_hex(LBS_DEB_RX, "RX Data: LLC/SNAP",
(u8 *) &p_rx_pkt->rfc1042_hdr,
sizeof(p_rx_pkt->rfc1042_hdr));
/* Chop off the rxpd */
hdrchop = (u8 *)&p_rx_pkt->eth803_hdr - (u8 *)p_rx_pd;
}
/* Chop off the leading header bytes so the skb points to the start of
* either the reconstructed EthII frame or the 802.2/llc/snap frame
*/
skb_pull(skb, hdrchop);
priv->cur_rate = lbs_fw_index_to_data_rate(p_rx_pd->rx_rate);
lbs_deb_rx("rx data: size of actual packet %d\n", skb->len);
dev->stats.rx_bytes += skb->len;
dev->stats.rx_packets++;
skb->protocol = eth_type_trans(skb, dev);
if (in_interrupt())
netif_rx(skb);
else
netif_rx_ni(skb);
ret = 0;
done:
lbs_deb_leave_args(LBS_DEB_RX, "ret %d", ret);
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
marcelo tosatti | marcelo tosatti | 408 | 72.34% | 1 | 5.00% |
holger schurig | holger schurig | 56 | 9.93% | 7 | 35.00% |
bing zhao | bing zhao | 34 | 6.03% | 2 | 10.00% |
david woodhouse | david woodhouse | 30 | 5.32% | 2 | 10.00% |
dan williams | dan williams | 11 | 1.95% | 2 | 10.00% |
john w. linville | john w. linville | 6 | 1.06% | 1 | 5.00% |
kiran divekar | kiran divekar | 5 | 0.89% | 1 | 5.00% |
philip rakity | philip rakity | 5 | 0.89% | 1 | 5.00% |
florin malita | florin malita | 5 | 0.89% | 1 | 5.00% |
stephen hemminger | stephen hemminger | 3 | 0.53% | 1 | 5.00% |
joe perches | joe perches | 1 | 0.18% | 1 | 5.00% |
| Total | 564 | 100.00% | 20 | 100.00% |
EXPORT_SYMBOL_GPL(lbs_process_rxed_packet);
/**
* convert_mv_rate_to_radiotap - converts Tx/Rx rates from Marvell WLAN format
* (see Table 2 in Section 3.1) to IEEE80211_RADIOTAP_RATE units (500 Kb/s)
*
* @rate: Input rate
* returns: Output Rate (0 if invalid)
*/
static u8 convert_mv_rate_to_radiotap(u8 rate)
{
switch (rate) {
case 0: /* 1 Mbps */
return 2;
case 1: /* 2 Mbps */
return 4;
case 2: /* 5.5 Mbps */
return 11;
case 3: /* 11 Mbps */
return 22;
/* case 4: reserved */
case 5: /* 6 Mbps */
return 12;
case 6: /* 9 Mbps */
return 18;
case 7: /* 12 Mbps */
return 24;
case 8: /* 18 Mbps */
return 36;
case 9: /* 24 Mbps */
return 48;
case 10: /* 36 Mbps */
return 72;
case 11: /* 48 Mbps */
return 96;
case 12: /* 54 Mbps */
return 108;
}
pr_alert("Invalid Marvell WLAN rate %i\n", rate);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
marcelo tosatti | marcelo tosatti | 99 | 90.00% | 1 | 25.00% |
luis carlos cobo rus | luis carlos cobo rus | 9 | 8.18% | 1 | 25.00% |
holger schurig | holger schurig | 1 | 0.91% | 1 | 25.00% |
joe perches | joe perches | 1 | 0.91% | 1 | 25.00% |
| Total | 110 | 100.00% | 4 | 100.00% |
/**
* process_rxed_802_11_packet - processes a received 802.11 packet and forwards
* it to kernel/upper layer
*
* @priv: A pointer to &struct lbs_private
* @skb: A pointer to skb which includes the received packet
* returns: 0 or -1
*/
static int process_rxed_802_11_packet(struct lbs_private *priv,
struct sk_buff *skb)
{
int ret = 0;
struct net_device *dev = priv->dev;
struct rx80211packethdr *p_rx_pkt;
struct rxpd *prxpd;
struct rx_radiotap_hdr radiotap_hdr;
struct rx_radiotap_hdr *pradiotap_hdr;
lbs_deb_enter(LBS_DEB_RX);
p_rx_pkt = (struct rx80211packethdr *) skb->data;
prxpd = &p_rx_pkt->rx_pd;
/* lbs_deb_hex(LBS_DEB_RX, "RX Data: Before chop rxpd", skb->data, min(skb->len, 100)); */
if (skb->len < (ETH_HLEN + 8 + sizeof(struct rxpd))) {
lbs_deb_rx("rx err: frame received with bad length\n");
dev->stats.rx_length_errors++;
ret = -EINVAL;
kfree_skb(skb);
goto done;
}
lbs_deb_rx("rx data: skb->len-sizeof(RxPd) = %d-%zd = %zd\n",
skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd));
/* create the exported radio header */
/* radiotap header */
memset(&radiotap_hdr, 0, sizeof(radiotap_hdr));
/* XXX must check radiotap_hdr.hdr.it_pad for pad */
radiotap_hdr.hdr.it_len = cpu_to_le16 (sizeof(struct rx_radiotap_hdr));
radiotap_hdr.hdr.it_present = cpu_to_le32 (RX_RADIOTAP_PRESENT);
radiotap_hdr.rate = convert_mv_rate_to_radiotap(prxpd->rx_rate);
/* XXX must check no carryout */
radiotap_hdr.antsignal = prxpd->snr + prxpd->nf;
/* chop the rxpd */
skb_pull(skb, sizeof(struct rxpd));
/* add space for the new radio header */
if ((skb_headroom(skb) < sizeof(struct rx_radiotap_hdr)) &&
pskb_expand_head(skb, sizeof(struct rx_radiotap_hdr), 0, GFP_ATOMIC)) {
netdev_alert(dev, "%s: couldn't pskb_expand_head\n", __func__);
ret = -ENOMEM;
kfree_skb(skb);
goto done;
}
pradiotap_hdr = (void *)skb_push(skb, sizeof(struct rx_radiotap_hdr));
memcpy(pradiotap_hdr, &radiotap_hdr, sizeof(struct rx_radiotap_hdr));
priv->cur_rate = lbs_fw_index_to_data_rate(prxpd->rx_rate);
lbs_deb_rx("rx data: size of actual packet %d\n", skb->len);
dev->stats.rx_bytes += skb->len;
dev->stats.rx_packets++;
skb->protocol = eth_type_trans(skb, priv->dev);
if (in_interrupt())
netif_rx(skb);
else
netif_rx_ni(skb);
ret = 0;
done:
lbs_deb_leave_args(LBS_DEB_RX, "ret %d", ret);
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
marcelo tosatti | marcelo tosatti | 286 | 73.15% | 1 | 5.88% |
david woodhouse | david woodhouse | 34 | 8.70% | 4 | 23.53% |
holger schurig | holger schurig | 20 | 5.12% | 3 | 17.65% |
kiran divekar | kiran divekar | 12 | 3.07% | 1 | 5.88% |
stephen hemminger | stephen hemminger | 12 | 3.07% | 1 | 5.88% |
prarit bhargava | prarit bhargava | 10 | 2.56% | 1 | 5.88% |
dan williams | dan williams | 7 | 1.79% | 2 | 11.76% |
florin malita | florin malita | 5 | 1.28% | 1 | 5.88% |
joe perches | joe perches | 3 | 0.77% | 1 | 5.88% |
sergio luis | sergio luis | 1 | 0.26% | 1 | 5.88% |
stewart malik | stewart malik | 1 | 0.26% | 1 | 5.88% |
| Total | 391 | 100.00% | 17 | 100.00% |
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
marcelo tosatti | marcelo tosatti | 891 | 73.94% | 1 | 2.78% |
holger schurig | holger schurig | 84 | 6.97% | 8 | 22.22% |
david woodhouse | david woodhouse | 64 | 5.31% | 4 | 11.11% |
bing zhao | bing zhao | 34 | 2.82% | 2 | 5.56% |
kiran divekar | kiran divekar | 25 | 2.07% | 1 | 2.78% |
dan williams | dan williams | 18 | 1.49% | 3 | 8.33% |
stephen hemminger | stephen hemminger | 15 | 1.24% | 1 | 2.78% |
joe perches | joe perches | 12 | 1.00% | 3 | 8.33% |
florin malita | florin malita | 10 | 0.83% | 1 | 2.78% |
prarit bhargava | prarit bhargava | 10 | 0.83% | 1 | 2.78% |
luis carlos cobo rus | luis carlos cobo rus | 9 | 0.75% | 1 | 2.78% |
john w. linville | john w. linville | 6 | 0.50% | 1 | 2.78% |
philip rakity | philip rakity | 5 | 0.41% | 1 | 2.78% |
randy dunlap | randy dunlap | 4 | 0.33% | 1 | 2.78% |
eric dumazet | eric dumazet | 4 | 0.33% | 1 | 2.78% |
tejun heo | tejun heo | 3 | 0.25% | 1 | 2.78% |
daniel drake | daniel drake | 3 | 0.25% | 1 | 2.78% |
alexey dobriyan | alexey dobriyan | 3 | 0.25% | 1 | 2.78% |
paul gortmaker | paul gortmaker | 3 | 0.25% | 1 | 2.78% |
stewart malik | stewart malik | 1 | 0.08% | 1 | 2.78% |
sergio luis | sergio luis | 1 | 0.08% | 1 | 2.78% |
| Total | 1205 | 100.00% | 36 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.