Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / target / inc / adf_net_types.h
1 /**
2  * @ingroup adf_net_public
3  * @file adf_net_types.h
4  * This file defines types used in the networking stack abstraction.
5  */
6
7 #ifndef _ADF_NET_TYPES_H
8 #define _ADF_NET_TYPES_H
9
10
11
12 /**
13  * @brief These control/get info from the device
14  */
15 #define ADF_NET_CMD(_x)           \
16     ADF_NET_CMD_GET_##_x,        \
17     ADF_NET_CMD_SET_##_x
18
19 /**
20  * @brief Get/Set commands from anet to adf_drv
21  */
22 typedef enum {
23     ADF_NET_CMD(LINK_INFO),
24     ADF_NET_CMD(POLL_INFO),
25     ADF_NET_CMD(CKSUM_INFO),
26     ADF_NET_CMD(RING_INFO),
27     ADF_NET_CMD(MAC_ADDR),
28     ADF_NET_CMD(MTU),
29     ADF_NET_CMD_GET_DMA_INFO,
30     ADF_NET_CMD_GET_OFFLOAD_CAP,
31     ADF_NET_CMD_GET_STATS,
32     ADF_NET_CMD_ADD_VID,
33     ADF_NET_CMD_DEL_VID,
34     ADF_NET_CMD_SET_MCAST,
35     ADF_NET_CMD_GET_MCAST_CAP
36 }adf_net_cmd_t;
37
38
39
40 /**
41  * @brief Indicates what features are supported by the interface. 
42  */
43 #define ADF_NET_LINK_SUPP_10baseT_Half      (1 << 0)
44 #define ADF_NET_LINK_SUPP_10baseT_Full      (1 << 1)
45 #define ADF_NET_LINK_SUPP_100baseT_Half     (1 << 2)
46 #define ADF_NET_LINK_SUPP_100baseT_Full     (1 << 3)
47 #define ADF_NET_LINK_SUPP_1000baseT_Half    (1 << 4)
48 #define ADF_NET_LINK_SUPP_1000baseT_Full    (1 << 5)
49 #define ADF_NET_LINK_SUPP_Autoneg           (1 << 6)
50 #define ADF_NET_LINK_SUPP_Pause             (1 << 7)
51 #define ADF_NET_LINK_SUPP_Asym_Pause        (1 << 8)
52
53 #define ADF_NET_LINK_SUPP_100               (ADF_NET_LINK_SUPP_10baseT_Half  |   \
54                                           ADF_NET_LINK_SUPP_10baseT_Full  |   \
55                                           ADF_NET_LINK_SUPP_100baseT_Half |   \
56                                           ADF_NET_LINK_SUPP_100baseT_Full)
57
58 #define ADF_NET_LINK_SUPP_1000               (ADF_NET_LINK_SUPP_100 |             \
59                                            ADF_NET_LINK_SUPP_1000baseT_Full)
60
61 /**
62  * @brief Indicates what features are advertised by the interface. 
63  */
64 #define ADF_NET_LINK_ADV_10baseT_Half     (1 << 0)
65 #define ADF_NET_LINK_ADV_10baseT_Full     (1 << 1)
66 #define ADF_NET_LINK_ADV_100baseT_Half    (1 << 2)
67 #define ADF_NET_LINK_ADV_100baseT_Full    (1 << 3)
68 #define ADF_NET_LINK_ADV_1000baseT_Half   (1 << 4)
69 #define ADF_NET_LINK_ADV_1000baseT_Full   (1 << 5)
70 #define ADF_NET_LINK_ADV_Autoneg          (1 << 6)
71 #define ADF_NET_LINK_ADV_Pause            (1 << 7)
72 #define ADF_NET_LINK_ADV_Asym_Pause       (1 << 8)
73
74 #define ADF_NET_LINK_ADV_100             (ADF_NET_LINK_ADV_10baseT_Half  |  \
75                                          ADF_NET_LINK_ADV_10baseT_Full  |   \
76                                          ADF_NET_LINK_ADV_100baseT_Half |   \
77                                          ADF_NET_LINK_ADV_100baseT_Full)
78
79 #define ADF_NET_LINK_ADV_1000            (ADF_NET_LINK_ADV_100 |            \
80                                           ADF_NET_LINK_ADV_1000baseT_Full)
81
82 /**
83  * @brief The forced/current speed/duplex/autoneg
84  */
85 #define ADF_NET_LINK_SPEED_10        10
86 #define ADF_NET_LINK_SPEED_100       100
87 #define ADF_NET_LINK_SPEED_1000      1000
88
89 #define ADF_NET_LINK_DUPLEX_HALF     0x00
90 #define ADF_NET_LINK_DUPLEX_FULL     0x01
91
92 #define ADF_NET_LINK_AUTONEG_DISABLE 0x00
93 #define ADF_NET_LINK_AUTONEG_ENABLE  0x01
94
95 #define ADF_NET_MAC_ADDR_MAX_LEN 6
96 #define ADF_NET_IF_NAME_SIZE    64
97 #define ADF_NET_ETH_LEN         ADF_NET_MAC_ADDR_MAX_LEN
98 #define ADF_NET_MAX_MCAST_ADDR  128
99
100 /**
101  * @brief link info capability/parameters for the device
102  * Note the flags below
103  */
104 typedef struct {
105     a_uint32_t  supported;   /*RO Features this if supports*/
106     a_uint32_t  advertized;  /*Features this interface advertizes*/
107     a_int16_t   speed;       /*Force speed 10M, 100M, gigE*/
108     a_int8_t    duplex;      /*duplex full or half*/
109     a_uint8_t   autoneg;     /*Enabled/disable autoneg*/
110 }adf_net_cmd_link_info_t;
111
112 typedef struct adf_net_ethaddr{
113         a_uint8_t   addr[ADF_NET_ETH_LEN];
114 } adf_net_ethaddr_t;
115 typedef struct {
116     a_uint8_t   ether_dhost[ADF_NET_ETH_LEN];   /* destination eth addr */
117     a_uint8_t   ether_shost[ADF_NET_ETH_LEN];   /* source ether addr    */
118     a_uint16_t  ether_type;                     /* packet type ID field */
119 }adf_net_ethhdr_t;
120
121 typedef struct {
122 #if defined (ADF_LITTLE_ENDIAN_MACHINE)
123     a_uint8_t       ip_hl:4,
124                     ip_version:4;
125 #elif defined (ADF_BIG_ENDIAN_MACHINE)
126     a_uint8_t       ip_version:4,
127                     ip_hl:4;
128 #else
129 #error  "Please fix"
130 #endif
131     a_uint8_t       ip_tos;
132
133     a_uint16_t      ip_len;
134     a_uint16_t      ip_id;
135     a_uint16_t      ip_frag_off;
136     a_uint8_t       ip_ttl;
137     a_uint8_t       ip_proto;
138     a_uint16_t      ip_check;
139     a_uint32_t      ip_saddr;
140     a_uint32_t      ip_daddr;
141     /*The options start here. */
142  }adf_net_iphdr_t;
143
144 /**
145  * @brief Vlan header
146  */
147 typedef struct adf_net_vlanhdr{
148     a_uint16_t      tpid;
149 #if defined (ADF_LITTLE_ENDIAN_MACHINE)
150     a_uint16_t      vid:12; /* Vlan id*/
151     a_uint8_t       cfi:1; /* reserved for CFI, don't use*/
152     a_uint8_t       prio:3; /* Priority*/
153 #elif defined (ADF_BIG_ENDIAN_MACHINE)
154     a_uint8_t       prio:3; /* Priority*/
155     a_uint8_t       cfi:1; /* reserved for CFI, don't use*/
156     a_uint16_t      vid:12; /* Vlan id*/
157 #else
158 #error  "Please fix"
159 #endif
160 }adf_net_vlanhdr_t;
161
162 typedef struct adf_net_vid{
163 #if defined (ADF_LITTLE_ENDIAN_MACHINE)
164     a_uint16_t      val:12;
165     a_uint8_t       res:4;  
166 #elif defined (ADF_BIG_ENDIAN_MACHINE)
167     a_uint8_t      res:4;
168     a_uint16_t      val:12;
169 #else
170 #error  "Please fix"
171 #endif
172 }adf_net_vid_t;
173
174
175 /**
176  * @brief Command for setting ring paramters.
177  */
178 typedef struct {
179     a_uint32_t rx_bufsize;  /*Ro field. For shim's that maintain a pool*/
180     a_uint32_t rx_ndesc;
181     a_uint32_t tx_ndesc;
182 }adf_net_cmd_ring_info_t;
183
184 /**
185  * @brief Whether the interface is polled or not. If so, the polling bias (number of
186  * packets it wants to process per invocation
187  */
188 typedef struct {
189     a_bool_t    polled;
190     a_uint32_t  poll_wt;
191 }adf_net_cmd_poll_info_t;
192
193 /**
194  * @brief Basic device info
195  */
196 typedef struct {
197     a_uint8_t      if_name[ADF_NET_IF_NAME_SIZE];
198     a_uint8_t       dev_addr[ADF_NET_MAC_ADDR_MAX_LEN];
199 }adf_net_dev_info_t;
200
201 typedef struct adf_dma_info {
202     adf_os_dma_mask_t   dma_mask;
203     a_uint32_t          sg_nsegs; /**< scatter segments */
204 }adf_net_cmd_dma_info_t;
205
206 /**
207  * @brief Defines the TX and RX checksumming capabilities/state of the device
208  * The actual checksum handling happens on an adf_nbuf
209  * If offload capability command not supported, all offloads are assumed to be
210  * none.
211  */
212 typedef enum {
213     ADF_NET_CKSUM_NONE,           /*Cannot do any checksum*/
214     ADF_NET_CKSUM_TCP_UDP_IPv4,   /*tcp/udp on ipv4 with pseudo hdr*/
215     ADF_NET_CKSUM_TCP_UDP_IPv6,   /*tcp/udp on ipv6*/
216 }adf_net_cksum_type_t;
217
218 typedef struct {
219     adf_net_cksum_type_t tx_cksum;
220     adf_net_cksum_type_t rx_cksum;
221 }adf_net_cksum_info_t;
222
223 typedef adf_net_cksum_info_t adf_net_cmd_cksum_info_t;    /*XXX needed?*/
224
225 /**
226  * @brief Command for set/unset vid
227  */
228 typedef a_uint16_t adf_net_cmd_vid_t ;        /*get/set vlan id*/
229
230 typedef enum {
231     ADF_NET_TSO_NONE,
232     ADF_NET_TSO_IPV4,     /**< for tsp ipv4 only*/
233     ADF_NET_TSO_ALL,      /**< ip4 & ipv6*/
234 }adf_net_tso_type_t;
235
236 /**
237  * @brief Command for getting offloading capabilities of a device
238  */
239 typedef struct {
240     adf_net_cksum_info_t cksum_cap;
241     adf_net_tso_type_t   tso;
242     a_uint8_t         vlan_supported;
243 }adf_net_cmd_offload_cap_t;
244
245 /**
246  * @brief Command for getting general stats from a device
247  */
248 typedef struct {
249     a_uint32_t tx_packets;  /**< total packets transmitted*/
250     a_uint32_t rx_packets;  /**< total packets recieved*/
251     a_uint32_t tx_bytes;    /**< total bytes transmitted*/
252     a_uint32_t rx_bytes;    /**< total bytes recieved*/
253     a_uint32_t tx_dropped;  /**< total tx dropped because of lack of buffers*/
254     a_uint32_t rx_dropped;  /**< total rx dropped because of lack of buffers*/
255     a_uint32_t rx_errors;   /**< bad packet recieved*/
256     a_uint32_t tx_errors;   /**< transmisison problems*/
257 }adf_net_cmd_stats_t;
258
259 typedef enum adf_net_cmd_mcast_cap{
260     ADF_NET_MCAST_SUP=0,
261     ADF_NET_MCAST_NOTSUP
262 }adf_net_cmd_mcast_cap_t;
263
264 typedef struct adf_net_cmd_mcaddr{
265     a_uint32_t              nelem; /**< No. of mcast addresses*/
266     adf_net_ethaddr_t       mcast[ADF_NET_MAX_MCAST_ADDR];
267 }adf_net_cmd_mcaddr_t;
268
269 typedef union {
270     adf_net_cmd_link_info_t     link_info;
271     adf_net_cmd_poll_info_t     poll_info;
272     adf_net_cmd_cksum_info_t    cksum_info;
273     adf_net_cmd_ring_info_t     ring_info;
274     adf_net_cmd_dma_info_t      dma_info;
275     adf_net_cmd_vid_t           vid;
276     adf_net_cmd_offload_cap_t   offload_cap;
277     adf_net_cmd_stats_t         stats;
278     adf_net_cmd_mcaddr_t        mcast_info;
279     adf_net_cmd_mcast_cap_t     mcast_cap;
280 }adf_net_cmd_data_t;
281
282 /**
283  * @brief For polled devices, adf_drv responds with one of the following status in 
284  * its poll function.
285  */
286 typedef enum {
287     ADF_NET_POLL_DONE,
288     ADF_NET_POLL_NOT_DONE,
289     ADF_NET_POLL_OOM,
290 }adf_net_poll_resp_t;
291
292 /**
293  * @brief For recieve checksum API
294  */
295 typedef enum {
296     ADF_NBUF_RX_CKSUM_NONE,        /*device failed to ckecksum*/
297     ADF_NBUF_RX_CKSUM_HW,          /*checksum successful and value returned*/
298     ADF_NBUF_RX_CKSUM_UNNECESSARY, /*cksum successful, no value*/
299 }adf_nbuf_rx_cksum_type_t;
300
301 typedef struct {
302     adf_nbuf_rx_cksum_type_t result;
303     a_uint32_t               val;
304 }adf_nbuf_rx_cksum_t;
305
306 /**
307  * @brief For TCP large Segment Offload
308  */
309 typedef struct {
310     adf_net_tso_type_t  type;
311     a_uint16_t          mss;
312     a_uint8_t           hdr_off;
313 }adf_nbuf_tso_t;
314
315 /**
316  * @brief Wireless events
317  * ADF_IEEE80211_ASSOC = station associate (bss mode)
318  * ADF_IEEE80211_REASSOC = station re-associate (bss mode)
319  * ADF_IEEE80211_DISASSOC = station disassociate (bss mode)
320  * ADF_IEEE80211_JOIN = station join (ap mode)
321  * ADF_IEEE80211_LEAVE = station leave (ap mode)
322  * ADF_IEEE80211_SCAN = scan complete, results available
323  * ADF_IEEE80211_REPLAY = sequence counter replay detected
324  * ADF_IEEE80211_MICHAEL = Michael MIC failure detected
325  * ADF_IEEE80211_REJOIN = station re-associate (ap mode)
326  * ADF_CUSTOM_PUSH_BUTTON =
327  */
328 typedef enum adf_net_wireless_events{
329     ADF_IEEE80211_ASSOC = __ADF_IEEE80211_ASSOC,
330     ADF_IEEE80211_REASSOC = __ADF_IEEE80211_REASSOC,
331     ADF_IEEE80211_DISASSOC = __ADF_IEEE80211_DISASSOC,
332     ADF_IEEE80211_JOIN = __ADF_IEEE80211_JOIN,
333     ADF_IEEE80211_LEAVE = __ADF_IEEE80211_LEAVE,
334     ADF_IEEE80211_SCAN = __ADF_IEEE80211_SCAN,
335     ADF_IEEE80211_REPLAY = __ADF_IEEE80211_REPLAY,
336     ADF_IEEE80211_MICHAEL = __ADF_IEEE80211_MICHAEL,
337     ADF_IEEE80211_REJOIN = __ADF_IEEE80211_REJOIN, 
338     ADF_CUSTOM_PUSH_BUTTON = __ADF_CUSTOM_PUSH_BUTTON
339 }adf_net_wireless_event_t;
340
341 #endif /*_ADF_NET_TYPES_H*/