2 * @file Header file describing the flow rings DHD interfaces.
4 * Flow rings are transmit traffic (=propagating towards antenna) related entities.
6 * Provides type definitions and function prototypes used to create, delete and manage flow rings at
9 * Copyright (C) 1999-2017, Broadcom Corporation
11 * Unless you and Broadcom execute a separate written software license
12 * agreement governing use of this software, this software is licensed to you
13 * under the terms of the GNU General Public License version 2 (the "GPL"),
14 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
15 * following added to such license:
17 * As a special exception, the copyright holders of this software give you
18 * permission to link this software with independent modules, and to copy and
19 * distribute the resulting executable under terms of your choice, provided that
20 * you also meet, for each linked independent module, the terms and conditions of
21 * the license of that module. An independent module is a module which is not
22 * derived from this software. The special exception does not apply to any
23 * modifications of the software.
25 * Notwithstanding the above, under no circumstances may you combine this
26 * software in any way with any other Broadcom software provided under a license
27 * other than the GPL, without Broadcom's express prior written consent.
30 * <<Broadcom-WL-IPTag/Open:>>
32 * $Id: dhd_flowring.h 672438 2016-11-28 12:35:24Z $
40 #ifndef _dhd_flowrings_h_
41 #define _dhd_flowrings_h_
43 /* Max pkts held in a flow ring's backup queue */
44 #define FLOW_RING_QUEUE_THRESHOLD (2048)
46 /* Number of H2D common rings */
47 #define FLOW_RING_COMMON BCMPCIE_H2D_COMMON_MSGRINGS
49 #define FLOWID_INVALID (ID16_INVALID)
50 #define FLOWID_RESERVED (FLOW_RING_COMMON)
52 #define FLOW_RING_STATUS_OPEN 0
53 #define FLOW_RING_STATUS_CREATE_PENDING 1
54 #define FLOW_RING_STATUS_CLOSED 2
55 #define FLOW_RING_STATUS_DELETE_PENDING 3
56 #define FLOW_RING_STATUS_FLUSH_PENDING 4
58 #ifdef IDLE_TX_FLOW_MGMT
59 #define FLOW_RING_STATUS_SUSPENDED 5
60 #define FLOW_RING_STATUS_RESUME_PENDING 6
61 #endif /* IDLE_TX_FLOW_MGMT */
62 #define FLOW_RING_STATUS_STA_FREEING 7
65 #define DHD_FLOWRING_RX_BUFPOST_PKTSZ 1600
67 #define DHD_FLOWRING_RX_BUFPOST_PKTSZ 2048
70 #define DHD_FLOW_PRIO_AC_MAP 0
71 #define DHD_FLOW_PRIO_TID_MAP 1
72 /* Flow ring prority map for lossless roaming */
73 #define DHD_FLOW_PRIO_LLR_MAP 2
75 /* Hashing a MacAddress for lkup into a per interface flow hash table */
76 #define DHD_FLOWRING_HASH_SIZE 256
77 #define DHD_FLOWRING_HASHINDEX(ea, prio) \
78 ((((uint8 *)(ea))[3] ^ ((uint8 *)(ea))[4] ^ ((uint8 *)(ea))[5] ^ ((uint8)(prio))) \
79 % DHD_FLOWRING_HASH_SIZE)
81 #define DHD_IF_ROLE(pub, idx) (((if_flow_lkup_t *)(pub)->if_flow_lkup)[idx].role)
82 #define DHD_IF_ROLE_AP(pub, idx) (DHD_IF_ROLE(pub, idx) == WLC_E_IF_ROLE_AP)
83 #define DHD_IF_ROLE_STA(pub, idx) (DHD_IF_ROLE(pub, idx) == WLC_E_IF_ROLE_STA)
84 #define DHD_IF_ROLE_P2PGO(pub, idx) (DHD_IF_ROLE(pub, idx) == WLC_E_IF_ROLE_P2P_GO)
85 #define DHD_IF_ROLE_WDS(pub, idx) (DHD_IF_ROLE(pub, idx) == WLC_E_IF_ROLE_WDS)
86 #define DHD_FLOW_RING(dhdp, flowid) \
87 (flow_ring_node_t *)&(((flow_ring_node_t *)((dhdp)->flow_ring_table))[flowid])
91 /* Flow Ring Queue Enqueue overflow callback */
92 typedef int (*flow_queue_cb_t
)(struct flow_queue
* queue
, void * pkt
);
95 * Each flow ring has an associated (tx flow controlled) queue. 802.3 packets are transferred
96 * between queue and ring. A packet from the host stack is first added to the queue, and in a later
97 * stage transferred to the flow ring. Packets in the queue are dhd owned, whereas packets in the
98 * flow ring are device owned.
100 typedef struct flow_queue
{
101 dll_t list
; /* manage a flowring queue in a double linked list */
102 void * head
; /* first packet in the queue */
103 void * tail
; /* last packet in the queue */
104 uint16 len
; /* number of packets in the queue */
105 uint16 max
; /* maximum or min budget (used in cumm) */
106 uint32 threshold
; /* parent's cummulative length threshold */
107 void * clen_ptr
; /* parent's cummulative length counter */
108 uint32 failures
; /* enqueue failures due to queue overflow */
109 flow_queue_cb_t cb
; /* callback invoked on threshold crossing */
110 uint32 l2threshold
; /* grandparent's (level 2) cummulative length threshold */
111 void * l2clen_ptr
; /* grandparent's (level 2) cummulative length counter */
114 #define DHD_FLOW_QUEUE_LEN(queue) ((int)(queue)->len)
115 #define DHD_FLOW_QUEUE_MAX(queue) ((int)(queue)->max)
116 #define DHD_FLOW_QUEUE_THRESHOLD(queue) ((int)(queue)->threshold)
117 #define DHD_FLOW_QUEUE_L2THRESHOLD(queue) ((int)(queue)->l2threshold)
118 #define DHD_FLOW_QUEUE_EMPTY(queue) ((queue)->len == 0)
119 #define DHD_FLOW_QUEUE_FAILURES(queue) ((queue)->failures)
121 #define DHD_FLOW_QUEUE_AVAIL(queue) ((int)((queue)->max - (queue)->len))
122 #define DHD_FLOW_QUEUE_FULL(queue) ((queue)->len >= (queue)->max)
124 #define DHD_FLOW_QUEUE_OVFL(queue, budget) \
125 (((queue)->len) > budget)
127 #define DHD_FLOW_QUEUE_SET_MAX(queue, budget) \
128 ((queue)->max) = ((budget) - 1)
130 /* Queue's cummulative threshold. */
131 #define DHD_FLOW_QUEUE_SET_THRESHOLD(queue, cumm_threshold) \
132 ((queue)->threshold) = ((cumm_threshold) - 1)
134 /* Queue's cummulative length object accessor. */
135 #define DHD_FLOW_QUEUE_CLEN_PTR(queue) ((queue)->clen_ptr)
137 /* Set a queue's cumm_len point to a parent's cumm_ctr_t cummulative length */
138 #define DHD_FLOW_QUEUE_SET_CLEN(queue, parent_clen_ptr) \
139 ((queue)->clen_ptr) = (void *)(parent_clen_ptr)
141 /* Queue's level 2 cummulative threshold. */
142 #define DHD_FLOW_QUEUE_SET_L2THRESHOLD(queue, l2cumm_threshold) \
143 ((queue)->l2threshold) = ((l2cumm_threshold) - 1)
145 /* Queue's level 2 cummulative length object accessor. */
146 #define DHD_FLOW_QUEUE_L2CLEN_PTR(queue) ((queue)->l2clen_ptr)
148 /* Set a queue's level 2 cumm_len point to a grandparent's cumm_ctr_t cummulative length */
149 #define DHD_FLOW_QUEUE_SET_L2CLEN(queue, grandparent_clen_ptr) \
150 ((queue)->l2clen_ptr) = (void *)(grandparent_clen_ptr)
152 /* see wlfc_proto.h for tx status details */
153 #define DHD_FLOWRING_MAXSTATUS_MSGS 5
154 #define DHD_FLOWRING_TXSTATUS_CNT_UPDATE(bus, flowid, txstatus)
156 /* Pkttag not compatible with PROP_TXSTATUS or WLFC */
157 typedef struct dhd_pkttag_fr
{
165 #define DHD_PKTTAG_SET_IFID(tag, idx) ((tag)->ifid = (uint16)(idx))
166 #define DHD_PKTTAG_SET_PA(tag, pa) ((tag)->physaddr = (pa))
167 #define DHD_PKTTAG_SET_PA_LEN(tag, palen) ((tag)->pa_len = (palen))
168 #define DHD_PKTTAG_IFID(tag) ((tag)->ifid)
169 #define DHD_PKTTAG_PA(tag) ((tag)->physaddr)
170 #define DHD_PKTTAG_PA_LEN(tag) ((tag)->pa_len)
173 /** each flow ring is dedicated to a tid/sa/da combination */
174 typedef struct flow_info
{
177 char sa
[ETHER_ADDR_LEN
];
178 char da
[ETHER_ADDR_LEN
];
181 /** a flow ring is used for outbound (towards antenna) 802.3 packets */
182 typedef struct flow_ring_node
{
183 dll_t list
; /* manage a constructed flowring in a dll, must be at first place */
184 flow_queue_t queue
; /* queues packets before they enter the flow ring, flow control */
188 * flowid: unique ID of a flow ring, which can either be unicast or broadcast/multicast. For
189 * unicast flow rings, the flow id accelerates ARM 802.3->802.11 header translation.
192 flow_info_t flow_info
;
194 void *lock
; /* lock for flowring access protection */
196 #ifdef IDLE_TX_FLOW_MGMT
197 uint64 last_active_ts
; /* contains last active timestamp */
198 #endif /* IDLE_TX_FLOW_MGMT */
199 #ifdef DEVICE_TX_STUCK_DETECT
200 /* Time stamp(msec) when last time a Tx packet completion is received on this flow ring */
203 * Holds the tx_cmpl which was read during the previous
204 * iteration of the stuck detection algo
207 /* counter to decide if this particlur flow is stuck or not */
209 #endif /* DEVICE_TX_STUCK_DETECT */
213 typedef flow_ring_node_t flow_ring_table_t
;
215 typedef struct flow_hash_info
{
217 flow_info_t flow_info
;
218 struct flow_hash_info
*next
;
221 typedef struct if_flow_lkup
{
223 uint8 role
; /* Interface role: STA/AP */
224 flow_hash_info_t
*fl_hash
[DHD_FLOWRING_HASH_SIZE
]; /* Lkup Hash table */
227 static INLINE flow_ring_node_t
*
228 dhd_constlist_to_flowring(dll_t
*item
)
230 return ((flow_ring_node_t
*)item
);
235 /* Flow ring's queue management functions */
236 extern flow_ring_node_t
* dhd_flow_ring_node(dhd_pub_t
*dhdp
, uint16 flowid
);
237 extern flow_queue_t
* dhd_flow_queue(dhd_pub_t
*dhdp
, uint16 flowid
);
239 extern void dhd_flow_queue_init(dhd_pub_t
*dhdp
, flow_queue_t
*queue
, int max
);
240 extern void dhd_flow_queue_reinit(dhd_pub_t
*dhdp
, flow_queue_t
*queue
, int max
);
241 extern void dhd_flow_queue_register(flow_queue_t
*queue
, flow_queue_cb_t cb
);
242 extern int dhd_flow_queue_enqueue(dhd_pub_t
*dhdp
, flow_queue_t
*queue
, void *pkt
);
243 extern void * dhd_flow_queue_dequeue(dhd_pub_t
*dhdp
, flow_queue_t
*queue
);
244 extern void dhd_flow_queue_reinsert(dhd_pub_t
*dhdp
, flow_queue_t
*queue
, void *pkt
);
246 extern void dhd_flow_ring_config_thresholds(dhd_pub_t
*dhdp
, uint16 flowid
,
247 int queue_budget
, int cumm_threshold
, void *cumm_ctr
,
248 int l2cumm_threshold
, void *l2cumm_ctr
);
249 extern int dhd_flow_rings_init(dhd_pub_t
*dhdp
, uint32 num_flow_rings
);
251 extern void dhd_flow_rings_deinit(dhd_pub_t
*dhdp
);
253 extern int dhd_flowid_update(dhd_pub_t
*dhdp
, uint8 ifindex
, uint8 prio
,
256 extern void dhd_flowid_free(dhd_pub_t
*dhdp
, uint8 ifindex
, uint16 flowid
);
258 extern void dhd_flow_rings_delete(dhd_pub_t
*dhdp
, uint8 ifindex
);
259 extern void dhd_flow_rings_flush(dhd_pub_t
*dhdp
, uint8 ifindex
);
261 extern void dhd_flow_rings_delete_for_peer(dhd_pub_t
*dhdp
, uint8 ifindex
,
264 /* Handle Interface ADD, DEL operations */
265 extern void dhd_update_interface_flow_info(dhd_pub_t
*dhdp
, uint8 ifindex
,
266 uint8 op
, uint8 role
);
268 /* Handle a STA interface link status update */
269 extern int dhd_update_interface_link_status(dhd_pub_t
*dhdp
, uint8 ifindex
,
271 extern int dhd_flow_prio_map(dhd_pub_t
*dhd
, uint8
*map
, bool set
);
272 extern int dhd_update_flow_prio_map(dhd_pub_t
*dhdp
, uint8 map
);
274 extern uint8
dhd_flow_rings_ifindex2role(dhd_pub_t
*dhdp
, uint8 ifindex
);
275 #endif /* _dhd_flowrings_h_ */