[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181006011325.GB32455@lunn.ch>
Date: Sat, 6 Oct 2018 03:13:25 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Igor Russkikh <Igor.Russkikh@...antia.com>
Cc: "David S . Miller" <davem@...emloft.net>,
"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
Dmitry Bezrukov <Dmitry.Bezrukov@...antia.com>
Subject: Re: [PATCH net-next 08/19] net: usb: aqc111: Implement TX data path
> +static struct sk_buff *aqc111_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
> + gfp_t flags)
> +{
> + struct aq_tx_packet_desc tx_hdr;
> + int frame_size = dev->maxpacket;
> + int headroom = 0;
> + int tailroom = 0;
> + int padding_size = 0;
> + struct sk_buff *new_skb = NULL;
> +
> + memset(&tx_hdr, 0x00, sizeof(tx_hdr));
> +
> + /*Length of actual data*/
> + tx_hdr.length = (skb->len & 0x1FFFFF);
> +
> + headroom = (skb->len + AQ_TX_HEADER_SIZE) % 8;
> + if (headroom != 0)
> + padding_size = 8 - headroom;
> +
> + if (((skb->len + AQ_TX_HEADER_SIZE + padding_size) % frame_size) == 0) {
> + padding_size += 8;
> + tx_hdr.drop_padding = 1;
> + }
> +
> + if (!dev->can_dma_sg && (dev->net->features & NETIF_F_SG) &&
> + skb_linearize(skb))
> + return NULL;
> +
> + headroom = skb_headroom(skb);
> + tailroom = skb_tailroom(skb);
> +
> + if (!(headroom >= AQ_TX_HEADER_SIZE && tailroom >= padding_size)) {
> + new_skb = skb_copy_expand(skb, AQ_TX_HEADER_SIZE,
> + padding_size, flags);
> + dev_kfree_skb_any(skb);
> + skb = new_skb;
> + if (!skb)
> + return NULL;
> + }
> + if (padding_size != 0)
> + skb_put(skb, padding_size);
> + /* Copy TX header */
> + skb_push(skb, AQ_TX_HEADER_SIZE);
> + cpu_to_le64s(&tx_hdr);
Is that portable? tx_hdr is a structure of 2x u32 bitfields. What
endian have you tested that one?
> + skb_copy_to_linear_data(skb, &tx_hdr, 8);
> +
> + usbnet_set_skb_tx_stats(skb, 1, 0);
> +
> + return skb;
> +}
> +struct aq_tx_packet_desc {
> + struct {
> + u32 length:21;
> + u32 checksum:7;
> + u32 drop_padding:1;
> + u32 vlan_tag:1;
> + u32 cphi:1;
> + u32 dicf:1;
> + };
> + struct {
> + u32 max_seg_size:15;
> + u32 reserved:1;
> + u32 vlan_info:16;
> + };
> +};
Andrew
Powered by blists - more mailing lists