]> Pileus Git - ~andy/linux/blob - drivers/net/wireless/brcm80211/brcmfmac/dhd.h
{xfrm,pktgen} Fix compiling error when CONFIG_XFRM is not set
[~andy/linux] / drivers / net / wireless / brcm80211 / brcmfmac / dhd.h
1 /*
2  * Copyright (c) 2010 Broadcom Corporation
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 ANY
11  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 /****************
18  * Common types *
19  */
20
21 #ifndef _BRCMF_H_
22 #define _BRCMF_H_
23
24 #define BRCMF_VERSION_STR               "4.218.248.5"
25
26 #include "fweh.h"
27
28 #define TOE_TX_CSUM_OL          0x00000001
29 #define TOE_RX_CSUM_OL          0x00000002
30
31 /* For supporting multiple interfaces */
32 #define BRCMF_MAX_IFS   16
33
34 #define DOT11_MAX_DEFAULT_KEYS  4
35
36 /* Small, medium and maximum buffer size for dcmd
37  */
38 #define BRCMF_DCMD_SMLEN        256
39 #define BRCMF_DCMD_MEDLEN       1536
40 #define BRCMF_DCMD_MAXLEN       8192
41
42 #define BRCMF_AMPDU_RX_REORDER_MAXFLOWS         256
43
44 /* Length of firmware version string stored for
45  * ethtool driver info which uses 32 bytes as well.
46  */
47 #define BRCMF_DRIVER_FIRMWARE_VERSION_LEN       32
48
49 /* Bus independent dongle command */
50 struct brcmf_dcmd {
51         uint cmd;               /* common dongle cmd definition */
52         void *buf;              /* pointer to user buffer */
53         uint len;               /* length of user buffer */
54         u8 set;                 /* get or set request (optional) */
55         uint used;              /* bytes read or written (optional) */
56         uint needed;            /* bytes needed (optional) */
57 };
58
59 /**
60  * struct brcmf_ampdu_rx_reorder - AMPDU receive reorder info
61  *
62  * @pktslots: dynamic allocated array for ordering AMPDU packets.
63  * @flow_id: AMPDU flow identifier.
64  * @cur_idx: last AMPDU index from firmware.
65  * @exp_idx: expected next AMPDU index.
66  * @max_idx: maximum amount of packets per AMPDU.
67  * @pend_pkts: number of packets currently in @pktslots.
68  */
69 struct brcmf_ampdu_rx_reorder {
70         struct sk_buff **pktslots;
71         u8 flow_id;
72         u8 cur_idx;
73         u8 exp_idx;
74         u8 max_idx;
75         u8 pend_pkts;
76 };
77
78 /* Forward decls for struct brcmf_pub (see below) */
79 struct brcmf_proto;     /* device communication protocol info */
80 struct brcmf_cfg80211_dev; /* cfg80211 device info */
81 struct brcmf_fws_info; /* firmware signalling info */
82
83 /* Common structure for module and instance linkage */
84 struct brcmf_pub {
85         /* Linkage ponters */
86         struct brcmf_bus *bus_if;
87         struct brcmf_proto *proto;
88         struct brcmf_cfg80211_info *config;
89
90         /* Internal brcmf items */
91         uint hdrlen;            /* Total BRCMF header length (proto + bus) */
92         uint rxsz;              /* Rx buffer size bus module should use */
93         u8 wme_dp;              /* wme discard priority */
94
95         /* Dongle media info */
96         char fwver[BRCMF_DRIVER_FIRMWARE_VERSION_LEN];
97         u8 mac[ETH_ALEN];               /* MAC address obtained from dongle */
98
99         /* Multicast data packets sent to dongle */
100         unsigned long tx_multicast;
101
102         struct brcmf_if *iflist[BRCMF_MAX_IFS];
103
104         struct mutex proto_block;
105         unsigned char proto_buf[BRCMF_DCMD_MAXLEN];
106
107         struct brcmf_fweh_info fweh;
108
109         struct brcmf_fws_info *fws;
110
111         struct brcmf_ampdu_rx_reorder
112                 *reorder_flows[BRCMF_AMPDU_RX_REORDER_MAXFLOWS];
113 #ifdef DEBUG
114         struct dentry *dbgfs_dir;
115 #endif
116 };
117
118 /* forward declarations */
119 struct brcmf_cfg80211_vif;
120 struct brcmf_fws_mac_descriptor;
121
122 /**
123  * enum brcmf_netif_stop_reason - reason for stopping netif queue.
124  *
125  * @BRCMF_NETIF_STOP_REASON_FWS_FC:
126  *      netif stopped due to firmware signalling flow control.
127  * @BRCMF_NETIF_STOP_REASON_BLOCK_BUS:
128  *      netif stopped due to bus blocking.
129  */
130 enum brcmf_netif_stop_reason {
131         BRCMF_NETIF_STOP_REASON_FWS_FC = 1,
132         BRCMF_NETIF_STOP_REASON_BLOCK_BUS = 2
133 };
134
135 /**
136  * struct brcmf_if - interface control information.
137  *
138  * @drvr: points to device related information.
139  * @vif: points to cfg80211 specific interface information.
140  * @ndev: associated network device.
141  * @stats: interface specific network statistics.
142  * @setmacaddr_work: worker object for setting mac address.
143  * @multicast_work: worker object for multicast provisioning.
144  * @fws_desc: interface specific firmware-signalling descriptor.
145  * @ifidx: interface index in device firmware.
146  * @bssidx: index of bss associated with this interface.
147  * @mac_addr: assigned mac address.
148  * @netif_stop: bitmap indicates reason why netif queues are stopped.
149  * @netif_stop_lock: spinlock for update netif_stop from multiple sources.
150  * @pend_8021x_cnt: tracks outstanding number of 802.1x frames.
151  * @pend_8021x_wait: used for signalling change in count.
152  */
153 struct brcmf_if {
154         struct brcmf_pub *drvr;
155         struct brcmf_cfg80211_vif *vif;
156         struct net_device *ndev;
157         struct net_device_stats stats;
158         struct work_struct setmacaddr_work;
159         struct work_struct multicast_work;
160         struct brcmf_fws_mac_descriptor *fws_desc;
161         int ifidx;
162         s32 bssidx;
163         u8 mac_addr[ETH_ALEN];
164         u8 netif_stop;
165         spinlock_t netif_stop_lock;
166         atomic_t pend_8021x_cnt;
167         wait_queue_head_t pend_8021x_wait;
168 };
169
170 struct brcmf_skb_reorder_data {
171         u8 *reorder;
172 };
173
174 int brcmf_netdev_wait_pend8021x(struct net_device *ndev);
175
176 /* Return pointer to interface name */
177 char *brcmf_ifname(struct brcmf_pub *drvr, int idx);
178
179 int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked);
180 struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx, s32 ifidx,
181                               char *name, u8 *mac_addr);
182 void brcmf_del_if(struct brcmf_pub *drvr, s32 bssidx);
183 void brcmf_txflowblock_if(struct brcmf_if *ifp,
184                           enum brcmf_netif_stop_reason reason, bool state);
185 u32 brcmf_get_chip_info(struct brcmf_if *ifp);
186 void brcmf_txfinalize(struct brcmf_pub *drvr, struct sk_buff *txp,
187                       bool success);
188
189 /* Sets dongle media info (drv_version, mac address). */
190 int brcmf_c_preinit_dcmds(struct brcmf_if *ifp);
191
192 #endif                          /* _BRCMF_H_ */