dhd_bus.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. #ifndef _BRCMF_BUS_H_
  17. #define _BRCMF_BUS_H_
  18. /* The level of bus communication with the dongle */
  19. enum brcmf_bus_state {
  20. BRCMF_BUS_DOWN, /* Not ready for frame transfers */
  21. BRCMF_BUS_LOAD, /* Download access only (CPU reset) */
  22. BRCMF_BUS_DATA /* Ready for frame transfers */
  23. };
  24. struct dngl_stats {
  25. unsigned long rx_packets; /* total packets received */
  26. unsigned long tx_packets; /* total packets transmitted */
  27. unsigned long rx_bytes; /* total bytes received */
  28. unsigned long tx_bytes; /* total bytes transmitted */
  29. unsigned long rx_errors; /* bad packets received */
  30. unsigned long tx_errors; /* packet transmit problems */
  31. unsigned long rx_dropped; /* packets dropped by dongle */
  32. unsigned long tx_dropped; /* packets dropped by dongle */
  33. unsigned long multicast; /* multicast packets received */
  34. };
  35. struct brcmf_bus_dcmd {
  36. char *name;
  37. char *param;
  38. int param_len;
  39. struct list_head list;
  40. };
  41. /* interface structure between common and bus layer */
  42. struct brcmf_bus {
  43. u8 type; /* bus type */
  44. union {
  45. struct brcmf_sdio_dev *sdio;
  46. struct brcmf_usbdev *usb;
  47. } bus_priv;
  48. struct brcmf_pub *drvr; /* pointer to driver pub structure brcmf_pub */
  49. enum brcmf_bus_state state;
  50. uint maxctl; /* Max size rxctl request from proto to bus */
  51. bool drvr_up; /* Status flag of driver up/down */
  52. unsigned long tx_realloc; /* Tx packets realloced for headroom */
  53. struct dngl_stats dstats; /* Stats for dongle-based data */
  54. u8 align; /* bus alignment requirement */
  55. struct list_head dcmd_list;
  56. /* interface functions pointers */
  57. /* Stop bus module: clear pending frames, disable data flow */
  58. void (*brcmf_bus_stop)(struct device *);
  59. /* Initialize bus module: prepare for communication w/dongle */
  60. int (*brcmf_bus_init)(struct device *);
  61. /* Send a data frame to the dongle. Callee disposes of txp. */
  62. int (*brcmf_bus_txdata)(struct device *, struct sk_buff *);
  63. /* Send/receive a control message to/from the dongle.
  64. * Expects caller to enforce a single outstanding transaction.
  65. */
  66. int (*brcmf_bus_txctl)(struct device *, unsigned char *, uint);
  67. int (*brcmf_bus_rxctl)(struct device *, unsigned char *, uint);
  68. };
  69. /*
  70. * interface functions from common layer
  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. extern bool brcmf_c_prec_enq(struct device *dev, struct pktq *q,
  76. struct sk_buff *pkt, int prec);
  77. /* Receive frame for delivery to OS. Callee disposes of rxp. */
  78. extern void brcmf_rx_frame(struct device *dev, int ifidx,
  79. struct sk_buff_head *rxlist);
  80. static inline void brcmf_rx_packet(struct device *dev, int ifidx,
  81. struct sk_buff *pkt)
  82. {
  83. struct sk_buff_head q;
  84. skb_queue_head_init(&q);
  85. skb_queue_tail(&q, pkt);
  86. brcmf_rx_frame(dev, ifidx, &q);
  87. }
  88. /* Indication from bus module regarding presence/insertion of dongle. */
  89. extern int brcmf_attach(uint bus_hdrlen, struct device *dev);
  90. /* Indication from bus module regarding removal/absence of dongle */
  91. extern void brcmf_detach(struct device *dev);
  92. /* Indication from bus module to change flow-control state */
  93. extern void brcmf_txflowcontrol(struct device *dev, int ifidx, bool on);
  94. /* Notify tx completion */
  95. extern void brcmf_txcomplete(struct device *dev, struct sk_buff *txp,
  96. bool success);
  97. extern int brcmf_bus_start(struct device *dev);
  98. extern int brcmf_add_if(struct device *dev, int ifidx,
  99. char *name, u8 *mac_addr);
  100. #ifdef CONFIG_BRCMFMAC_SDIO
  101. extern void brcmf_sdio_exit(void);
  102. extern void brcmf_sdio_init(void);
  103. #endif
  104. #ifdef CONFIG_BRCMFMAC_USB
  105. extern void brcmf_usb_exit(void);
  106. extern void brcmf_usb_init(void);
  107. #endif
  108. #endif /* _BRCMF_BUS_H_ */