Commit 5f46e3cd authored by Malcolm Priestley's avatar Malcolm Priestley Committed by Greg Kroah-Hartman
Browse files

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: default avatarMalcolm Priestley <tvboxspy@gmail.com>
Link: https://lore.kernel.org/r/aa6257eb-1758-4e75-ab39-2a15ff6ffa7c@gmail.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7077256b
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -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;
+2 −1
Original line number Diff line number Diff line
@@ -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);
+5 −25
Original line number Diff line number Diff line
@@ -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);
+0 −7
Original line number Diff line number Diff line
@@ -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;
+15 −6
Original line number Diff line number Diff line
@@ -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);

Loading