Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1 | /** |
| 2 | * This file contains the handling of RX in wlan driver. |
| 3 | */ |
| 4 | #include <linux/etherdevice.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 5 | #include <linux/slab.h> |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 6 | #include <linux/types.h> |
Kiran Divekar | e86dc1c | 2010-06-14 22:01:26 +0530 | [diff] [blame^] | 7 | #include <net/cfg80211.h> |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 8 | |
Kiran Divekar | e86dc1c | 2010-06-14 22:01:26 +0530 | [diff] [blame^] | 9 | #include "defs.h" |
Holger Schurig | 9e66e70 | 2009-10-16 17:32:16 +0200 | [diff] [blame] | 10 | #include "host.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 11 | #include "radiotap.h" |
| 12 | #include "decl.h" |
| 13 | #include "dev.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 14 | |
| 15 | struct eth803hdr { |
| 16 | u8 dest_addr[6]; |
| 17 | u8 src_addr[6]; |
| 18 | u16 h803_len; |
| 19 | } __attribute__ ((packed)); |
| 20 | |
| 21 | struct rfc1042hdr { |
| 22 | u8 llc_dsap; |
| 23 | u8 llc_ssap; |
| 24 | u8 llc_ctrl; |
| 25 | u8 snap_oui[3]; |
| 26 | u16 snap_type; |
| 27 | } __attribute__ ((packed)); |
| 28 | |
| 29 | struct rxpackethdr { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 30 | struct eth803hdr eth803_hdr; |
| 31 | struct rfc1042hdr rfc1042_hdr; |
| 32 | } __attribute__ ((packed)); |
| 33 | |
| 34 | struct rx80211packethdr { |
| 35 | struct rxpd rx_pd; |
| 36 | void *eth80211_hdr; |
| 37 | } __attribute__ ((packed)); |
| 38 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 39 | static int process_rxed_802_11_packet(struct lbs_private *priv, |
| 40 | struct sk_buff *skb); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 41 | |
| 42 | /** |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 43 | * @brief This function processes received packet and forwards it |
| 44 | * to kernel/upper layer |
| 45 | * |
Stewart Malik | 819cf15 | 2010-03-11 20:28:29 +1030 | [diff] [blame] | 46 | * @param priv A pointer to struct lbs_private |
| 47 | * @param skb A pointer to skb which includes the received packet |
| 48 | * @return 0 or -1 |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 49 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 50 | int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 51 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 52 | int ret = 0; |
David Woodhouse | 6f93a8e | 2007-12-10 00:49:26 -0500 | [diff] [blame] | 53 | struct net_device *dev = priv->dev; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 54 | struct rxpackethdr *p_rx_pkt; |
| 55 | struct rxpd *p_rx_pd; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 56 | int hdrchop; |
| 57 | struct ethhdr *p_ethhdr; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 58 | const u8 rfc1042_eth_hdr[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; |
| 59 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 60 | lbs_deb_enter(LBS_DEB_RX); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 61 | |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 62 | BUG_ON(!skb); |
| 63 | |
David Woodhouse | 6f93a8e | 2007-12-10 00:49:26 -0500 | [diff] [blame] | 64 | skb->ip_summed = CHECKSUM_NONE; |
| 65 | |
Kiran Divekar | e86dc1c | 2010-06-14 22:01:26 +0530 | [diff] [blame^] | 66 | if (priv->wdev->iftype == NL80211_IFTYPE_MONITOR) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 67 | return process_rxed_802_11_packet(priv, skb); |
| 68 | |
Bing Zhao | e45d8e5 | 2009-04-06 15:50:56 -0700 | [diff] [blame] | 69 | p_rx_pd = (struct rxpd *) skb->data; |
| 70 | p_rx_pkt = (struct rxpackethdr *) ((u8 *)p_rx_pd + |
| 71 | le32_to_cpu(p_rx_pd->pkt_ptr)); |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 72 | |
| 73 | dev = lbs_mesh_set_dev(priv, dev, p_rx_pd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 74 | |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 75 | lbs_deb_hex(LBS_DEB_RX, "RX Data: Before chop rxpd", skb->data, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 76 | min_t(unsigned int, skb->len, 100)); |
| 77 | |
| 78 | if (skb->len < (ETH_HLEN + 8 + sizeof(struct rxpd))) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 79 | lbs_deb_rx("rx err: frame received with bad length\n"); |
Stephen Hemminger | bbfc6b7 | 2009-03-20 19:36:36 +0000 | [diff] [blame] | 80 | dev->stats.rx_length_errors++; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 81 | ret = 0; |
Philip Rakity | f54930f | 2009-04-07 12:41:17 -0700 | [diff] [blame] | 82 | dev_kfree_skb(skb); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 83 | goto done; |
| 84 | } |
| 85 | |
Bing Zhao | e45d8e5 | 2009-04-06 15:50:56 -0700 | [diff] [blame] | 86 | lbs_deb_rx("rx data: skb->len - pkt_ptr = %d-%zd = %zd\n", |
John W. Linville | a2caba6 | 2009-04-14 11:45:57 -0400 | [diff] [blame] | 87 | skb->len, (size_t)le32_to_cpu(p_rx_pd->pkt_ptr), |
| 88 | skb->len - (size_t)le32_to_cpu(p_rx_pd->pkt_ptr)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 89 | |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 90 | lbs_deb_hex(LBS_DEB_RX, "RX Data: Dest", p_rx_pkt->eth803_hdr.dest_addr, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 91 | sizeof(p_rx_pkt->eth803_hdr.dest_addr)); |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 92 | lbs_deb_hex(LBS_DEB_RX, "RX Data: Src", p_rx_pkt->eth803_hdr.src_addr, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 93 | sizeof(p_rx_pkt->eth803_hdr.src_addr)); |
| 94 | |
| 95 | if (memcmp(&p_rx_pkt->rfc1042_hdr, |
| 96 | rfc1042_eth_hdr, sizeof(rfc1042_eth_hdr)) == 0) { |
| 97 | /* |
| 98 | * Replace the 803 header and rfc1042 header (llc/snap) with an |
| 99 | * EthernetII header, keep the src/dst and snap_type (ethertype) |
| 100 | * |
| 101 | * The firmware only passes up SNAP frames converting |
| 102 | * all RX Data from 802.11 to 802.2/LLC/SNAP frames. |
| 103 | * |
| 104 | * To create the Ethernet II, just move the src, dst address right |
| 105 | * before the snap_type. |
| 106 | */ |
| 107 | p_ethhdr = (struct ethhdr *) |
Stewart Malik | 819cf15 | 2010-03-11 20:28:29 +1030 | [diff] [blame] | 108 | ((u8 *) &p_rx_pkt->eth803_hdr |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 109 | + sizeof(p_rx_pkt->eth803_hdr) + sizeof(p_rx_pkt->rfc1042_hdr) |
| 110 | - sizeof(p_rx_pkt->eth803_hdr.dest_addr) |
| 111 | - sizeof(p_rx_pkt->eth803_hdr.src_addr) |
| 112 | - sizeof(p_rx_pkt->rfc1042_hdr.snap_type)); |
| 113 | |
| 114 | memcpy(p_ethhdr->h_source, p_rx_pkt->eth803_hdr.src_addr, |
| 115 | sizeof(p_ethhdr->h_source)); |
| 116 | memcpy(p_ethhdr->h_dest, p_rx_pkt->eth803_hdr.dest_addr, |
| 117 | sizeof(p_ethhdr->h_dest)); |
| 118 | |
| 119 | /* Chop off the rxpd + the excess memory from the 802.2/llc/snap header |
| 120 | * that was removed |
| 121 | */ |
Bing Zhao | e45d8e5 | 2009-04-06 15:50:56 -0700 | [diff] [blame] | 122 | hdrchop = (u8 *)p_ethhdr - (u8 *)p_rx_pd; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 123 | } else { |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 124 | lbs_deb_hex(LBS_DEB_RX, "RX Data: LLC/SNAP", |
Stewart Malik | 819cf15 | 2010-03-11 20:28:29 +1030 | [diff] [blame] | 125 | (u8 *) &p_rx_pkt->rfc1042_hdr, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 126 | sizeof(p_rx_pkt->rfc1042_hdr)); |
| 127 | |
| 128 | /* Chop off the rxpd */ |
Bing Zhao | e45d8e5 | 2009-04-06 15:50:56 -0700 | [diff] [blame] | 129 | hdrchop = (u8 *)&p_rx_pkt->eth803_hdr - (u8 *)p_rx_pd; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | /* Chop off the leading header bytes so the skb points to the start of |
| 133 | * either the reconstructed EthII frame or the 802.2/llc/snap frame |
| 134 | */ |
| 135 | skb_pull(skb, hdrchop); |
| 136 | |
Kiran Divekar | e86dc1c | 2010-06-14 22:01:26 +0530 | [diff] [blame^] | 137 | priv->cur_rate = lbs_fw_index_to_data_rate(p_rx_pd->rx_rate); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 138 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 139 | lbs_deb_rx("rx data: size of actual packet %d\n", skb->len); |
Stephen Hemminger | bbfc6b7 | 2009-03-20 19:36:36 +0000 | [diff] [blame] | 140 | dev->stats.rx_bytes += skb->len; |
| 141 | dev->stats.rx_packets++; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 142 | |
David Woodhouse | 6f93a8e | 2007-12-10 00:49:26 -0500 | [diff] [blame] | 143 | skb->protocol = eth_type_trans(skb, dev); |
Holger Schurig | ae3e0fc | 2008-01-16 15:48:44 +0100 | [diff] [blame] | 144 | if (in_interrupt()) |
| 145 | netif_rx(skb); |
| 146 | else |
| 147 | netif_rx_ni(skb); |
Florin Malita | 3d4bd24 | 2007-05-18 16:04:33 -0400 | [diff] [blame] | 148 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 149 | ret = 0; |
| 150 | done: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 151 | lbs_deb_leave_args(LBS_DEB_RX, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 152 | return ret; |
| 153 | } |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 154 | EXPORT_SYMBOL_GPL(lbs_process_rxed_packet); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 155 | |
| 156 | /** |
| 157 | * @brief This function converts Tx/Rx rates from the Marvell WLAN format |
| 158 | * (see Table 2 in Section 3.1) to IEEE80211_RADIOTAP_RATE units (500 Kb/s) |
| 159 | * |
Stewart Malik | 819cf15 | 2010-03-11 20:28:29 +1030 | [diff] [blame] | 160 | * @param rate Input rate |
| 161 | * @return Output Rate (0 if invalid) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 162 | */ |
| 163 | static u8 convert_mv_rate_to_radiotap(u8 rate) |
| 164 | { |
| 165 | switch (rate) { |
| 166 | case 0: /* 1 Mbps */ |
| 167 | return 2; |
| 168 | case 1: /* 2 Mbps */ |
| 169 | return 4; |
| 170 | case 2: /* 5.5 Mbps */ |
| 171 | return 11; |
| 172 | case 3: /* 11 Mbps */ |
| 173 | return 22; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 174 | /* case 4: reserved */ |
| 175 | case 5: /* 6 Mbps */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 176 | return 12; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 177 | case 6: /* 9 Mbps */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 178 | return 18; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 179 | case 7: /* 12 Mbps */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 180 | return 24; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 181 | case 8: /* 18 Mbps */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 182 | return 36; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 183 | case 9: /* 24 Mbps */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 184 | return 48; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 185 | case 10: /* 36 Mbps */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 186 | return 72; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 187 | case 11: /* 48 Mbps */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 188 | return 96; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 189 | case 12: /* 54 Mbps */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 190 | return 108; |
| 191 | } |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 192 | lbs_pr_alert("Invalid Marvell WLAN rate %i\n", rate); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 193 | return 0; |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * @brief This function processes a received 802.11 packet and forwards it |
| 198 | * to kernel/upper layer |
| 199 | * |
Stewart Malik | 819cf15 | 2010-03-11 20:28:29 +1030 | [diff] [blame] | 200 | * @param priv A pointer to struct lbs_private |
| 201 | * @param skb A pointer to skb which includes the received packet |
| 202 | * @return 0 or -1 |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 203 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 204 | static int process_rxed_802_11_packet(struct lbs_private *priv, |
| 205 | struct sk_buff *skb) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 206 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 207 | int ret = 0; |
Stephen Hemminger | bbfc6b7 | 2009-03-20 19:36:36 +0000 | [diff] [blame] | 208 | struct net_device *dev = priv->dev; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 209 | struct rx80211packethdr *p_rx_pkt; |
| 210 | struct rxpd *prxpd; |
| 211 | struct rx_radiotap_hdr radiotap_hdr; |
| 212 | struct rx_radiotap_hdr *pradiotap_hdr; |
| 213 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 214 | lbs_deb_enter(LBS_DEB_RX); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 215 | |
| 216 | p_rx_pkt = (struct rx80211packethdr *) skb->data; |
| 217 | prxpd = &p_rx_pkt->rx_pd; |
| 218 | |
Stewart Malik | 819cf15 | 2010-03-11 20:28:29 +1030 | [diff] [blame] | 219 | /* lbs_deb_hex(LBS_DEB_RX, "RX Data: Before chop rxpd", skb->data, min(skb->len, 100)); */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 220 | |
| 221 | if (skb->len < (ETH_HLEN + 8 + sizeof(struct rxpd))) { |
David Woodhouse | 7bf02c2 | 2007-12-10 00:17:28 -0500 | [diff] [blame] | 222 | lbs_deb_rx("rx err: frame received with bad length\n"); |
Stephen Hemminger | bbfc6b7 | 2009-03-20 19:36:36 +0000 | [diff] [blame] | 223 | dev->stats.rx_length_errors++; |
David Woodhouse | 7bf02c2 | 2007-12-10 00:17:28 -0500 | [diff] [blame] | 224 | ret = -EINVAL; |
Sergio Luis | b700a98 | 2008-10-26 23:09:27 -0700 | [diff] [blame] | 225 | kfree_skb(skb); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 226 | goto done; |
| 227 | } |
| 228 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 229 | lbs_deb_rx("rx data: skb->len-sizeof(RxPd) = %d-%zd = %zd\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 230 | skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); |
| 231 | |
| 232 | /* create the exported radio header */ |
David Woodhouse | 180be75 | 2007-12-10 00:05:37 -0500 | [diff] [blame] | 233 | |
| 234 | /* radiotap header */ |
Prarit Bhargava | c6a6368 | 2010-05-27 14:41:20 -0400 | [diff] [blame] | 235 | memset(&radiotap_hdr, 0, sizeof(radiotap_hdr)); |
| 236 | /* XXX must check radiotap_hdr.hdr.it_pad for pad */ |
David Woodhouse | 180be75 | 2007-12-10 00:05:37 -0500 | [diff] [blame] | 237 | radiotap_hdr.hdr.it_len = cpu_to_le16 (sizeof(struct rx_radiotap_hdr)); |
| 238 | radiotap_hdr.hdr.it_present = cpu_to_le32 (RX_RADIOTAP_PRESENT); |
David Woodhouse | 180be75 | 2007-12-10 00:05:37 -0500 | [diff] [blame] | 239 | radiotap_hdr.rate = convert_mv_rate_to_radiotap(prxpd->rx_rate); |
| 240 | /* XXX must check no carryout */ |
| 241 | radiotap_hdr.antsignal = prxpd->snr + prxpd->nf; |
David Woodhouse | 180be75 | 2007-12-10 00:05:37 -0500 | [diff] [blame] | 242 | |
| 243 | /* chop the rxpd */ |
| 244 | skb_pull(skb, sizeof(struct rxpd)); |
| 245 | |
| 246 | /* add space for the new radio header */ |
| 247 | if ((skb_headroom(skb) < sizeof(struct rx_radiotap_hdr)) && |
David Woodhouse | 7bf02c2 | 2007-12-10 00:17:28 -0500 | [diff] [blame] | 248 | pskb_expand_head(skb, sizeof(struct rx_radiotap_hdr), 0, GFP_ATOMIC)) { |
| 249 | lbs_pr_alert("%s: couldn't pskb_expand_head\n", __func__); |
| 250 | ret = -ENOMEM; |
| 251 | kfree_skb(skb); |
| 252 | goto done; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 253 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 254 | |
David Woodhouse | 180be75 | 2007-12-10 00:05:37 -0500 | [diff] [blame] | 255 | pradiotap_hdr = (void *)skb_push(skb, sizeof(struct rx_radiotap_hdr)); |
| 256 | memcpy(pradiotap_hdr, &radiotap_hdr, sizeof(struct rx_radiotap_hdr)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 257 | |
Kiran Divekar | e86dc1c | 2010-06-14 22:01:26 +0530 | [diff] [blame^] | 258 | priv->cur_rate = lbs_fw_index_to_data_rate(prxpd->rx_rate); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 259 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 260 | lbs_deb_rx("rx data: size of actual packet %d\n", skb->len); |
Stephen Hemminger | bbfc6b7 | 2009-03-20 19:36:36 +0000 | [diff] [blame] | 261 | dev->stats.rx_bytes += skb->len; |
| 262 | dev->stats.rx_packets++; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 263 | |
Kiran Divekar | e86dc1c | 2010-06-14 22:01:26 +0530 | [diff] [blame^] | 264 | skb->protocol = eth_type_trans(skb, priv->dev); |
| 265 | |
| 266 | if (in_interrupt()) |
| 267 | netif_rx(skb); |
| 268 | else |
| 269 | netif_rx_ni(skb); |
Florin Malita | 3d4bd24 | 2007-05-18 16:04:33 -0400 | [diff] [blame] | 270 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 271 | ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 272 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 273 | done: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 274 | lbs_deb_leave_args(LBS_DEB_RX, "ret %d", ret); |
| 275 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 276 | } |