staging: vt6656: Move vnt_tx_usb_header to vnt_tx_context

Move the USB element out of vnt_tx_packet and vnt_beacon_xmit to
vnt_tx_context with sk_buff passed in parameters with the data now
between skb->data and skb->len.

The vnt_tx_usb header is moved from vnt_tx_buffer to usbpipe.h with the
size added to extra_tx_headroom the largest possible size.

The CONTEXT enums types are aligned with usb ones and CONTEXT_MGMT_PACKET
is removed and is never be used.

The skb_push in vnt_tx_packet is now only ever used with
vnt_get_hdr_size with variables tx_bytes and tx_header_size removed.

buf_len in vnt_usb_send_context is no longer used and replaced with
urb->actual_length in vnt_tx_context_complete.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Link: https://lore.kernel.org/r/aa6257eb-1758-4e75-ab39-2a15ff6ffa7c@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Malcolm Priestley 2020-05-27 09:54:44 +01:00 committed by Greg Kroah-Hartman
parent 7077256b52
commit 5f46e3cde5
6 changed files with 31 additions and 43 deletions

View file

@ -206,8 +206,7 @@ struct vnt_rsp_card_init {
* Enum of context types for SendPacket
*/
enum {
CONTEXT_DATA_PACKET = 1,
CONTEXT_MGMT_PACKET,
CONTEXT_DATA_PACKET = 0,
CONTEXT_BEACON_PACKET
};
@ -239,7 +238,6 @@ struct vnt_usb_send_context {
void *priv;
struct sk_buff *skb;
void *tx_buffer;
unsigned int buf_len;
u32 frame_len;
u16 tx_hdr_size;
u16 tx_rate;

View file

@ -1043,7 +1043,8 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
ieee80211_hw_set(priv->hw, SUPPORTS_PS);
ieee80211_hw_set(priv->hw, PS_NULLFUNC_STACK);
priv->hw->extra_tx_headroom = sizeof(struct vnt_tx_buffer);
priv->hw->extra_tx_headroom =
sizeof(struct vnt_tx_buffer) + sizeof(struct vnt_tx_usb_header);
priv->hw->max_signal = 100;
SET_IEEE80211_DEV(priv->hw, &intf->dev);

View file

@ -512,7 +512,6 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
struct vnt_tx_fifo_head *tx_buffer_head;
struct vnt_usb_send_context *tx_context;
unsigned long flags;
u16 tx_bytes, tx_header_size;
u8 pkt_type;
hdr = (struct ieee80211_hdr *)(skb->data);
@ -557,21 +556,11 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
return -ENOMEM;
}
tx_header_size = vnt_get_hdr_size(info);
tx_bytes = tx_header_size + skb->len;
tx_header_size += sizeof(struct vnt_tx_usb_header);
tx_buffer = skb_push(skb, tx_header_size);
tx_buffer = skb_push(skb, vnt_get_hdr_size(info));
tx_context->tx_buffer = tx_buffer;
tx_buffer_head = &tx_buffer->fifo_head;
/* Fill USB header */
tx_buffer->usb.tx_byte_count = cpu_to_le16(tx_bytes);
tx_buffer->usb.pkt_no = tx_context->pkt_no;
tx_buffer->usb.type = 0x00;
tx_context->type = CONTEXT_DATA_PACKET;
tx_context->tx_buffer = skb->data;
tx_context->buf_len = skb->len;
/*Set fifo controls */
if (pkt_type == PK_TYPE_11A)
@ -624,7 +613,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
spin_lock_irqsave(&priv->lock, flags);
if (vnt_tx_context(priv, tx_context)) {
if (vnt_tx_context(priv, tx_context, skb)) {
dev_kfree_skb(tx_context->skb);
spin_unlock_irqrestore(&priv->lock, flags);
return -EIO;
@ -639,14 +628,13 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
static int vnt_beacon_xmit(struct vnt_private *priv, struct sk_buff *skb)
{
struct vnt_tx_usb_header *usb;
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;
u16 current_rate;
spin_lock_irqsave(&priv->lock, flags);
@ -663,7 +651,6 @@ static int vnt_beacon_xmit(struct vnt_private *priv, struct sk_buff *skb)
mgmt_hdr = (struct ieee80211_mgmt *)skb->data;
short_head = skb_push(skb, sizeof(*short_head));
count = skb->len;
if (priv->bb_type == BB_TYPE_11A) {
current_rate = RATE_6M;
@ -706,18 +693,11 @@ static int vnt_beacon_xmit(struct vnt_private *priv, struct sk_buff *skb)
if (priv->seq_counter > 0x0fff)
priv->seq_counter = 0;
usb = skb_push(skb, sizeof(*usb));
usb->tx_byte_count = cpu_to_le16(count);
usb->pkt_no = context->pkt_no;
usb->type = 0x01;
context->type = CONTEXT_BEACON_PACKET;
context->tx_buffer = usb;
context->buf_len = skb->len;
spin_lock_irqsave(&priv->lock, flags);
if (vnt_tx_context(priv, context))
if (vnt_tx_context(priv, context, skb))
ieee80211_free_txskb(priv->hw, context->skb);
spin_unlock_irqrestore(&priv->lock, flags);

View file

@ -159,14 +159,7 @@ struct vnt_tx_fifo_head {
__le16 current_rate;
} __packed;
struct vnt_tx_usb_header {
u8 type;
u8 pkt_no;
__le16 tx_byte_count;
} __packed;
struct vnt_tx_buffer {
struct vnt_tx_usb_header usb;
struct vnt_tx_fifo_head fifo_head;
union vnt_tx_head tx_head;
} __packed;

View file

@ -428,7 +428,8 @@ static void vnt_tx_context_complete(struct urb *urb)
switch (urb->status) {
case 0:
dev_dbg(&priv->usb->dev, "Write %d bytes\n", context->buf_len);
dev_dbg(&priv->usb->dev,
"Write %d bytes\n", urb->actual_length);
break;
case -ECONNRESET:
case -ENOENT:
@ -453,17 +454,25 @@ static void vnt_tx_context_complete(struct urb *urb)
}
int vnt_tx_context(struct vnt_private *priv,
struct vnt_usb_send_context *context)
struct vnt_usb_send_context *context,
struct sk_buff *skb)
{
int status;
struct vnt_tx_usb_header *usb;
struct urb *urb;
int status;
u16 count = skb->len;
usb = skb_push(skb, sizeof(*usb));
usb->tx_byte_count = cpu_to_le16(count);
usb->pkt_no = context->pkt_no;
usb->type = context->type;
if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) {
context->in_use = false;
return -ENODEV;
}
if (context->buf_len > MAX_TOTAL_SIZE_WITH_ALL_HEADERS) {
if (skb->len > MAX_TOTAL_SIZE_WITH_ALL_HEADERS) {
context->in_use = false;
return -E2BIG;
}
@ -477,8 +486,8 @@ int vnt_tx_context(struct vnt_private *priv,
usb_fill_bulk_urb(urb,
priv->usb,
usb_sndbulkpipe(priv->usb, 3),
context->tx_buffer,
context->buf_len,
skb->data,
skb->len,
vnt_tx_context_complete,
context);

View file

@ -41,6 +41,12 @@ struct vnt_interrupt_data {
u8 sw[2];
} __packed;
struct vnt_tx_usb_header {
u8 type;
u8 pkt_no;
__le16 tx_byte_count;
} __packed;
#define VNT_REG_BLOCK_SIZE 64
int vnt_control_out(struct vnt_private *priv, u8 request, u16 value,
@ -57,6 +63,7 @@ int vnt_control_out_blocks(struct vnt_private *priv,
int vnt_start_interrupt_urb(struct vnt_private *priv);
int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb);
int vnt_tx_context(struct vnt_private *priv,
struct vnt_usb_send_context *context);
struct vnt_usb_send_context *context,
struct sk_buff *skb);
#endif /* __USBPIPE_H__ */