/drivers/net/wireless/bcmdhd_29/dhd_wlfc.h

https://bitbucket.org/cyanogenmod/android_kernel_asus_tf300t · C Header · 276 lines · 180 code · 37 blank · 59 comment · 12 complexity · 845923df5792f05a2934f7e6129ec9bd MD5 · raw file

  1. /*
  2. * Copyright (C) 1999-2011, Broadcom Corporation
  3. *
  4. * Unless you and Broadcom execute a separate written software license
  5. * agreement governing use of this software, this software is licensed to you
  6. * under the terms of the GNU General Public License version 2 (the "GPL"),
  7. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  8. * following added to such license:
  9. *
  10. * As a special exception, the copyright holders of this software give you
  11. * permission to link this software with independent modules, and to copy and
  12. * distribute the resulting executable under terms of your choice, provided that
  13. * you also meet, for each linked independent module, the terms and conditions of
  14. * the license of that module. An independent module is a module which is not
  15. * derived from this software. The special exception does not apply to any
  16. * modifications of the software.
  17. *
  18. * Notwithstanding the above, under no circumstances may you combine this
  19. * software in any way with any other Broadcom software provided under a license
  20. * other than the GPL, without Broadcom's express prior written consent.
  21. * $Id: dhd_wlfc.h 286994 2011-09-29 21:27:44Z $
  22. *
  23. */
  24. #ifndef __wlfc_host_driver_definitions_h__
  25. #define __wlfc_host_driver_definitions_h__
  26. /* 16 bits will provide an absolute max of 65536 slots */
  27. #define WLFC_HANGER_MAXITEMS 1024
  28. #define WLFC_HANGER_ITEM_STATE_FREE 1
  29. #define WLFC_HANGER_ITEM_STATE_INUSE 2
  30. #define WLFC_PKTID_HSLOT_MASK 0xffff /* allow 16 bits only */
  31. #define WLFC_PKTID_HSLOT_SHIFT 8
  32. /* x -> TXSTATUS TAG to/from firmware */
  33. #define WLFC_PKTID_HSLOT_GET(x) \
  34. (((x) >> WLFC_PKTID_HSLOT_SHIFT) & WLFC_PKTID_HSLOT_MASK)
  35. #define WLFC_PKTID_HSLOT_SET(var, slot) \
  36. ((var) = ((var) & ~(WLFC_PKTID_HSLOT_MASK << WLFC_PKTID_HSLOT_SHIFT)) | \
  37. (((slot) & WLFC_PKTID_HSLOT_MASK) << WLFC_PKTID_HSLOT_SHIFT))
  38. #define WLFC_PKTID_FREERUNCTR_MASK 0xff
  39. #define WLFC_PKTID_FREERUNCTR_GET(x) ((x) & WLFC_PKTID_FREERUNCTR_MASK)
  40. #define WLFC_PKTID_FREERUNCTR_SET(var, ctr) \
  41. ((var) = (((var) & ~WLFC_PKTID_FREERUNCTR_MASK) | \
  42. (((ctr) & WLFC_PKTID_FREERUNCTR_MASK))))
  43. #define WLFC_PKTQ_PENQ(pq, prec, p) ((pktq_full((pq)) || pktq_pfull((pq), (prec)))? \
  44. NULL : pktq_penq((pq), (prec), (p)))
  45. #define WLFC_PKTQ_PENQ_HEAD(pq, prec, p) ((pktq_full((pq)) || pktq_pfull((pq), (prec))) ? \
  46. NULL : pktq_penq_head((pq), (prec), (p)))
  47. typedef enum ewlfc_packet_state {
  48. eWLFC_PKTTYPE_NEW,
  49. eWLFC_PKTTYPE_DELAYED,
  50. eWLFC_PKTTYPE_SUPPRESSED,
  51. eWLFC_PKTTYPE_MAX
  52. } ewlfc_packet_state_t;
  53. typedef enum ewlfc_mac_entry_action {
  54. eWLFC_MAC_ENTRY_ACTION_ADD,
  55. eWLFC_MAC_ENTRY_ACTION_DEL,
  56. eWLFC_MAC_ENTRY_ACTION_MAX
  57. } ewlfc_mac_entry_action_t;
  58. typedef struct wlfc_hanger_item {
  59. uint8 state;
  60. uint8 pad[3];
  61. uint32 identifier;
  62. void* pkt;
  63. #ifdef PROP_TXSTATUS_DEBUG
  64. uint32 push_time;
  65. #endif
  66. } wlfc_hanger_item_t;
  67. typedef struct wlfc_hanger {
  68. int max_items;
  69. uint32 pushed;
  70. uint32 popped;
  71. uint32 failed_to_push;
  72. uint32 failed_to_pop;
  73. uint32 failed_slotfind;
  74. wlfc_hanger_item_t items[1];
  75. } wlfc_hanger_t;
  76. #define WLFC_HANGER_SIZE(n) ((sizeof(wlfc_hanger_t) - \
  77. sizeof(wlfc_hanger_item_t)) + ((n)*sizeof(wlfc_hanger_item_t)))
  78. #define WLFC_STATE_OPEN 1
  79. #define WLFC_STATE_CLOSE 2
  80. #define WLFC_PSQ_PREC_COUNT ((AC_COUNT + 1) * 2) /* 2 for each AC traffic and bc/mc */
  81. #define WLFC_PSQ_LEN 64
  82. #define WLFC_SENDQ_LEN 256
  83. #define WLFC_FLOWCONTROL_DELTA 8
  84. #define WLFC_FLOWCONTROL_HIWATER (WLFC_PSQ_LEN - WLFC_FLOWCONTROL_DELTA)
  85. #define WLFC_FLOWCONTROL_LOWATER (WLFC_FLOWCONTROL_HIWATER - WLFC_FLOWCONTROL_DELTA)
  86. typedef struct wlfc_mac_descriptor {
  87. uint8 occupied;
  88. uint8 interface_id;
  89. uint8 iftype;
  90. uint8 state;
  91. uint8 ac_bitmap; /* for APSD */
  92. uint8 requested_credit;
  93. uint8 requested_packet;
  94. uint8 ea[ETHER_ADDR_LEN];
  95. /*
  96. maintain (MAC,AC) based seq count for
  97. packets going to the device. As well as bc/mc.
  98. */
  99. uint8 seq[AC_COUNT + 1];
  100. uint8 generation;
  101. struct pktq psq;
  102. /* The AC pending bitmap that was reported to the fw at last change */
  103. uint8 traffic_lastreported_bmp;
  104. /* The new AC pending bitmap */
  105. uint8 traffic_pending_bmp;
  106. /* 1= send on next opportunity */
  107. uint8 send_tim_signal;
  108. uint8 mac_handle;
  109. #ifdef PROP_TXSTATUS_DEBUG
  110. uint32 dstncredit_sent_packets;
  111. uint32 dstncredit_acks;
  112. uint32 opened_ct;
  113. uint32 closed_ct;
  114. #endif
  115. } wlfc_mac_descriptor_t;
  116. #define WLFC_DECR_SEQCOUNT(entry, prec) do { if (entry->seq[(prec)] == 0) {\
  117. entry->seq[prec] = 0xff; } else entry->seq[prec]--;} while (0)
  118. #define WLFC_INCR_SEQCOUNT(entry, prec) entry->seq[(prec)]++
  119. #define WLFC_SEQCOUNT(entry, prec) entry->seq[(prec)]
  120. typedef struct athost_wl_stat_counters {
  121. uint32 pktin;
  122. uint32 pkt2bus;
  123. uint32 pktdropped;
  124. uint32 tlv_parse_failed;
  125. uint32 rollback;
  126. uint32 rollback_failed;
  127. uint32 sendq_full_error;
  128. uint32 delayq_full_error;
  129. uint32 credit_request_failed;
  130. uint32 packet_request_failed;
  131. uint32 mac_update_failed;
  132. uint32 psmode_update_failed;
  133. uint32 interface_update_failed;
  134. uint32 wlfc_header_only_pkt;
  135. uint32 txstatus_in;
  136. uint32 d11_suppress;
  137. uint32 wl_suppress;
  138. uint32 bad_suppress;
  139. uint32 pkt_freed;
  140. uint32 pkt_free_err;
  141. uint32 psq_wlsup_retx;
  142. uint32 psq_wlsup_enq;
  143. uint32 psq_d11sup_retx;
  144. uint32 psq_d11sup_enq;
  145. uint32 psq_hostq_retx;
  146. uint32 psq_hostq_enq;
  147. uint32 mac_handle_notfound;
  148. uint32 wlc_tossed_pkts;
  149. uint32 dhd_hdrpulls;
  150. uint32 generic_error;
  151. /* an extra one for bc/mc traffic */
  152. uint32 sendq_pkts[AC_COUNT + 1];
  153. #ifdef PROP_TXSTATUS_DEBUG
  154. /* all pkt2bus -> txstatus latency accumulated */
  155. uint32 latency_sample_count;
  156. uint32 total_status_latency;
  157. uint32 latency_most_recent;
  158. int idx_delta;
  159. uint32 deltas[10];
  160. uint32 fifo_credits_sent[6];
  161. uint32 fifo_credits_back[6];
  162. uint32 dropped_qfull[6];
  163. uint32 signal_only_pkts_sent;
  164. uint32 signal_only_pkts_freed;
  165. #endif
  166. } athost_wl_stat_counters_t;
  167. #ifdef PROP_TXSTATUS_DEBUG
  168. #define WLFC_HOST_FIFO_CREDIT_INC_SENTCTRS(ctx, ac) do { \
  169. (ctx)->stats.fifo_credits_sent[(ac)]++;} while (0)
  170. #define WLFC_HOST_FIFO_CREDIT_INC_BACKCTRS(ctx, ac) do { \
  171. (ctx)->stats.fifo_credits_back[(ac)]++;} while (0)
  172. #define WLFC_HOST_FIFO_DROPPEDCTR_INC(ctx, ac) do { \
  173. (ctx)->stats.dropped_qfull[(ac)]++;} while (0)
  174. #else
  175. #define WLFC_HOST_FIFO_CREDIT_INC_SENTCTRS(ctx, ac) do {} while (0)
  176. #define WLFC_HOST_FIFO_CREDIT_INC_BACKCTRS(ctx, ac) do {} while (0)
  177. #define WLFC_HOST_FIFO_DROPPEDCTR_INC(ctx, ac) do {} while (0)
  178. #endif
  179. #define WLFC_FCMODE_NONE 0
  180. #define WLFC_FCMODE_IMPLIED_CREDIT 1
  181. #define WLFC_FCMODE_EXPLICIT_CREDIT 2
  182. /* How long to defer borrowing in milliseconds */
  183. #define WLFC_BORROW_DEFER_PERIOD_MS 100
  184. /* Mask to represent available ACs (note: BC/MC is ignored */
  185. #define WLFC_AC_MASK 0xF
  186. /* Mask to check for only on-going AC_BE traffic */
  187. #define WLFC_AC_BE_TRAFFIC_ONLY 0xD
  188. typedef struct athost_wl_status_info {
  189. uint8 last_seqid_to_wlc;
  190. /* OSL handle */
  191. osl_t* osh;
  192. /* dhd pub */
  193. void* dhdp;
  194. /* stats */
  195. athost_wl_stat_counters_t stats;
  196. /* the additional ones are for bc/mc and ATIM FIFO */
  197. int FIFO_credit[AC_COUNT + 2];
  198. /* Credit borrow counts for each FIFO from each of the other FIFOs */
  199. int credits_borrowed[AC_COUNT + 2][AC_COUNT + 2];
  200. struct pktq SENDQ;
  201. /* packet hanger and MAC->handle lookup table */
  202. void* hanger;
  203. struct {
  204. /* table for individual nodes */
  205. wlfc_mac_descriptor_t nodes[WLFC_MAC_DESC_TABLE_SIZE];
  206. /* table for interfaces */
  207. wlfc_mac_descriptor_t interfaces[WLFC_MAX_IFNUM];
  208. /* OS may send packets to unknown (unassociated) destinations */
  209. /* A place holder for bc/mc and packets to unknown destinations */
  210. wlfc_mac_descriptor_t other;
  211. } destination_entries;
  212. /* token position for different priority packets */
  213. uint8 token_pos[AC_COUNT+1];
  214. /* ON/OFF state for flow control to the host network interface */
  215. uint8 hostif_flow_state[WLFC_MAX_IFNUM];
  216. uint8 host_ifidx;
  217. /* to flow control an OS interface */
  218. uint8 toggle_host_if;
  219. /*
  220. Mode in which the dhd flow control shall operate. Must be set before
  221. traffic starts to the device.
  222. 0 - Do not do any proptxtstatus flow control
  223. 1 - Use implied credit from a packet status
  224. 2 - Use explicit credit
  225. */
  226. uint8 proptxstatus_mode;
  227. /* To borrow credits */
  228. uint8 allow_credit_borrow;
  229. /* Timestamp to compute how long to defer borrowing for */
  230. uint32 borrow_defer_timestamp;
  231. } athost_wl_status_info_t;
  232. int dhd_wlfc_enable(dhd_pub_t *dhd);
  233. int dhd_wlfc_interface_event(struct dhd_info *,
  234. ewlfc_mac_entry_action_t action, uint8 ifid, uint8 iftype, uint8* ea);
  235. int dhd_wlfc_FIFOcreditmap_event(struct dhd_info *dhd, uint8* event_data);
  236. int dhd_wlfc_event(struct dhd_info *dhd);
  237. int dhd_os_wlfc_block(dhd_pub_t *pub);
  238. int dhd_os_wlfc_unblock(dhd_pub_t *pub);
  239. #endif /* __wlfc_host_driver_definitions_h__ */