2017-11-07 20:07:52 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2009-06-13 11:38:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* File: rxtx.c
|
|
|
|
*
|
|
|
|
* Purpose: handle WMAC/802.3/802.11 rx & tx functions
|
|
|
|
*
|
|
|
|
* Author: Lyndon Chen
|
|
|
|
*
|
|
|
|
* Date: May 20, 2003
|
|
|
|
*
|
|
|
|
* Functions:
|
2014-07-10 18:56:15 +00:00
|
|
|
* vnt_generate_tx_parameter - Generate tx dma required parameter.
|
2014-07-11 00:08:22 +00:00
|
|
|
* vnt_get_duration_le - get tx data required duration
|
2014-07-11 00:08:20 +00:00
|
|
|
* vnt_get_rtscts_duration_le- get rtx/cts required duration
|
2014-07-11 00:08:23 +00:00
|
|
|
* vnt_get_rtscts_rsvtime_le- get rts/cts reserved time
|
2014-07-11 00:08:24 +00:00
|
|
|
* vnt_get_rsvtime- get frame reserved time
|
2014-07-10 18:56:17 +00:00
|
|
|
* vnt_fill_cts_head- fulfill CTS ctl header
|
2009-06-13 11:38:31 +00:00
|
|
|
*
|
|
|
|
* Revision History:
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-12-08 11:13:41 +00:00
|
|
|
#include <linux/etherdevice.h>
|
2009-06-13 11:38:31 +00:00
|
|
|
#include "device.h"
|
|
|
|
#include "rxtx.h"
|
|
|
|
#include "card.h"
|
|
|
|
#include "mac.h"
|
|
|
|
#include "rf.h"
|
|
|
|
#include "usbpipe.h"
|
2009-08-12 21:54:08 +00:00
|
|
|
|
2014-07-11 00:08:25 +00:00
|
|
|
static const u16 vnt_time_stampoff[2][MAX_RATE] = {
|
2015-06-20 04:46:50 +00:00
|
|
|
/* Long Preamble */
|
|
|
|
{384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23},
|
|
|
|
|
|
|
|
/* Short Preamble */
|
|
|
|
{384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23},
|
2014-07-11 00:08:25 +00:00
|
|
|
};
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-07-11 00:08:26 +00:00
|
|
|
static const u16 vnt_fb_opt0[2][5] = {
|
|
|
|
{RATE_12M, RATE_18M, RATE_24M, RATE_36M, RATE_48M}, /* fallback_rate0 */
|
|
|
|
{RATE_12M, RATE_12M, RATE_18M, RATE_24M, RATE_36M}, /* fallback_rate1 */
|
|
|
|
};
|
|
|
|
|
2014-07-11 00:08:27 +00:00
|
|
|
static const u16 vnt_fb_opt1[2][5] = {
|
|
|
|
{RATE_12M, RATE_18M, RATE_24M, RATE_24M, RATE_36M}, /* fallback_rate0 */
|
2014-12-10 17:05:31 +00:00
|
|
|
{RATE_6M, RATE_6M, RATE_12M, RATE_12M, RATE_18M}, /* fallback_rate1 */
|
2014-07-11 00:08:27 +00:00
|
|
|
};
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
#define RTSDUR_BB 0
|
|
|
|
#define RTSDUR_BA 1
|
|
|
|
#define RTSDUR_AA 2
|
|
|
|
#define CTSDUR_BA 3
|
|
|
|
#define RTSDUR_BA_F0 4
|
|
|
|
#define RTSDUR_AA_F0 5
|
|
|
|
#define RTSDUR_BA_F1 6
|
|
|
|
#define RTSDUR_AA_F1 7
|
|
|
|
#define CTSDUR_BA_F0 8
|
|
|
|
#define CTSDUR_BA_F1 9
|
|
|
|
#define DATADUR_B 10
|
|
|
|
#define DATADUR_A 11
|
|
|
|
#define DATADUR_A_F0 12
|
|
|
|
#define DATADUR_A_F1 13
|
|
|
|
|
2013-11-26 19:06:35 +00:00
|
|
|
static struct vnt_usb_send_context
|
2014-07-11 00:08:28 +00:00
|
|
|
*vnt_get_free_context(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2013-11-26 19:16:59 +00:00
|
|
|
struct vnt_usb_send_context *context = NULL;
|
2013-01-17 23:15:22 +00:00
|
|
|
int ii;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-07-11 00:08:31 +00:00
|
|
|
dev_dbg(&priv->usb->dev, "%s\n", __func__);
|
2013-11-26 19:16:59 +00:00
|
|
|
|
2014-07-19 11:30:04 +00:00
|
|
|
for (ii = 0; ii < priv->num_tx_context; ii++) {
|
2014-07-18 05:36:16 +00:00
|
|
|
if (!priv->tx_context[ii])
|
2013-11-26 19:16:59 +00:00
|
|
|
return NULL;
|
|
|
|
|
2014-07-18 05:36:16 +00:00
|
|
|
context = priv->tx_context[ii];
|
2015-06-16 05:43:16 +00:00
|
|
|
if (!context->in_use) {
|
2014-05-15 21:49:11 +00:00
|
|
|
context->in_use = true;
|
|
|
|
memset(context->data, 0,
|
2017-02-14 19:23:47 +00:00
|
|
|
MAX_TOTAL_SIZE_WITH_ALL_HEADERS);
|
2014-05-31 12:34:58 +00:00
|
|
|
|
|
|
|
context->hdr = NULL;
|
|
|
|
|
2013-11-26 19:16:59 +00:00
|
|
|
return context;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-27 08:17:43 +00:00
|
|
|
if (ii == priv->num_tx_context) {
|
2014-07-11 00:08:31 +00:00
|
|
|
dev_dbg(&priv->usb->dev, "%s No Free Tx Context\n", __func__);
|
2013-11-26 19:06:35 +00:00
|
|
|
|
2015-09-27 08:17:43 +00:00
|
|
|
ieee80211_stop_queues(priv->hw);
|
|
|
|
}
|
|
|
|
|
2013-11-26 19:12:38 +00:00
|
|
|
return NULL;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-03-18 19:25:03 +00:00
|
|
|
static __le16 vnt_time_stamp_off(struct vnt_private *priv, u16 rate)
|
2013-08-23 10:48:46 +00:00
|
|
|
{
|
2014-07-20 14:33:17 +00:00
|
|
|
return cpu_to_le16(vnt_time_stampoff[priv->preamble_type % 2]
|
2013-08-23 10:48:46 +00:00
|
|
|
[rate % MAX_RATE]);
|
|
|
|
}
|
|
|
|
|
2014-07-11 00:08:24 +00:00
|
|
|
static u32 vnt_get_rsvtime(struct vnt_private *priv, u8 pkt_type,
|
2017-05-07 13:18:17 +00:00
|
|
|
u32 frame_length, u16 rate, int need_ack)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-01-08 20:08:42 +00:00
|
|
|
u32 data_time, ack_time;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-07-20 14:33:17 +00:00
|
|
|
data_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
|
2017-02-14 19:23:47 +00:00
|
|
|
frame_length, rate);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-01-08 20:08:42 +00:00
|
|
|
if (pkt_type == PK_TYPE_11B)
|
2014-07-20 14:33:17 +00:00
|
|
|
ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
|
2017-02-14 19:23:47 +00:00
|
|
|
14, (u16)priv->top_cck_basic_rate);
|
2014-01-08 20:08:42 +00:00
|
|
|
else
|
2014-07-20 14:33:17 +00:00
|
|
|
ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
|
2017-02-14 19:23:47 +00:00
|
|
|
14, (u16)priv->top_ofdm_basic_rate);
|
2014-01-08 20:08:42 +00:00
|
|
|
|
|
|
|
if (need_ack)
|
2014-07-19 11:30:18 +00:00
|
|
|
return data_time + priv->sifs + ack_time;
|
2014-01-08 20:08:42 +00:00
|
|
|
|
|
|
|
return data_time;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-03-18 19:25:07 +00:00
|
|
|
static __le16 vnt_rxtx_rsvtime_le16(struct vnt_private *priv, u8 pkt_type,
|
2017-05-07 13:18:17 +00:00
|
|
|
u32 frame_length, u16 rate, int need_ack)
|
2013-08-23 10:32:26 +00:00
|
|
|
{
|
2014-07-11 00:08:24 +00:00
|
|
|
return cpu_to_le16((u16)vnt_get_rsvtime(priv, pkt_type,
|
2013-08-23 10:32:26 +00:00
|
|
|
frame_length, rate, need_ack));
|
|
|
|
}
|
|
|
|
|
2017-05-07 13:18:17 +00:00
|
|
|
static __le16 vnt_get_rtscts_rsvtime_le(struct vnt_private *priv, u8 rsv_type,
|
|
|
|
u8 pkt_type, u32 frame_length,
|
|
|
|
u16 current_rate)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-01-08 20:13:29 +00:00
|
|
|
u32 rrv_time, rts_time, cts_time, ack_time, data_time;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2017-05-16 12:39:54 +00:00
|
|
|
rrv_time = 0;
|
|
|
|
rts_time = 0;
|
|
|
|
cts_time = 0;
|
|
|
|
ack_time = 0;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-07-20 14:33:17 +00:00
|
|
|
data_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
|
2017-02-14 19:23:47 +00:00
|
|
|
frame_length, current_rate);
|
2014-01-08 20:13:29 +00:00
|
|
|
|
|
|
|
if (rsv_type == 0) {
|
2017-05-07 13:18:17 +00:00
|
|
|
rts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
|
|
|
|
20, priv->top_cck_basic_rate);
|
2017-05-16 12:39:54 +00:00
|
|
|
ack_time = vnt_get_frame_time(priv->preamble_type,
|
|
|
|
pkt_type, 14,
|
|
|
|
priv->top_cck_basic_rate);
|
|
|
|
cts_time = ack_time;
|
|
|
|
|
2014-01-08 20:13:29 +00:00
|
|
|
} else if (rsv_type == 1) {
|
2017-05-07 13:18:17 +00:00
|
|
|
rts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
|
|
|
|
20, priv->top_cck_basic_rate);
|
2014-07-20 14:33:17 +00:00
|
|
|
cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
|
2017-04-28 11:25:37 +00:00
|
|
|
14, priv->top_cck_basic_rate);
|
2014-07-20 14:33:17 +00:00
|
|
|
ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
|
2017-04-28 11:25:37 +00:00
|
|
|
14, priv->top_ofdm_basic_rate);
|
2014-01-08 20:13:29 +00:00
|
|
|
} else if (rsv_type == 2) {
|
2014-07-20 14:33:17 +00:00
|
|
|
rts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
|
2017-04-28 11:25:37 +00:00
|
|
|
20, priv->top_ofdm_basic_rate);
|
2017-05-16 12:39:54 +00:00
|
|
|
ack_time = vnt_get_frame_time(priv->preamble_type,
|
|
|
|
pkt_type, 14,
|
|
|
|
priv->top_ofdm_basic_rate);
|
|
|
|
cts_time = ack_time;
|
|
|
|
|
2014-01-08 20:13:29 +00:00
|
|
|
} else if (rsv_type == 3) {
|
2014-07-20 14:33:17 +00:00
|
|
|
cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
|
2017-04-28 11:25:37 +00:00
|
|
|
14, priv->top_cck_basic_rate);
|
2014-07-20 14:33:17 +00:00
|
|
|
ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
|
2017-04-28 11:25:37 +00:00
|
|
|
14, priv->top_ofdm_basic_rate);
|
2014-01-08 20:13:29 +00:00
|
|
|
|
2014-07-19 11:30:18 +00:00
|
|
|
rrv_time = cts_time + ack_time + data_time + 2 * priv->sifs;
|
2014-01-08 20:13:29 +00:00
|
|
|
|
2014-03-18 19:25:08 +00:00
|
|
|
return cpu_to_le16((u16)rrv_time);
|
2014-01-08 20:13:29 +00:00
|
|
|
}
|
|
|
|
|
2014-07-19 11:30:18 +00:00
|
|
|
rrv_time = rts_time + cts_time + ack_time + data_time + 3 * priv->sifs;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-01-08 20:13:29 +00:00
|
|
|
return cpu_to_le16((u16)rrv_time);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2017-05-07 13:18:17 +00:00
|
|
|
static __le16 vnt_get_duration_le(struct vnt_private *priv, u8 pkt_type,
|
|
|
|
int need_ack)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-07-11 00:08:21 +00:00
|
|
|
u32 ack_time = 0;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-07-11 00:08:21 +00:00
|
|
|
if (need_ack) {
|
|
|
|
if (pkt_type == PK_TYPE_11B)
|
2014-07-20 14:33:30 +00:00
|
|
|
ack_time = vnt_get_frame_time(priv->preamble_type,
|
2017-05-07 13:18:17 +00:00
|
|
|
pkt_type, 14,
|
|
|
|
priv->top_cck_basic_rate);
|
2013-08-13 18:59:31 +00:00
|
|
|
else
|
2014-07-20 14:33:30 +00:00
|
|
|
ack_time = vnt_get_frame_time(priv->preamble_type,
|
2017-05-07 13:18:17 +00:00
|
|
|
pkt_type, 14,
|
|
|
|
priv->top_ofdm_basic_rate);
|
2014-07-11 00:08:21 +00:00
|
|
|
|
2014-07-20 14:33:30 +00:00
|
|
|
return cpu_to_le16((u16)(priv->sifs + ack_time));
|
2013-08-13 18:59:31 +00:00
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-07-20 14:33:35 +00:00
|
|
|
static __le16 vnt_get_rtscts_duration_le(struct vnt_usb_send_context *context,
|
|
|
|
u8 dur_type, u8 pkt_type, u16 rate)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-07-20 14:33:35 +00:00
|
|
|
struct vnt_private *priv = context->priv;
|
2014-07-11 00:08:19 +00:00
|
|
|
u32 cts_time = 0, dur_time = 0;
|
2014-07-20 14:33:35 +00:00
|
|
|
u32 frame_length = context->frame_len;
|
|
|
|
u8 need_ack = context->need_ack;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-07-11 00:08:19 +00:00
|
|
|
switch (dur_type) {
|
2013-10-15 20:05:02 +00:00
|
|
|
case RTSDUR_BB:
|
|
|
|
case RTSDUR_BA:
|
|
|
|
case RTSDUR_BA_F0:
|
|
|
|
case RTSDUR_BA_F1:
|
2017-05-07 13:18:17 +00:00
|
|
|
cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
|
|
|
|
14, priv->top_cck_basic_rate);
|
2014-07-19 11:30:18 +00:00
|
|
|
dur_time = cts_time + 2 * priv->sifs +
|
2014-07-11 00:08:24 +00:00
|
|
|
vnt_get_rsvtime(priv, pkt_type,
|
2017-02-14 19:23:47 +00:00
|
|
|
frame_length, rate, need_ack);
|
2013-10-15 20:05:02 +00:00
|
|
|
break;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-10-15 20:05:02 +00:00
|
|
|
case RTSDUR_AA:
|
|
|
|
case RTSDUR_AA_F0:
|
|
|
|
case RTSDUR_AA_F1:
|
2017-05-07 13:18:17 +00:00
|
|
|
cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
|
|
|
|
14, priv->top_ofdm_basic_rate);
|
2014-07-19 11:30:18 +00:00
|
|
|
dur_time = cts_time + 2 * priv->sifs +
|
2014-07-11 00:08:24 +00:00
|
|
|
vnt_get_rsvtime(priv, pkt_type,
|
2017-02-14 19:23:47 +00:00
|
|
|
frame_length, rate, need_ack);
|
2013-10-15 20:05:02 +00:00
|
|
|
break;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-10-15 20:05:02 +00:00
|
|
|
case CTSDUR_BA:
|
|
|
|
case CTSDUR_BA_F0:
|
|
|
|
case CTSDUR_BA_F1:
|
2014-07-19 11:30:18 +00:00
|
|
|
dur_time = priv->sifs + vnt_get_rsvtime(priv,
|
2014-07-11 00:08:19 +00:00
|
|
|
pkt_type, frame_length, rate, need_ack);
|
2013-10-15 20:05:02 +00:00
|
|
|
break;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-10-15 20:05:02 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-07-11 00:08:19 +00:00
|
|
|
return cpu_to_le16((u16)dur_time);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 12:34:58 +00:00
|
|
|
static u16 vnt_mac_hdr_pos(struct vnt_usb_send_context *tx_context,
|
2017-05-07 13:18:17 +00:00
|
|
|
struct ieee80211_hdr *hdr)
|
2014-05-31 12:34:58 +00:00
|
|
|
{
|
|
|
|
u8 *head = tx_context->data + offsetof(struct vnt_tx_buffer, fifo_head);
|
|
|
|
u8 *hdr_pos = (u8 *)hdr;
|
|
|
|
|
|
|
|
tx_context->hdr = hdr;
|
|
|
|
if (!tx_context->hdr)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return (u16)(hdr_pos - head);
|
|
|
|
}
|
|
|
|
|
2014-05-31 12:34:57 +00:00
|
|
|
static u16 vnt_rxtx_datahead_g(struct vnt_usb_send_context *tx_context,
|
2014-07-20 14:33:34 +00:00
|
|
|
struct vnt_tx_datahead_g *buf)
|
2013-10-01 14:52:16 +00:00
|
|
|
{
|
2014-05-31 12:34:57 +00:00
|
|
|
struct vnt_private *priv = tx_context->priv;
|
2014-06-25 20:14:38 +00:00
|
|
|
struct ieee80211_hdr *hdr =
|
|
|
|
(struct ieee80211_hdr *)tx_context->skb->data;
|
2014-07-20 14:33:33 +00:00
|
|
|
u32 frame_len = tx_context->frame_len;
|
2014-07-20 14:33:34 +00:00
|
|
|
u16 rate = tx_context->tx_rate;
|
2014-07-20 14:33:32 +00:00
|
|
|
u8 need_ack = tx_context->need_ack;
|
2014-05-31 12:34:57 +00:00
|
|
|
|
2013-10-01 14:52:16 +00:00
|
|
|
/* Get SignalField,ServiceField,Length */
|
2014-07-20 14:33:31 +00:00
|
|
|
vnt_get_phy_field(priv, frame_len, rate, tx_context->pkt_type, &buf->a);
|
2014-07-20 14:33:15 +00:00
|
|
|
vnt_get_phy_field(priv, frame_len, priv->top_cck_basic_rate,
|
2017-05-07 13:18:17 +00:00
|
|
|
PK_TYPE_11B, &buf->b);
|
2013-10-01 14:52:16 +00:00
|
|
|
|
|
|
|
/* Get Duration and TimeStamp */
|
2014-06-25 20:14:38 +00:00
|
|
|
if (ieee80211_is_pspoll(hdr->frame_control)) {
|
|
|
|
__le16 dur = cpu_to_le16(priv->current_aid | BIT(14) | BIT(15));
|
|
|
|
|
|
|
|
buf->duration_a = dur;
|
|
|
|
buf->duration_b = dur;
|
|
|
|
} else {
|
2014-07-20 14:33:31 +00:00
|
|
|
buf->duration_a = vnt_get_duration_le(priv,
|
|
|
|
tx_context->pkt_type, need_ack);
|
2014-07-11 00:08:22 +00:00
|
|
|
buf->duration_b = vnt_get_duration_le(priv,
|
2014-06-25 20:14:38 +00:00
|
|
|
PK_TYPE_11B, need_ack);
|
|
|
|
}
|
2013-10-01 14:52:16 +00:00
|
|
|
|
2014-03-18 19:25:01 +00:00
|
|
|
buf->time_stamp_off_a = vnt_time_stamp_off(priv, rate);
|
|
|
|
buf->time_stamp_off_b = vnt_time_stamp_off(priv,
|
2014-07-20 14:33:15 +00:00
|
|
|
priv->top_cck_basic_rate);
|
2013-10-01 14:52:16 +00:00
|
|
|
|
2014-05-31 12:34:58 +00:00
|
|
|
tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, &buf->hdr);
|
|
|
|
|
2014-03-18 19:25:04 +00:00
|
|
|
return le16_to_cpu(buf->duration_a);
|
2013-10-01 14:52:16 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 12:34:57 +00:00
|
|
|
static u16 vnt_rxtx_datahead_g_fb(struct vnt_usb_send_context *tx_context,
|
2014-07-20 14:33:34 +00:00
|
|
|
struct vnt_tx_datahead_g_fb *buf)
|
2013-10-01 14:54:56 +00:00
|
|
|
{
|
2014-05-31 12:34:57 +00:00
|
|
|
struct vnt_private *priv = tx_context->priv;
|
2014-07-20 14:33:33 +00:00
|
|
|
u32 frame_len = tx_context->frame_len;
|
2014-07-20 14:33:34 +00:00
|
|
|
u16 rate = tx_context->tx_rate;
|
2014-07-20 14:33:32 +00:00
|
|
|
u8 need_ack = tx_context->need_ack;
|
2014-05-31 12:34:57 +00:00
|
|
|
|
2013-10-01 14:54:56 +00:00
|
|
|
/* Get SignalField,ServiceField,Length */
|
2014-07-20 14:33:31 +00:00
|
|
|
vnt_get_phy_field(priv, frame_len, rate, tx_context->pkt_type, &buf->a);
|
2013-10-01 14:54:56 +00:00
|
|
|
|
2014-07-20 14:33:15 +00:00
|
|
|
vnt_get_phy_field(priv, frame_len, priv->top_cck_basic_rate,
|
2017-05-07 13:18:17 +00:00
|
|
|
PK_TYPE_11B, &buf->b);
|
2013-10-01 14:54:56 +00:00
|
|
|
|
|
|
|
/* Get Duration and TimeStamp */
|
2014-07-20 14:33:31 +00:00
|
|
|
buf->duration_a = vnt_get_duration_le(priv, tx_context->pkt_type,
|
|
|
|
need_ack);
|
2014-07-11 00:08:22 +00:00
|
|
|
buf->duration_b = vnt_get_duration_le(priv, PK_TYPE_11B, need_ack);
|
2013-10-01 14:54:56 +00:00
|
|
|
|
2014-07-20 14:33:31 +00:00
|
|
|
buf->duration_a_f0 = vnt_get_duration_le(priv, tx_context->pkt_type,
|
|
|
|
need_ack);
|
|
|
|
buf->duration_a_f1 = vnt_get_duration_le(priv, tx_context->pkt_type,
|
|
|
|
need_ack);
|
2013-10-01 14:54:56 +00:00
|
|
|
|
2014-03-18 19:25:01 +00:00
|
|
|
buf->time_stamp_off_a = vnt_time_stamp_off(priv, rate);
|
|
|
|
buf->time_stamp_off_b = vnt_time_stamp_off(priv,
|
2014-07-20 14:33:15 +00:00
|
|
|
priv->top_cck_basic_rate);
|
2013-10-01 14:54:56 +00:00
|
|
|
|
2014-05-31 12:34:58 +00:00
|
|
|
tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, &buf->hdr);
|
|
|
|
|
2014-03-18 19:25:04 +00:00
|
|
|
return le16_to_cpu(buf->duration_a);
|
2013-10-01 14:54:56 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 12:34:57 +00:00
|
|
|
static u16 vnt_rxtx_datahead_a_fb(struct vnt_usb_send_context *tx_context,
|
2014-07-20 14:33:34 +00:00
|
|
|
struct vnt_tx_datahead_a_fb *buf)
|
2013-10-01 14:56:48 +00:00
|
|
|
{
|
2014-05-31 12:34:57 +00:00
|
|
|
struct vnt_private *priv = tx_context->priv;
|
2014-07-20 14:33:34 +00:00
|
|
|
u16 rate = tx_context->tx_rate;
|
2014-07-20 14:33:31 +00:00
|
|
|
u8 pkt_type = tx_context->pkt_type;
|
2014-07-20 14:33:32 +00:00
|
|
|
u8 need_ack = tx_context->need_ack;
|
2014-07-20 14:33:33 +00:00
|
|
|
u32 frame_len = tx_context->frame_len;
|
2014-05-31 12:34:57 +00:00
|
|
|
|
2013-10-01 14:56:48 +00:00
|
|
|
/* Get SignalField,ServiceField,Length */
|
2014-06-04 17:25:34 +00:00
|
|
|
vnt_get_phy_field(priv, frame_len, rate, pkt_type, &buf->a);
|
2013-10-01 14:56:48 +00:00
|
|
|
/* Get Duration and TimeStampOff */
|
2014-07-11 00:08:22 +00:00
|
|
|
buf->duration = vnt_get_duration_le(priv, pkt_type, need_ack);
|
2013-10-01 14:56:48 +00:00
|
|
|
|
2014-07-11 00:08:22 +00:00
|
|
|
buf->duration_f0 = vnt_get_duration_le(priv, pkt_type, need_ack);
|
|
|
|
buf->duration_f1 = vnt_get_duration_le(priv, pkt_type, need_ack);
|
2013-10-01 14:56:48 +00:00
|
|
|
|
2014-03-18 19:25:01 +00:00
|
|
|
buf->time_stamp_off = vnt_time_stamp_off(priv, rate);
|
2013-10-01 14:56:48 +00:00
|
|
|
|
2014-05-31 12:34:58 +00:00
|
|
|
tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, &buf->hdr);
|
|
|
|
|
2014-03-18 19:25:04 +00:00
|
|
|
return le16_to_cpu(buf->duration);
|
2013-10-01 14:56:48 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 12:34:57 +00:00
|
|
|
static u16 vnt_rxtx_datahead_ab(struct vnt_usb_send_context *tx_context,
|
2014-07-20 14:33:34 +00:00
|
|
|
struct vnt_tx_datahead_ab *buf)
|
2013-10-01 15:00:20 +00:00
|
|
|
{
|
2014-05-31 12:34:57 +00:00
|
|
|
struct vnt_private *priv = tx_context->priv;
|
2014-06-25 20:14:38 +00:00
|
|
|
struct ieee80211_hdr *hdr =
|
|
|
|
(struct ieee80211_hdr *)tx_context->skb->data;
|
2014-07-20 14:33:33 +00:00
|
|
|
u32 frame_len = tx_context->frame_len;
|
2014-07-20 14:33:34 +00:00
|
|
|
u16 rate = tx_context->tx_rate;
|
2014-07-20 14:33:32 +00:00
|
|
|
u8 need_ack = tx_context->need_ack;
|
2014-05-31 12:34:57 +00:00
|
|
|
|
2013-10-01 15:00:20 +00:00
|
|
|
/* Get SignalField,ServiceField,Length */
|
2014-07-20 14:33:31 +00:00
|
|
|
vnt_get_phy_field(priv, frame_len, rate,
|
|
|
|
tx_context->pkt_type, &buf->ab);
|
2014-06-25 20:14:38 +00:00
|
|
|
|
2013-10-01 15:00:20 +00:00
|
|
|
/* Get Duration and TimeStampOff */
|
2014-06-25 20:14:38 +00:00
|
|
|
if (ieee80211_is_pspoll(hdr->frame_control)) {
|
|
|
|
__le16 dur = cpu_to_le16(priv->current_aid | BIT(14) | BIT(15));
|
|
|
|
|
|
|
|
buf->duration = dur;
|
|
|
|
} else {
|
2014-07-20 14:33:31 +00:00
|
|
|
buf->duration = vnt_get_duration_le(priv, tx_context->pkt_type,
|
|
|
|
need_ack);
|
2014-06-25 20:14:38 +00:00
|
|
|
}
|
2013-10-01 15:00:20 +00:00
|
|
|
|
2014-03-18 19:25:01 +00:00
|
|
|
buf->time_stamp_off = vnt_time_stamp_off(priv, rate);
|
2013-10-01 15:00:20 +00:00
|
|
|
|
2014-05-31 12:34:58 +00:00
|
|
|
tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, &buf->hdr);
|
|
|
|
|
2014-03-18 19:25:04 +00:00
|
|
|
return le16_to_cpu(buf->duration);
|
2013-10-01 15:00:20 +00:00
|
|
|
}
|
|
|
|
|
2014-06-25 20:14:23 +00:00
|
|
|
static int vnt_fill_ieee80211_rts(struct vnt_usb_send_context *tx_context,
|
2017-05-07 13:18:17 +00:00
|
|
|
struct ieee80211_rts *rts, __le16 duration)
|
2013-08-26 10:04:50 +00:00
|
|
|
{
|
2014-06-25 20:14:23 +00:00
|
|
|
struct ieee80211_hdr *hdr =
|
|
|
|
(struct ieee80211_hdr *)tx_context->skb->data;
|
|
|
|
|
2013-08-26 10:04:50 +00:00
|
|
|
rts->duration = duration;
|
2014-03-22 09:01:31 +00:00
|
|
|
rts->frame_control =
|
|
|
|
cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
|
2013-08-26 10:04:50 +00:00
|
|
|
|
2014-12-08 11:13:41 +00:00
|
|
|
ether_addr_copy(rts->ra, hdr->addr1);
|
|
|
|
ether_addr_copy(rts->ta, hdr->addr2);
|
2013-08-26 10:04:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-31 12:34:57 +00:00
|
|
|
static u16 vnt_rxtx_rts_g_head(struct vnt_usb_send_context *tx_context,
|
2014-07-20 14:33:34 +00:00
|
|
|
struct vnt_rts_g *buf)
|
2013-08-26 10:04:50 +00:00
|
|
|
{
|
2014-05-31 12:34:57 +00:00
|
|
|
struct vnt_private *priv = tx_context->priv;
|
2013-08-26 10:04:50 +00:00
|
|
|
u16 rts_frame_len = 20;
|
2014-07-20 14:33:34 +00:00
|
|
|
u16 current_rate = tx_context->tx_rate;
|
2014-07-20 14:33:32 +00:00
|
|
|
|
2014-07-20 14:33:15 +00:00
|
|
|
vnt_get_phy_field(priv, rts_frame_len, priv->top_cck_basic_rate,
|
2017-04-28 11:25:37 +00:00
|
|
|
PK_TYPE_11B, &buf->b);
|
2014-07-20 14:33:31 +00:00
|
|
|
vnt_get_phy_field(priv, rts_frame_len, priv->top_ofdm_basic_rate,
|
|
|
|
tx_context->pkt_type, &buf->a);
|
2013-08-26 10:04:50 +00:00
|
|
|
|
2014-07-20 14:33:35 +00:00
|
|
|
buf->duration_bb = vnt_get_rtscts_duration_le(tx_context, RTSDUR_BB,
|
|
|
|
PK_TYPE_11B,
|
|
|
|
priv->top_cck_basic_rate);
|
|
|
|
buf->duration_aa = vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA,
|
|
|
|
tx_context->pkt_type,
|
|
|
|
current_rate);
|
|
|
|
buf->duration_ba = vnt_get_rtscts_duration_le(tx_context, RTSDUR_BA,
|
|
|
|
tx_context->pkt_type,
|
|
|
|
current_rate);
|
2013-08-26 10:04:50 +00:00
|
|
|
|
2014-06-25 20:14:23 +00:00
|
|
|
vnt_fill_ieee80211_rts(tx_context, &buf->data, buf->duration_aa);
|
2013-08-26 10:04:50 +00:00
|
|
|
|
2014-07-20 14:33:34 +00:00
|
|
|
return vnt_rxtx_datahead_g(tx_context, &buf->data_head);
|
2013-08-26 10:04:50 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 12:34:57 +00:00
|
|
|
static u16 vnt_rxtx_rts_g_fb_head(struct vnt_usb_send_context *tx_context,
|
2014-07-20 14:33:34 +00:00
|
|
|
struct vnt_rts_g_fb *buf)
|
2013-08-26 10:07:46 +00:00
|
|
|
{
|
2014-05-31 12:34:57 +00:00
|
|
|
struct vnt_private *priv = tx_context->priv;
|
2014-07-20 14:33:34 +00:00
|
|
|
u16 current_rate = tx_context->tx_rate;
|
2013-08-26 10:07:46 +00:00
|
|
|
u16 rts_frame_len = 20;
|
2014-07-20 14:33:32 +00:00
|
|
|
|
2014-07-20 14:33:15 +00:00
|
|
|
vnt_get_phy_field(priv, rts_frame_len, priv->top_cck_basic_rate,
|
2017-04-28 11:25:37 +00:00
|
|
|
PK_TYPE_11B, &buf->b);
|
2014-07-20 14:33:31 +00:00
|
|
|
vnt_get_phy_field(priv, rts_frame_len, priv->top_ofdm_basic_rate,
|
|
|
|
tx_context->pkt_type, &buf->a);
|
2013-08-26 10:07:46 +00:00
|
|
|
|
2014-07-20 14:33:35 +00:00
|
|
|
buf->duration_bb = vnt_get_rtscts_duration_le(tx_context, RTSDUR_BB,
|
|
|
|
PK_TYPE_11B,
|
|
|
|
priv->top_cck_basic_rate);
|
|
|
|
buf->duration_aa = vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA,
|
|
|
|
tx_context->pkt_type,
|
|
|
|
current_rate);
|
|
|
|
buf->duration_ba = vnt_get_rtscts_duration_le(tx_context, RTSDUR_BA,
|
|
|
|
tx_context->pkt_type,
|
|
|
|
current_rate);
|
|
|
|
|
|
|
|
buf->rts_duration_ba_f0 =
|
|
|
|
vnt_get_rtscts_duration_le(tx_context, RTSDUR_BA_F0,
|
|
|
|
tx_context->pkt_type,
|
|
|
|
priv->tx_rate_fb0);
|
|
|
|
buf->rts_duration_aa_f0 =
|
|
|
|
vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA_F0,
|
|
|
|
tx_context->pkt_type,
|
|
|
|
priv->tx_rate_fb0);
|
|
|
|
buf->rts_duration_ba_f1 =
|
|
|
|
vnt_get_rtscts_duration_le(tx_context, RTSDUR_BA_F1,
|
|
|
|
tx_context->pkt_type,
|
|
|
|
priv->tx_rate_fb1);
|
|
|
|
buf->rts_duration_aa_f1 =
|
|
|
|
vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA_F1,
|
|
|
|
tx_context->pkt_type,
|
|
|
|
priv->tx_rate_fb1);
|
2013-08-26 10:07:46 +00:00
|
|
|
|
2014-06-25 20:14:23 +00:00
|
|
|
vnt_fill_ieee80211_rts(tx_context, &buf->data, buf->duration_aa);
|
2013-08-26 10:07:46 +00:00
|
|
|
|
2014-07-20 14:33:34 +00:00
|
|
|
return vnt_rxtx_datahead_g_fb(tx_context, &buf->data_head);
|
2013-08-26 10:07:46 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 12:34:57 +00:00
|
|
|
static u16 vnt_rxtx_rts_ab_head(struct vnt_usb_send_context *tx_context,
|
2014-07-20 14:33:34 +00:00
|
|
|
struct vnt_rts_ab *buf)
|
2013-08-26 10:09:38 +00:00
|
|
|
{
|
2014-05-31 12:34:57 +00:00
|
|
|
struct vnt_private *priv = tx_context->priv;
|
2014-07-20 14:33:34 +00:00
|
|
|
u16 current_rate = tx_context->tx_rate;
|
2013-08-26 10:09:38 +00:00
|
|
|
u16 rts_frame_len = 20;
|
|
|
|
|
2014-07-20 14:33:31 +00:00
|
|
|
vnt_get_phy_field(priv, rts_frame_len, priv->top_ofdm_basic_rate,
|
|
|
|
tx_context->pkt_type, &buf->ab);
|
2013-08-26 10:09:38 +00:00
|
|
|
|
2014-07-20 14:33:35 +00:00
|
|
|
buf->duration = vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA,
|
2014-07-20 14:33:31 +00:00
|
|
|
tx_context->pkt_type,
|
2014-07-20 14:33:35 +00:00
|
|
|
current_rate);
|
2013-08-26 10:09:38 +00:00
|
|
|
|
2014-06-25 20:14:23 +00:00
|
|
|
vnt_fill_ieee80211_rts(tx_context, &buf->data, buf->duration);
|
2013-08-26 10:09:38 +00:00
|
|
|
|
2014-07-20 14:33:34 +00:00
|
|
|
return vnt_rxtx_datahead_ab(tx_context, &buf->data_head);
|
2013-08-26 10:09:38 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 12:34:57 +00:00
|
|
|
static u16 vnt_rxtx_rts_a_fb_head(struct vnt_usb_send_context *tx_context,
|
2014-07-20 14:33:34 +00:00
|
|
|
struct vnt_rts_a_fb *buf)
|
2013-08-26 10:12:00 +00:00
|
|
|
{
|
2014-05-31 12:34:57 +00:00
|
|
|
struct vnt_private *priv = tx_context->priv;
|
2014-07-20 14:33:34 +00:00
|
|
|
u16 current_rate = tx_context->tx_rate;
|
2013-08-26 10:12:00 +00:00
|
|
|
u16 rts_frame_len = 20;
|
2014-07-20 14:33:32 +00:00
|
|
|
|
2017-05-07 13:18:17 +00:00
|
|
|
vnt_get_phy_field(priv, rts_frame_len, priv->top_ofdm_basic_rate,
|
|
|
|
tx_context->pkt_type, &buf->a);
|
2013-08-26 10:12:00 +00:00
|
|
|
|
2014-07-20 14:33:35 +00:00
|
|
|
buf->duration = vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA,
|
2014-07-20 14:33:31 +00:00
|
|
|
tx_context->pkt_type,
|
2014-07-20 14:33:35 +00:00
|
|
|
current_rate);
|
2013-08-26 10:12:00 +00:00
|
|
|
|
2014-07-20 14:33:35 +00:00
|
|
|
buf->rts_duration_f0 =
|
|
|
|
vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA_F0,
|
|
|
|
tx_context->pkt_type,
|
|
|
|
priv->tx_rate_fb0);
|
2013-08-26 10:12:00 +00:00
|
|
|
|
2014-07-20 14:33:35 +00:00
|
|
|
buf->rts_duration_f1 =
|
|
|
|
vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA_F1,
|
|
|
|
tx_context->pkt_type,
|
|
|
|
priv->tx_rate_fb1);
|
2013-08-26 10:12:00 +00:00
|
|
|
|
2014-06-25 20:14:23 +00:00
|
|
|
vnt_fill_ieee80211_rts(tx_context, &buf->data, buf->duration);
|
2013-08-26 10:12:00 +00:00
|
|
|
|
2014-07-20 14:33:34 +00:00
|
|
|
return vnt_rxtx_datahead_a_fb(tx_context, &buf->data_head);
|
2013-08-26 10:12:00 +00:00
|
|
|
}
|
|
|
|
|
2015-02-01 11:59:43 +00:00
|
|
|
static u16 vnt_fill_cts_fb_head(struct vnt_usb_send_context *tx_context,
|
|
|
|
union vnt_tx_data_head *head)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-07-10 18:56:16 +00:00
|
|
|
struct vnt_private *priv = tx_context->priv;
|
2015-02-01 11:59:43 +00:00
|
|
|
struct vnt_cts_fb *buf = &head->cts_g_fb;
|
2014-07-10 18:56:16 +00:00
|
|
|
u32 cts_frame_len = 14;
|
2014-07-20 14:33:34 +00:00
|
|
|
u16 current_rate = tx_context->tx_rate;
|
2014-07-20 14:33:32 +00:00
|
|
|
|
2015-02-01 11:59:43 +00:00
|
|
|
/* Get SignalField,ServiceField,Length */
|
|
|
|
vnt_get_phy_field(priv, cts_frame_len, priv->top_cck_basic_rate,
|
|
|
|
PK_TYPE_11B, &buf->b);
|
2014-03-22 09:01:32 +00:00
|
|
|
|
2015-02-01 11:59:43 +00:00
|
|
|
buf->duration_ba =
|
|
|
|
vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA,
|
|
|
|
tx_context->pkt_type,
|
|
|
|
current_rate);
|
|
|
|
/* Get CTSDuration_ba_f0 */
|
|
|
|
buf->cts_duration_ba_f0 =
|
|
|
|
vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA_F0,
|
|
|
|
tx_context->pkt_type,
|
|
|
|
priv->tx_rate_fb0);
|
|
|
|
/* Get CTSDuration_ba_f1 */
|
|
|
|
buf->cts_duration_ba_f1 =
|
|
|
|
vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA_F1,
|
|
|
|
tx_context->pkt_type,
|
|
|
|
priv->tx_rate_fb1);
|
|
|
|
/* Get CTS Frame body */
|
|
|
|
buf->data.duration = buf->duration_ba;
|
|
|
|
buf->data.frame_control =
|
|
|
|
cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
|
2013-10-01 14:54:56 +00:00
|
|
|
|
2015-02-01 11:59:43 +00:00
|
|
|
ether_addr_copy(buf->data.ra, priv->current_net_addr);
|
|
|
|
|
|
|
|
return vnt_rxtx_datahead_g_fb(tx_context, &buf->data_head);
|
|
|
|
}
|
2014-03-22 09:01:32 +00:00
|
|
|
|
2015-02-01 11:59:43 +00:00
|
|
|
static u16 vnt_fill_cts_head(struct vnt_usb_send_context *tx_context,
|
|
|
|
union vnt_tx_data_head *head)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = tx_context->priv;
|
|
|
|
struct vnt_cts *buf = &head->cts_g;
|
|
|
|
u32 cts_frame_len = 14;
|
|
|
|
u16 current_rate = tx_context->tx_rate;
|
2013-10-01 14:52:16 +00:00
|
|
|
|
2015-02-01 11:59:43 +00:00
|
|
|
/* Get SignalField,ServiceField,Length */
|
|
|
|
vnt_get_phy_field(priv, cts_frame_len, priv->top_cck_basic_rate,
|
|
|
|
PK_TYPE_11B, &buf->b);
|
|
|
|
/* Get CTSDuration_ba */
|
|
|
|
buf->duration_ba =
|
|
|
|
vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA,
|
|
|
|
tx_context->pkt_type,
|
|
|
|
current_rate);
|
|
|
|
/*Get CTS Frame body*/
|
|
|
|
buf->data.duration = buf->duration_ba;
|
|
|
|
buf->data.frame_control =
|
|
|
|
cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
|
|
|
|
|
|
|
|
ether_addr_copy(buf->data.ra, priv->current_net_addr);
|
|
|
|
|
|
|
|
return vnt_rxtx_datahead_g(tx_context, &buf->data_head);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-07-10 18:56:06 +00:00
|
|
|
static u16 vnt_rxtx_rts(struct vnt_usb_send_context *tx_context,
|
2014-07-20 14:33:34 +00:00
|
|
|
union vnt_tx_head *tx_head, bool need_mic)
|
2014-07-10 18:56:06 +00:00
|
|
|
{
|
|
|
|
struct vnt_private *priv = tx_context->priv;
|
|
|
|
struct vnt_rrv_time_rts *buf = &tx_head->tx_rts.rts;
|
2014-07-10 18:56:10 +00:00
|
|
|
union vnt_tx_data_head *head = &tx_head->tx_rts.tx.head;
|
2014-07-20 14:33:33 +00:00
|
|
|
u32 frame_len = tx_context->frame_len;
|
2014-07-20 14:33:34 +00:00
|
|
|
u16 current_rate = tx_context->tx_rate;
|
2014-07-20 14:33:32 +00:00
|
|
|
u8 need_ack = tx_context->need_ack;
|
2014-07-10 18:56:06 +00:00
|
|
|
|
2014-07-11 00:08:23 +00:00
|
|
|
buf->rts_rrv_time_aa = vnt_get_rtscts_rsvtime_le(priv, 2,
|
2014-07-20 14:33:33 +00:00
|
|
|
tx_context->pkt_type, frame_len, current_rate);
|
2014-07-11 00:08:23 +00:00
|
|
|
buf->rts_rrv_time_ba = vnt_get_rtscts_rsvtime_le(priv, 1,
|
2014-07-20 14:33:33 +00:00
|
|
|
tx_context->pkt_type, frame_len, current_rate);
|
2014-07-11 00:08:23 +00:00
|
|
|
buf->rts_rrv_time_bb = vnt_get_rtscts_rsvtime_le(priv, 0,
|
2014-07-20 14:33:33 +00:00
|
|
|
tx_context->pkt_type, frame_len, current_rate);
|
2014-07-10 18:56:06 +00:00
|
|
|
|
2014-07-20 14:33:31 +00:00
|
|
|
buf->rrv_time_a = vnt_rxtx_rsvtime_le16(priv, tx_context->pkt_type,
|
2014-07-20 14:33:33 +00:00
|
|
|
frame_len, current_rate,
|
2014-07-20 14:33:31 +00:00
|
|
|
need_ack);
|
2014-07-20 14:33:33 +00:00
|
|
|
buf->rrv_time_b = vnt_rxtx_rsvtime_le16(priv, PK_TYPE_11B, frame_len,
|
2014-07-20 14:33:15 +00:00
|
|
|
priv->top_cck_basic_rate, need_ack);
|
2014-07-10 18:56:06 +00:00
|
|
|
|
2014-07-10 18:56:10 +00:00
|
|
|
if (need_mic)
|
|
|
|
head = &tx_head->tx_rts.tx.mic.head;
|
|
|
|
|
|
|
|
if (tx_context->fb_option)
|
2014-07-20 14:33:34 +00:00
|
|
|
return vnt_rxtx_rts_g_fb_head(tx_context, &head->rts_g_fb);
|
2014-07-10 18:56:10 +00:00
|
|
|
|
2014-07-20 14:33:34 +00:00
|
|
|
return vnt_rxtx_rts_g_head(tx_context, &head->rts_g);
|
2014-07-10 18:56:06 +00:00
|
|
|
}
|
|
|
|
|
2014-07-10 18:56:07 +00:00
|
|
|
static u16 vnt_rxtx_cts(struct vnt_usb_send_context *tx_context,
|
2014-07-20 14:33:34 +00:00
|
|
|
union vnt_tx_head *tx_head, bool need_mic)
|
2014-07-10 18:56:07 +00:00
|
|
|
{
|
|
|
|
struct vnt_private *priv = tx_context->priv;
|
|
|
|
struct vnt_rrv_time_cts *buf = &tx_head->tx_cts.cts;
|
2014-07-10 18:56:11 +00:00
|
|
|
union vnt_tx_data_head *head = &tx_head->tx_cts.tx.head;
|
2014-07-20 14:33:33 +00:00
|
|
|
u32 frame_len = tx_context->frame_len;
|
2014-07-20 14:33:34 +00:00
|
|
|
u16 current_rate = tx_context->tx_rate;
|
2014-07-20 14:33:32 +00:00
|
|
|
u8 need_ack = tx_context->need_ack;
|
|
|
|
|
2014-07-20 14:33:31 +00:00
|
|
|
buf->rrv_time_a = vnt_rxtx_rsvtime_le16(priv, tx_context->pkt_type,
|
2014-07-20 14:33:33 +00:00
|
|
|
frame_len, current_rate, need_ack);
|
2014-07-10 18:56:07 +00:00
|
|
|
buf->rrv_time_b = vnt_rxtx_rsvtime_le16(priv, PK_TYPE_11B,
|
2014-07-20 14:33:33 +00:00
|
|
|
frame_len, priv->top_cck_basic_rate, need_ack);
|
2014-07-10 18:56:07 +00:00
|
|
|
|
2014-07-11 00:08:23 +00:00
|
|
|
buf->cts_rrv_time_ba = vnt_get_rtscts_rsvtime_le(priv, 3,
|
2014-07-20 14:33:33 +00:00
|
|
|
tx_context->pkt_type, frame_len, current_rate);
|
2014-07-10 18:56:07 +00:00
|
|
|
|
2014-07-10 18:56:11 +00:00
|
|
|
if (need_mic)
|
|
|
|
head = &tx_head->tx_cts.tx.mic.head;
|
|
|
|
|
|
|
|
/* Fill CTS */
|
2015-02-01 11:59:43 +00:00
|
|
|
if (tx_context->fb_option)
|
|
|
|
return vnt_fill_cts_fb_head(tx_context, head);
|
|
|
|
|
2014-07-20 14:33:34 +00:00
|
|
|
return vnt_fill_cts_head(tx_context, head);
|
2014-07-10 18:56:07 +00:00
|
|
|
}
|
|
|
|
|
2014-07-10 18:56:09 +00:00
|
|
|
static u16 vnt_rxtx_ab(struct vnt_usb_send_context *tx_context,
|
2014-07-20 14:33:34 +00:00
|
|
|
union vnt_tx_head *tx_head, bool need_rts, bool need_mic)
|
2014-07-10 18:56:09 +00:00
|
|
|
{
|
|
|
|
struct vnt_private *priv = tx_context->priv;
|
|
|
|
struct vnt_rrv_time_ab *buf = &tx_head->tx_ab.ab;
|
2014-07-10 18:56:12 +00:00
|
|
|
union vnt_tx_data_head *head = &tx_head->tx_ab.tx.head;
|
2014-07-20 14:33:33 +00:00
|
|
|
u32 frame_len = tx_context->frame_len;
|
2014-07-20 14:33:34 +00:00
|
|
|
u16 current_rate = tx_context->tx_rate;
|
2014-07-20 14:33:32 +00:00
|
|
|
u8 need_ack = tx_context->need_ack;
|
2014-07-10 18:56:09 +00:00
|
|
|
|
2014-07-20 14:33:31 +00:00
|
|
|
buf->rrv_time = vnt_rxtx_rsvtime_le16(priv, tx_context->pkt_type,
|
2014-07-20 14:33:33 +00:00
|
|
|
frame_len, current_rate, need_ack);
|
2014-07-10 18:56:09 +00:00
|
|
|
|
2014-07-10 18:56:12 +00:00
|
|
|
if (need_mic)
|
|
|
|
head = &tx_head->tx_ab.tx.mic.head;
|
|
|
|
|
2014-07-10 18:56:09 +00:00
|
|
|
if (need_rts) {
|
2014-07-20 14:33:31 +00:00
|
|
|
if (tx_context->pkt_type == PK_TYPE_11B)
|
2014-07-11 00:08:23 +00:00
|
|
|
buf->rts_rrv_time = vnt_get_rtscts_rsvtime_le(priv, 0,
|
2014-07-20 14:33:33 +00:00
|
|
|
tx_context->pkt_type, frame_len, current_rate);
|
2014-07-10 18:56:09 +00:00
|
|
|
else /* PK_TYPE_11A */
|
2014-07-11 00:08:23 +00:00
|
|
|
buf->rts_rrv_time = vnt_get_rtscts_rsvtime_le(priv, 2,
|
2014-07-20 14:33:33 +00:00
|
|
|
tx_context->pkt_type, frame_len, current_rate);
|
2014-07-10 18:56:12 +00:00
|
|
|
|
2014-07-20 14:33:31 +00:00
|
|
|
if (tx_context->fb_option &&
|
|
|
|
tx_context->pkt_type == PK_TYPE_11A)
|
2014-07-10 18:56:12 +00:00
|
|
|
return vnt_rxtx_rts_a_fb_head(tx_context,
|
2014-07-20 14:33:34 +00:00
|
|
|
&head->rts_a_fb);
|
2014-07-10 18:56:12 +00:00
|
|
|
|
2014-07-20 14:33:34 +00:00
|
|
|
return vnt_rxtx_rts_ab_head(tx_context, &head->rts_ab);
|
2014-07-10 18:56:09 +00:00
|
|
|
}
|
|
|
|
|
2014-07-20 14:33:31 +00:00
|
|
|
if (tx_context->pkt_type == PK_TYPE_11A)
|
2014-07-20 14:33:34 +00:00
|
|
|
return vnt_rxtx_datahead_a_fb(tx_context,
|
2014-07-20 14:33:33 +00:00
|
|
|
&head->data_head_a_fb);
|
2014-07-10 18:56:12 +00:00
|
|
|
|
2014-07-20 14:33:34 +00:00
|
|
|
return vnt_rxtx_datahead_ab(tx_context, &head->data_head_ab);
|
2014-07-10 18:56:09 +00:00
|
|
|
}
|
|
|
|
|
2014-07-10 18:56:15 +00:00
|
|
|
static u16 vnt_generate_tx_parameter(struct vnt_usb_send_context *tx_context,
|
2017-05-07 13:18:17 +00:00
|
|
|
struct vnt_tx_buffer *tx_buffer,
|
|
|
|
struct vnt_mic_hdr **mic_hdr, u32 need_mic,
|
|
|
|
bool need_rts)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-07-20 14:33:31 +00:00
|
|
|
if (tx_context->pkt_type == PK_TYPE_11GB ||
|
|
|
|
tx_context->pkt_type == PK_TYPE_11GA) {
|
2013-10-07 19:14:01 +00:00
|
|
|
if (need_rts) {
|
2014-07-10 18:56:10 +00:00
|
|
|
if (need_mic)
|
2017-02-16 02:47:41 +00:00
|
|
|
*mic_hdr =
|
|
|
|
&tx_buffer->tx_head.tx_rts.tx.mic.hdr;
|
2013-09-26 17:52:10 +00:00
|
|
|
|
2014-07-10 18:56:10 +00:00
|
|
|
return vnt_rxtx_rts(tx_context, &tx_buffer->tx_head,
|
2014-07-20 14:33:34 +00:00
|
|
|
need_mic);
|
2013-10-07 19:14:01 +00:00
|
|
|
}
|
2014-07-10 18:56:13 +00:00
|
|
|
|
2014-07-10 18:56:12 +00:00
|
|
|
if (need_mic)
|
2014-07-10 18:56:13 +00:00
|
|
|
*mic_hdr = &tx_buffer->tx_head.tx_cts.tx.mic.hdr;
|
2013-10-01 15:03:40 +00:00
|
|
|
|
2014-07-20 14:33:34 +00:00
|
|
|
return vnt_rxtx_cts(tx_context, &tx_buffer->tx_head, need_mic);
|
2013-10-07 19:14:01 +00:00
|
|
|
}
|
2013-10-01 14:50:24 +00:00
|
|
|
|
2014-07-10 18:56:13 +00:00
|
|
|
if (need_mic)
|
|
|
|
*mic_hdr = &tx_buffer->tx_head.tx_ab.tx.mic.hdr;
|
|
|
|
|
2014-07-20 14:33:34 +00:00
|
|
|
return vnt_rxtx_ab(tx_context, &tx_buffer->tx_head, need_rts, need_mic);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
static void vnt_fill_txkey(struct vnt_usb_send_context *tx_context,
|
2017-05-07 13:18:17 +00:00
|
|
|
u8 *key_buffer, struct ieee80211_key_conf *tx_key,
|
|
|
|
struct sk_buff *skb, u16 payload_len,
|
|
|
|
struct vnt_mic_hdr *mic_hdr)
|
2014-06-25 20:14:23 +00:00
|
|
|
{
|
|
|
|
struct ieee80211_hdr *hdr = tx_context->hdr;
|
2016-02-15 10:34:10 +00:00
|
|
|
u64 pn64;
|
2014-06-25 20:14:23 +00:00
|
|
|
u8 *iv = ((u8 *)hdr + ieee80211_get_hdrlen_from_skb(skb));
|
|
|
|
|
|
|
|
/* strip header and icv len from payload */
|
|
|
|
payload_len -= ieee80211_get_hdrlen_from_skb(skb);
|
|
|
|
payload_len -= tx_key->icv_len;
|
|
|
|
|
|
|
|
switch (tx_key->cipher) {
|
|
|
|
case WLAN_CIPHER_SUITE_WEP40:
|
|
|
|
case WLAN_CIPHER_SUITE_WEP104:
|
|
|
|
memcpy(key_buffer, iv, 3);
|
|
|
|
memcpy(key_buffer + 3, tx_key->key, tx_key->keylen);
|
|
|
|
|
|
|
|
if (tx_key->keylen == WLAN_KEY_LEN_WEP40) {
|
|
|
|
memcpy(key_buffer + 8, iv, 3);
|
|
|
|
memcpy(key_buffer + 11,
|
2017-02-14 19:23:47 +00:00
|
|
|
tx_key->key, WLAN_KEY_LEN_WEP40);
|
2014-06-25 20:14:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case WLAN_CIPHER_SUITE_TKIP:
|
|
|
|
ieee80211_get_tkip_p2k(tx_key, skb, key_buffer);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case WLAN_CIPHER_SUITE_CCMP:
|
|
|
|
|
|
|
|
if (!mic_hdr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mic_hdr->id = 0x59;
|
|
|
|
mic_hdr->payload_len = cpu_to_be16(payload_len);
|
2015-01-21 11:08:48 +00:00
|
|
|
ether_addr_copy(mic_hdr->mic_addr2, hdr->addr2);
|
2014-06-25 20:14:23 +00:00
|
|
|
|
2016-02-15 10:34:10 +00:00
|
|
|
pn64 = atomic64_read(&tx_key->tx_pn);
|
|
|
|
mic_hdr->ccmp_pn[5] = pn64;
|
|
|
|
mic_hdr->ccmp_pn[4] = pn64 >> 8;
|
|
|
|
mic_hdr->ccmp_pn[3] = pn64 >> 16;
|
|
|
|
mic_hdr->ccmp_pn[2] = pn64 >> 24;
|
|
|
|
mic_hdr->ccmp_pn[1] = pn64 >> 32;
|
|
|
|
mic_hdr->ccmp_pn[0] = pn64 >> 40;
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
if (ieee80211_has_a4(hdr->frame_control))
|
|
|
|
mic_hdr->hlen = cpu_to_be16(28);
|
|
|
|
else
|
|
|
|
mic_hdr->hlen = cpu_to_be16(22);
|
|
|
|
|
Staging: vt6656: replace memcpy() by ether_addr_copy() using coccinelle and pack variable
This patch focuses on fixing the following warning generated
by checkpatch.pl for the file rxtx.c
Prefer ether_addr_copy() over memcpy() if the Ethernet addresses
are __aligned(2)
@@ expression e1, e2; @@
- memcpy(e1, e2, ETH_ALEN);
+ ether_addr_copy(e1, e2);
According to ether_addr_copy() description and functionality,
all Ethernet addresses should align to the u16 datatype.
The changes were applied using the following coccinelle rule:
Here is the output of pahole for the relevant datastructures:
struct vnt_usb_send_context {
void * priv; /* 0 8*/
struct sk_buff * skb; /* 8 8*/
struct urb * urb; /* 16 8*/
struct ieee80211_hdr * hdr; /* 24 8*/
unsigned int buf_len; /* 32 4*/
u32 frame_len; /* 36 4*/
u16 tx_hdr_size; /* 40 2*/
u16 tx_rate; /* 42 2*/
u8 type; /* 44 1*/
u8 pkt_no; /* 45 1*/
u8 pkt_type; /* 46 1*/
u8 need_ack; /* 47 1*/
u8 fb_option; /* 48 1*/
bool in_use; /* 49 1*/
unsigned char data[2900]; /* 50 2900*/
/* --- cacheline 46 boundary (2944 bytes) was 6 bytes ago --- */
/* size: 2952, cachelines: 47, members: 15 */
/* padding: 2 */
/* last cacheline: 8 bytes */
};
struct ieee80211_key_conf {
u32 cipher; /* 0 4*/
u8 icv_len; /* 4 1*/
u8 iv_len; /* 5 1*/
u8 hw_key_idx; /* 6 1*/
u8 flags; /* 7 1*/
s8 keyidx; /* 8 1*/
u8 keylen; /* 9 1*/
u8 key[0]; /* 10 0*/
/* size: 12, cachelines: 1, members: 8 */
/* padding: 2 */
/* last cacheline: 12 bytes */
};
struct vnt_mic_hdr {
u8 id; /* 0 1*/
u8 tx_priority; /* 1 1*/
u8 mic_addr2[6]; /* 2 6*/
u8 ccmp_pn[6]; /* 8 6*/
__be16 payload_len; /* 14 2*/
__be16 hlen; /* 16 2*/
__le16 frame_control; /* 18 2*/
u8 addr1[6]; /* 20 6*/
u8 addr2[6]; /* 26 6*/
u8 addr3[6]; /* 32 6*/
__le16 seq_ctrl; /* 38 2*/
u8 addr4[6]; /* 40 6*/
u16 packing; /* 46 2*/
/* size: 48, cachelines: 1, members: 13 */
/* last cacheline: 48 bytes */
};
Signed-off-by: aybuke ozdemir <aybuke.147@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-02-22 13:27:56 +00:00
|
|
|
ether_addr_copy(mic_hdr->addr1, hdr->addr1);
|
|
|
|
ether_addr_copy(mic_hdr->addr2, hdr->addr2);
|
|
|
|
ether_addr_copy(mic_hdr->addr3, hdr->addr3);
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
mic_hdr->frame_control = cpu_to_le16(
|
|
|
|
le16_to_cpu(hdr->frame_control) & 0xc78f);
|
|
|
|
mic_hdr->seq_ctrl = cpu_to_le16(
|
|
|
|
le16_to_cpu(hdr->seq_ctrl) & 0xf);
|
|
|
|
|
|
|
|
if (ieee80211_has_a4(hdr->frame_control))
|
Staging: vt6656: replace memcpy() by ether_addr_copy() using coccinelle and pack variable
This patch focuses on fixing the following warning generated
by checkpatch.pl for the file rxtx.c
Prefer ether_addr_copy() over memcpy() if the Ethernet addresses
are __aligned(2)
@@ expression e1, e2; @@
- memcpy(e1, e2, ETH_ALEN);
+ ether_addr_copy(e1, e2);
According to ether_addr_copy() description and functionality,
all Ethernet addresses should align to the u16 datatype.
The changes were applied using the following coccinelle rule:
Here is the output of pahole for the relevant datastructures:
struct vnt_usb_send_context {
void * priv; /* 0 8*/
struct sk_buff * skb; /* 8 8*/
struct urb * urb; /* 16 8*/
struct ieee80211_hdr * hdr; /* 24 8*/
unsigned int buf_len; /* 32 4*/
u32 frame_len; /* 36 4*/
u16 tx_hdr_size; /* 40 2*/
u16 tx_rate; /* 42 2*/
u8 type; /* 44 1*/
u8 pkt_no; /* 45 1*/
u8 pkt_type; /* 46 1*/
u8 need_ack; /* 47 1*/
u8 fb_option; /* 48 1*/
bool in_use; /* 49 1*/
unsigned char data[2900]; /* 50 2900*/
/* --- cacheline 46 boundary (2944 bytes) was 6 bytes ago --- */
/* size: 2952, cachelines: 47, members: 15 */
/* padding: 2 */
/* last cacheline: 8 bytes */
};
struct ieee80211_key_conf {
u32 cipher; /* 0 4*/
u8 icv_len; /* 4 1*/
u8 iv_len; /* 5 1*/
u8 hw_key_idx; /* 6 1*/
u8 flags; /* 7 1*/
s8 keyidx; /* 8 1*/
u8 keylen; /* 9 1*/
u8 key[0]; /* 10 0*/
/* size: 12, cachelines: 1, members: 8 */
/* padding: 2 */
/* last cacheline: 12 bytes */
};
struct vnt_mic_hdr {
u8 id; /* 0 1*/
u8 tx_priority; /* 1 1*/
u8 mic_addr2[6]; /* 2 6*/
u8 ccmp_pn[6]; /* 8 6*/
__be16 payload_len; /* 14 2*/
__be16 hlen; /* 16 2*/
__le16 frame_control; /* 18 2*/
u8 addr1[6]; /* 20 6*/
u8 addr2[6]; /* 26 6*/
u8 addr3[6]; /* 32 6*/
__le16 seq_ctrl; /* 38 2*/
u8 addr4[6]; /* 40 6*/
u16 packing; /* 46 2*/
/* size: 48, cachelines: 1, members: 13 */
/* last cacheline: 48 bytes */
};
Signed-off-by: aybuke ozdemir <aybuke.147@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-02-22 13:27:56 +00:00
|
|
|
ether_addr_copy(mic_hdr->addr4, hdr->addr4);
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
memcpy(key_buffer, tx_key->key, WLAN_KEY_LEN_CCMP);
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
|
|
|
|
struct ieee80211_tx_rate *tx_rate = &info->control.rates[0];
|
|
|
|
struct ieee80211_rate *rate;
|
|
|
|
struct ieee80211_key_conf *tx_key;
|
|
|
|
struct ieee80211_hdr *hdr;
|
|
|
|
struct vnt_mic_hdr *mic_hdr = NULL;
|
|
|
|
struct vnt_tx_buffer *tx_buffer;
|
|
|
|
struct vnt_tx_fifo_head *tx_buffer_head;
|
|
|
|
struct vnt_usb_send_context *tx_context;
|
|
|
|
unsigned long flags;
|
|
|
|
u16 tx_bytes, tx_header_size, tx_body_size, current_rate, duration_id;
|
|
|
|
u8 pkt_type, fb_option = AUTO_FB_NONE;
|
2014-07-20 14:33:32 +00:00
|
|
|
bool need_rts = false, is_pspoll = false;
|
2014-06-25 20:14:23 +00:00
|
|
|
bool need_mic = false;
|
|
|
|
|
|
|
|
hdr = (struct ieee80211_hdr *)(skb->data);
|
|
|
|
|
|
|
|
rate = ieee80211_get_tx_rate(priv->hw, info);
|
|
|
|
|
|
|
|
current_rate = rate->hw_value;
|
2014-07-20 14:33:19 +00:00
|
|
|
if (priv->current_rate != current_rate &&
|
2017-05-07 13:18:17 +00:00
|
|
|
!(priv->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) {
|
2014-07-20 14:33:19 +00:00
|
|
|
priv->current_rate = current_rate;
|
2014-07-13 09:42:50 +00:00
|
|
|
vnt_schedule_command(priv, WLAN_CMD_SETPOWER);
|
2014-06-25 20:14:23 +00:00
|
|
|
}
|
|
|
|
|
2015-04-04 19:49:10 +00:00
|
|
|
if (current_rate > RATE_11M) {
|
2016-04-12 13:56:15 +00:00
|
|
|
if (info->band == NL80211_BAND_5GHZ) {
|
2015-04-04 19:49:10 +00:00
|
|
|
pkt_type = PK_TYPE_11A;
|
|
|
|
} else {
|
|
|
|
if (tx_rate->flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
|
|
|
|
pkt_type = PK_TYPE_11GB;
|
|
|
|
else
|
|
|
|
pkt_type = PK_TYPE_11GA;
|
|
|
|
}
|
|
|
|
} else {
|
2014-06-25 20:14:23 +00:00
|
|
|
pkt_type = PK_TYPE_11B;
|
2015-04-04 19:49:10 +00:00
|
|
|
}
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
|
|
|
|
2014-07-11 00:08:28 +00:00
|
|
|
tx_context = vnt_get_free_context(priv);
|
2014-06-25 20:14:23 +00:00
|
|
|
if (!tx_context) {
|
|
|
|
dev_dbg(&priv->usb->dev, "%s No free context\n", __func__);
|
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
tx_context->skb = skb;
|
2014-07-20 14:33:31 +00:00
|
|
|
tx_context->pkt_type = pkt_type;
|
2014-07-20 14:33:32 +00:00
|
|
|
tx_context->need_ack = false;
|
2014-07-20 14:33:33 +00:00
|
|
|
tx_context->frame_len = skb->len + 4;
|
2014-07-20 14:33:34 +00:00
|
|
|
tx_context->tx_rate = current_rate;
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
|
|
|
|
tx_buffer = (struct vnt_tx_buffer *)tx_context->data;
|
|
|
|
tx_buffer_head = &tx_buffer->fifo_head;
|
|
|
|
tx_body_size = skb->len;
|
|
|
|
|
|
|
|
/*Set fifo controls */
|
|
|
|
if (pkt_type == PK_TYPE_11A)
|
2014-07-22 21:49:43 +00:00
|
|
|
tx_buffer_head->fifo_ctl = 0;
|
2014-06-25 20:14:23 +00:00
|
|
|
else if (pkt_type == PK_TYPE_11B)
|
2014-07-22 21:49:48 +00:00
|
|
|
tx_buffer_head->fifo_ctl = cpu_to_le16(FIFOCTL_11B);
|
2014-06-25 20:14:23 +00:00
|
|
|
else if (pkt_type == PK_TYPE_11GB)
|
2014-07-22 21:49:48 +00:00
|
|
|
tx_buffer_head->fifo_ctl = cpu_to_le16(FIFOCTL_11GB);
|
2014-06-25 20:14:23 +00:00
|
|
|
else if (pkt_type == PK_TYPE_11GA)
|
2014-07-22 21:49:48 +00:00
|
|
|
tx_buffer_head->fifo_ctl = cpu_to_le16(FIFOCTL_11GA);
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
if (!ieee80211_is_data(hdr->frame_control)) {
|
2014-07-22 21:49:48 +00:00
|
|
|
tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_GENINT |
|
|
|
|
FIFOCTL_ISDMA0);
|
|
|
|
tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_TMOEN);
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
tx_buffer_head->time_stamp =
|
|
|
|
cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us);
|
|
|
|
} else {
|
|
|
|
tx_buffer_head->time_stamp =
|
|
|
|
cpu_to_le16(DEFAULT_MSDU_LIFETIME_RES_64us);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) {
|
2014-07-22 21:49:48 +00:00
|
|
|
tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_NEEDACK);
|
2014-07-20 14:33:32 +00:00
|
|
|
tx_context->need_ack = true;
|
2014-06-25 20:14:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ieee80211_has_retry(hdr->frame_control))
|
2014-07-22 21:49:48 +00:00
|
|
|
tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LRETRY);
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
if (tx_rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
|
2014-07-20 14:33:17 +00:00
|
|
|
priv->preamble_type = PREAMBLE_SHORT;
|
2014-06-25 20:14:23 +00:00
|
|
|
else
|
2014-07-20 14:33:17 +00:00
|
|
|
priv->preamble_type = PREAMBLE_LONG;
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
if (tx_rate->flags & IEEE80211_TX_RC_USE_RTS_CTS) {
|
|
|
|
need_rts = true;
|
2014-07-22 21:49:48 +00:00
|
|
|
tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_RTS);
|
2014-06-25 20:14:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ieee80211_has_a4(hdr->frame_control))
|
2014-07-22 21:49:48 +00:00
|
|
|
tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LHEAD);
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)
|
|
|
|
is_pspoll = true;
|
|
|
|
|
2014-06-28 22:55:40 +00:00
|
|
|
tx_buffer_head->frag_ctl =
|
|
|
|
cpu_to_le16(ieee80211_get_hdrlen_from_skb(skb) << 10);
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
if (info->control.hw_key) {
|
|
|
|
tx_key = info->control.hw_key;
|
|
|
|
switch (info->control.hw_key->cipher) {
|
|
|
|
case WLAN_CIPHER_SUITE_WEP40:
|
|
|
|
case WLAN_CIPHER_SUITE_WEP104:
|
2014-06-28 22:55:40 +00:00
|
|
|
tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_LEGACY);
|
2014-06-25 20:14:23 +00:00
|
|
|
break;
|
|
|
|
case WLAN_CIPHER_SUITE_TKIP:
|
2014-06-28 22:55:40 +00:00
|
|
|
tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_TKIP);
|
2014-06-25 20:14:23 +00:00
|
|
|
break;
|
|
|
|
case WLAN_CIPHER_SUITE_CCMP:
|
2014-06-28 22:55:40 +00:00
|
|
|
tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_AES);
|
2014-06-25 20:14:23 +00:00
|
|
|
need_mic = true;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-07-20 14:33:33 +00:00
|
|
|
tx_context->frame_len += tx_key->icv_len;
|
2014-06-25 20:14:23 +00:00
|
|
|
}
|
|
|
|
|
2014-07-10 18:56:05 +00:00
|
|
|
tx_buffer_head->current_rate = cpu_to_le16(current_rate);
|
|
|
|
|
2014-06-25 20:14:23 +00:00
|
|
|
/* legacy rates TODO use ieee80211_tx_rate */
|
|
|
|
if (current_rate >= RATE_18M && ieee80211_is_data(hdr->frame_control)) {
|
2014-07-20 14:33:24 +00:00
|
|
|
if (priv->auto_fb_ctrl == AUTO_FB_0) {
|
2014-07-22 21:49:48 +00:00
|
|
|
tx_buffer_head->fifo_ctl |=
|
|
|
|
cpu_to_le16(FIFOCTL_AUTO_FB_0);
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
priv->tx_rate_fb0 =
|
2014-07-11 00:08:26 +00:00
|
|
|
vnt_fb_opt0[FB_RATE0][current_rate - RATE_18M];
|
2014-06-25 20:14:23 +00:00
|
|
|
priv->tx_rate_fb1 =
|
2014-07-11 00:08:26 +00:00
|
|
|
vnt_fb_opt0[FB_RATE1][current_rate - RATE_18M];
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
fb_option = AUTO_FB_0;
|
2014-07-20 14:33:24 +00:00
|
|
|
} else if (priv->auto_fb_ctrl == AUTO_FB_1) {
|
2014-07-22 21:49:48 +00:00
|
|
|
tx_buffer_head->fifo_ctl |=
|
|
|
|
cpu_to_le16(FIFOCTL_AUTO_FB_1);
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
priv->tx_rate_fb0 =
|
2014-07-11 00:08:27 +00:00
|
|
|
vnt_fb_opt1[FB_RATE0][current_rate - RATE_18M];
|
2014-06-25 20:14:23 +00:00
|
|
|
priv->tx_rate_fb1 =
|
2014-07-11 00:08:27 +00:00
|
|
|
vnt_fb_opt1[FB_RATE1][current_rate - RATE_18M];
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
fb_option = AUTO_FB_1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-05 18:24:27 +00:00
|
|
|
tx_context->fb_option = fb_option;
|
|
|
|
|
2014-07-20 14:33:34 +00:00
|
|
|
duration_id = vnt_generate_tx_parameter(tx_context, tx_buffer, &mic_hdr,
|
|
|
|
need_mic, need_rts);
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
tx_header_size = tx_context->tx_hdr_size;
|
|
|
|
if (!tx_header_size) {
|
|
|
|
tx_context->in_use = false;
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2014-06-28 22:55:40 +00:00
|
|
|
tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_NONFRAG);
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
tx_bytes = tx_header_size + tx_body_size;
|
|
|
|
|
|
|
|
memcpy(tx_context->hdr, skb->data, tx_body_size);
|
|
|
|
|
|
|
|
hdr->duration_id = cpu_to_le16(duration_id);
|
|
|
|
|
|
|
|
if (info->control.hw_key) {
|
|
|
|
tx_key = info->control.hw_key;
|
|
|
|
if (tx_key->keylen > 0)
|
|
|
|
vnt_fill_txkey(tx_context, tx_buffer_head->tx_key,
|
2017-05-07 13:18:17 +00:00
|
|
|
tx_key, skb, tx_body_size, mic_hdr);
|
2014-06-25 20:14:23 +00:00
|
|
|
}
|
|
|
|
|
2014-07-20 14:33:23 +00:00
|
|
|
priv->seq_counter = (le16_to_cpu(hdr->seq_ctrl) &
|
2014-06-25 20:14:23 +00:00
|
|
|
IEEE80211_SCTL_SEQ) >> 4;
|
|
|
|
|
|
|
|
tx_buffer->tx_byte_count = cpu_to_le16(tx_bytes);
|
2014-07-22 21:49:44 +00:00
|
|
|
tx_buffer->pkt_no = tx_context->pkt_no;
|
2014-07-22 21:49:46 +00:00
|
|
|
tx_buffer->type = 0x00;
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
tx_bytes += 4;
|
|
|
|
|
|
|
|
tx_context->type = CONTEXT_DATA_PACKET;
|
|
|
|
tx_context->buf_len = tx_bytes;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
|
|
|
|
2014-07-15 18:54:39 +00:00
|
|
|
if (vnt_tx_context(priv, tx_context) != STATUS_PENDING) {
|
2014-06-25 20:14:23 +00:00
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-05-07 13:18:17 +00:00
|
|
|
static int vnt_beacon_xmit(struct vnt_private *priv, struct sk_buff *skb)
|
2014-06-25 20:14:23 +00:00
|
|
|
{
|
|
|
|
struct vnt_beacon_buffer *beacon_buffer;
|
|
|
|
struct vnt_tx_short_buf_head *short_head;
|
|
|
|
struct ieee80211_tx_info *info;
|
|
|
|
struct vnt_usb_send_context *context;
|
|
|
|
struct ieee80211_mgmt *mgmt_hdr;
|
|
|
|
unsigned long flags;
|
|
|
|
u32 frame_size = skb->len + 4;
|
|
|
|
u16 current_rate, count;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
|
|
|
|
2014-07-11 00:08:28 +00:00
|
|
|
context = vnt_get_free_context(priv);
|
2014-06-25 20:14:23 +00:00
|
|
|
if (!context) {
|
|
|
|
dev_dbg(&priv->usb->dev, "%s No free context!\n", __func__);
|
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
context->skb = skb;
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
|
|
|
|
beacon_buffer = (struct vnt_beacon_buffer *)&context->data[0];
|
|
|
|
short_head = &beacon_buffer->short_head;
|
|
|
|
|
2014-07-20 14:33:11 +00:00
|
|
|
if (priv->bb_type == BB_TYPE_11A) {
|
2014-06-25 20:14:23 +00:00
|
|
|
current_rate = RATE_6M;
|
|
|
|
|
|
|
|
/* Get SignalField,ServiceField,Length */
|
|
|
|
vnt_get_phy_field(priv, frame_size, current_rate,
|
2017-04-28 11:25:37 +00:00
|
|
|
PK_TYPE_11A, &short_head->ab);
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
/* Get Duration and TimeStampOff */
|
2014-07-11 00:08:22 +00:00
|
|
|
short_head->duration = vnt_get_duration_le(priv,
|
2017-02-14 19:23:47 +00:00
|
|
|
PK_TYPE_11A, false);
|
2014-06-25 20:14:23 +00:00
|
|
|
short_head->time_stamp_off =
|
|
|
|
vnt_time_stamp_off(priv, current_rate);
|
|
|
|
} else {
|
|
|
|
current_rate = RATE_1M;
|
2014-07-22 21:49:49 +00:00
|
|
|
short_head->fifo_ctl |= cpu_to_le16(FIFOCTL_11B);
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
/* Get SignalField,ServiceField,Length */
|
|
|
|
vnt_get_phy_field(priv, frame_size, current_rate,
|
2017-02-14 19:23:47 +00:00
|
|
|
PK_TYPE_11B, &short_head->ab);
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
/* Get Duration and TimeStampOff */
|
2014-07-11 00:08:22 +00:00
|
|
|
short_head->duration = vnt_get_duration_le(priv,
|
2014-06-25 20:14:23 +00:00
|
|
|
PK_TYPE_11B, false);
|
|
|
|
short_head->time_stamp_off =
|
|
|
|
vnt_time_stamp_off(priv, current_rate);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate Beacon Header */
|
|
|
|
mgmt_hdr = &beacon_buffer->mgmt_hdr;
|
|
|
|
memcpy(mgmt_hdr, skb->data, skb->len);
|
|
|
|
|
|
|
|
/* time stamp always 0 */
|
|
|
|
mgmt_hdr->u.beacon.timestamp = 0;
|
|
|
|
|
|
|
|
info = IEEE80211_SKB_CB(skb);
|
|
|
|
if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
|
|
|
|
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)mgmt_hdr;
|
2014-08-10 22:23:50 +00:00
|
|
|
|
2014-06-25 20:14:23 +00:00
|
|
|
hdr->duration_id = 0;
|
2014-07-20 14:33:23 +00:00
|
|
|
hdr->seq_ctrl = cpu_to_le16(priv->seq_counter << 4);
|
2014-06-25 20:14:23 +00:00
|
|
|
}
|
|
|
|
|
2014-07-20 14:33:23 +00:00
|
|
|
priv->seq_counter++;
|
|
|
|
if (priv->seq_counter > 0x0fff)
|
|
|
|
priv->seq_counter = 0;
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
count = sizeof(struct vnt_tx_short_buf_head) + skb->len;
|
|
|
|
|
|
|
|
beacon_buffer->tx_byte_count = cpu_to_le16(count);
|
2014-07-22 21:49:45 +00:00
|
|
|
beacon_buffer->pkt_no = context->pkt_no;
|
2014-07-22 21:49:47 +00:00
|
|
|
beacon_buffer->type = 0x01;
|
2014-06-25 20:14:23 +00:00
|
|
|
|
|
|
|
context->type = CONTEXT_BEACON_PACKET;
|
|
|
|
context->buf_len = count + 4; /* USB header */
|
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
|
|
|
|
2014-07-15 18:54:39 +00:00
|
|
|
if (vnt_tx_context(priv, context) != STATUS_PENDING)
|
2014-06-25 20:14:23 +00:00
|
|
|
ieee80211_free_txskb(priv->hw, context->skb);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int vnt_beacon_make(struct vnt_private *priv, struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct sk_buff *beacon;
|
|
|
|
|
|
|
|
beacon = ieee80211_beacon_get(priv->hw, vif);
|
|
|
|
if (!beacon)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
if (vnt_beacon_xmit(priv, beacon)) {
|
|
|
|
ieee80211_free_txskb(priv->hw, beacon);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int vnt_beacon_enable(struct vnt_private *priv, struct ieee80211_vif *vif,
|
2017-05-07 13:18:17 +00:00
|
|
|
struct ieee80211_bss_conf *conf)
|
2014-06-25 20:14:23 +00:00
|
|
|
{
|
|
|
|
vnt_mac_reg_bits_off(priv, MAC_REG_TCR, TCR_AUTOBCNTX);
|
|
|
|
|
|
|
|
vnt_mac_reg_bits_off(priv, MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
|
|
|
|
|
|
|
|
vnt_mac_set_beacon_interval(priv, conf->beacon_int);
|
|
|
|
|
|
|
|
vnt_clear_current_tsf(priv);
|
|
|
|
|
|
|
|
vnt_mac_reg_bits_on(priv, MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
|
|
|
|
|
|
|
|
vnt_reset_next_tbtt(priv, conf->beacon_int);
|
|
|
|
|
2014-09-21 15:24:52 +00:00
|
|
|
return vnt_beacon_make(priv, vif);
|
2014-06-25 20:14:23 +00:00
|
|
|
}
|