Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 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 | |
Franky Lin | a8a363a | 2011-12-16 18:37:13 -0800 | [diff] [blame] | 20 | /* The level of bus communication with the dongle */ |
| 21 | enum 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 | |
| 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 | |
| 39 | /* interface structure between common and bus layer */ |
| 40 | struct brcmf_bus { |
| 41 | u8 type; /* bus type */ |
Arend van Spriel | 0a332e4 | 2012-02-09 21:09:02 +0100 | [diff] [blame] | 42 | union { |
Arend van Spriel | 0a332e4 | 2012-02-09 21:09:02 +0100 | [diff] [blame] | 43 | struct brcmf_sdio_dev *sdio; |
Arend van Spriel | 71bb244 | 2012-02-09 21:09:08 +0100 | [diff] [blame^] | 44 | struct brcmf_usbdev *usb; |
Arend van Spriel | 0a332e4 | 2012-02-09 21:09:02 +0100 | [diff] [blame] | 45 | } bus_priv; |
| 46 | struct brcmf_pub *drvr; /* pointer to driver pub structure brcmf_pub */ |
Franky Lin | a8a363a | 2011-12-16 18:37:13 -0800 | [diff] [blame] | 47 | enum brcmf_bus_state state; |
| 48 | uint maxctl; /* Max size rxctl request from proto to bus */ |
| 49 | bool drvr_up; /* Status flag of driver up/down */ |
| 50 | unsigned long tx_realloc; /* Tx packets realloced for headroom */ |
| 51 | struct dngl_stats dstats; /* Stats for dongle-based data */ |
| 52 | u8 align; /* bus alignment requirement */ |
| 53 | |
| 54 | /* interface functions pointers */ |
| 55 | /* Stop bus module: clear pending frames, disable data flow */ |
| 56 | void (*brcmf_bus_stop)(struct device *); |
Franky Lin | 99a0b8f | 2011-12-16 18:37:14 -0800 | [diff] [blame] | 57 | /* Initialize bus module: prepare for communication w/dongle */ |
| 58 | int (*brcmf_bus_init)(struct device *); |
Franky Lin | b9692d1 | 2011-12-16 18:37:15 -0800 | [diff] [blame] | 59 | /* Send a data frame to the dongle. Callee disposes of txp. */ |
| 60 | int (*brcmf_bus_txdata)(struct device *, struct sk_buff *); |
Franky Lin | fcf094f | 2011-12-16 18:37:16 -0800 | [diff] [blame] | 61 | /* Send/receive a control message to/from the dongle. |
| 62 | * Expects caller to enforce a single outstanding transaction. |
| 63 | */ |
| 64 | int (*brcmf_bus_txctl)(struct device *, unsigned char *, uint); |
| 65 | int (*brcmf_bus_rxctl)(struct device *, unsigned char *, uint); |
Franky Lin | a8a363a | 2011-12-16 18:37:13 -0800 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | /* |
| 69 | * interface functions from common layer |
| 70 | */ |
| 71 | |
| 72 | /* Remove any protocol-specific data header. */ |
| 73 | extern int brcmf_proto_hdrpull(struct device *dev, int *ifidx, |
| 74 | struct sk_buff *rxp); |
| 75 | |
| 76 | extern bool brcmf_c_prec_enq(struct device *dev, struct pktq *q, |
| 77 | struct sk_buff *pkt, int prec); |
| 78 | |
| 79 | /* Receive frame for delivery to OS. Callee disposes of rxp. */ |
| 80 | extern void brcmf_rx_frame(struct device *dev, int ifidx, |
| 81 | struct sk_buff_head *rxlist); |
| 82 | static inline void brcmf_rx_packet(struct device *dev, int ifidx, |
| 83 | struct sk_buff *pkt) |
| 84 | { |
| 85 | struct sk_buff_head q; |
| 86 | |
| 87 | skb_queue_head_init(&q); |
| 88 | skb_queue_tail(&q, pkt); |
| 89 | brcmf_rx_frame(dev, ifidx, &q); |
| 90 | } |
| 91 | |
| 92 | /* Indication from bus module regarding presence/insertion of dongle. */ |
| 93 | extern int brcmf_attach(uint bus_hdrlen, struct device *dev); |
| 94 | /* Indication from bus module regarding removal/absence of dongle */ |
| 95 | extern void brcmf_detach(struct device *dev); |
| 96 | |
| 97 | /* Indication from bus module to change flow-control state */ |
| 98 | extern void brcmf_txflowcontrol(struct device *dev, int ifidx, bool on); |
| 99 | |
| 100 | /* Notify tx completion */ |
| 101 | extern void brcmf_txcomplete(struct device *dev, struct sk_buff *txp, |
| 102 | bool success); |
| 103 | |
| 104 | extern int brcmf_bus_start(struct device *dev); |
| 105 | |
| 106 | extern int brcmf_add_if(struct device *dev, int ifidx, |
| 107 | char *name, u8 *mac_addr); |
Arend van Spriel | f3d7cdc | 2012-02-09 21:09:03 +0100 | [diff] [blame] | 108 | |
| 109 | #ifdef CONFIG_BRCMFMAC_SDIO |
| 110 | extern void brcmf_sdio_exit(void); |
| 111 | extern int brcmf_sdio_init(void); |
| 112 | #endif |
Arend van Spriel | 71bb244 | 2012-02-09 21:09:08 +0100 | [diff] [blame^] | 113 | #ifdef CONFIG_BRCMFMAC_USB |
| 114 | extern void brcmf_usb_exit(void); |
| 115 | extern int brcmf_usb_init(void); |
| 116 | #endif |
Arend van Spriel | f3d7cdc | 2012-02-09 21:09:03 +0100 | [diff] [blame] | 117 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 118 | #endif /* _BRCMF_BUS_H_ */ |