Merge tag 'soc-ep93xx-dt-6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-2.6-block.git] / drivers / net / wireless / marvell / mwifiex / uap_txrx.c
CommitLineData
828c91f7 1// SPDX-License-Identifier: GPL-2.0-only
838e4f44 2/*
932183aa 3 * NXP Wireless LAN device driver: AP TX and RX data handling
838e4f44 4 *
932183aa 5 * Copyright 2011-2020 NXP
838e4f44
AP
6 */
7
8#include "decl.h"
9#include "ioctl.h"
10#include "main.h"
11#include "wmm.h"
d1cf3b95
AP
12#include "11n_aggr.h"
13#include "11n_rxreorder.h"
838e4f44 14
61c87304
AP
15/* This function checks if particular RA list has packets more than low bridge
16 * packet threshold and then deletes packet from this RA list.
17 * Function deletes packets from such RA list and returns true. If no such list
18 * is found, false is returned.
19 */
20static bool
21mwifiex_uap_del_tx_pkts_in_ralist(struct mwifiex_private *priv,
70c5ad7e
ZL
22 struct list_head *ra_list_head,
23 int tid)
61c87304
AP
24{
25 struct mwifiex_ra_list_tbl *ra_list;
26 struct sk_buff *skb, *tmp;
27 bool pkt_deleted = false;
28 struct mwifiex_txinfo *tx_info;
29 struct mwifiex_adapter *adapter = priv->adapter;
30
31 list_for_each_entry(ra_list, ra_list_head, list) {
32 if (skb_queue_empty(&ra_list->skb_head))
33 continue;
34
35 skb_queue_walk_safe(&ra_list->skb_head, skb, tmp) {
36 tx_info = MWIFIEX_SKB_TXCB(skb);
37 if (tx_info->flags & MWIFIEX_BUF_FLAG_BRIDGED_PKT) {
38 __skb_unlink(skb, &ra_list->skb_head);
39 mwifiex_write_data_complete(adapter, skb, 0,
40 -1);
70c5ad7e
ZL
41 if (ra_list->tx_paused)
42 priv->wmm.pkts_paused[tid]--;
43 else
44 atomic_dec(&priv->wmm.tx_pkts_queued);
61c87304
AP
45 pkt_deleted = true;
46 }
47 if ((atomic_read(&adapter->pending_bridged_pkts) <=
48 MWIFIEX_BRIDGED_PKTS_THR_LOW))
49 break;
50 }
51 }
52
53 return pkt_deleted;
54}
55
56/* This function deletes packets from particular RA List. RA list index
57 * from which packets are deleted is preserved so that packets from next RA
58 * list are deleted upon subsequent call thus maintaining fairness.
59 */
60static void mwifiex_uap_cleanup_tx_queues(struct mwifiex_private *priv)
61{
61c87304
AP
62 struct list_head *ra_list;
63 int i;
64
8a7f9fd8 65 spin_lock_bh(&priv->wmm.ra_list_spinlock);
61c87304
AP
66
67 for (i = 0; i < MAX_NUM_TID; i++, priv->del_list_idx++) {
68 if (priv->del_list_idx == MAX_NUM_TID)
69 priv->del_list_idx = 0;
70 ra_list = &priv->wmm.tid_tbl_ptr[priv->del_list_idx].ra_list;
70c5ad7e 71 if (mwifiex_uap_del_tx_pkts_in_ralist(priv, ra_list, i)) {
61c87304
AP
72 priv->del_list_idx++;
73 break;
74 }
75 }
76
8a7f9fd8 77 spin_unlock_bh(&priv->wmm.ra_list_spinlock);
61c87304
AP
78}
79
80
838e4f44
AP
81static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv,
82 struct sk_buff *skb)
83{
84 struct mwifiex_adapter *adapter = priv->adapter;
85 struct uap_rxpd *uap_rx_pd;
86 struct rx_packet_hdr *rx_pkt_hdr;
87 struct sk_buff *new_skb;
88 struct mwifiex_txinfo *tx_info;
89 int hdr_chop;
8d93f1f3 90 struct ethhdr *p_ethhdr;
442f6f9b 91 struct mwifiex_sta_node *src_node;
bb28c28e 92 int index;
838e4f44
AP
93
94 uap_rx_pd = (struct uap_rxpd *)(skb->data);
95 rx_pkt_hdr = (void *)uap_rx_pd + le16_to_cpu(uap_rx_pd->rx_pkt_offset);
96
97 if ((atomic_read(&adapter->pending_bridged_pkts) >=
61c87304 98 MWIFIEX_BRIDGED_PKTS_THR_HIGH)) {
acebe8c1
ZL
99 mwifiex_dbg(priv->adapter, ERROR,
100 "Tx: Bridge packet limit reached. Drop packet!\n");
838e4f44 101 kfree_skb(skb);
61c87304 102 mwifiex_uap_cleanup_tx_queues(priv);
838e4f44
AP
103 return;
104 }
105
11958528
PP
106 if (sizeof(*rx_pkt_hdr) +
107 le16_to_cpu(uap_rx_pd->rx_pkt_offset) > skb->len) {
108 mwifiex_dbg(adapter, ERROR,
109 "wrong rx packet offset: len=%d,rx_pkt_offset=%d\n",
110 skb->len, le16_to_cpu(uap_rx_pd->rx_pkt_offset));
111 priv->stats.rx_dropped++;
112 dev_kfree_skb_any(skb);
2785851c 113 return;
11958528
PP
114 }
115
c613d16f
AK
116 if ((!memcmp(&rx_pkt_hdr->rfc1042_hdr, bridge_tunnel_header,
117 sizeof(bridge_tunnel_header))) ||
118 (!memcmp(&rx_pkt_hdr->rfc1042_hdr, rfc1042_header,
119 sizeof(rfc1042_header)) &&
120 ntohs(rx_pkt_hdr->rfc1042_hdr.snap_type) != ETH_P_AARP &&
121 ntohs(rx_pkt_hdr->rfc1042_hdr.snap_type) != ETH_P_IPX)) {
8d93f1f3
UR
122 /* Replace the 803 header and rfc1042 header (llc/snap) with
123 * an Ethernet II header, keep the src/dst and snap_type
124 * (ethertype).
125 *
126 * The firmware only passes up SNAP frames converting all RX
127 * data from 802.11 to 802.2/LLC/SNAP frames.
128 *
129 * To create the Ethernet II, just move the src, dst address
130 * right before the snap_type.
131 */
132 p_ethhdr = (struct ethhdr *)
133 ((u8 *)(&rx_pkt_hdr->eth803_hdr)
134 + sizeof(rx_pkt_hdr->eth803_hdr)
135 + sizeof(rx_pkt_hdr->rfc1042_hdr)
136 - sizeof(rx_pkt_hdr->eth803_hdr.h_dest)
137 - sizeof(rx_pkt_hdr->eth803_hdr.h_source)
138 - sizeof(rx_pkt_hdr->rfc1042_hdr.snap_type));
139 memcpy(p_ethhdr->h_source, rx_pkt_hdr->eth803_hdr.h_source,
140 sizeof(p_ethhdr->h_source));
141 memcpy(p_ethhdr->h_dest, rx_pkt_hdr->eth803_hdr.h_dest,
142 sizeof(p_ethhdr->h_dest));
838e4f44
AP
143 /* Chop off the rxpd + the excess memory from
144 * 802.2/llc/snap header that was removed.
145 */
8d93f1f3
UR
146 hdr_chop = (u8 *)p_ethhdr - (u8 *)uap_rx_pd;
147 } else {
838e4f44
AP
148 /* Chop off the rxpd */
149 hdr_chop = (u8 *)&rx_pkt_hdr->eth803_hdr - (u8 *)uap_rx_pd;
8d93f1f3 150 }
838e4f44 151
f7b59853 152 /* Chop off the leading header bytes so that it points
838e4f44
AP
153 * to the start of either the reconstructed EthII frame
154 * or the 802.2/llc/snap frame.
155 */
156 skb_pull(skb, hdr_chop);
157
158 if (skb_headroom(skb) < MWIFIEX_MIN_DATA_HEADER_LEN) {
acebe8c1
ZL
159 mwifiex_dbg(priv->adapter, ERROR,
160 "data: Tx: insufficient skb headroom %d\n",
161 skb_headroom(skb));
838e4f44
AP
162 /* Insufficient skb headroom - allocate a new skb */
163 new_skb =
164 skb_realloc_headroom(skb, MWIFIEX_MIN_DATA_HEADER_LEN);
165 if (unlikely(!new_skb)) {
acebe8c1
ZL
166 mwifiex_dbg(priv->adapter, ERROR,
167 "Tx: cannot allocate new_skb\n");
838e4f44
AP
168 kfree_skb(skb);
169 priv->stats.tx_dropped++;
170 return;
171 }
172
173 kfree_skb(skb);
174 skb = new_skb;
acebe8c1
ZL
175 mwifiex_dbg(priv->adapter, INFO,
176 "info: new skb headroom %d\n",
177 skb_headroom(skb));
838e4f44
AP
178 }
179
180 tx_info = MWIFIEX_SKB_TXCB(skb);
701a9e61 181 memset(tx_info, 0, sizeof(*tx_info));
838e4f44
AP
182 tx_info->bss_num = priv->bss_num;
183 tx_info->bss_type = priv->bss_type;
184 tx_info->flags |= MWIFIEX_BUF_FLAG_BRIDGED_PKT;
185
442f6f9b
XH
186 src_node = mwifiex_get_sta_entry(priv, rx_pkt_hdr->eth803_hdr.h_source);
187 if (src_node) {
188 src_node->stats.last_rx = jiffies;
189 src_node->stats.rx_bytes += skb->len;
190 src_node->stats.rx_packets++;
191 src_node->stats.last_tx_rate = uap_rx_pd->rx_rate;
192 src_node->stats.last_tx_htinfo = uap_rx_pd->ht_info;
193 }
194
f7b59853
UR
195 if (is_unicast_ether_addr(rx_pkt_hdr->eth803_hdr.h_dest)) {
196 /* Update bridge packet statistics as the
197 * packet is not going to kernel/upper layer.
198 */
199 priv->stats.rx_bytes += skb->len;
200 priv->stats.rx_packets++;
201
202 /* Sending bridge packet to TX queue, so save the packet
203 * length in TXCB to update statistics in TX complete.
204 */
205 tx_info->pkt_len = skb->len;
206 }
207
c64800e7 208 __net_timestamp(skb);
bb28c28e
MF
209
210 index = mwifiex_1d_to_wmm_queue[skb->priority];
211 atomic_inc(&priv->wmm_tx_pending[index]);
838e4f44
AP
212 mwifiex_wmm_add_buf_txqueue(priv, skb);
213 atomic_inc(&adapter->tx_pending);
214 atomic_inc(&adapter->pending_bridged_pkts);
215
ad5ca845
XH
216 mwifiex_queue_main_work(priv->adapter);
217
838e4f44
AP
218 return;
219}
220
221/*
222 * This function contains logic for AP packet forwarding.
223 *
224 * If a packet is multicast/broadcast, it is sent to kernel/upper layer
225 * as well as queued back to AP TX queue so that it can be sent to other
226 * associated stations.
227 * If a packet is unicast and RA is present in associated station list,
228 * it is again requeued into AP TX queue.
229 * If a packet is unicast and RA is not in associated station list,
230 * packet is forwarded to kernel to handle routing logic.
231 */
232int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv,
233 struct sk_buff *skb)
234{
235 struct mwifiex_adapter *adapter = priv->adapter;
236 struct uap_rxpd *uap_rx_pd;
237 struct rx_packet_hdr *rx_pkt_hdr;
238 u8 ra[ETH_ALEN];
239 struct sk_buff *skb_uap;
240
241 uap_rx_pd = (struct uap_rxpd *)(skb->data);
242 rx_pkt_hdr = (void *)uap_rx_pd + le16_to_cpu(uap_rx_pd->rx_pkt_offset);
243
244 /* don't do packet forwarding in disconnected state */
245 if (!priv->media_connected) {
acebe8c1
ZL
246 mwifiex_dbg(adapter, ERROR,
247 "drop packet in disconnected state.\n");
838e4f44
AP
248 dev_kfree_skb_any(skb);
249 return 0;
250 }
251
252 memcpy(ra, rx_pkt_hdr->eth803_hdr.h_dest, ETH_ALEN);
253
254 if (is_multicast_ether_addr(ra)) {
255 skb_uap = skb_copy(skb, GFP_ATOMIC);
35a7a1ce
DA
256 if (likely(skb_uap)) {
257 mwifiex_uap_queue_bridged_pkt(priv, skb_uap);
258 } else {
259 mwifiex_dbg(adapter, ERROR,
260 "failed to copy skb for uAP\n");
261 priv->stats.rx_dropped++;
262 dev_kfree_skb_any(skb);
263 return -1;
264 }
838e4f44
AP
265 } else {
266 if (mwifiex_get_sta_entry(priv, ra)) {
267 /* Requeue Intra-BSS packet */
268 mwifiex_uap_queue_bridged_pkt(priv, skb);
269 return 0;
270 }
271 }
272
273 /* Forward unicat/Inter-BSS packets to kernel. */
f3b369e4 274 return mwifiex_process_rx_packet(priv, skb);
838e4f44
AP
275}
276
bf00dc22
XH
277int mwifiex_uap_recv_packet(struct mwifiex_private *priv,
278 struct sk_buff *skb)
279{
3fdbda44 280 struct mwifiex_adapter *adapter = priv->adapter;
bf00dc22
XH
281 struct mwifiex_sta_node *src_node;
282 struct ethhdr *p_ethhdr;
283 struct sk_buff *skb_uap;
284 struct mwifiex_txinfo *tx_info;
285
286 if (!skb)
287 return -1;
288
289 p_ethhdr = (void *)skb->data;
290 src_node = mwifiex_get_sta_entry(priv, p_ethhdr->h_source);
291 if (src_node) {
292 src_node->stats.last_rx = jiffies;
293 src_node->stats.rx_bytes += skb->len;
294 src_node->stats.rx_packets++;
295 }
296
bf00dc22
XH
297 if (is_multicast_ether_addr(p_ethhdr->h_dest) ||
298 mwifiex_get_sta_entry(priv, p_ethhdr->h_dest)) {
299 if (skb_headroom(skb) < MWIFIEX_MIN_DATA_HEADER_LEN)
300 skb_uap =
301 skb_realloc_headroom(skb, MWIFIEX_MIN_DATA_HEADER_LEN);
302 else
303 skb_uap = skb_copy(skb, GFP_ATOMIC);
304
305 if (likely(skb_uap)) {
306 tx_info = MWIFIEX_SKB_TXCB(skb_uap);
307 memset(tx_info, 0, sizeof(*tx_info));
308 tx_info->bss_num = priv->bss_num;
309 tx_info->bss_type = priv->bss_type;
310 tx_info->flags |= MWIFIEX_BUF_FLAG_BRIDGED_PKT;
311 __net_timestamp(skb_uap);
312 mwifiex_wmm_add_buf_txqueue(priv, skb_uap);
313 atomic_inc(&adapter->tx_pending);
314 atomic_inc(&adapter->pending_bridged_pkts);
315 if ((atomic_read(&adapter->pending_bridged_pkts) >=
316 MWIFIEX_BRIDGED_PKTS_THR_HIGH)) {
317 mwifiex_dbg(adapter, ERROR,
318 "Tx: Bridge packet limit reached. Drop packet!\n");
319 mwifiex_uap_cleanup_tx_queues(priv);
320 }
321
322 } else {
323 mwifiex_dbg(adapter, ERROR, "failed to allocate skb_uap");
324 }
325
326 mwifiex_queue_main_work(adapter);
327 /* Don't forward Intra-BSS unicast packet to upper layer*/
328 if (mwifiex_get_sta_entry(priv, p_ethhdr->h_dest))
329 return 0;
330 }
331
38013eef
XH
332 skb->dev = priv->netdev;
333 skb->protocol = eth_type_trans(skb, priv->netdev);
334 skb->ip_summed = CHECKSUM_NONE;
335
336 /* This is required only in case of 11n and USB/PCIE as we alloc
337 * a buffer of 4K only if its 11N (to be able to receive 4K
338 * AMSDU packets). In case of SD we allocate buffers based
339 * on the size of packet and hence this is not needed.
340 *
341 * Modifying the truesize here as our allocation for each
342 * skb is 4K but we only receive 2K packets and this cause
343 * the kernel to start dropping packets in case where
344 * application has allocated buffer based on 2K size i.e.
345 * if there a 64K packet received (in IP fragments and
346 * application allocates 64K to receive this packet but
347 * this packet would almost double up because we allocate
348 * each 1.5K fragment in 4K and pass it up. As soon as the
349 * 64K limit hits kernel will start to drop rest of the
350 * fragments. Currently we fail the Filesndl-ht.scr script
351 * for UDP, hence this fix
352 */
353 if ((adapter->iface_type == MWIFIEX_USB ||
354 adapter->iface_type == MWIFIEX_PCIE) &&
355 skb->truesize > MWIFIEX_RX_DATA_BUF_SIZE)
356 skb->truesize += (skb->len - MWIFIEX_RX_DATA_BUF_SIZE);
357
bf00dc22 358 /* Forward multicast/broadcast packet to upper layer*/
afb6d39f 359 netif_rx(skb);
bf00dc22
XH
360 return 0;
361}
362
838e4f44
AP
363/*
364 * This function processes the packet received on AP interface.
365 *
366 * The function looks into the RxPD and performs sanity tests on the
367 * received buffer to ensure its a valid packet before processing it
368 * further. If the packet is determined to be aggregated, it is
369 * de-aggregated accordingly. Then skb is passed to AP packet forwarding logic.
370 *
371 * The completion callback is called after processing is complete.
372 */
f3b369e4 373int mwifiex_process_uap_rx_packet(struct mwifiex_private *priv,
838e4f44
AP
374 struct sk_buff *skb)
375{
f3b369e4 376 struct mwifiex_adapter *adapter = priv->adapter;
838e4f44
AP
377 int ret;
378 struct uap_rxpd *uap_rx_pd;
838e4f44
AP
379 struct rx_packet_hdr *rx_pkt_hdr;
380 u16 rx_pkt_type;
d1cf3b95
AP
381 u8 ta[ETH_ALEN], pkt_type;
382 struct mwifiex_sta_node *node;
383
838e4f44
AP
384 uap_rx_pd = (struct uap_rxpd *)(skb->data);
385 rx_pkt_type = le16_to_cpu(uap_rx_pd->rx_pkt_type);
386 rx_pkt_hdr = (void *)uap_rx_pd + le16_to_cpu(uap_rx_pd->rx_pkt_offset);
387
11958528
PP
388 if (le16_to_cpu(uap_rx_pd->rx_pkt_offset) +
389 sizeof(rx_pkt_hdr->eth803_hdr) > skb->len) {
390 mwifiex_dbg(adapter, ERROR,
391 "wrong rx packet for struct ethhdr: len=%d, offset=%d\n",
392 skb->len, le16_to_cpu(uap_rx_pd->rx_pkt_offset));
393 priv->stats.rx_dropped++;
394 dev_kfree_skb_any(skb);
395 return 0;
396 }
397
442f6f9b
XH
398 ether_addr_copy(ta, rx_pkt_hdr->eth803_hdr.h_source);
399
838e4f44
AP
400 if ((le16_to_cpu(uap_rx_pd->rx_pkt_offset) +
401 le16_to_cpu(uap_rx_pd->rx_pkt_length)) > (u16) skb->len) {
acebe8c1
ZL
402 mwifiex_dbg(adapter, ERROR,
403 "wrong rx packet: len=%d, offset=%d, length=%d\n",
404 skb->len, le16_to_cpu(uap_rx_pd->rx_pkt_offset),
405 le16_to_cpu(uap_rx_pd->rx_pkt_length));
838e4f44 406 priv->stats.rx_dropped++;
442f6f9b
XH
407
408 node = mwifiex_get_sta_entry(priv, ta);
409 if (node)
410 node->stats.tx_failed++;
411
ca8d6dfc 412 dev_kfree_skb_any(skb);
838e4f44
AP
413 return 0;
414 }
838e4f44 415
4c9f9fb2 416 if (rx_pkt_type == PKT_TYPE_MGMT) {
f3b369e4 417 ret = mwifiex_process_mgmt_packet(priv, skb);
2dbaf751 418 if (ret)
bd642acf 419 mwifiex_dbg(adapter, DATA, "Rx of mgmt packet failed");
2dbaf751
SP
420 dev_kfree_skb_any(skb);
421 return ret;
d1cf3b95
AP
422 }
423
d1cf3b95
AP
424
425 if (rx_pkt_type != PKT_TYPE_BAR && uap_rx_pd->priority < MAX_NUM_TID) {
8a7f9fd8 426 spin_lock_bh(&priv->sta_list_spinlock);
d1cf3b95
AP
427 node = mwifiex_get_sta_entry(priv, ta);
428 if (node)
429 node->rx_seq[uap_rx_pd->priority] =
430 le16_to_cpu(uap_rx_pd->seq_num);
8a7f9fd8 431 spin_unlock_bh(&priv->sta_list_spinlock);
d1cf3b95
AP
432 }
433
434 if (!priv->ap_11n_enabled ||
435 (!mwifiex_11n_get_rx_reorder_tbl(priv, uap_rx_pd->priority, ta) &&
436 (le16_to_cpu(uap_rx_pd->rx_pkt_type) != PKT_TYPE_AMSDU))) {
437 ret = mwifiex_handle_uap_rx_forward(priv, skb);
438 return ret;
439 }
440
441 /* Reorder and send to kernel */
442 pkt_type = (u8)le16_to_cpu(uap_rx_pd->rx_pkt_type);
443 ret = mwifiex_11n_rx_reorder_pkt(priv, le16_to_cpu(uap_rx_pd->seq_num),
444 uap_rx_pd->priority, ta, pkt_type,
445 skb);
446
ca8d6dfc
UR
447 if (ret || (rx_pkt_type == PKT_TYPE_BAR))
448 dev_kfree_skb_any(skb);
838e4f44 449
d1cf3b95
AP
450 if (ret)
451 priv->stats.rx_dropped++;
452
838e4f44
AP
453 return ret;
454}
4ac8764a
AP
455
456/*
457 * This function fills the TxPD for AP tx packets.
458 *
459 * The Tx buffer received by this function should already have the
460 * header space allocated for TxPD.
461 *
462 * This function inserts the TxPD in between interface header and actual
463 * data and adjusts the buffer pointers accordingly.
464 *
465 * The following TxPD fields are set by this function, as required -
466 * - BSS number
467 * - Tx packet length and offset
468 * - Priority
469 * - Packet delay
470 * - Priority specific Tx control
471 * - Flags
472 */
35983875
DA
473void mwifiex_process_uap_txpd(struct mwifiex_private *priv,
474 struct sk_buff *skb)
4ac8764a
AP
475{
476 struct mwifiex_adapter *adapter = priv->adapter;
477 struct uap_txpd *txpd;
478 struct mwifiex_txinfo *tx_info = MWIFIEX_SKB_TXCB(skb);
84b313b3
XH
479 int pad;
480 u16 pkt_type, pkt_offset;
f4c5d599 481 int hroom = adapter->intf_hdr_len;
4ac8764a 482
84b313b3 483 pkt_type = mwifiex_is_skb_mgmt_frame(skb) ? PKT_TYPE_MGMT : 0;
4ac8764a 484
603a1621
AB
485 pad = ((uintptr_t)skb->data - (sizeof(*txpd) + hroom)) &
486 (MWIFIEX_DMA_ALIGN_SZ - 1);
4ac8764a 487
84b313b3 488 skb_push(skb, sizeof(*txpd) + pad);
4ac8764a
AP
489
490 txpd = (struct uap_txpd *)skb->data;
491 memset(txpd, 0, sizeof(*txpd));
492 txpd->bss_num = priv->bss_num;
493 txpd->bss_type = priv->bss_type;
84b313b3
XH
494 txpd->tx_pkt_length = cpu_to_le16((u16)(skb->len - (sizeof(*txpd) +
495 pad)));
4ac8764a 496 txpd->priority = (u8)skb->priority;
808bbebc 497
4ac8764a
AP
498 txpd->pkt_delay_2ms = mwifiex_wmm_compute_drv_pkt_delay(priv, skb);
499
18ca4382
AK
500 if (tx_info->flags & MWIFIEX_BUF_FLAG_EAPOL_TX_STATUS ||
501 tx_info->flags & MWIFIEX_BUF_FLAG_ACTION_TX_STATUS) {
808bbebc
AK
502 txpd->tx_token_id = tx_info->ack_frame_id;
503 txpd->flags |= MWIFIEX_TXPD_FLAGS_REQ_TX_STATUS;
504 }
505
4ac8764a
AP
506 if (txpd->priority < ARRAY_SIZE(priv->wmm.user_pri_pkt_tx_ctrl))
507 /*
508 * Set the priority specific tx_control field, setting of 0 will
509 * cause the default value to be used later in this function.
510 */
511 txpd->tx_control =
512 cpu_to_le32(priv->wmm.user_pri_pkt_tx_ctrl[txpd->priority]);
513
514 /* Offset of actual data */
84b313b3 515 pkt_offset = sizeof(*txpd) + pad;
3215215a
SP
516 if (pkt_type == PKT_TYPE_MGMT) {
517 /* Set the packet type and add header for management frame */
518 txpd->tx_pkt_type = cpu_to_le16(pkt_type);
84b313b3 519 pkt_offset += MWIFIEX_MGMT_FRAME_HEADER_SIZE;
3215215a
SP
520 }
521
84b313b3 522 txpd->tx_pkt_offset = cpu_to_le16(pkt_offset);
4ac8764a 523
f4c5d599 524 /* make space for adapter->intf_hdr_len */
84b313b3 525 skb_push(skb, hroom);
4ac8764a
AP
526
527 if (!txpd->tx_control)
528 /* TxCtrl set by user or default */
529 txpd->tx_control = cpu_to_le32(priv->pkt_tx_ctrl);
4ac8764a 530}