2007-02-10 22:25:27 +08:00
|
|
|
/**
|
|
|
|
* This file contains the handling of RX in wlan driver.
|
|
|
|
*/
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
#include "hostcmd.h"
|
|
|
|
#include "radiotap.h"
|
|
|
|
#include "decl.h"
|
|
|
|
#include "dev.h"
|
|
|
|
#include "wext.h"
|
|
|
|
|
|
|
|
struct eth803hdr {
|
|
|
|
u8 dest_addr[6];
|
|
|
|
u8 src_addr[6];
|
|
|
|
u16 h803_len;
|
|
|
|
} __attribute__ ((packed));
|
|
|
|
|
|
|
|
struct rfc1042hdr {
|
|
|
|
u8 llc_dsap;
|
|
|
|
u8 llc_ssap;
|
|
|
|
u8 llc_ctrl;
|
|
|
|
u8 snap_oui[3];
|
|
|
|
u16 snap_type;
|
|
|
|
} __attribute__ ((packed));
|
|
|
|
|
|
|
|
struct rxpackethdr {
|
|
|
|
struct rxpd rx_pd;
|
|
|
|
struct eth803hdr eth803_hdr;
|
|
|
|
struct rfc1042hdr rfc1042_hdr;
|
|
|
|
} __attribute__ ((packed));
|
|
|
|
|
|
|
|
struct rx80211packethdr {
|
|
|
|
struct rxpd rx_pd;
|
|
|
|
void *eth80211_hdr;
|
|
|
|
} __attribute__ ((packed));
|
|
|
|
|
2007-11-23 22:43:44 +08:00
|
|
|
static int process_rxed_802_11_packet(struct lbs_private *priv,
|
|
|
|
struct sk_buff *skb);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function computes the avgSNR .
|
|
|
|
*
|
2007-11-23 22:43:44 +08:00
|
|
|
* @param priv A pointer to struct lbs_private structure
|
2007-02-10 22:25:27 +08:00
|
|
|
* @return avgSNR
|
|
|
|
*/
|
2007-11-23 22:43:44 +08:00
|
|
|
static u8 lbs_getavgsnr(struct lbs_private *priv)
|
2007-02-10 22:25:27 +08:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u16 temp = 0;
|
2007-12-09 04:04:36 +08:00
|
|
|
if (priv->numSNRNF == 0)
|
2007-02-10 22:25:27 +08:00
|
|
|
return 0;
|
2007-12-09 04:04:36 +08:00
|
|
|
for (i = 0; i < priv->numSNRNF; i++)
|
|
|
|
temp += priv->rawSNR[i];
|
|
|
|
return (u8) (temp / priv->numSNRNF);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function computes the AvgNF
|
|
|
|
*
|
2007-11-23 22:43:44 +08:00
|
|
|
* @param priv A pointer to struct lbs_private structure
|
2007-02-10 22:25:27 +08:00
|
|
|
* @return AvgNF
|
|
|
|
*/
|
2007-11-23 22:43:44 +08:00
|
|
|
static u8 lbs_getavgnf(struct lbs_private *priv)
|
2007-02-10 22:25:27 +08:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u16 temp = 0;
|
2007-12-09 04:04:36 +08:00
|
|
|
if (priv->numSNRNF == 0)
|
2007-02-10 22:25:27 +08:00
|
|
|
return 0;
|
2007-12-09 04:04:36 +08:00
|
|
|
for (i = 0; i < priv->numSNRNF; i++)
|
|
|
|
temp += priv->rawNF[i];
|
|
|
|
return (u8) (temp / priv->numSNRNF);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function save the raw SNR/NF to our internel buffer
|
|
|
|
*
|
2007-11-23 22:43:44 +08:00
|
|
|
* @param priv A pointer to struct lbs_private structure
|
2007-02-10 22:25:27 +08:00
|
|
|
* @param prxpd A pointer to rxpd structure of received packet
|
|
|
|
* @return n/a
|
|
|
|
*/
|
2007-11-23 22:43:44 +08:00
|
|
|
static void lbs_save_rawSNRNF(struct lbs_private *priv, struct rxpd *p_rx_pd)
|
2007-02-10 22:25:27 +08:00
|
|
|
{
|
2007-12-09 04:04:36 +08:00
|
|
|
if (priv->numSNRNF < DEFAULT_DATA_AVG_FACTOR)
|
|
|
|
priv->numSNRNF++;
|
|
|
|
priv->rawSNR[priv->nextSNRNF] = p_rx_pd->snr;
|
|
|
|
priv->rawNF[priv->nextSNRNF] = p_rx_pd->nf;
|
|
|
|
priv->nextSNRNF++;
|
|
|
|
if (priv->nextSNRNF >= DEFAULT_DATA_AVG_FACTOR)
|
|
|
|
priv->nextSNRNF = 0;
|
2007-02-10 22:25:27 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function computes the RSSI in received packet.
|
|
|
|
*
|
2007-11-23 22:43:44 +08:00
|
|
|
* @param priv A pointer to struct lbs_private structure
|
2007-02-10 22:25:27 +08:00
|
|
|
* @param prxpd A pointer to rxpd structure of received packet
|
|
|
|
* @return n/a
|
|
|
|
*/
|
2007-11-23 22:43:44 +08:00
|
|
|
static void lbs_compute_rssi(struct lbs_private *priv, struct rxpd *p_rx_pd)
|
2007-02-10 22:25:27 +08:00
|
|
|
{
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_RX);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_rx("rxpd: SNR %d, NF %d\n", p_rx_pd->snr, p_rx_pd->nf);
|
|
|
|
lbs_deb_rx("before computing SNR: SNR-avg = %d, NF-avg = %d\n",
|
2007-12-09 04:04:36 +08:00
|
|
|
priv->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE,
|
|
|
|
priv->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-12-09 04:04:36 +08:00
|
|
|
priv->SNR[TYPE_RXPD][TYPE_NOAVG] = p_rx_pd->snr;
|
|
|
|
priv->NF[TYPE_RXPD][TYPE_NOAVG] = p_rx_pd->nf;
|
2007-11-16 07:05:47 +08:00
|
|
|
lbs_save_rawSNRNF(priv, p_rx_pd);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-12-09 04:04:36 +08:00
|
|
|
priv->SNR[TYPE_RXPD][TYPE_AVG] = lbs_getavgsnr(priv) * AVG_SCALE;
|
|
|
|
priv->NF[TYPE_RXPD][TYPE_AVG] = lbs_getavgnf(priv) * AVG_SCALE;
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_rx("after computing SNR: SNR-avg = %d, NF-avg = %d\n",
|
2007-12-09 04:04:36 +08:00
|
|
|
priv->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE,
|
|
|
|
priv->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-12-09 04:04:36 +08:00
|
|
|
priv->RSSI[TYPE_RXPD][TYPE_NOAVG] =
|
|
|
|
CAL_RSSI(priv->SNR[TYPE_RXPD][TYPE_NOAVG],
|
|
|
|
priv->NF[TYPE_RXPD][TYPE_NOAVG]);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-12-09 04:04:36 +08:00
|
|
|
priv->RSSI[TYPE_RXPD][TYPE_AVG] =
|
|
|
|
CAL_RSSI(priv->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE,
|
|
|
|
priv->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_leave(LBS_DEB_RX);
|
2007-02-10 22:25:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function processes received packet and forwards it
|
|
|
|
* to kernel/upper layer
|
|
|
|
*
|
2007-11-23 22:43:44 +08:00
|
|
|
* @param priv A pointer to struct lbs_private
|
2007-02-10 22:25:27 +08:00
|
|
|
* @param skb A pointer to skb which includes the received packet
|
|
|
|
* @return 0 or -1
|
|
|
|
*/
|
2007-11-23 22:43:44 +08:00
|
|
|
int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb)
|
2007-02-10 22:25:27 +08:00
|
|
|
{
|
|
|
|
int ret = 0;
|
2007-12-10 13:49:26 +08:00
|
|
|
struct net_device *dev = priv->dev;
|
2007-02-10 22:25:27 +08:00
|
|
|
struct rxpackethdr *p_rx_pkt;
|
|
|
|
struct rxpd *p_rx_pd;
|
|
|
|
int hdrchop;
|
|
|
|
struct ethhdr *p_ethhdr;
|
|
|
|
const u8 rfc1042_eth_hdr[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_RX);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2008-04-01 20:50:43 +08:00
|
|
|
BUG_ON(!skb);
|
|
|
|
|
2007-12-10 13:49:26 +08:00
|
|
|
skb->ip_summed = CHECKSUM_NONE;
|
|
|
|
|
2008-03-26 16:57:14 +08:00
|
|
|
if (priv->monitormode)
|
2007-02-10 22:25:27 +08:00
|
|
|
return process_rxed_802_11_packet(priv, skb);
|
|
|
|
|
|
|
|
p_rx_pkt = (struct rxpackethdr *) skb->data;
|
|
|
|
p_rx_pd = &p_rx_pkt->rx_pd;
|
2007-12-10 13:49:26 +08:00
|
|
|
if (priv->mesh_dev && (p_rx_pd->rx_control & RxPD_MESH_FRAME))
|
|
|
|
dev = priv->mesh_dev;
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-08-02 23:53:06 +08:00
|
|
|
lbs_deb_hex(LBS_DEB_RX, "RX Data: Before chop rxpd", skb->data,
|
2007-02-10 22:25:27 +08:00
|
|
|
min_t(unsigned int, skb->len, 100));
|
|
|
|
|
|
|
|
if (skb->len < (ETH_HLEN + 8 + sizeof(struct rxpd))) {
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_rx("rx err: frame received with bad length\n");
|
2009-03-21 03:36:36 +08:00
|
|
|
dev->stats.rx_length_errors++;
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check rxpd status and update 802.3 stat,
|
|
|
|
*/
|
2007-05-26 11:36:54 +08:00
|
|
|
if (!(p_rx_pd->status & cpu_to_le16(MRVDRV_RXPD_STATUS_OK))) {
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_rx("rx err: frame received with bad status\n");
|
|
|
|
lbs_pr_alert("rxpd not ok\n");
|
2009-03-21 03:36:36 +08:00
|
|
|
dev->stats.rx_errors++;
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_rx("rx data: skb->len-sizeof(RxPd) = %d-%zd = %zd\n",
|
2007-02-10 22:25:27 +08:00
|
|
|
skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd));
|
|
|
|
|
2007-08-02 23:53:06 +08:00
|
|
|
lbs_deb_hex(LBS_DEB_RX, "RX Data: Dest", p_rx_pkt->eth803_hdr.dest_addr,
|
2007-02-10 22:25:27 +08:00
|
|
|
sizeof(p_rx_pkt->eth803_hdr.dest_addr));
|
2007-08-02 23:53:06 +08:00
|
|
|
lbs_deb_hex(LBS_DEB_RX, "RX Data: Src", p_rx_pkt->eth803_hdr.src_addr,
|
2007-02-10 22:25:27 +08:00
|
|
|
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_pkt;
|
|
|
|
} else {
|
2007-08-02 23:53:06 +08:00
|
|
|
lbs_deb_hex(LBS_DEB_RX, "RX Data: LLC/SNAP",
|
2007-02-10 22:25:27 +08:00
|
|
|
(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_pkt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
|
|
|
/* Take the data rate from the rxpd structure
|
|
|
|
* only if the rate is auto
|
|
|
|
*/
|
2008-05-24 17:59:49 +08:00
|
|
|
if (priv->enablehwauto)
|
2007-12-09 04:04:36 +08:00
|
|
|
priv->cur_rate = lbs_fw_index_to_data_rate(p_rx_pd->rx_rate);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-11-16 07:05:47 +08:00
|
|
|
lbs_compute_rssi(priv, p_rx_pd);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_rx("rx data: size of actual packet %d\n", skb->len);
|
2009-03-21 03:36:36 +08:00
|
|
|
dev->stats.rx_bytes += skb->len;
|
|
|
|
dev->stats.rx_packets++;
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-12-10 13:49:26 +08:00
|
|
|
skb->protocol = eth_type_trans(skb, dev);
|
2008-01-16 22:48:44 +08:00
|
|
|
if (in_interrupt())
|
|
|
|
netif_rx(skb);
|
|
|
|
else
|
|
|
|
netif_rx_ni(skb);
|
2007-05-19 04:04:33 +08:00
|
|
|
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = 0;
|
|
|
|
done:
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_leave_args(LBS_DEB_RX, "ret %d", ret);
|
2007-02-10 22:25:27 +08:00
|
|
|
return ret;
|
|
|
|
}
|
2007-11-16 07:05:47 +08:00
|
|
|
EXPORT_SYMBOL_GPL(lbs_process_rxed_packet);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function converts Tx/Rx rates from the Marvell WLAN format
|
|
|
|
* (see Table 2 in Section 3.1) to IEEE80211_RADIOTAP_RATE units (500 Kb/s)
|
|
|
|
*
|
|
|
|
* @param rate Input rate
|
|
|
|
* @return 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;
|
2007-08-03 01:16:55 +08:00
|
|
|
/* case 4: reserved */
|
|
|
|
case 5: /* 6 Mbps */
|
2007-02-10 22:25:27 +08:00
|
|
|
return 12;
|
2007-08-03 01:16:55 +08:00
|
|
|
case 6: /* 9 Mbps */
|
2007-02-10 22:25:27 +08:00
|
|
|
return 18;
|
2007-08-03 01:16:55 +08:00
|
|
|
case 7: /* 12 Mbps */
|
2007-02-10 22:25:27 +08:00
|
|
|
return 24;
|
2007-08-03 01:16:55 +08:00
|
|
|
case 8: /* 18 Mbps */
|
2007-02-10 22:25:27 +08:00
|
|
|
return 36;
|
2007-08-03 01:16:55 +08:00
|
|
|
case 9: /* 24 Mbps */
|
2007-02-10 22:25:27 +08:00
|
|
|
return 48;
|
2007-08-03 01:16:55 +08:00
|
|
|
case 10: /* 36 Mbps */
|
2007-02-10 22:25:27 +08:00
|
|
|
return 72;
|
2007-08-03 01:16:55 +08:00
|
|
|
case 11: /* 48 Mbps */
|
2007-02-10 22:25:27 +08:00
|
|
|
return 96;
|
2007-08-03 01:16:55 +08:00
|
|
|
case 12: /* 54 Mbps */
|
2007-02-10 22:25:27 +08:00
|
|
|
return 108;
|
|
|
|
}
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_pr_alert("Invalid Marvell WLAN rate %i\n", rate);
|
2007-02-10 22:25:27 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function processes a received 802.11 packet and forwards it
|
|
|
|
* to kernel/upper layer
|
|
|
|
*
|
2007-11-23 22:43:44 +08:00
|
|
|
* @param priv A pointer to struct lbs_private
|
2007-02-10 22:25:27 +08:00
|
|
|
* @param skb A pointer to skb which includes the received packet
|
|
|
|
* @return 0 or -1
|
|
|
|
*/
|
2007-11-23 22:43:44 +08:00
|
|
|
static int process_rxed_802_11_packet(struct lbs_private *priv,
|
|
|
|
struct sk_buff *skb)
|
2007-02-10 22:25:27 +08:00
|
|
|
{
|
|
|
|
int ret = 0;
|
2009-03-21 03:36:36 +08:00
|
|
|
struct net_device *dev = priv->dev;
|
2007-02-10 22:25:27 +08:00
|
|
|
struct rx80211packethdr *p_rx_pkt;
|
|
|
|
struct rxpd *prxpd;
|
|
|
|
struct rx_radiotap_hdr radiotap_hdr;
|
|
|
|
struct rx_radiotap_hdr *pradiotap_hdr;
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_RX);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
p_rx_pkt = (struct rx80211packethdr *) skb->data;
|
|
|
|
prxpd = &p_rx_pkt->rx_pd;
|
|
|
|
|
2007-08-02 23:53:06 +08:00
|
|
|
// lbs_deb_hex(LBS_DEB_RX, "RX Data: Before chop rxpd", skb->data, min(skb->len, 100));
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
if (skb->len < (ETH_HLEN + 8 + sizeof(struct rxpd))) {
|
2007-12-10 13:17:28 +08:00
|
|
|
lbs_deb_rx("rx err: frame received with bad length\n");
|
2009-03-21 03:36:36 +08:00
|
|
|
dev->stats.rx_length_errors++;
|
2007-12-10 13:17:28 +08:00
|
|
|
ret = -EINVAL;
|
2008-10-27 14:09:27 +08:00
|
|
|
kfree_skb(skb);
|
2007-02-10 22:25:27 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check rxpd status and update 802.3 stat,
|
|
|
|
*/
|
2007-05-26 11:36:54 +08:00
|
|
|
if (!(prxpd->status & cpu_to_le16(MRVDRV_RXPD_STATUS_OK))) {
|
2007-05-25 23:27:16 +08:00
|
|
|
//lbs_deb_rx("rx err: frame received with bad status\n");
|
2009-03-21 03:36:36 +08:00
|
|
|
dev->stats.rx_errors++;
|
2007-02-10 22:25:27 +08:00
|
|
|
}
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_rx("rx data: skb->len-sizeof(RxPd) = %d-%zd = %zd\n",
|
2007-02-10 22:25:27 +08:00
|
|
|
skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd));
|
|
|
|
|
|
|
|
/* create the exported radio header */
|
|
|
|
|
2007-12-10 13:05:37 +08:00
|
|
|
/* radiotap header */
|
|
|
|
radiotap_hdr.hdr.it_version = 0;
|
|
|
|
/* XXX must check this value for pad */
|
|
|
|
radiotap_hdr.hdr.it_pad = 0;
|
|
|
|
radiotap_hdr.hdr.it_len = cpu_to_le16 (sizeof(struct rx_radiotap_hdr));
|
|
|
|
radiotap_hdr.hdr.it_present = cpu_to_le32 (RX_RADIOTAP_PRESENT);
|
2009-03-13 19:52:10 +08:00
|
|
|
if (!(prxpd->status & cpu_to_le16(MRVDRV_RXPD_STATUS_OK)))
|
|
|
|
radiotap_hdr.flags |= IEEE80211_RADIOTAP_F_BADFCS;
|
2007-12-10 13:05:37 +08:00
|
|
|
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)) &&
|
2007-12-10 13:17:28 +08:00
|
|
|
pskb_expand_head(skb, sizeof(struct rx_radiotap_hdr), 0, GFP_ATOMIC)) {
|
|
|
|
lbs_pr_alert("%s: couldn't pskb_expand_head\n", __func__);
|
|
|
|
ret = -ENOMEM;
|
|
|
|
kfree_skb(skb);
|
|
|
|
goto done;
|
2007-02-10 22:25:27 +08:00
|
|
|
}
|
|
|
|
|
2007-12-10 13:05:37 +08:00
|
|
|
pradiotap_hdr = (void *)skb_push(skb, sizeof(struct rx_radiotap_hdr));
|
|
|
|
memcpy(pradiotap_hdr, &radiotap_hdr, sizeof(struct rx_radiotap_hdr));
|
|
|
|
|
2007-02-10 22:25:27 +08:00
|
|
|
/* Take the data rate from the rxpd structure
|
|
|
|
* only if the rate is auto
|
|
|
|
*/
|
2008-05-24 17:59:49 +08:00
|
|
|
if (priv->enablehwauto)
|
2007-12-09 04:04:36 +08:00
|
|
|
priv->cur_rate = lbs_fw_index_to_data_rate(prxpd->rx_rate);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-11-16 07:05:47 +08:00
|
|
|
lbs_compute_rssi(priv, prxpd);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_rx("rx data: size of actual packet %d\n", skb->len);
|
2009-03-21 03:36:36 +08:00
|
|
|
dev->stats.rx_bytes += skb->len;
|
|
|
|
dev->stats.rx_packets++;
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-12-10 13:49:26 +08:00
|
|
|
skb->protocol = eth_type_trans(skb, priv->rtap_net_dev);
|
|
|
|
netif_rx(skb);
|
2007-05-19 04:04:33 +08:00
|
|
|
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = 0;
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
done:
|
|
|
|
lbs_deb_leave_args(LBS_DEB_RX, "ret %d", ret);
|
|
|
|
return ret;
|
2007-02-10 22:25:27 +08:00
|
|
|
}
|