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