2 * Copyright (c) 2013 Qualcomm Atheros, Inc.
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:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
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
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.
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.
36 * @ingroup adf_net_public
37 * @file adf_net_types.h
38 * This file defines types used in the networking stack abstraction.
41 #ifndef _ADF_NET_TYPES_H
42 #define _ADF_NET_TYPES_H
47 * @brief These control/get info from the device
49 #define ADF_NET_CMD(_x) \
50 ADF_NET_CMD_GET_##_x, \
54 * @brief Get/Set commands from anet to adf_drv
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),
63 ADF_NET_CMD_GET_DMA_INFO,
64 ADF_NET_CMD_GET_OFFLOAD_CAP,
65 ADF_NET_CMD_GET_STATS,
68 ADF_NET_CMD_SET_MCAST,
69 ADF_NET_CMD_GET_MCAST_CAP
75 * @brief Indicates what features are supported by the interface.
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)
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)
92 #define ADF_NET_LINK_SUPP_1000 (ADF_NET_LINK_SUPP_100 | \
93 ADF_NET_LINK_SUPP_1000baseT_Full)
96 * @brief Indicates what features are advertised by the interface.
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)
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)
113 #define ADF_NET_LINK_ADV_1000 (ADF_NET_LINK_ADV_100 | \
114 ADF_NET_LINK_ADV_1000baseT_Full)
117 * @brief The forced/current speed/duplex/autoneg
119 #define ADF_NET_LINK_SPEED_10 10
120 #define ADF_NET_LINK_SPEED_100 100
121 #define ADF_NET_LINK_SPEED_1000 1000
123 #define ADF_NET_LINK_DUPLEX_HALF 0x00
124 #define ADF_NET_LINK_DUPLEX_FULL 0x01
126 #define ADF_NET_LINK_AUTONEG_DISABLE 0x00
127 #define ADF_NET_LINK_AUTONEG_ENABLE 0x01
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
135 * @brief link info capability/parameters for the device
136 * Note the flags below
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;
146 typedef struct adf_net_ethaddr{
147 a_uint8_t addr[ADF_NET_ETH_LEN];
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 */
156 #if defined (ADF_LITTLE_ENDIAN_MACHINE)
159 #elif defined (ADF_BIG_ENDIAN_MACHINE)
160 a_uint8_t ip_version:4,
169 a_uint16_t ip_frag_off;
175 /*The options start here. */
181 typedef struct adf_net_vlanhdr{
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*/
196 typedef struct adf_net_vid{
197 #if defined (ADF_LITTLE_ENDIAN_MACHINE)
200 #elif defined (ADF_BIG_ENDIAN_MACHINE)
210 * @brief Command for setting ring paramters.
213 a_uint32_t rx_bufsize; /*Ro field. For shim's that maintain a pool*/
216 }adf_net_cmd_ring_info_t;
219 * @brief Whether the interface is polled or not. If so, the polling bias (number of
220 * packets it wants to process per invocation
225 }adf_net_cmd_poll_info_t;
228 * @brief Basic device info
231 a_uint8_t if_name[ADF_NET_IF_NAME_SIZE];
232 a_uint8_t dev_addr[ADF_NET_MAC_ADDR_MAX_LEN];
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;
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
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;
253 adf_net_cksum_type_t tx_cksum;
254 adf_net_cksum_type_t rx_cksum;
255 }adf_net_cksum_info_t;
257 typedef adf_net_cksum_info_t adf_net_cmd_cksum_info_t; /*XXX needed?*/
260 * @brief Command for set/unset vid
262 typedef a_uint16_t adf_net_cmd_vid_t ; /*get/set vlan id*/
266 ADF_NET_TSO_IPV4, /**< for tsp ipv4 only*/
267 ADF_NET_TSO_ALL, /**< ip4 & ipv6*/
271 * @brief Command for getting offloading capabilities of a device
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;
280 * @brief Command for getting general stats from a device
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;
293 typedef enum adf_net_cmd_mcast_cap{
296 }adf_net_cmd_mcast_cap_t;
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;
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;
317 * @brief For polled devices, adf_drv responds with one of the following status in
322 ADF_NET_POLL_NOT_DONE,
324 }adf_net_poll_resp_t;
327 * @brief For recieve checksum API
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;
336 adf_nbuf_rx_cksum_type_t result;
338 }adf_nbuf_rx_cksum_t;
341 * @brief For TCP large Segment Offload
344 adf_net_tso_type_t type;
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 =
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;
375 #endif /*_ADF_NET_TYPES_H*/