added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / drivers / staging / otus / wrap_pkt.c
blob5db0004c873953cd348c33532536f93a5129a181
1 /*
2 * Copyright (c) 2007-2008 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 /* */
17 /* Module Name : wrap_pkt.c */
18 /* */
19 /* Abstract */
20 /* This module contains wrapper functions for packet handling */
21 /* */
22 /* NOTES */
23 /* Platform dependent. */
24 /* */
25 /************************************************************************/
27 #include "oal_dt.h"
28 #include "usbdrv.h"
30 #include <linux/netlink.h>
32 #if WIRELESS_EXT > 12
33 #include <net/iw_handler.h>
34 #endif
38 //extern struct zsWdsStruct wds[ZM_WDS_PORT_NUMBER];
39 extern struct zsVapStruct vap[ZM_VAP_PORT_NUMBER];
42 /***** Rx *****/
43 void zfLnxRecv80211(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo)
45 u16_t frameType;
46 u16_t frameCtrl;
47 u16_t frameSubtype;
48 zbuf_t *skb1;
49 struct usbdrv_private *macp = dev->ml_priv;
51 //frameCtrl = zmw_buf_readb(dev, buf, 0);
52 frameCtrl = *(u8_t*)((u8_t*)buf->data);
53 frameType = frameCtrl & 0xf;
54 frameSubtype = frameCtrl & 0xf0;
56 if ((frameType == 0x0) && (macp->forwardMgmt))
58 switch (frameSubtype)
60 /* Beacon */
61 case 0x80 :
62 /* Probe response */
63 case 0x50 :
64 skb1 = skb_copy(buf, GFP_ATOMIC);
65 if(skb1 != NULL)
67 skb1->dev = dev;
68 skb1->mac_header = skb1->data;
69 skb1->ip_summed = CHECKSUM_NONE;
70 skb1->pkt_type = PACKET_OTHERHOST;
71 skb1->protocol = __constant_htons(0x0019); /* ETH_P_80211_RAW */
72 netif_rx(skb1);
74 break;
75 default:
76 break;
80 zfiRecv80211(dev, buf, addInfo);
81 return;
84 #define ZM_AVOID_UDP_LARGE_PACKET_FAIL
85 void zfLnxRecvEth(zdev_t* dev, zbuf_t* buf, u16_t port)
87 struct usbdrv_private *macp = dev->ml_priv;
88 #ifdef ZM_AVOID_UDP_LARGE_PACKET_FAIL
89 zbuf_t *new_buf;
91 //new_buf = dev_alloc_skb(2048);
92 new_buf = dev_alloc_skb(buf->len);
94 #ifdef NET_SKBUFF_DATA_USES_OFFSET
95 new_buf->tail = 0;
96 new_buf->len = 0;
97 #else
98 new_buf->tail = new_buf->data;
99 new_buf->len = 0;
100 #endif
102 skb_put(new_buf, buf->len);
103 memcpy(new_buf->data, buf->data, buf->len);
105 /* Free buffer */
106 dev_kfree_skb_any(buf);
108 if (port == 0)
110 new_buf->dev = dev;
111 new_buf->protocol = eth_type_trans(new_buf, dev);
113 else
115 /* VAP */
116 if (vap[0].dev != NULL)
118 new_buf->dev = vap[0].dev;
119 new_buf->protocol = eth_type_trans(new_buf, vap[0].dev);
121 else
123 new_buf->dev = dev;
124 new_buf->protocol = eth_type_trans(new_buf, dev);
128 new_buf->ip_summed = CHECKSUM_NONE;
129 dev->last_rx = jiffies;
131 switch(netif_rx(new_buf))
132 #else
133 if (port == 0)
135 buf->dev = dev;
136 buf->protocol = eth_type_trans(buf, dev);
138 else
140 /* VAP */
141 if (vap[0].dev != NULL)
143 buf->dev = vap[0].dev;
144 buf->protocol = eth_type_trans(buf, vap[0].dev);
146 else
148 buf->dev = dev;
149 buf->protocol = eth_type_trans(buf, dev);
153 buf->ip_summed = CHECKSUM_NONE;
154 dev->last_rx = jiffies;
156 switch(netif_rx(buf))
157 #endif
159 case NET_RX_BAD:
160 case NET_RX_DROP:
161 case NET_RX_CN_MOD:
162 case NET_RX_CN_HIGH:
163 break;
164 default:
165 macp->drv_stats.net_stats.rx_packets++;
166 macp->drv_stats.net_stats.rx_bytes += buf->len;
167 break;
170 return;
173 /* Leave an empty line below to remove warning message on some compiler */