dhd.h 5.9 KB

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