core.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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 BRCMFMAC_CORE_H
  20. #define BRCMFMAC_CORE_H
  21. #include "fweh.h"
  22. #define TOE_TX_CSUM_OL 0x00000001
  23. #define TOE_RX_CSUM_OL 0x00000002
  24. /* For supporting multiple interfaces */
  25. #define BRCMF_MAX_IFS 16
  26. /* Small, medium and maximum buffer size for dcmd
  27. */
  28. #define BRCMF_DCMD_SMLEN 256
  29. #define BRCMF_DCMD_MEDLEN 1536
  30. #define BRCMF_DCMD_MAXLEN 8192
  31. /* IOCTL from host to device are limited in lenght. A device can only handle
  32. * ethernet frame size. This limitation is to be applied by protocol layer.
  33. */
  34. #define BRCMF_TX_IOCTL_MAX_MSG_SIZE (ETH_FRAME_LEN+ETH_FCS_LEN)
  35. #define BRCMF_AMPDU_RX_REORDER_MAXFLOWS 256
  36. /* Length of firmware version string stored for
  37. * ethtool driver info which uses 32 bytes as well.
  38. */
  39. #define BRCMF_DRIVER_FIRMWARE_VERSION_LEN 32
  40. /**
  41. * struct brcmf_ampdu_rx_reorder - AMPDU receive reorder info
  42. *
  43. * @pktslots: dynamic allocated array for ordering AMPDU packets.
  44. * @flow_id: AMPDU flow identifier.
  45. * @cur_idx: last AMPDU index from firmware.
  46. * @exp_idx: expected next AMPDU index.
  47. * @max_idx: maximum amount of packets per AMPDU.
  48. * @pend_pkts: number of packets currently in @pktslots.
  49. */
  50. struct brcmf_ampdu_rx_reorder {
  51. struct sk_buff **pktslots;
  52. u8 flow_id;
  53. u8 cur_idx;
  54. u8 exp_idx;
  55. u8 max_idx;
  56. u8 pend_pkts;
  57. };
  58. /* Forward decls for struct brcmf_pub (see below) */
  59. struct brcmf_proto; /* device communication protocol info */
  60. struct brcmf_cfg80211_dev; /* cfg80211 device info */
  61. struct brcmf_fws_info; /* firmware signalling info */
  62. /*
  63. * struct brcmf_rev_info
  64. *
  65. * The result field stores the error code of the
  66. * revision info request from firmware. For the
  67. * other fields see struct brcmf_rev_info_le in
  68. * fwil_types.h
  69. */
  70. struct brcmf_rev_info {
  71. int result;
  72. u32 vendorid;
  73. u32 deviceid;
  74. u32 radiorev;
  75. u32 chiprev;
  76. u32 corerev;
  77. u32 boardid;
  78. u32 boardvendor;
  79. u32 boardrev;
  80. u32 driverrev;
  81. u32 ucoderev;
  82. u32 bus;
  83. u32 chipnum;
  84. u32 phytype;
  85. u32 phyrev;
  86. u32 anarev;
  87. u32 chippkg;
  88. u32 nvramrev;
  89. };
  90. /* Common structure for module and instance linkage */
  91. struct brcmf_pub {
  92. /* Linkage ponters */
  93. struct brcmf_bus *bus_if;
  94. struct brcmf_proto *proto;
  95. struct brcmf_cfg80211_info *config;
  96. /* Internal brcmf items */
  97. uint hdrlen; /* Total BRCMF header length (proto + bus) */
  98. uint rxsz; /* Rx buffer size bus module should use */
  99. /* Dongle media info */
  100. char fwver[BRCMF_DRIVER_FIRMWARE_VERSION_LEN];
  101. u8 mac[ETH_ALEN]; /* MAC address obtained from dongle */
  102. /* Multicast data packets sent to dongle */
  103. unsigned long tx_multicast;
  104. struct brcmf_if *iflist[BRCMF_MAX_IFS];
  105. struct mutex proto_block;
  106. unsigned char proto_buf[BRCMF_DCMD_MAXLEN];
  107. struct brcmf_fweh_info fweh;
  108. struct brcmf_fws_info *fws;
  109. struct brcmf_ampdu_rx_reorder
  110. *reorder_flows[BRCMF_AMPDU_RX_REORDER_MAXFLOWS];
  111. u32 feat_flags;
  112. u32 chip_quirks;
  113. struct brcmf_rev_info revinfo;
  114. #ifdef DEBUG
  115. struct dentry *dbgfs_dir;
  116. #endif
  117. };
  118. /* forward declarations */
  119. struct brcmf_cfg80211_vif;
  120. struct brcmf_fws_mac_descriptor;
  121. /**
  122. * enum brcmf_netif_stop_reason - reason for stopping netif queue.
  123. *
  124. * @BRCMF_NETIF_STOP_REASON_FWS_FC:
  125. * netif stopped due to firmware signalling flow control.
  126. * @BRCMF_NETIF_STOP_REASON_FLOW:
  127. * netif stopped due to flowring full.
  128. */
  129. enum brcmf_netif_stop_reason {
  130. BRCMF_NETIF_STOP_REASON_FWS_FC = 1,
  131. BRCMF_NETIF_STOP_REASON_FLOW = 2
  132. };
  133. /**
  134. * struct brcmf_if - interface control information.
  135. *
  136. * @drvr: points to device related information.
  137. * @vif: points to cfg80211 specific interface information.
  138. * @ndev: associated network device.
  139. * @stats: interface specific network statistics.
  140. * @setmacaddr_work: worker object for setting mac address.
  141. * @multicast_work: worker object for multicast provisioning.
  142. * @fws_desc: interface specific firmware-signalling descriptor.
  143. * @ifidx: interface index in device firmware.
  144. * @bssidx: index of bss associated with this interface.
  145. * @mac_addr: assigned mac address.
  146. * @netif_stop: bitmap indicates reason why netif queues are stopped.
  147. * @netif_stop_lock: spinlock for update netif_stop from multiple sources.
  148. * @pend_8021x_cnt: tracks outstanding number of 802.1x frames.
  149. * @pend_8021x_wait: used for signalling change in count.
  150. */
  151. struct brcmf_if {
  152. struct brcmf_pub *drvr;
  153. struct brcmf_cfg80211_vif *vif;
  154. struct net_device *ndev;
  155. struct net_device_stats stats;
  156. struct work_struct setmacaddr_work;
  157. struct work_struct multicast_work;
  158. struct brcmf_fws_mac_descriptor *fws_desc;
  159. int ifidx;
  160. s32 bssidx;
  161. u8 mac_addr[ETH_ALEN];
  162. u8 netif_stop;
  163. spinlock_t netif_stop_lock;
  164. atomic_t pend_8021x_cnt;
  165. wait_queue_head_t pend_8021x_wait;
  166. };
  167. struct brcmf_skb_reorder_data {
  168. u8 *reorder;
  169. };
  170. int brcmf_netdev_wait_pend8021x(struct brcmf_if *ifp);
  171. /* Return pointer to interface name */
  172. char *brcmf_ifname(struct brcmf_pub *drvr, int idx);
  173. int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked);
  174. struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx, s32 ifidx,
  175. char *name, u8 *mac_addr);
  176. void brcmf_remove_interface(struct brcmf_pub *drvr, u32 bssidx);
  177. int brcmf_get_next_free_bsscfgidx(struct brcmf_pub *drvr);
  178. void brcmf_txflowblock_if(struct brcmf_if *ifp,
  179. enum brcmf_netif_stop_reason reason, bool state);
  180. void brcmf_txfinalize(struct brcmf_pub *drvr, struct sk_buff *txp, u8 ifidx,
  181. bool success);
  182. void brcmf_netif_rx(struct brcmf_if *ifp, struct sk_buff *skb);
  183. /* Sets dongle media info (drv_version, mac address). */
  184. int brcmf_c_preinit_dcmds(struct brcmf_if *ifp);
  185. #endif /* BRCMFMAC_CORE_H */