Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dhd_bus.h
Go to the documentation of this file.
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 _BRCMF_BUS_H_
18 #define _BRCMF_BUS_H_
19 
20 /* The level of bus communication with the dongle */
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 
27 struct 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 
40  char *name;
41  char *param;
42  int param_len;
43  struct list_head list;
44 };
45 
46 /* interface structure between common and bus layer */
47 struct brcmf_bus {
48  u8 type; /* bus type */
49  union {
51  struct brcmf_usbdev *usb;
52  } bus_priv;
53  struct brcmf_pub *drvr; /* pointer to driver pub structure brcmf_pub */
55  uint maxctl; /* Max size rxctl request from proto to bus */
56  bool drvr_up; /* Status flag of driver up/down */
57  unsigned long tx_realloc; /* Tx packets realloced for headroom */
58  struct dngl_stats dstats; /* Stats for dongle-based data */
59  u8 align; /* bus alignment requirement */
61 
62  /* interface functions pointers */
63  /* Stop bus module: clear pending frames, disable data flow */
64  void (*brcmf_bus_stop)(struct device *);
65  /* Initialize bus module: prepare for communication w/dongle */
66  int (*brcmf_bus_init)(struct device *);
67  /* Send a data frame to the dongle. Callee disposes of txp. */
68  int (*brcmf_bus_txdata)(struct device *, struct sk_buff *);
69  /* Send/receive a control message to/from the dongle.
70  * Expects caller to enforce a single outstanding transaction.
71  */
72  int (*brcmf_bus_txctl)(struct device *, unsigned char *, uint);
73  int (*brcmf_bus_rxctl)(struct device *, unsigned char *, uint);
74 };
75 
76 /*
77  * interface functions from common layer
78  */
79 
80 /* Remove any protocol-specific data header. */
81 extern int brcmf_proto_hdrpull(struct device *dev, int *ifidx,
82  struct sk_buff *rxp);
83 
84 extern bool brcmf_c_prec_enq(struct device *dev, struct pktq *q,
85  struct sk_buff *pkt, int prec);
86 
87 /* Receive frame for delivery to OS. Callee disposes of rxp. */
88 extern void brcmf_rx_frame(struct device *dev, int ifidx,
89  struct sk_buff_head *rxlist);
90 static inline void brcmf_rx_packet(struct device *dev, int ifidx,
91  struct sk_buff *pkt)
92 {
93  struct sk_buff_head q;
94 
95  skb_queue_head_init(&q);
96  skb_queue_tail(&q, pkt);
97  brcmf_rx_frame(dev, ifidx, &q);
98 }
99 
100 /* Indication from bus module regarding presence/insertion of dongle. */
101 extern int brcmf_attach(uint bus_hdrlen, struct device *dev);
102 /* Indication from bus module regarding removal/absence of dongle */
103 extern void brcmf_detach(struct device *dev);
104 
105 /* Indication from bus module to change flow-control state */
106 extern void brcmf_txflowblock(struct device *dev, bool state);
107 
108 /* Notify tx completion */
109 extern void brcmf_txcomplete(struct device *dev, struct sk_buff *txp,
110  bool success);
111 
112 extern int brcmf_bus_start(struct device *dev);
113 
114 extern int brcmf_add_if(struct device *dev, int ifidx,
115  char *name, u8 *mac_addr);
116 
117 #ifdef CONFIG_BRCMFMAC_SDIO
118 extern void brcmf_sdio_exit(void);
119 extern void brcmf_sdio_init(void);
120 #endif
121 #ifdef CONFIG_BRCMFMAC_USB
122 extern void brcmf_usb_exit(void);
123 extern void brcmf_usb_init(void);
124 #endif
125 
126 #endif /* _BRCMF_BUS_H_ */