1 /* 2 * Copyright (C) 2020, Broadcom. 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 * 19 * <<Broadcom-WL-IPTag/Open:>> 20 * 21 * $Id$ 22 * 23 */ 24 #ifndef __wlfc_host_driver_definitions_h__ 25 #define __wlfc_host_driver_definitions_h__ 26 27 #ifdef QMONITOR 28 #include <dhd_qmon.h> 29 #endif 30 31 /* #define OOO_DEBUG */ 32 33 #define KERNEL_THREAD_RETURN_TYPE int 34 35 typedef int (*f_commitpkt_t)(struct dhd_bus *ctx, void* p); 36 typedef bool (*f_processpkt_t)(void* p, void* arg); 37 38 #define WLFC_UNSUPPORTED -9999 39 40 #define WLFC_NO_TRAFFIC -1 41 #define WLFC_MULTI_TRAFFIC 0 42 43 #define BUS_RETRIES 1 /* # of retries before aborting a bus tx operation */ 44 45 /** 16 bits will provide an absolute max of 65536 slots */ 46 #define WLFC_HANGER_MAXITEMS 3072 47 48 #define WLFC_HANGER_ITEM_STATE_FREE 1 49 #define WLFC_HANGER_ITEM_STATE_INUSE 2 50 #define WLFC_HANGER_ITEM_STATE_INUSE_SUPPRESSED 3 51 #define WLFC_HANGER_ITEM_STATE_FLUSHED 4 52 53 #define WLFC_HANGER_PKT_STATE_TXSTATUS 1 54 #define WLFC_HANGER_PKT_STATE_BUSRETURNED 2 55 #define WLFC_HANGER_PKT_STATE_COMPLETE \ 56 (WLFC_HANGER_PKT_STATE_TXSTATUS | WLFC_HANGER_PKT_STATE_BUSRETURNED) 57 58 typedef enum { 59 Q_TYPE_PSQ, /**< Power Save Queue, contains both delayed and suppressed packets */ 60 Q_TYPE_AFQ /**< At Firmware Queue */ 61 } q_type_t; 62 63 typedef enum ewlfc_packet_state { 64 eWLFC_PKTTYPE_NEW, /**< unused in the code (Jan 2015) */ 65 eWLFC_PKTTYPE_DELAYED, /**< packet did not enter wlfc yet */ 66 eWLFC_PKTTYPE_SUPPRESSED, /**< packet entered wlfc and was suppressed by the dongle */ 67 eWLFC_PKTTYPE_MAX 68 } ewlfc_packet_state_t; 69 70 typedef enum ewlfc_mac_entry_action { 71 eWLFC_MAC_ENTRY_ACTION_ADD, 72 eWLFC_MAC_ENTRY_ACTION_DEL, 73 eWLFC_MAC_ENTRY_ACTION_UPDATE, 74 eWLFC_MAC_ENTRY_ACTION_MAX 75 } ewlfc_mac_entry_action_t; 76 77 typedef struct wlfc_hanger_item { 78 uint8 state; 79 uint8 gen; 80 uint8 pkt_state; /**< bitmask containing eg WLFC_HANGER_PKT_STATE_TXCOMPLETE */ 81 uint8 pkt_txstatus; 82 uint32 identifier; 83 void* pkt; 84 #ifdef PROP_TXSTATUS_DEBUG 85 uint32 push_time; 86 #endif 87 struct wlfc_hanger_item *next; 88 } wlfc_hanger_item_t; 89 90 /** hanger contains packets that have been posted by the dhd to the dongle and are expected back */ 91 typedef struct wlfc_hanger { 92 int max_items; 93 uint32 pushed; 94 uint32 popped; 95 uint32 failed_to_push; 96 uint32 failed_to_pop; 97 uint32 failed_slotfind; 98 uint32 slot_pos; 99 /** XXX: items[1] should be the last element here. Do not add new elements below it. */ 100 wlfc_hanger_item_t items[1]; 101 } wlfc_hanger_t; 102 103 #define WLFC_HANGER_SIZE(n) ((sizeof(wlfc_hanger_t) - \ 104 sizeof(wlfc_hanger_item_t)) + ((n)*sizeof(wlfc_hanger_item_t))) 105 106 #define WLFC_STATE_OPEN 1 /**< remote MAC is able to receive packets */ 107 #define WLFC_STATE_CLOSE 2 /**< remote MAC is in power save mode */ 108 109 #define WLFC_PSQ_PREC_COUNT ((AC_COUNT + 1) * 2) /**< 2 for each AC traffic and bc/mc */ 110 #define WLFC_AFQ_PREC_COUNT (AC_COUNT + 1) 111 112 #define WLFC_PSQ_LEN (4096 * 8) 113 114 #ifdef BCMDBUS 115 #define WLFC_FLOWCONTROL_HIWATER 512 116 #define WLFC_FLOWCONTROL_LOWATER (WLFC_FLOWCONTROL_HIWATER / 4) 117 #else 118 #define WLFC_FLOWCONTROL_HIWATER ((4096 * 8) - 256) 119 #define WLFC_FLOWCONTROL_LOWATER 256 120 #endif 121 122 #if (WLFC_FLOWCONTROL_HIWATER >= (WLFC_PSQ_LEN - 256)) 123 #undef WLFC_FLOWCONTROL_HIWATER 124 #define WLFC_FLOWCONTROL_HIWATER (WLFC_PSQ_LEN - 256) 125 #undef WLFC_FLOWCONTROL_LOWATER 126 #define WLFC_FLOWCONTROL_LOWATER (WLFC_FLOWCONTROL_HIWATER / 4) 127 #endif 128 129 #define WLFC_LOG_BUF_SIZE (1024*1024) 130 131 /** Properties related to a remote MAC entity */ 132 typedef struct wlfc_mac_descriptor { 133 uint8 occupied; /**< if 0, this descriptor is unused and thus can be (re)used */ 134 uint8 interface_id; 135 uint8 iftype; /**< eg WLC_E_IF_ROLE_STA */ 136 uint8 state; /**< eg WLFC_STATE_OPEN */ 137 uint8 ac_bitmap; /**< automatic power save delivery (APSD) */ 138 uint8 requested_credit; 139 uint8 requested_packet; /**< unit: [number of packets] */ 140 uint8 ea[ETHER_ADDR_LEN]; 141 142 /** maintain (MAC,AC) based seq count for packets going to the device. As well as bc/mc. */ 143 uint8 seq[AC_COUNT + 1]; 144 uint8 generation; /**< toggles between 0 and 1 */ 145 struct pktq psq; /**< contains both 'delayed' and 'suppressed' packets */ 146 /** packets at firmware queue */ 147 struct pktq afq; 148 #if defined(BCMINTERNAL) && defined(OOO_DEBUG) 149 uint8 last_send_gen[AC_COUNT+1]; 150 uint8 last_send_seq[AC_COUNT+1]; 151 uint8 last_complete_seq[AC_COUNT+1]; 152 #endif /* defined(BCMINTERNAL) && defined(OOO_DEBUG) */ 153 /** The AC pending bitmap that was reported to the fw at last change */ 154 uint8 traffic_lastreported_bmp; 155 /** The new AC pending bitmap */ 156 uint8 traffic_pending_bmp; 157 /** 1= send on next opportunity */ 158 uint8 send_tim_signal; 159 uint8 mac_handle; /**< mac handles are assigned by the dongle */ 160 /** Number of packets at dongle for this entry. */ 161 int transit_count; 162 /** Number of suppression to wait before evict from delayQ */ 163 int suppr_transit_count; 164 /** pkt sent to bus but no bus TX complete yet */ 165 int onbus_pkts_count; 166 /** flag. TRUE when remote MAC is in suppressed state */ 167 uint8 suppressed; 168 169 #ifdef QMONITOR 170 dhd_qmon_t qmon; 171 #endif /* QMONITOR */ 172 173 #ifdef PROP_TXSTATUS_DEBUG 174 uint32 dstncredit_sent_packets; 175 uint32 dstncredit_acks; 176 uint32 opened_ct; 177 uint32 closed_ct; 178 #endif 179 #ifdef PROPTX_MAXCOUNT 180 /** Max Number of packets at dongle for this entry. */ 181 int transit_maxcount; 182 #endif /* PROPTX_MAXCOUNT */ 183 struct wlfc_mac_descriptor* prev; 184 struct wlfc_mac_descriptor* next; 185 #ifdef BULK_DEQUEUE 186 uint16 release_count[AC_COUNT + 1]; 187 #endif 188 } wlfc_mac_descriptor_t; 189 190 /** A 'commit' is the hand over of a packet from the host OS layer to the layer below (eg DBUS) */ 191 typedef struct dhd_wlfc_commit_info { 192 uint8 needs_hdr; 193 uint8 ac_fifo_credit_spent; 194 ewlfc_packet_state_t pkt_type; 195 wlfc_mac_descriptor_t* mac_entry; 196 void* p; 197 } dhd_wlfc_commit_info_t; 198 199 #define WLFC_DECR_SEQCOUNT(entry, prec) do { if (entry->seq[(prec)] == 0) {\ 200 entry->seq[prec] = 0xff; } else entry->seq[prec]--;} while (0) 201 202 #define WLFC_INCR_SEQCOUNT(entry, prec) entry->seq[(prec)]++ 203 #define WLFC_SEQCOUNT(entry, prec) entry->seq[(prec)] 204 205 typedef struct athost_wl_stat_counters { 206 uint32 pktin; 207 uint32 pktout; 208 uint32 pkt2bus; 209 uint32 pktdropped; 210 uint32 tlv_parse_failed; 211 uint32 rollback; 212 uint32 rollback_failed; 213 uint32 delayq_full_error; 214 uint32 credit_request_failed; 215 uint32 packet_request_failed; 216 uint32 mac_update_failed; 217 uint32 psmode_update_failed; 218 uint32 interface_update_failed; 219 uint32 wlfc_header_only_pkt; 220 uint32 txstatus_in; 221 uint32 d11_suppress; 222 uint32 wl_suppress; 223 uint32 bad_suppress; 224 uint32 pkt_dropped; 225 uint32 pkt_exptime; 226 uint32 pkt_freed; 227 uint32 pkt_free_err; 228 uint32 psq_wlsup_retx; 229 uint32 psq_wlsup_enq; 230 uint32 psq_d11sup_retx; 231 uint32 psq_d11sup_enq; 232 uint32 psq_hostq_retx; 233 uint32 psq_hostq_enq; 234 uint32 mac_handle_notfound; 235 uint32 wlc_tossed_pkts; 236 uint32 dhd_hdrpulls; 237 uint32 generic_error; 238 /* an extra one for bc/mc traffic */ 239 uint32 send_pkts[AC_COUNT + 1]; 240 uint32 drop_pkts[WLFC_PSQ_PREC_COUNT]; 241 uint32 ooo_pkts[AC_COUNT + 1]; 242 #ifdef PROP_TXSTATUS_DEBUG 243 /** all pkt2bus -> txstatus latency accumulated */ 244 uint32 latency_sample_count; 245 uint32 total_status_latency; 246 uint32 latency_most_recent; 247 int idx_delta; 248 uint32 deltas[10]; 249 uint32 fifo_credits_sent[6]; 250 uint32 fifo_credits_back[6]; 251 uint32 dropped_qfull[6]; 252 uint32 signal_only_pkts_sent; 253 uint32 signal_only_pkts_freed; 254 #endif 255 uint32 cleanup_txq_cnt; 256 uint32 cleanup_psq_cnt; 257 uint32 cleanup_fw_cnt; 258 } athost_wl_stat_counters_t; 259 260 #ifdef PROP_TXSTATUS_DEBUG 261 #define WLFC_HOST_FIFO_CREDIT_INC_SENTCTRS(ctx, ac) do { \ 262 (ctx)->stats.fifo_credits_sent[(ac)]++;} while (0) 263 #define WLFC_HOST_FIFO_CREDIT_INC_BACKCTRS(ctx, ac) do { \ 264 (ctx)->stats.fifo_credits_back[(ac)]++;} while (0) 265 #define WLFC_HOST_FIFO_DROPPEDCTR_INC(ctx, ac) do { \ 266 (ctx)->stats.dropped_qfull[(ac)]++;} while (0) 267 #else 268 #define WLFC_HOST_FIFO_CREDIT_INC_SENTCTRS(ctx, ac) do {} while (0) 269 #define WLFC_HOST_FIFO_CREDIT_INC_BACKCTRS(ctx, ac) do {} while (0) 270 #define WLFC_HOST_FIFO_DROPPEDCTR_INC(ctx, ac) do {} while (0) 271 #endif 272 #define WLFC_PACKET_BOUND 10 273 #define WLFC_FCMODE_NONE 0 274 #define WLFC_FCMODE_IMPLIED_CREDIT 1 275 #define WLFC_FCMODE_EXPLICIT_CREDIT 2 276 #define WLFC_ONLY_AMPDU_HOSTREORDER 3 277 278 /** Reserved credits ratio when borrowed by hihger priority */ 279 #define WLFC_BORROW_LIMIT_RATIO 4 280 281 /** How long to defer borrowing in milliseconds */ 282 #define WLFC_BORROW_DEFER_PERIOD_MS 100 283 284 /** How long to defer flow control in milliseconds */ 285 #define WLFC_FC_DEFER_PERIOD_MS 200 286 287 /** How long to detect occurance per AC in miliseconds */ 288 #define WLFC_RX_DETECTION_THRESHOLD_MS 100 289 290 /** Mask to represent available ACs (note: BC/MC is ignored) */ 291 #define WLFC_AC_MASK 0xF 292 293 /** flow control specific information, only 1 instance during driver lifetime */ 294 typedef struct athost_wl_status_info { 295 uint8 last_seqid_to_wlc; 296 297 /** OSL handle */ 298 osl_t *osh; 299 /** dhd public struct pointer */ 300 void *dhdp; 301 302 f_commitpkt_t fcommit; 303 void* commit_ctx; 304 305 /** statistics */ 306 athost_wl_stat_counters_t stats; 307 308 /** incremented on eg receiving a credit map event from the dongle */ 309 int Init_FIFO_credit[AC_COUNT + 2]; 310 /** the additional ones are for bc/mc and ATIM FIFO */ 311 int FIFO_credit[AC_COUNT + 2]; 312 /** Credit borrow counts for each FIFO from each of the other FIFOs */ 313 int credits_borrowed[AC_COUNT + 2][AC_COUNT + 2]; 314 315 /** packet hanger and MAC->handle lookup table */ 316 void *hanger; 317 318 struct { 319 /** table for individual nodes */ 320 wlfc_mac_descriptor_t nodes[WLFC_MAC_DESC_TABLE_SIZE]; 321 /** table for interfaces */ 322 wlfc_mac_descriptor_t interfaces[WLFC_MAX_IFNUM]; 323 /* OS may send packets to unknown (unassociated) destinations */ 324 /** A place holder for bc/mc and packets to unknown destinations */ 325 wlfc_mac_descriptor_t other; 326 } destination_entries; 327 328 wlfc_mac_descriptor_t *active_entry_head; /**< a chain of MAC descriptors */ 329 int active_entry_count; 330 331 wlfc_mac_descriptor_t *requested_entry[WLFC_MAC_DESC_TABLE_SIZE]; 332 int requested_entry_count; 333 334 /* pkt counts for each interface and ac */ 335 int pkt_cnt_in_q[WLFC_MAX_IFNUM][AC_COUNT+1]; 336 int pkt_cnt_per_ac[AC_COUNT+1]; 337 int pkt_cnt_in_drv[WLFC_MAX_IFNUM][AC_COUNT+1]; 338 int pkt_cnt_in_psq; 339 uint8 allow_fc; /**< Boolean */ 340 uint32 fc_defer_timestamp; 341 uint32 rx_timestamp[AC_COUNT+1]; 342 343 /** ON/OFF state for flow control to the host network interface */ 344 uint8 hostif_flow_state[WLFC_MAX_IFNUM]; 345 uint8 host_ifidx; 346 347 /** to flow control an OS interface */ 348 uint8 toggle_host_if; 349 350 /** To borrow credits */ 351 uint8 allow_credit_borrow; 352 353 /** ac number for the first single ac traffic */ 354 uint8 single_ac; 355 356 /** Timestamp for the first single ac traffic */ 357 uint32 single_ac_timestamp; 358 359 bool bcmc_credit_supported; 360 361 #if defined(BCMINTERNAL) && defined(OOO_DEBUG) 362 uint8* log_buf; 363 uint32 log_buf_offset; 364 bool log_buf_full; 365 #endif /* defined(BCMINTERNAL) && defined(OOO_DEBUG) */ 366 367 #ifdef BULK_DEQUEUE 368 uint8 max_release_count; 369 #endif /* total_credit */ 370 } athost_wl_status_info_t; 371 372 /** Please be mindful that total pkttag space is 32 octets only */ 373 typedef struct dhd_pkttag { 374 375 #ifdef BCM_OBJECT_TRACE 376 /* if use this field, keep it at the first 4 bytes */ 377 uint32 sn; 378 #endif /* BCM_OBJECT_TRACE */ 379 380 /** 381 b[15] - 1 = wlfc packet 382 b[14:13] - encryption exemption 383 b[12 ] - 1 = event channel 384 b[11 ] - 1 = this packet was sent in response to one time packet request, 385 do not increment credit on status for this one. [WLFC_CTL_TYPE_MAC_REQUEST_PACKET]. 386 b[10 ] - 1 = signal-only-packet to firmware [i.e. nothing to piggyback on] 387 b[9 ] - 1 = packet is host->firmware (transmit direction) 388 - 0 = packet received from firmware (firmware->host) 389 b[8 ] - 1 = packet was sent due to credit_request (pspoll), 390 packet does not count against FIFO credit. 391 - 0 = normal transaction, packet counts against FIFO credit 392 b[7 ] - 1 = AP, 0 = STA 393 b[6:4] - AC FIFO number 394 b[3:0] - interface index 395 */ 396 uint16 if_flags; 397 398 /** 399 * destination MAC address for this packet so that not every module needs to open the packet 400 * to find this 401 */ 402 uint8 dstn_ether[ETHER_ADDR_LEN]; 403 404 /** This 32-bit goes from host to device for every packet. */ 405 uint32 htod_tag; 406 407 /** This 16-bit is original d11seq number for every suppressed packet. */ 408 uint16 htod_seq; 409 410 /** This address is mac entry for every packet. */ 411 void *entry; 412 413 /** bus specific stuff */ 414 union { 415 struct { 416 void *stuff; 417 uint32 thing1; 418 uint32 thing2; 419 } sd; 420 421 /* XXX: using the USB typedef here will complicate life for anybody using dhd.h */ 422 struct { 423 void *bus; 424 void *urb; 425 } usb; 426 } bus_specific; 427 } dhd_pkttag_t; 428 429 #define DHD_PKTTAG_WLFCPKT_MASK 0x1 430 #define DHD_PKTTAG_WLFCPKT_SHIFT 15 431 #define DHD_PKTTAG_WLFCPKT_SET(tag, value) ((dhd_pkttag_t*)(tag))->if_flags = \ 432 (((dhd_pkttag_t*)(tag))->if_flags & \ 433 ~(DHD_PKTTAG_WLFCPKT_MASK << DHD_PKTTAG_WLFCPKT_SHIFT)) | \ 434 (((value) & DHD_PKTTAG_WLFCPKT_MASK) << DHD_PKTTAG_WLFCPKT_SHIFT) 435 #define DHD_PKTTAG_WLFCPKT(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \ 436 DHD_PKTTAG_WLFCPKT_SHIFT) & DHD_PKTTAG_WLFCPKT_MASK) 437 438 #define DHD_PKTTAG_EXEMPT_MASK 0x3 439 #define DHD_PKTTAG_EXEMPT_SHIFT 13 440 #define DHD_PKTTAG_EXEMPT_SET(tag, value) ((dhd_pkttag_t*)(tag))->if_flags = \ 441 (((dhd_pkttag_t*)(tag))->if_flags & \ 442 ~(DHD_PKTTAG_EXEMPT_MASK << DHD_PKTTAG_EXEMPT_SHIFT)) | \ 443 (((value) & DHD_PKTTAG_EXEMPT_MASK) << DHD_PKTTAG_EXEMPT_SHIFT) 444 #define DHD_PKTTAG_EXEMPT(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \ 445 DHD_PKTTAG_EXEMPT_SHIFT) & DHD_PKTTAG_EXEMPT_MASK) 446 447 #define DHD_PKTTAG_EVENT_MASK 0x1 448 #define DHD_PKTTAG_EVENT_SHIFT 12 449 #define DHD_PKTTAG_SETEVENT(tag, event) ((dhd_pkttag_t*)(tag))->if_flags = \ 450 (((dhd_pkttag_t*)(tag))->if_flags & \ 451 ~(DHD_PKTTAG_EVENT_MASK << DHD_PKTTAG_EVENT_SHIFT)) | \ 452 (((event) & DHD_PKTTAG_EVENT_MASK) << DHD_PKTTAG_EVENT_SHIFT) 453 #define DHD_PKTTAG_EVENT(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \ 454 DHD_PKTTAG_EVENT_SHIFT) & DHD_PKTTAG_EVENT_MASK) 455 456 #define DHD_PKTTAG_ONETIMEPKTRQST_MASK 0x1 457 #define DHD_PKTTAG_ONETIMEPKTRQST_SHIFT 11 458 #define DHD_PKTTAG_SETONETIMEPKTRQST(tag) ((dhd_pkttag_t*)(tag))->if_flags = \ 459 (((dhd_pkttag_t*)(tag))->if_flags & \ 460 ~(DHD_PKTTAG_ONETIMEPKTRQST_MASK << DHD_PKTTAG_ONETIMEPKTRQST_SHIFT)) | \ 461 (1 << DHD_PKTTAG_ONETIMEPKTRQST_SHIFT) 462 #define DHD_PKTTAG_ONETIMEPKTRQST(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \ 463 DHD_PKTTAG_ONETIMEPKTRQST_SHIFT) & DHD_PKTTAG_ONETIMEPKTRQST_MASK) 464 465 #define DHD_PKTTAG_SIGNALONLY_MASK 0x1 466 #define DHD_PKTTAG_SIGNALONLY_SHIFT 10 467 #define DHD_PKTTAG_SETSIGNALONLY(tag, signalonly) ((dhd_pkttag_t*)(tag))->if_flags = \ 468 (((dhd_pkttag_t*)(tag))->if_flags & \ 469 ~(DHD_PKTTAG_SIGNALONLY_MASK << DHD_PKTTAG_SIGNALONLY_SHIFT)) | \ 470 (((signalonly) & DHD_PKTTAG_SIGNALONLY_MASK) << DHD_PKTTAG_SIGNALONLY_SHIFT) 471 #define DHD_PKTTAG_SIGNALONLY(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \ 472 DHD_PKTTAG_SIGNALONLY_SHIFT) & DHD_PKTTAG_SIGNALONLY_MASK) 473 474 #define DHD_PKTTAG_PKTDIR_MASK 0x1 475 #define DHD_PKTTAG_PKTDIR_SHIFT 9 476 #define DHD_PKTTAG_SETPKTDIR(tag, dir) ((dhd_pkttag_t*)(tag))->if_flags = \ 477 (((dhd_pkttag_t*)(tag))->if_flags & \ 478 ~(DHD_PKTTAG_PKTDIR_MASK << DHD_PKTTAG_PKTDIR_SHIFT)) | \ 479 (((dir) & DHD_PKTTAG_PKTDIR_MASK) << DHD_PKTTAG_PKTDIR_SHIFT) 480 #define DHD_PKTTAG_PKTDIR(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \ 481 DHD_PKTTAG_PKTDIR_SHIFT) & DHD_PKTTAG_PKTDIR_MASK) 482 483 #define DHD_PKTTAG_CREDITCHECK_MASK 0x1 484 #define DHD_PKTTAG_CREDITCHECK_SHIFT 8 485 #define DHD_PKTTAG_SETCREDITCHECK(tag, check) ((dhd_pkttag_t*)(tag))->if_flags = \ 486 (((dhd_pkttag_t*)(tag))->if_flags & \ 487 ~(DHD_PKTTAG_CREDITCHECK_MASK << DHD_PKTTAG_CREDITCHECK_SHIFT)) | \ 488 (((check) & DHD_PKTTAG_CREDITCHECK_MASK) << DHD_PKTTAG_CREDITCHECK_SHIFT) 489 #define DHD_PKTTAG_CREDITCHECK(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \ 490 DHD_PKTTAG_CREDITCHECK_SHIFT) & DHD_PKTTAG_CREDITCHECK_MASK) 491 492 #define DHD_PKTTAG_IFTYPE_MASK 0x1 493 #define DHD_PKTTAG_IFTYPE_SHIFT 7 494 #define DHD_PKTTAG_SETIFTYPE(tag, isAP) ((dhd_pkttag_t*)(tag))->if_flags = \ 495 (((dhd_pkttag_t*)(tag))->if_flags & \ 496 ~(DHD_PKTTAG_IFTYPE_MASK << DHD_PKTTAG_IFTYPE_SHIFT)) | \ 497 (((isAP) & DHD_PKTTAG_IFTYPE_MASK) << DHD_PKTTAG_IFTYPE_SHIFT) 498 #define DHD_PKTTAG_IFTYPE(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \ 499 DHD_PKTTAG_IFTYPE_SHIFT) & DHD_PKTTAG_IFTYPE_MASK) 500 501 #define DHD_PKTTAG_FIFO_MASK 0x7 502 #define DHD_PKTTAG_FIFO_SHIFT 4 503 #define DHD_PKTTAG_SETFIFO(tag, fifo) ((dhd_pkttag_t*)(tag))->if_flags = \ 504 (((dhd_pkttag_t*)(tag))->if_flags & ~(DHD_PKTTAG_FIFO_MASK << DHD_PKTTAG_FIFO_SHIFT)) | \ 505 (((fifo) & DHD_PKTTAG_FIFO_MASK) << DHD_PKTTAG_FIFO_SHIFT) 506 #define DHD_PKTTAG_FIFO(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \ 507 DHD_PKTTAG_FIFO_SHIFT) & DHD_PKTTAG_FIFO_MASK) 508 509 #define DHD_PKTTAG_IF_MASK 0xf 510 #define DHD_PKTTAG_IF_SHIFT 0 511 #define DHD_PKTTAG_SETIF(tag, if) ((dhd_pkttag_t*)(tag))->if_flags = \ 512 (((dhd_pkttag_t*)(tag))->if_flags & ~(DHD_PKTTAG_IF_MASK << DHD_PKTTAG_IF_SHIFT)) | \ 513 (((if) & DHD_PKTTAG_IF_MASK) << DHD_PKTTAG_IF_SHIFT) 514 #define DHD_PKTTAG_IF(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \ 515 DHD_PKTTAG_IF_SHIFT) & DHD_PKTTAG_IF_MASK) 516 517 #define DHD_PKTTAG_SETDSTN(tag, dstn_MAC_ea) memcpy(((dhd_pkttag_t*)((tag)))->dstn_ether, \ 518 (dstn_MAC_ea), ETHER_ADDR_LEN) 519 #define DHD_PKTTAG_DSTN(tag) ((dhd_pkttag_t*)(tag))->dstn_ether 520 521 #define DHD_PKTTAG_SET_H2DTAG(tag, h2dvalue) ((dhd_pkttag_t*)(tag))->htod_tag = (h2dvalue) 522 #define DHD_PKTTAG_H2DTAG(tag) (((dhd_pkttag_t*)(tag))->htod_tag) 523 524 #define DHD_PKTTAG_SET_H2DSEQ(tag, seq) ((dhd_pkttag_t*)(tag))->htod_seq = (seq) 525 #define DHD_PKTTAG_H2DSEQ(tag) (((dhd_pkttag_t*)(tag))->htod_seq) 526 527 #define DHD_PKTTAG_SET_ENTRY(tag, entry) ((dhd_pkttag_t*)(tag))->entry = (entry) 528 #define DHD_PKTTAG_ENTRY(tag) (((dhd_pkttag_t*)(tag))->entry) 529 530 #define PSQ_SUP_IDX(x) (x * 2 + 1) 531 #define PSQ_DLY_IDX(x) (x * 2) 532 533 #ifdef PROP_TXSTATUS_DEBUG 534 #define DHD_WLFC_CTRINC_MAC_CLOSE(entry) do { (entry)->closed_ct++; } while (0) 535 #define DHD_WLFC_CTRINC_MAC_OPEN(entry) do { (entry)->opened_ct++; } while (0) 536 #else 537 #define DHD_WLFC_CTRINC_MAC_CLOSE(entry) do {} while (0) 538 #define DHD_WLFC_CTRINC_MAC_OPEN(entry) do {} while (0) 539 #endif 540 541 #ifdef BCM_OBJECT_TRACE 542 #define DHD_PKTTAG_SET_SN(tag, val) ((dhd_pkttag_t*)(tag))->sn = (val) 543 #define DHD_PKTTAG_SN(tag) (((dhd_pkttag_t*)(tag))->sn) 544 #endif /* BCM_OBJECT_TRACE */ 545 546 #define DHD_PKTID_IF_SHIFT (16u) 547 #define DHD_PKTID_FIFO_SHIFT (8u) 548 549 /* public functions */ 550 int dhd_wlfc_parse_header_info(dhd_pub_t *dhd, void* pktbuf, int tlv_hdr_len, 551 uchar *reorder_info_buf, uint *reorder_info_len); 552 KERNEL_THREAD_RETURN_TYPE dhd_wlfc_transfer_packets(void *data); 553 int dhd_wlfc_commit_packets(dhd_pub_t *dhdp, f_commitpkt_t fcommit, 554 struct dhd_bus *commit_ctx, void *pktbuf, bool need_toggle_host_if); 555 int dhd_wlfc_txcomplete(dhd_pub_t *dhd, void *txp, bool success); 556 int dhd_wlfc_init(dhd_pub_t *dhd); 557 #ifdef SUPPORT_P2P_GO_PS 558 int dhd_wlfc_suspend(dhd_pub_t *dhd); 559 int dhd_wlfc_resume(dhd_pub_t *dhd); 560 #endif /* SUPPORT_P2P_GO_PS */ 561 int dhd_wlfc_hostreorder_init(dhd_pub_t *dhd); 562 int dhd_wlfc_cleanup_txq(dhd_pub_t *dhd, f_processpkt_t fn, void *arg); 563 int dhd_wlfc_cleanup(dhd_pub_t *dhd, f_processpkt_t fn, void* arg); 564 int dhd_wlfc_deinit(dhd_pub_t *dhd); 565 int dhd_wlfc_interface_event(dhd_pub_t *dhdp, uint8 action, uint8 ifid, uint8 iftype, uint8* ea); 566 int dhd_wlfc_FIFOcreditmap_event(dhd_pub_t *dhdp, uint8* event_data); 567 #ifdef LIMIT_BORROW 568 int dhd_wlfc_disable_credit_borrow_event(dhd_pub_t *dhdp, uint8* event_data); 569 #endif /* LIMIT_BORROW */ 570 int dhd_wlfc_BCMCCredit_support_event(dhd_pub_t *dhdp); 571 int dhd_wlfc_enable(dhd_pub_t *dhdp); 572 int dhd_wlfc_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf); 573 int dhd_wlfc_clear_counts(dhd_pub_t *dhd); 574 int dhd_wlfc_get_enable(dhd_pub_t *dhd, bool *val); 575 int dhd_wlfc_get_mode(dhd_pub_t *dhd, int *val); 576 int dhd_wlfc_set_mode(dhd_pub_t *dhd, int val); 577 bool dhd_wlfc_is_supported(dhd_pub_t *dhd); 578 bool dhd_wlfc_is_header_only_pkt(dhd_pub_t * dhd, void *pktbuf); 579 int dhd_wlfc_flowcontrol(dhd_pub_t *dhdp, bool state, bool bAcquireLock); 580 int dhd_wlfc_save_rxpath_ac_time(dhd_pub_t * dhd, uint8 prio); 581 582 int dhd_wlfc_get_module_ignore(dhd_pub_t *dhd, int *val); 583 int dhd_wlfc_set_module_ignore(dhd_pub_t *dhd, int val); 584 int dhd_wlfc_get_credit_ignore(dhd_pub_t *dhd, int *val); 585 int dhd_wlfc_set_credit_ignore(dhd_pub_t *dhd, int val); 586 int dhd_wlfc_get_txstatus_ignore(dhd_pub_t *dhd, int *val); 587 int dhd_wlfc_set_txstatus_ignore(dhd_pub_t *dhd, int val); 588 589 int dhd_wlfc_get_rxpkt_chk(dhd_pub_t *dhd, int *val); 590 int dhd_wlfc_set_rxpkt_chk(dhd_pub_t *dhd, int val); 591 int dhd_txpkt_log_and_dump(dhd_pub_t *dhdp, void* pkt, uint16 *pktfate_status); 592 #ifdef PROPTX_MAXCOUNT 593 int dhd_wlfc_update_maxcount(dhd_pub_t *dhdp, uint8 ifid, int maxcount); 594 #endif /* PROPTX_MAXCOUNT */ 595 596 #endif /* __wlfc_host_driver_definitions_h__ */ 597