core.h 6.2 KB

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