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