dhd.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. * Common types *
  18. */
  19. #ifndef _BRCMF_H_
  20. #define _BRCMF_H_
  21. #define BRCMF_VERSION_STR "4.218.248.5"
  22. #include "fweh.h"
  23. #define TOE_TX_CSUM_OL 0x00000001
  24. #define TOE_RX_CSUM_OL 0x00000002
  25. /* For supporting multiple interfaces */
  26. #define BRCMF_MAX_IFS 16
  27. #define DOT11_MAX_DEFAULT_KEYS 4
  28. /* Small, medium and maximum buffer size for dcmd
  29. */
  30. #define BRCMF_DCMD_SMLEN 256
  31. #define BRCMF_DCMD_MEDLEN 1536
  32. #define BRCMF_DCMD_MAXLEN 8192
  33. #define BRCMF_AMPDU_RX_REORDER_MAXFLOWS 256
  34. /* Length of firmware version string stored for
  35. * ethtool driver info which uses 32 bytes as well.
  36. */
  37. #define BRCMF_DRIVER_FIRMWARE_VERSION_LEN 32
  38. /* Bus independent dongle command */
  39. struct brcmf_dcmd {
  40. uint cmd; /* common dongle cmd definition */
  41. void *buf; /* pointer to user buffer */
  42. uint len; /* length of user buffer */
  43. u8 set; /* get or set request (optional) */
  44. uint used; /* bytes read or written (optional) */
  45. uint needed; /* bytes needed (optional) */
  46. };
  47. /**
  48. * struct brcmf_ampdu_rx_reorder - AMPDU receive reorder info
  49. *
  50. * @pktslots: dynamic allocated array for ordering AMPDU packets.
  51. * @flow_id: AMPDU flow identifier.
  52. * @cur_idx: last AMPDU index from firmware.
  53. * @exp_idx: expected next AMPDU index.
  54. * @max_idx: maximum amount of packets per AMPDU.
  55. * @pend_pkts: number of packets currently in @pktslots.
  56. */
  57. struct brcmf_ampdu_rx_reorder {
  58. struct sk_buff **pktslots;
  59. u8 flow_id;
  60. u8 cur_idx;
  61. u8 exp_idx;
  62. u8 max_idx;
  63. u8 pend_pkts;
  64. };
  65. /* Forward decls for struct brcmf_pub (see below) */
  66. struct brcmf_proto; /* device communication protocol info */
  67. struct brcmf_cfg80211_dev; /* cfg80211 device info */
  68. struct brcmf_fws_info; /* firmware signalling info */
  69. /* Common structure for module and instance linkage */
  70. struct brcmf_pub {
  71. /* Linkage ponters */
  72. struct brcmf_bus *bus_if;
  73. struct brcmf_proto *proto;
  74. struct brcmf_cfg80211_info *config;
  75. /* Internal brcmf items */
  76. uint hdrlen; /* Total BRCMF header length (proto + bus) */
  77. uint rxsz; /* Rx buffer size bus module should use */
  78. u8 wme_dp; /* wme discard priority */
  79. /* Dongle media info */
  80. char fwver[BRCMF_DRIVER_FIRMWARE_VERSION_LEN];
  81. u8 mac[ETH_ALEN]; /* MAC address obtained from dongle */
  82. /* Multicast data packets sent to dongle */
  83. unsigned long tx_multicast;
  84. struct brcmf_if *iflist[BRCMF_MAX_IFS];
  85. struct mutex proto_block;
  86. unsigned char proto_buf[BRCMF_DCMD_MAXLEN];
  87. struct brcmf_fweh_info fweh;
  88. struct brcmf_fws_info *fws;
  89. struct brcmf_ampdu_rx_reorder
  90. *reorder_flows[BRCMF_AMPDU_RX_REORDER_MAXFLOWS];
  91. #ifdef DEBUG
  92. struct dentry *dbgfs_dir;
  93. #endif
  94. };
  95. /* forward declarations */
  96. struct brcmf_cfg80211_vif;
  97. struct brcmf_fws_mac_descriptor;
  98. /**
  99. * enum brcmf_netif_stop_reason - reason for stopping netif queue.
  100. *
  101. * @BRCMF_NETIF_STOP_REASON_FWS_FC:
  102. * netif stopped due to firmware signalling flow control.
  103. * @BRCMF_NETIF_STOP_REASON_BLOCK_BUS:
  104. * netif stopped due to bus blocking.
  105. */
  106. enum brcmf_netif_stop_reason {
  107. BRCMF_NETIF_STOP_REASON_FWS_FC = 1,
  108. BRCMF_NETIF_STOP_REASON_BLOCK_BUS = 2
  109. };
  110. /**
  111. * struct brcmf_if - interface control information.
  112. *
  113. * @drvr: points to device related information.
  114. * @vif: points to cfg80211 specific interface information.
  115. * @ndev: associated network device.
  116. * @stats: interface specific network statistics.
  117. * @setmacaddr_work: worker object for setting mac address.
  118. * @multicast_work: worker object for multicast provisioning.
  119. * @fws_desc: interface specific firmware-signalling descriptor.
  120. * @ifidx: interface index in device firmware.
  121. * @bssidx: index of bss associated with this interface.
  122. * @mac_addr: assigned mac address.
  123. * @netif_stop: bitmap indicates reason why netif queues are stopped.
  124. * @netif_stop_lock: spinlock for update netif_stop from multiple sources.
  125. * @pend_8021x_cnt: tracks outstanding number of 802.1x frames.
  126. * @pend_8021x_wait: used for signalling change in count.
  127. */
  128. struct brcmf_if {
  129. struct brcmf_pub *drvr;
  130. struct brcmf_cfg80211_vif *vif;
  131. struct net_device *ndev;
  132. struct net_device_stats stats;
  133. struct work_struct setmacaddr_work;
  134. struct work_struct multicast_work;
  135. struct brcmf_fws_mac_descriptor *fws_desc;
  136. int ifidx;
  137. s32 bssidx;
  138. u8 mac_addr[ETH_ALEN];
  139. u8 netif_stop;
  140. spinlock_t netif_stop_lock;
  141. atomic_t pend_8021x_cnt;
  142. wait_queue_head_t pend_8021x_wait;
  143. };
  144. struct brcmf_skb_reorder_data {
  145. u8 *reorder;
  146. };
  147. int brcmf_netdev_wait_pend8021x(struct net_device *ndev);
  148. /* Return pointer to interface name */
  149. char *brcmf_ifname(struct brcmf_pub *drvr, int idx);
  150. int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked);
  151. struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx, s32 ifidx,
  152. char *name, u8 *mac_addr);
  153. void brcmf_del_if(struct brcmf_pub *drvr, s32 bssidx);
  154. void brcmf_txflowblock_if(struct brcmf_if *ifp,
  155. enum brcmf_netif_stop_reason reason, bool state);
  156. u32 brcmf_get_chip_info(struct brcmf_if *ifp);
  157. void brcmf_txfinalize(struct brcmf_pub *drvr, struct sk_buff *txp,
  158. bool success);
  159. /* Sets dongle media info (drv_version, mac address). */
  160. int brcmf_c_preinit_dcmds(struct brcmf_if *ifp);
  161. #endif /* _BRCMF_H_ */