core.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. #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. /**
  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. /* Common structure for module and instance linkage */
  64. struct brcmf_pub {
  65. /* Linkage ponters */
  66. struct brcmf_bus *bus_if;
  67. struct brcmf_proto *proto;
  68. struct brcmf_cfg80211_info *config;
  69. /* Internal brcmf items */
  70. uint hdrlen; /* Total BRCMF header length (proto + bus) */
  71. uint rxsz; /* Rx buffer size bus module should use */
  72. /* Dongle media info */
  73. char fwver[BRCMF_DRIVER_FIRMWARE_VERSION_LEN];
  74. u8 mac[ETH_ALEN]; /* MAC address obtained from dongle */
  75. /* Multicast data packets sent to dongle */
  76. unsigned long tx_multicast;
  77. struct brcmf_if *iflist[BRCMF_MAX_IFS];
  78. struct mutex proto_block;
  79. unsigned char proto_buf[BRCMF_DCMD_MAXLEN];
  80. struct brcmf_fweh_info fweh;
  81. struct brcmf_fws_info *fws;
  82. struct brcmf_ampdu_rx_reorder
  83. *reorder_flows[BRCMF_AMPDU_RX_REORDER_MAXFLOWS];
  84. u32 feat_flags;
  85. u32 chip_quirks;
  86. #ifdef DEBUG
  87. struct dentry *dbgfs_dir;
  88. #endif
  89. };
  90. /* forward declarations */
  91. struct brcmf_cfg80211_vif;
  92. struct brcmf_fws_mac_descriptor;
  93. /**
  94. * enum brcmf_netif_stop_reason - reason for stopping netif queue.
  95. *
  96. * @BRCMF_NETIF_STOP_REASON_FWS_FC:
  97. * netif stopped due to firmware signalling flow control.
  98. * @BRCMF_NETIF_STOP_REASON_FLOW:
  99. * netif stopped due to flowring full.
  100. */
  101. enum brcmf_netif_stop_reason {
  102. BRCMF_NETIF_STOP_REASON_FWS_FC = 1,
  103. BRCMF_NETIF_STOP_REASON_FLOW = 2
  104. };
  105. /**
  106. * struct brcmf_if - interface control information.
  107. *
  108. * @drvr: points to device related information.
  109. * @vif: points to cfg80211 specific interface information.
  110. * @ndev: associated network device.
  111. * @stats: interface specific network statistics.
  112. * @setmacaddr_work: worker object for setting mac address.
  113. * @multicast_work: worker object for multicast provisioning.
  114. * @fws_desc: interface specific firmware-signalling descriptor.
  115. * @ifidx: interface index in device firmware.
  116. * @bssidx: index of bss associated with this interface.
  117. * @mac_addr: assigned mac address.
  118. * @netif_stop: bitmap indicates reason why netif queues are stopped.
  119. * @netif_stop_lock: spinlock for update netif_stop from multiple sources.
  120. * @pend_8021x_cnt: tracks outstanding number of 802.1x frames.
  121. * @pend_8021x_wait: used for signalling change in count.
  122. */
  123. struct brcmf_if {
  124. struct brcmf_pub *drvr;
  125. struct brcmf_cfg80211_vif *vif;
  126. struct net_device *ndev;
  127. struct net_device_stats stats;
  128. struct work_struct setmacaddr_work;
  129. struct work_struct multicast_work;
  130. struct brcmf_fws_mac_descriptor *fws_desc;
  131. int ifidx;
  132. s32 bssidx;
  133. u8 mac_addr[ETH_ALEN];
  134. u8 netif_stop;
  135. spinlock_t netif_stop_lock;
  136. atomic_t pend_8021x_cnt;
  137. wait_queue_head_t pend_8021x_wait;
  138. };
  139. struct brcmf_skb_reorder_data {
  140. u8 *reorder;
  141. };
  142. int brcmf_netdev_wait_pend8021x(struct net_device *ndev);
  143. /* Return pointer to interface name */
  144. char *brcmf_ifname(struct brcmf_pub *drvr, int idx);
  145. int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked);
  146. struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx, s32 ifidx,
  147. char *name, u8 *mac_addr);
  148. void brcmf_remove_interface(struct brcmf_pub *drvr, u32 bssidx);
  149. int brcmf_get_next_free_bsscfgidx(struct brcmf_pub *drvr);
  150. void brcmf_txflowblock_if(struct brcmf_if *ifp,
  151. enum brcmf_netif_stop_reason reason, bool state);
  152. void brcmf_txfinalize(struct brcmf_pub *drvr, struct sk_buff *txp, u8 ifidx,
  153. bool success);
  154. void brcmf_netif_rx(struct brcmf_if *ifp, struct sk_buff *skb);
  155. /* Sets dongle media info (drv_version, mac address). */
  156. int brcmf_c_preinit_dcmds(struct brcmf_if *ifp);
  157. #endif /* BRCMFMAC_CORE_H */