blob: dc022e336b8999d11d56543a4da90e9d815279a0 [file] [log] [blame]
Arend van Spriel5b435de2011-10-05 13:19:03 +02001/*
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 _BRCMF_BUS_H_
18#define _BRCMF_BUS_H_
19
Franky Lina8a363a2011-12-16 18:37:13 -080020/* The level of bus communication with the dongle */
21enum brcmf_bus_state {
22 BRCMF_BUS_DOWN, /* Not ready for frame transfers */
23 BRCMF_BUS_LOAD, /* Download access only (CPU reset) */
24 BRCMF_BUS_DATA /* Ready for frame transfers */
25};
26
27struct dngl_stats {
28 unsigned long rx_packets; /* total packets received */
29 unsigned long tx_packets; /* total packets transmitted */
30 unsigned long rx_bytes; /* total bytes received */
31 unsigned long tx_bytes; /* total bytes transmitted */
32 unsigned long rx_errors; /* bad packets received */
33 unsigned long tx_errors; /* packet transmit problems */
34 unsigned long rx_dropped; /* packets dropped by dongle */
35 unsigned long tx_dropped; /* packets dropped by dongle */
36 unsigned long multicast; /* multicast packets received */
37};
38
39/* interface structure between common and bus layer */
40struct brcmf_bus {
41 u8 type; /* bus type */
42 void *bus_priv; /* pointer to bus private structure */
43 void *drvr; /* pointer to driver pub structure brcmf_pub */
44 enum brcmf_bus_state state;
45 uint maxctl; /* Max size rxctl request from proto to bus */
46 bool drvr_up; /* Status flag of driver up/down */
47 unsigned long tx_realloc; /* Tx packets realloced for headroom */
48 struct dngl_stats dstats; /* Stats for dongle-based data */
49 u8 align; /* bus alignment requirement */
50
51 /* interface functions pointers */
52 /* Stop bus module: clear pending frames, disable data flow */
53 void (*brcmf_bus_stop)(struct device *);
54};
55
56/*
57 * interface functions from common layer
58 */
59
60/* Remove any protocol-specific data header. */
61extern int brcmf_proto_hdrpull(struct device *dev, int *ifidx,
62 struct sk_buff *rxp);
63
64extern bool brcmf_c_prec_enq(struct device *dev, struct pktq *q,
65 struct sk_buff *pkt, int prec);
66
67/* Receive frame for delivery to OS. Callee disposes of rxp. */
68extern void brcmf_rx_frame(struct device *dev, int ifidx,
69 struct sk_buff_head *rxlist);
70static inline void brcmf_rx_packet(struct device *dev, int ifidx,
71 struct sk_buff *pkt)
72{
73 struct sk_buff_head q;
74
75 skb_queue_head_init(&q);
76 skb_queue_tail(&q, pkt);
77 brcmf_rx_frame(dev, ifidx, &q);
78}
79
80/* Indication from bus module regarding presence/insertion of dongle. */
81extern int brcmf_attach(uint bus_hdrlen, struct device *dev);
82/* Indication from bus module regarding removal/absence of dongle */
83extern void brcmf_detach(struct device *dev);
84
85/* Indication from bus module to change flow-control state */
86extern void brcmf_txflowcontrol(struct device *dev, int ifidx, bool on);
87
88/* Notify tx completion */
89extern void brcmf_txcomplete(struct device *dev, struct sk_buff *txp,
90 bool success);
91
92extern int brcmf_bus_start(struct device *dev);
93
94extern int brcmf_add_if(struct device *dev, int ifidx,
95 char *name, u8 *mac_addr);
96
Arend van Spriel5b435de2011-10-05 13:19:03 +020097/*
98 * Exported from brcmf bus module (brcmf_usb, brcmf_sdio)
99 */
Arend van Spriel5b435de2011-10-05 13:19:03 +0200100/* Initialize bus module: prepare for communication w/dongle */
Franky Linfa20b912011-11-22 17:21:57 -0800101extern int brcmf_sdbrcm_bus_init(struct device *dev);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200102
103/* Send a data frame to the dongle. Callee disposes of txp. */
Franky Linbf347bb2011-11-22 17:21:56 -0800104extern int brcmf_sdbrcm_bus_txdata(struct device *dev, struct sk_buff *txp);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200105
106/* Send/receive a control message to/from the dongle.
107 * Expects caller to enforce a single outstanding transaction.
108 */
109extern int
Franky Lin47a1ce72011-11-22 17:21:55 -0800110brcmf_sdbrcm_bus_txctl(struct device *dev, unsigned char *msg, uint msglen);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200111
112extern int
Franky Lin532cdd32011-11-22 17:21:54 -0800113brcmf_sdbrcm_bus_rxctl(struct device *dev, unsigned char *msg, uint msglen);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200114#endif /* _BRCMF_BUS_H_ */