cfg80211: remove 80+80 MHz rate reporting
[deliverable/linux.git] / drivers / net / wireless / mwifiex / sta_tx.c
1 /*
2 * Marvell Wireless LAN device driver: station TX data handling
3 *
4 * Copyright (C) 2011-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 "util.h"
23 #include "fw.h"
24 #include "main.h"
25 #include "wmm.h"
26
27 /*
28 * This function fills the TxPD for tx packets.
29 *
30 * The Tx buffer received by this function should already have the
31 * header space allocated for TxPD.
32 *
33 * This function inserts the TxPD in between interface header and actual
34 * data and adjusts the buffer pointers accordingly.
35 *
36 * The following TxPD fields are set by this function, as required -
37 * - BSS number
38 * - Tx packet length and offset
39 * - Priority
40 * - Packet delay
41 * - Priority specific Tx control
42 * - Flags
43 */
44 void *mwifiex_process_sta_txpd(struct mwifiex_private *priv,
45 struct sk_buff *skb)
46 {
47 struct mwifiex_adapter *adapter = priv->adapter;
48 struct txpd *local_tx_pd;
49 struct mwifiex_txinfo *tx_info = MWIFIEX_SKB_TXCB(skb);
50 u8 pad;
51 u16 pkt_type, pkt_offset;
52
53 if (!skb->len) {
54 dev_err(adapter->dev, "Tx: bad packet length: %d\n", skb->len);
55 tx_info->status_code = -1;
56 return skb->data;
57 }
58
59 pkt_type = mwifiex_is_skb_mgmt_frame(skb) ? PKT_TYPE_MGMT : 0;
60
61 /* If skb->data is not aligned; add padding */
62 pad = (4 - (((void *)skb->data - NULL) & 0x3)) % 4;
63
64 BUG_ON(skb_headroom(skb) < (sizeof(*local_tx_pd) + INTF_HEADER_LEN
65 + pad));
66 skb_push(skb, sizeof(*local_tx_pd) + pad);
67
68 local_tx_pd = (struct txpd *) skb->data;
69 memset(local_tx_pd, 0, sizeof(struct txpd));
70 local_tx_pd->bss_num = priv->bss_num;
71 local_tx_pd->bss_type = priv->bss_type;
72 local_tx_pd->tx_pkt_length = cpu_to_le16((u16)(skb->len -
73 (sizeof(struct txpd)
74 + pad)));
75
76 local_tx_pd->priority = (u8) skb->priority;
77 local_tx_pd->pkt_delay_2ms =
78 mwifiex_wmm_compute_drv_pkt_delay(priv, skb);
79
80 if (tx_info->flags & MWIFIEX_BUF_FLAG_EAPOL_TX_STATUS ||
81 tx_info->flags & MWIFIEX_BUF_FLAG_ACTION_TX_STATUS) {
82 local_tx_pd->tx_token_id = tx_info->ack_frame_id;
83 local_tx_pd->flags |= MWIFIEX_TXPD_FLAGS_REQ_TX_STATUS;
84 }
85
86 if (local_tx_pd->priority <
87 ARRAY_SIZE(priv->wmm.user_pri_pkt_tx_ctrl))
88 /*
89 * Set the priority specific tx_control field, setting of 0 will
90 * cause the default value to be used later in this function
91 */
92 local_tx_pd->tx_control =
93 cpu_to_le32(priv->wmm.user_pri_pkt_tx_ctrl[local_tx_pd->
94 priority]);
95
96 if (adapter->pps_uapsd_mode) {
97 if (mwifiex_check_last_packet_indication(priv)) {
98 adapter->tx_lock_flag = true;
99 local_tx_pd->flags =
100 MWIFIEX_TxPD_POWER_MGMT_LAST_PACKET;
101 }
102 }
103
104 if (tx_info->flags & MWIFIEX_BUF_FLAG_TDLS_PKT)
105 local_tx_pd->flags |= MWIFIEX_TXPD_FLAGS_TDLS_PACKET;
106
107 /* Offset of actual data */
108 pkt_offset = sizeof(struct txpd) + pad;
109 if (pkt_type == PKT_TYPE_MGMT) {
110 /* Set the packet type and add header for management frame */
111 local_tx_pd->tx_pkt_type = cpu_to_le16(pkt_type);
112 pkt_offset += MWIFIEX_MGMT_FRAME_HEADER_SIZE;
113 }
114
115 local_tx_pd->tx_pkt_offset = cpu_to_le16(pkt_offset);
116
117 /* make space for INTF_HEADER_LEN */
118 skb_push(skb, INTF_HEADER_LEN);
119
120 if (!local_tx_pd->tx_control)
121 /* TxCtrl set by user or default */
122 local_tx_pd->tx_control = cpu_to_le32(priv->pkt_tx_ctrl);
123
124 return skb->data;
125 }
126
127 /*
128 * This function tells firmware to send a NULL data packet.
129 *
130 * The function creates a NULL data packet with TxPD and sends to the
131 * firmware for transmission, with highest priority setting.
132 */
133 int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags)
134 {
135 struct mwifiex_adapter *adapter = priv->adapter;
136 struct txpd *local_tx_pd;
137 struct mwifiex_tx_param tx_param;
138 /* sizeof(struct txpd) + Interface specific header */
139 #define NULL_PACKET_HDR 64
140 u32 data_len = NULL_PACKET_HDR;
141 struct sk_buff *skb;
142 int ret;
143 struct mwifiex_txinfo *tx_info = NULL;
144
145 if (adapter->surprise_removed)
146 return -1;
147
148 if (!priv->media_connected)
149 return -1;
150
151 if (adapter->data_sent)
152 return -1;
153
154 skb = dev_alloc_skb(data_len);
155 if (!skb)
156 return -1;
157
158 tx_info = MWIFIEX_SKB_TXCB(skb);
159 memset(tx_info, 0, sizeof(*tx_info));
160 tx_info->bss_num = priv->bss_num;
161 tx_info->bss_type = priv->bss_type;
162 tx_info->pkt_len = data_len - (sizeof(struct txpd) + INTF_HEADER_LEN);
163 skb_reserve(skb, sizeof(struct txpd) + INTF_HEADER_LEN);
164 skb_push(skb, sizeof(struct txpd));
165
166 local_tx_pd = (struct txpd *) skb->data;
167 local_tx_pd->tx_control = cpu_to_le32(priv->pkt_tx_ctrl);
168 local_tx_pd->flags = flags;
169 local_tx_pd->priority = WMM_HIGHEST_PRIORITY;
170 local_tx_pd->tx_pkt_offset = cpu_to_le16(sizeof(struct txpd));
171 local_tx_pd->bss_num = priv->bss_num;
172 local_tx_pd->bss_type = priv->bss_type;
173
174 if (adapter->iface_type == MWIFIEX_USB) {
175 ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_USB_EP_DATA,
176 skb, NULL);
177 } else {
178 skb_push(skb, INTF_HEADER_LEN);
179 tx_param.next_pkt_len = 0;
180 ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_TYPE_DATA,
181 skb, &tx_param);
182 }
183 switch (ret) {
184 case -EBUSY:
185 adapter->data_sent = true;
186 /* Fall through FAILURE handling */
187 case -1:
188 dev_kfree_skb_any(skb);
189 dev_err(adapter->dev, "%s: host_to_card failed: ret=%d\n",
190 __func__, ret);
191 adapter->dbg.num_tx_host_to_card_failure++;
192 break;
193 case 0:
194 dev_kfree_skb_any(skb);
195 dev_dbg(adapter->dev, "data: %s: host_to_card succeeded\n",
196 __func__);
197 adapter->tx_lock_flag = true;
198 break;
199 case -EINPROGRESS:
200 break;
201 default:
202 break;
203 }
204
205 return ret;
206 }
207
208 /*
209 * This function checks if we need to send last packet indication.
210 */
211 u8
212 mwifiex_check_last_packet_indication(struct mwifiex_private *priv)
213 {
214 struct mwifiex_adapter *adapter = priv->adapter;
215 u8 ret = false;
216
217 if (!adapter->sleep_period.period)
218 return ret;
219 if (mwifiex_wmm_lists_empty(adapter))
220 ret = true;
221
222 if (ret && !adapter->cmd_sent && !adapter->curr_cmd &&
223 !is_command_pending(adapter)) {
224 adapter->delay_null_pkt = false;
225 ret = true;
226 } else {
227 ret = false;
228 adapter->delay_null_pkt = true;
229 }
230 return ret;
231 }
This page took 0.050925 seconds and 5 git commands to generate.