]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/staging/otus/wrap_pkt.c
f2dda4b4dcf0f471633124f735c328523a5ae60b
[linux-2.6-omap-h63xx.git] / drivers / staging / otus / wrap_pkt.c
1 /*
2  * Copyright (c) 2007-2008 Atheros Communications Inc.
3  *
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.
7  *
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.
15  */
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 /************************************************************************/
26
27 #include "oal_dt.h"
28 #include "usbdrv.h"
29
30 #include <linux/netlink.h>
31
32 #if WIRELESS_EXT > 12
33 #include <net/iw_handler.h>
34 #endif
35
36
37
38 //extern struct zsWdsStruct wds[ZM_WDS_PORT_NUMBER];
39 extern struct zsVapStruct vap[ZM_VAP_PORT_NUMBER];
40
41
42 /***** Rx *****/
43 void zfLnxRecv80211(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo)
44 {
45     u16_t frameType;
46     u16_t frameCtrl;
47     u16_t frameSubtype;
48     zbuf_t *skb1;
49     struct usbdrv_private *macp = dev->priv;
50
51     //frameCtrl = zmw_buf_readb(dev, buf, 0);
52     frameCtrl = *(u8_t*)((u8_t*)buf->data);
53     frameType = frameCtrl & 0xf;
54     frameSubtype = frameCtrl & 0xf0;
55
56     if ((frameType == 0x0) && (macp->forwardMgmt))
57     {
58         switch (frameSubtype)
59         {
60                 /* Beacon */
61             case 0x80 :
62                 /* Probe response */
63             case 0x50 :
64                 skb1 = skb_copy(buf, GFP_ATOMIC);
65                 if(skb1 != NULL)
66                 {
67                     skb1->dev = dev;
68                 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
69                     skb1->mac.raw = skb1->data;
70                 #else
71                     skb1->mac_header = skb1->data;
72                 #endif
73                     skb1->ip_summed = CHECKSUM_NONE;
74                     skb1->pkt_type = PACKET_OTHERHOST;
75                     skb1->protocol = __constant_htons(0x0019);  /* ETH_P_80211_RAW */
76                     netif_rx(skb1);
77                     }
78                 break;
79             default:
80                 break;
81         }
82     }
83
84     zfiRecv80211(dev, buf, addInfo);
85     return;
86 }
87
88 #define ZM_AVOID_UDP_LARGE_PACKET_FAIL
89 void zfLnxRecvEth(zdev_t* dev, zbuf_t* buf, u16_t port)
90 {
91 #ifdef ZM_AVOID_UDP_LARGE_PACKET_FAIL
92     zbuf_t *new_buf;
93
94     //new_buf = dev_alloc_skb(2048);
95     new_buf = dev_alloc_skb(buf->len);
96
97 #ifdef NET_SKBUFF_DATA_USES_OFFSET
98     new_buf->tail = 0;
99     new_buf->len = 0;
100 #else
101     new_buf->tail = new_buf->data;
102     new_buf->len = 0;
103 #endif
104
105     skb_put(new_buf, buf->len);
106     memcpy(new_buf->data, buf->data, buf->len);
107
108     /* Free buffer */
109     dev_kfree_skb_any(buf);
110
111     if (port == 0)
112     {
113         new_buf->dev = dev;
114         new_buf->protocol = eth_type_trans(new_buf, dev);
115     }
116     else
117     {
118         /* VAP */
119         if (vap[0].dev != NULL)
120         {
121             new_buf->dev = vap[0].dev;
122             new_buf->protocol = eth_type_trans(new_buf, vap[0].dev);
123         }
124         else
125         {
126             new_buf->dev = dev;
127             new_buf->protocol = eth_type_trans(new_buf, dev);
128         }
129     }
130
131     new_buf->ip_summed = CHECKSUM_NONE;
132     dev->last_rx = jiffies;
133
134     switch(netif_rx(new_buf))
135 #else
136     if (port == 0)
137     {
138         buf->dev = dev;
139         buf->protocol = eth_type_trans(buf, dev);
140     }
141     else
142     {
143         /* VAP */
144         if (vap[0].dev != NULL)
145         {
146             buf->dev = vap[0].dev;
147             buf->protocol = eth_type_trans(buf, vap[0].dev);
148         }
149         else
150         {
151             buf->dev = dev;
152             buf->protocol = eth_type_trans(buf, dev);
153         }
154     }
155
156     buf->ip_summed = CHECKSUM_NONE;
157     dev->last_rx = jiffies;
158
159     switch(netif_rx(buf))
160 #endif
161     {
162     case NET_RX_BAD:
163     case NET_RX_DROP:
164     case NET_RX_CN_MOD:
165     case NET_RX_CN_HIGH:
166         break;
167     default:
168             ((struct usbdrv_private*)(dev->priv))->
169                     drv_stats.net_stats.rx_packets++;
170             ((struct usbdrv_private*)(dev->priv))->
171                     drv_stats.net_stats.rx_bytes += buf->len;
172         break;
173     }
174
175     return;
176 }
177
178 /* Leave an empty line below to remove warning message on some compiler */