2 * Copyright (C) 1999-2011, Broadcom Corporation
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:
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.
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,v 1.1.8.1 2010-09-09 22:41:08 $
24 #ifndef __wlfc_host_driver_definitions_h__
25 #define __wlfc_host_driver_definitions_h__
27 /* 16 bits will provide an absolute max of 65536 slots */
28 #define WLFC_HANGER_MAXITEMS 1024
30 #define WLFC_HANGER_ITEM_STATE_FREE 1
31 #define WLFC_HANGER_ITEM_STATE_INUSE 2
33 #define WLFC_PKTID_HSLOT_MASK 0xffff /* allow 16 bits only */
34 #define WLFC_PKTID_HSLOT_SHIFT 8
36 /* x -> TXSTATUS TAG to/from firmware */
37 #define WLFC_PKTID_HSLOT_GET(x) \
38 (((x) >> WLFC_PKTID_HSLOT_SHIFT) & WLFC_PKTID_HSLOT_MASK)
39 #define WLFC_PKTID_HSLOT_SET(var, slot) \
40 ((var) = ((var) & ~(WLFC_PKTID_HSLOT_MASK << WLFC_PKTID_HSLOT_SHIFT)) | \
41 (((slot) & WLFC_PKTID_HSLOT_MASK) << WLFC_PKTID_HSLOT_SHIFT))
43 #define WLFC_PKTID_FREERUNCTR_MASK 0xff
45 #define WLFC_PKTID_FREERUNCTR_GET(x) ((x) & WLFC_PKTID_FREERUNCTR_MASK)
46 #define WLFC_PKTID_FREERUNCTR_SET(var, ctr) \
47 ((var) = (((var) & ~WLFC_PKTID_FREERUNCTR_MASK) | \
48 (((ctr) & WLFC_PKTID_FREERUNCTR_MASK))))
50 #define WLFC_PKTQ_PENQ(pq, prec, p) ((pktq_full((pq)) || pktq_pfull((pq), (prec)))? \
51 NULL : pktq_penq((pq), (prec), (p)))
52 #define WLFC_PKTQ_PENQ_HEAD(pq, prec, p) ((pktq_full((pq)) || pktq_pfull((pq), (prec))) ? \
53 NULL : pktq_penq_head((pq), (prec), (p)))
55 typedef enum ewlfc_packet_state {
57 eWLFC_PKTTYPE_DELAYED,
58 eWLFC_PKTTYPE_SUPPRESSED,
60 } ewlfc_packet_state_t;
62 typedef enum ewlfc_mac_entry_action {
63 eWLFC_MAC_ENTRY_ACTION_ADD,
64 eWLFC_MAC_ENTRY_ACTION_DEL,
65 eWLFC_MAC_ENTRY_ACTION_MAX
66 } ewlfc_mac_entry_action_t;
68 typedef struct wlfc_hanger_item {
75 typedef struct wlfc_hanger {
79 uint32 failed_to_push;
81 uint32 failed_slotfind;
82 wlfc_hanger_item_t items[1];
85 #define WLFC_HANGER_SIZE(n) ((sizeof(wlfc_hanger_t) - \
86 sizeof(wlfc_hanger_item_t)) + ((n)*sizeof(wlfc_hanger_item_t)))
88 #define WLFC_STATE_OPEN 1
89 #define WLFC_STATE_CLOSE 2
91 #define WLFC_PSQ_PREC_COUNT ((AC_COUNT + 1) * 2) /* 2 for each AC traffic and bc/mc */
92 #define WLFC_PSQ_LEN 64
93 #define WLFC_SENDQ_LEN 256
95 #define WLFC_FLOWCONTROL_DELTA 8
96 #define WLFC_FLOWCONTROL_HIWATER (WLFC_PSQ_LEN - WLFC_FLOWCONTROL_DELTA)
97 #define WLFC_FLOWCONTROL_LOWATER (WLFC_FLOWCONTROL_HIWATER - WLFC_FLOWCONTROL_DELTA)
99 typedef struct wlfc_mac_descriptor {
104 uint8 ac_bitmap; /* for APSD */
105 uint8 requested_credit;
106 uint8 requested_packet;
107 uint8 ea[ETHER_ADDR_LEN];
109 maintain (MAC,AC) based seq count for
110 packets going to the device. As well as bc/mc.
112 uint8 seq[AC_COUNT + 1];
115 /* The AC pending bitmap that was reported to the fw at last change */
116 uint8 traffic_lastreported_bmp;
117 /* The new AC pending bitmap */
118 uint8 traffic_pending_bmp;
119 /* 1= send on next opportunity */
120 uint8 send_tim_signal;
122 } wlfc_mac_descriptor_t;
124 #define WLFC_DECR_SEQCOUNT(entry, prec) do { if (entry->seq[(prec)] == 0) {\
125 entry->seq[prec] = 0xff; } else entry->seq[prec]--;} while (0)
127 #define WLFC_INCR_SEQCOUNT(entry, prec) entry->seq[(prec)]++
128 #define WLFC_SEQCOUNT(entry, prec) entry->seq[(prec)]
130 typedef struct athost_wl_stat_counters {
134 uint32 tlv_parse_failed;
136 uint32 rollback_failed;
137 uint32 sendq_full_error;
138 uint32 delayq_full_error;
139 uint32 credit_request_failed;
140 uint32 packet_request_failed;
141 uint32 mac_update_failed;
142 uint32 psmode_update_failed;
143 uint32 interface_update_failed;
144 uint32 wlfc_header_only_pkt;
151 uint32 psq_wlsup_retx;
152 uint32 psq_wlsup_enq;
153 uint32 psq_d11sup_retx;
154 uint32 psq_d11sup_enq;
155 uint32 psq_hostq_retx;
156 uint32 psq_hostq_enq;
157 uint32 mac_handle_notfound;
158 uint32 wlc_tossed_pkts;
160 uint32 generic_error;
161 /* an extra one for bc/mc traffic */
162 uint32 sendq_pkts[AC_COUNT + 1];
163 } athost_wl_stat_counters_t;
165 #define WLFC_HOST_FIFO_CREDIT_INC_SENTCTRS(ctx, ac) do {} while (0)
166 #define WLFC_HOST_FIFO_CREDIT_INC_BACKCTRS(ctx, ac) do {} while (0)
167 #define WLFC_HOST_FIFO_DROPPEDCTR_INC(ctx, ac) do {} while (0)
169 #define WLFC_FCMODE_NONE 0
170 #define WLFC_FCMODE_IMPLIED_CREDIT 1
171 #define WLFC_FCMODE_EXPLICIT_CREDIT 2
173 typedef struct athost_wl_status_info {
174 uint8 last_seqid_to_wlc;
182 athost_wl_stat_counters_t stats;
184 /* the additional ones are for bc/mc and ATIM FIFO */
185 int FIFO_credit[AC_COUNT + 2];
188 /* packet hanger and MAC->handle lookup table */
191 /* table for individual nodes */
192 wlfc_mac_descriptor_t nodes[WLFC_MAC_DESC_TABLE_SIZE];
193 /* table for interfaces */
194 wlfc_mac_descriptor_t interfaces[WLFC_MAX_IFNUM];
195 /* OS may send packets to unknown (unassociated) destinations */
196 /* A place holder for bc/mc and packets to unknown destinations */
197 wlfc_mac_descriptor_t other;
198 } destination_entries;
199 /* token position for different priority packets */
200 uint8 token_pos[AC_COUNT];
201 /* ON/OFF state for flow control to the host network interface */
202 uint8 hostif_flow_state[WLFC_MAX_IFNUM];
204 /* to flow control an OS interface */
205 uint8 toggle_host_if;
208 Mode in which the dhd flow control shall operate. Must be set before
209 traffic starts to the device.
210 0 - Do not do any proptxtstatus flow control
211 1 - Use implied credit from a packet status
212 2 - Use explicit credit
214 uint8 proptxstatus_mode;
215 } athost_wl_status_info_t;
217 #endif /* __wlfc_host_driver_definitions_h__ */