Blackfin: fix cache Kconfig typo
[safe/jmp/linux-2.6] / 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 #include <net/iw_handler.h>
32
33
34 //extern struct zsWdsStruct wds[ZM_WDS_PORT_NUMBER];
35 extern struct zsVapStruct vap[ZM_VAP_PORT_NUMBER];
36
37
38 /***** Rx *****/
39 void zfLnxRecv80211(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo)
40 {
41     u16_t frameType;
42     u16_t frameCtrl;
43     u16_t frameSubtype;
44     zbuf_t *skb1;
45     struct usbdrv_private *macp = dev->ml_priv;
46
47     //frameCtrl = zmw_buf_readb(dev, buf, 0);
48     frameCtrl = *(u8_t*)((u8_t*)buf->data);
49     frameType = frameCtrl & 0xf;
50     frameSubtype = frameCtrl & 0xf0;
51
52     if ((frameType == 0x0) && (macp->forwardMgmt))
53     {
54         switch (frameSubtype)
55         {
56                 /* Beacon */
57             case 0x80 :
58                 /* Probe response */
59             case 0x50 :
60                 skb1 = skb_copy(buf, GFP_ATOMIC);
61                 if(skb1 != NULL)
62                 {
63                     skb1->dev = dev;
64                     skb1->mac_header = skb1->data;
65                     skb1->ip_summed = CHECKSUM_NONE;
66                     skb1->pkt_type = PACKET_OTHERHOST;
67                     skb1->protocol = __constant_htons(0x0019);  /* ETH_P_80211_RAW */
68                     netif_rx(skb1);
69                     }
70                 break;
71             default:
72                 break;
73         }
74     }
75
76     zfiRecv80211(dev, buf, addInfo);
77     return;
78 }
79
80 #define ZM_AVOID_UDP_LARGE_PACKET_FAIL
81 void zfLnxRecvEth(zdev_t* dev, zbuf_t* buf, u16_t port)
82 {
83     struct usbdrv_private *macp = dev->ml_priv;
84 #ifdef ZM_AVOID_UDP_LARGE_PACKET_FAIL
85     zbuf_t *new_buf;
86
87     //new_buf = dev_alloc_skb(2048);
88     new_buf = dev_alloc_skb(buf->len);
89
90 #ifdef NET_SKBUFF_DATA_USES_OFFSET
91     new_buf->tail = 0;
92     new_buf->len = 0;
93 #else
94     new_buf->tail = new_buf->data;
95     new_buf->len = 0;
96 #endif
97
98     skb_put(new_buf, buf->len);
99     memcpy(new_buf->data, buf->data, buf->len);
100
101     /* Free buffer */
102     dev_kfree_skb_any(buf);
103
104     if (port == 0)
105     {
106         new_buf->dev = dev;
107         new_buf->protocol = eth_type_trans(new_buf, dev);
108     }
109     else
110     {
111         /* VAP */
112         if (vap[0].dev != NULL)
113         {
114             new_buf->dev = vap[0].dev;
115             new_buf->protocol = eth_type_trans(new_buf, vap[0].dev);
116         }
117         else
118         {
119             new_buf->dev = dev;
120             new_buf->protocol = eth_type_trans(new_buf, dev);
121         }
122     }
123
124     new_buf->ip_summed = CHECKSUM_NONE;
125     dev->last_rx = jiffies;
126
127     switch(netif_rx(new_buf))
128 #else
129     if (port == 0)
130     {
131         buf->dev = dev;
132         buf->protocol = eth_type_trans(buf, dev);
133     }
134     else
135     {
136         /* VAP */
137         if (vap[0].dev != NULL)
138         {
139             buf->dev = vap[0].dev;
140             buf->protocol = eth_type_trans(buf, vap[0].dev);
141         }
142         else
143         {
144             buf->dev = dev;
145             buf->protocol = eth_type_trans(buf, dev);
146         }
147     }
148
149     buf->ip_summed = CHECKSUM_NONE;
150     dev->last_rx = jiffies;
151
152     switch(netif_rx(buf))
153 #endif
154     {
155     case NET_RX_DROP:
156         break;
157     default:
158             macp->drv_stats.net_stats.rx_packets++;
159             macp->drv_stats.net_stats.rx_bytes += buf->len;
160         break;
161     }
162
163     return;
164 }
165
166 /* Leave an empty line below to remove warning message on some compiler */