core.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. #define NDOL_MAX_ENTRIES 8
  42. /**
  43. * struct brcmf_ampdu_rx_reorder - AMPDU receive reorder info
  44. *
  45. * @pktslots: dynamic allocated array for ordering AMPDU packets.
  46. * @flow_id: AMPDU flow identifier.
  47. * @cur_idx: last AMPDU index from firmware.
  48. * @exp_idx: expected next AMPDU index.
  49. * @max_idx: maximum amount of packets per AMPDU.
  50. * @pend_pkts: number of packets currently in @pktslots.
  51. */
  52. struct brcmf_ampdu_rx_reorder {
  53. struct sk_buff **pktslots;
  54. u8 flow_id;
  55. u8 cur_idx;
  56. u8 exp_idx;
  57. u8 max_idx;
  58. u8 pend_pkts;
  59. };
  60. /* Forward decls for struct brcmf_pub (see below) */
  61. struct brcmf_proto; /* device communication protocol info */
  62. struct brcmf_fws_info; /* firmware signalling info */
  63. struct brcmf_mp_device; /* module paramateres, device specific */
  64. /*
  65. * struct brcmf_rev_info
  66. *
  67. * The result field stores the error code of the
  68. * revision info request from firmware. For the
  69. * other fields see struct brcmf_rev_info_le in
  70. * fwil_types.h
  71. */
  72. struct brcmf_rev_info {
  73. int result;
  74. u32 vendorid;
  75. u32 deviceid;
  76. u32 radiorev;
  77. u32 corerev;
  78. u32 boardid;
  79. u32 boardvendor;
  80. u32 boardrev;
  81. u32 driverrev;
  82. u32 ucoderev;
  83. u32 bus;
  84. char chipname[12];
  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 wiphy *wiphy;
  97. struct brcmf_cfg80211_info *config;
  98. /* Internal brcmf items */
  99. uint hdrlen; /* Total BRCMF header length (proto + bus) */
  100. /* Dongle media info */
  101. char fwver[BRCMF_DRIVER_FIRMWARE_VERSION_LEN];
  102. u8 mac[ETH_ALEN]; /* MAC address obtained from dongle */
  103. struct mac_address addresses[BRCMF_MAX_IFS];
  104. struct brcmf_if *iflist[BRCMF_MAX_IFS];
  105. s32 if2bss[BRCMF_MAX_IFS];
  106. struct brcmf_if *mon_if;
  107. struct mutex proto_block;
  108. unsigned char proto_buf[BRCMF_DCMD_MAXLEN];
  109. struct brcmf_fweh_info fweh;
  110. struct brcmf_ampdu_rx_reorder
  111. *reorder_flows[BRCMF_AMPDU_RX_REORDER_MAXFLOWS];
  112. u32 feat_flags;
  113. u32 chip_quirks;
  114. struct brcmf_rev_info revinfo;
  115. #ifdef DEBUG
  116. struct dentry *dbgfs_dir;
  117. #endif
  118. struct notifier_block inetaddr_notifier;
  119. struct notifier_block inet6addr_notifier;
  120. struct brcmf_mp_device *settings;
  121. u8 clmver[BRCMF_DCMD_SMLEN];
  122. };
  123. /* forward declarations */
  124. struct brcmf_cfg80211_vif;
  125. struct brcmf_fws_mac_descriptor;
  126. /**
  127. * enum brcmf_netif_stop_reason - reason for stopping netif queue.
  128. *
  129. * @BRCMF_NETIF_STOP_REASON_FWS_FC:
  130. * netif stopped due to firmware signalling flow control.
  131. * @BRCMF_NETIF_STOP_REASON_FLOW:
  132. * netif stopped due to flowring full.
  133. * @BRCMF_NETIF_STOP_REASON_DISCONNECTED:
  134. * netif stopped due to not being connected (STA mode).
  135. */
  136. enum brcmf_netif_stop_reason {
  137. BRCMF_NETIF_STOP_REASON_FWS_FC = BIT(0),
  138. BRCMF_NETIF_STOP_REASON_FLOW = BIT(1),
  139. BRCMF_NETIF_STOP_REASON_DISCONNECTED = BIT(2)
  140. };
  141. /**
  142. * struct brcmf_if - interface control information.
  143. *
  144. * @drvr: points to device related information.
  145. * @vif: points to cfg80211 specific interface information.
  146. * @ndev: associated network device.
  147. * @multicast_work: worker object for multicast provisioning.
  148. * @ndoffload_work: worker object for neighbor discovery offload configuration.
  149. * @fws_desc: interface specific firmware-signalling descriptor.
  150. * @ifidx: interface index in device firmware.
  151. * @bsscfgidx: index of bss associated with this interface.
  152. * @mac_addr: assigned mac address.
  153. * @netif_stop: bitmap indicates reason why netif queues are stopped.
  154. * @netif_stop_lock: spinlock for update netif_stop from multiple sources.
  155. * @pend_8021x_cnt: tracks outstanding number of 802.1x frames.
  156. * @pend_8021x_wait: used for signalling change in count.
  157. * @fwil_fwerr: flag indicating fwil layer should return firmware error codes.
  158. */
  159. struct brcmf_if {
  160. struct brcmf_pub *drvr;
  161. struct brcmf_cfg80211_vif *vif;
  162. struct net_device *ndev;
  163. struct work_struct multicast_work;
  164. struct work_struct ndoffload_work;
  165. struct brcmf_fws_mac_descriptor *fws_desc;
  166. int ifidx;
  167. s32 bsscfgidx;
  168. u8 mac_addr[ETH_ALEN];
  169. u8 netif_stop;
  170. spinlock_t netif_stop_lock;
  171. atomic_t pend_8021x_cnt;
  172. wait_queue_head_t pend_8021x_wait;
  173. struct in6_addr ipv6_addr_tbl[NDOL_MAX_ENTRIES];
  174. u8 ipv6addr_idx;
  175. bool fwil_fwerr;
  176. };
  177. int brcmf_netdev_wait_pend8021x(struct brcmf_if *ifp);
  178. /* Return pointer to interface name */
  179. char *brcmf_ifname(struct brcmf_if *ifp);
  180. struct brcmf_if *brcmf_get_ifp(struct brcmf_pub *drvr, int ifidx);
  181. void brcmf_configure_arp_nd_offload(struct brcmf_if *ifp, bool enable);
  182. int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked);
  183. struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bsscfgidx, s32 ifidx,
  184. bool is_p2pdev, const char *name, u8 *mac_addr);
  185. void brcmf_remove_interface(struct brcmf_if *ifp, bool rtnl_locked);
  186. void brcmf_txflowblock_if(struct brcmf_if *ifp,
  187. enum brcmf_netif_stop_reason reason, bool state);
  188. void brcmf_txfinalize(struct brcmf_if *ifp, struct sk_buff *txp, bool success);
  189. void brcmf_netif_rx(struct brcmf_if *ifp, struct sk_buff *skb);
  190. void brcmf_netif_mon_rx(struct brcmf_if *ifp, struct sk_buff *skb);
  191. void brcmf_net_setcarrier(struct brcmf_if *ifp, bool on);
  192. int __init brcmf_core_init(void);
  193. void __exit brcmf_core_exit(void);
  194. #endif /* BRCMFMAC_CORE_H */