From: Andrew Lunn <andrew@lunn.ch>
To: Igor Russkikh <Igor.Russkikh@aquantia.com>
Cc: "David S . Miller" <davem@davemloft.net>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Dmitry Bezrukov <Dmitry.Bezrukov@aquantia.com>
Subject: [net-next,08/19] net: usb: aqc111: Implement TX data path
Date: Sat, 6 Oct 2018 03:13:25 +0200 [thread overview]
Message-ID: <20181006011325.GB32455@lunn.ch> (raw)
> +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
next reply other threads:[~2018-10-06 1:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-06 1:13 Andrew Lunn [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-10-09 13:50 [net-next,08/19] net: usb: aqc111: Implement TX data path Bjørn Mork
2018-10-08 14:07 Oliver Neukum
2018-10-08 13:43 Igor Russkikh
2018-10-05 10:25 Igor Russkikh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181006011325.GB32455@lunn.ch \
--to=andrew@lunn.ch \
--cc=Dmitry.Bezrukov@aquantia.com \
--cc=Igor.Russkikh@aquantia.com \
--cc=davem@davemloft.net \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.