nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 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 #ifndef BRCMFMAC_BUS_H
18 #define BRCMFMAC_BUS_H
19  
20 #include "debug.h"
21  
22 /* IDs of the 6 default common rings of msgbuf protocol */
23 #define BRCMF_H2D_MSGRING_CONTROL_SUBMIT 0
24 #define BRCMF_H2D_MSGRING_RXPOST_SUBMIT 1
25 #define BRCMF_D2H_MSGRING_CONTROL_COMPLETE 2
26 #define BRCMF_D2H_MSGRING_TX_COMPLETE 3
27 #define BRCMF_D2H_MSGRING_RX_COMPLETE 4
28  
29 #define BRCMF_NROF_H2D_COMMON_MSGRINGS 2
30 #define BRCMF_NROF_D2H_COMMON_MSGRINGS 3
31 #define BRCMF_NROF_COMMON_MSGRINGS (BRCMF_NROF_H2D_COMMON_MSGRINGS + \
32 BRCMF_NROF_D2H_COMMON_MSGRINGS)
33  
34 /* The level of bus communication with the dongle */
35 enum brcmf_bus_state {
36 BRCMF_BUS_DOWN, /* Not ready for frame transfers */
37 BRCMF_BUS_UP /* Ready for frame transfers */
38 };
39  
40 /* The level of bus communication with the dongle */
41 enum brcmf_bus_protocol_type {
42 BRCMF_PROTO_BCDC,
43 BRCMF_PROTO_MSGBUF
44 };
45  
46 struct brcmf_mp_device;
47  
48 struct brcmf_bus_dcmd {
49 char *name;
50 char *param;
51 int param_len;
52 struct list_head list;
53 };
54  
55 /**
56 * struct brcmf_bus_ops - bus callback operations.
57 *
58 * @preinit: execute bus/device specific dongle init commands (optional).
59 * @init: prepare for communication with dongle.
60 * @stop: clear pending frames, disable data flow.
61 * @txdata: send a data frame to the dongle. When the data
62 * has been transferred, the common driver must be
63 * notified using brcmf_txcomplete(). The common
64 * driver calls this function with interrupts
65 * disabled.
66 * @txctl: transmit a control request message to dongle.
67 * @rxctl: receive a control response message from dongle.
68 * @gettxq: obtain a reference of bus transmit queue (optional).
69 * @wowl_config: specify if dongle is configured for wowl when going to suspend
70 * @get_ramsize: obtain size of device memory.
71 * @get_memdump: obtain device memory dump in provided buffer.
72 * @get_fwname: obtain firmware name.
73 *
74 * This structure provides an abstract interface towards the
75 * bus specific driver. For control messages to common driver
76 * will assure there is only one active transaction. Unless
77 * indicated otherwise these callbacks are mandatory.
78 */
79 struct brcmf_bus_ops {
80 int (*preinit)(struct device *dev);
81 void (*stop)(struct device *dev);
82 int (*txdata)(struct device *dev, struct sk_buff *skb);
83 int (*txctl)(struct device *dev, unsigned char *msg, uint len);
84 int (*rxctl)(struct device *dev, unsigned char *msg, uint len);
85 struct pktq * (*gettxq)(struct device *dev);
86 void (*wowl_config)(struct device *dev, bool enabled);
87 size_t (*get_ramsize)(struct device *dev);
88 int (*get_memdump)(struct device *dev, void *data, size_t len);
89 int (*get_fwname)(struct device *dev, uint chip, uint chiprev,
90 unsigned char *fw_name);
91 };
92  
93  
94 /**
95 * struct brcmf_bus_msgbuf - bus ringbuf if in case of msgbuf.
96 *
97 * @commonrings: commonrings which are always there.
98 * @flowrings: commonrings which are dynamically created and destroyed for data.
99 * @rx_dataoffset: if set then all rx data has this this offset.
100 * @max_rxbufpost: maximum number of buffers to post for rx.
101 * @nrof_flowrings: number of flowrings.
102 */
103 struct brcmf_bus_msgbuf {
104 struct brcmf_commonring *commonrings[BRCMF_NROF_COMMON_MSGRINGS];
105 struct brcmf_commonring **flowrings;
106 u32 rx_dataoffset;
107 u32 max_rxbufpost;
108 u32 nrof_flowrings;
109 };
110  
111  
112 /**
113 * struct brcmf_bus - interface structure between common and bus layer
114 *
115 * @bus_priv: pointer to private bus device.
116 * @proto_type: protocol type, bcdc or msgbuf
117 * @dev: device pointer of bus device.
118 * @drvr: public driver information.
119 * @state: operational state of the bus interface.
120 * @maxctl: maximum size for rxctl request message.
121 * @tx_realloc: number of tx packets realloced for headroom.
122 * @dstats: dongle-based statistical data.
123 * @dcmd_list: bus/device specific dongle initialization commands.
124 * @chip: device identifier of the dongle chip.
125 * @wowl_supported: is wowl supported by bus driver.
126 * @chiprev: revision of the dongle chip.
127 */
128 struct brcmf_bus {
129 union {
130 struct brcmf_sdio_dev *sdio;
131 struct brcmf_usbdev *usb;
132 struct brcmf_pciedev *pcie;
133 } bus_priv;
134 enum brcmf_bus_protocol_type proto_type;
135 struct device *dev;
136 struct brcmf_pub *drvr;
137 enum brcmf_bus_state state;
138 uint maxctl;
139 unsigned long tx_realloc;
140 u32 chip;
141 u32 chiprev;
142 bool always_use_fws_queue;
143 bool wowl_supported;
144  
145 const struct brcmf_bus_ops *ops;
146 struct brcmf_bus_msgbuf *msgbuf;
147 };
148  
149 /*
150 * callback wrappers
151 */
152 static inline int brcmf_bus_preinit(struct brcmf_bus *bus)
153 {
154 if (!bus->ops->preinit)
155 return 0;
156 return bus->ops->preinit(bus->dev);
157 }
158  
159 static inline void brcmf_bus_stop(struct brcmf_bus *bus)
160 {
161 bus->ops->stop(bus->dev);
162 }
163  
164 static inline int brcmf_bus_txdata(struct brcmf_bus *bus, struct sk_buff *skb)
165 {
166 return bus->ops->txdata(bus->dev, skb);
167 }
168  
169 static inline
170 int brcmf_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint len)
171 {
172 return bus->ops->txctl(bus->dev, msg, len);
173 }
174  
175 static inline
176 int brcmf_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint len)
177 {
178 return bus->ops->rxctl(bus->dev, msg, len);
179 }
180  
181 static inline
182 struct pktq *brcmf_bus_gettxq(struct brcmf_bus *bus)
183 {
184 if (!bus->ops->gettxq)
185 return ERR_PTR(-ENOENT);
186  
187 return bus->ops->gettxq(bus->dev);
188 }
189  
190 static inline
191 void brcmf_bus_wowl_config(struct brcmf_bus *bus, bool enabled)
192 {
193 if (bus->ops->wowl_config)
194 bus->ops->wowl_config(bus->dev, enabled);
195 }
196  
197 static inline size_t brcmf_bus_get_ramsize(struct brcmf_bus *bus)
198 {
199 if (!bus->ops->get_ramsize)
200 return 0;
201  
202 return bus->ops->get_ramsize(bus->dev);
203 }
204  
205 static inline
206 int brcmf_bus_get_memdump(struct brcmf_bus *bus, void *data, size_t len)
207 {
208 if (!bus->ops->get_memdump)
209 return -EOPNOTSUPP;
210  
211 return bus->ops->get_memdump(bus->dev, data, len);
212 }
213  
214 static inline
215 int brcmf_bus_get_fwname(struct brcmf_bus *bus, uint chip, uint chiprev,
216 unsigned char *fw_name)
217 {
218 if (!bus->ops->get_fwname)
219 return -EOPNOTSUPP;
220  
221 return bus->ops->get_fwname(bus->dev, chip, chiprev, fw_name);
222 }
223  
224 /*
225 * interface functions from common layer
226 */
227  
228 bool brcmf_c_prec_enq(struct device *dev, struct pktq *q, struct sk_buff *pkt,
229 int prec);
230  
231 /* Receive frame for delivery to OS. Callee disposes of rxp. */
232 void brcmf_rx_frame(struct device *dev, struct sk_buff *rxp, bool handle_event);
233 /* Receive async event packet from firmware. Callee disposes of rxp. */
234 void brcmf_rx_event(struct device *dev, struct sk_buff *rxp);
235  
236 /* Indication from bus module regarding presence/insertion of dongle. */
237 int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings);
238 /* Indication from bus module regarding removal/absence of dongle */
239 void brcmf_detach(struct device *dev);
240 /* Indication from bus module that dongle should be reset */
241 void brcmf_dev_reset(struct device *dev);
242 /* Indication from bus module to change flow-control state */
243 void brcmf_txflowblock(struct device *dev, bool state);
244  
245 /* Notify the bus has transferred the tx packet to firmware */
246 void brcmf_txcomplete(struct device *dev, struct sk_buff *txp, bool success);
247  
248 /* Configure the "global" bus state used by upper layers */
249 void brcmf_bus_change_state(struct brcmf_bus *bus, enum brcmf_bus_state state);
250  
251 int brcmf_bus_start(struct device *dev);
252 s32 brcmf_iovar_data_set(struct device *dev, char *name, void *data, u32 len);
253 void brcmf_bus_add_txhdrlen(struct device *dev, uint len);
254  
255 #ifdef CONFIG_BRCMFMAC_SDIO
256 void brcmf_sdio_exit(void);
257 void brcmf_sdio_init(void);
258 void brcmf_sdio_register(void);
259 #endif
260 #ifdef CONFIG_BRCMFMAC_USB
261 void brcmf_usb_exit(void);
262 void brcmf_usb_register(void);
263 #endif
264  
265 #endif /* BRCMFMAC_BUS_H */