qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Dmitry Fleytman <dmitry@daynix.com>, qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	Yan Vugenfirer <yan@daynix.com>, Leonid Bloch <leonid@daynix.com>,
	Shmulik Ladkani <shmulik.ladkani@ravellosystems.com>
Subject: Re: [Qemu-devel] [PATCH v7 12/17] net_pkt: Extend packet abstraction as required by e1000e functionality
Date: Wed, 1 Jun 2016 12:25:23 +0800	[thread overview]
Message-ID: <574E63B3.1090000@redhat.com> (raw)
In-Reply-To: <1464679259-1378-13-git-send-email-dmitry@daynix.com>



On 2016年05月31日 15:20, Dmitry Fleytman wrote:
> From: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
>
> This patch extends the TX/RX packet abstractions with features that will
> be used by the e1000e device implementation.
>
> Changes are:
>
>    1. Support iovec lists for RX buffers
>    2. Deeper RX packets parsing
>    3. Loopback option for TX packets
>    4. Extended VLAN headers handling
>    5. RSS processing for RX packets
>
> Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
> Signed-off-by: Leonid Bloch <leonid.bloch@ravellosystems.com>
> ---
>   hw/net/net_rx_pkt.c    | 473 +++++++++++++++++++++++++++++++++++++++++++++----
>   hw/net/net_rx_pkt.h    | 193 +++++++++++++++++++-
>   hw/net/net_tx_pkt.c    | 204 +++++++++++++--------
>   hw/net/net_tx_pkt.h    |  60 ++++++-
>   include/net/checksum.h |   4 +-
>   include/net/eth.h      | 153 +++++++++++-----
>   net/checksum.c         |   7 +-
>   net/eth.c              | 410 +++++++++++++++++++++++++++++++++++++-----
>   trace-events           |  40 +++++
>   9 files changed, 1336 insertions(+), 208 deletions(-)

[...]

>   struct udp_hdr {
>     uint16_t uh_sport;           /* source port */
>     uint16_t uh_dport;           /* destination port */
> @@ -169,19 +194,22 @@ struct tcp_hdr {
>   #define PKT_GET_IP_HDR(p)         \
>       ((struct ip_header *)(((uint8_t *)(p)) + eth_get_l2_hdr_length(p)))
>   #define IP_HDR_GET_LEN(p)         \
> -    ((((struct ip_header *)p)->ip_ver_len & 0x0F) << 2)
> +    ((((struct ip_header *)(p))->ip_ver_len & 0x0F) << 2)
>   #define PKT_GET_IP_HDR_LEN(p)     \
>       (IP_HDR_GET_LEN(PKT_GET_IP_HDR(p)))
>   #define PKT_GET_IP6_HDR(p)        \
>       ((struct ip6_header *) (((uint8_t *)(p)) + eth_get_l2_hdr_length(p)))
>   #define IP_HEADER_VERSION(ip)     \
> -    ((ip->ip_ver_len >> 4)&0xf)
> +    (((ip)->ip_ver_len >> 4) & 0xf)
> +#define IP4_IS_FRAGMENT(ip) \
> +    ((be16_to_cpu((ip)->ip_off) & (IP_OFFMASK | IP_MF)) != 0)
>   
>   #define ETH_P_IP                  (0x0800)      /* Internet Protocol packet  */
>   #define ETH_P_ARP                 (0x0806)      /* Address Resolution packet */
>   #define ETH_P_IPV6                (0x86dd)
>   #define ETH_P_VLAN                (0x8100)
>   #define ETH_P_DVLAN               (0x88a8)
> +#define ETH_P_UNKNOWN             (0xffff)
>   #define VLAN_VID_MASK             0x0fff
>   #define IP_HEADER_VERSION_4       (4)
>   #define IP_HEADER_VERSION_6       (6)
> @@ -258,15 +286,25 @@ get_eth_packet_type(const struct eth_header *ehdr)
>   }
>   
>   static inline uint32_t
> -eth_get_l2_hdr_length(const void *p)
> +eth_get_l2_hdr_length(const struct iovec *iov, int iovcnt)
>   {

Looks like this changes breaks the above PKT_GET_IP_HDR and 
PKT_GET_IP6_HDR. This will be a problem e.g ENET series depends on this.

A solution is keeping current eth_get_l2_hdr_length() and call it in a 
new helper e.g eth_get_l2_hdr_length_iov().

> -    uint16_t proto = be16_to_cpu(PKT_GET_ETH_HDR(p)->h_proto);
> -    struct vlan_header *hvlan = PKT_GET_VLAN_HDR(p);
> +    uint8_t p[sizeof(struct eth_header) + sizeof(struct vlan_header)];
> +    size_t copied = iov_to_buf(iov, iovcnt, 0, p, ARRAY_SIZE(p));
> +    uint16_t proto;
> +    struct vlan_header *hvlan;
> +
> +    if (copied < ARRAY_SIZE(p)) {
> +        return copied;
> +    }
> +
> +    proto = be16_to_cpu(PKT_GET_ETH_HDR(p)->h_proto);
> +    hvlan = PKT_GET_VLAN_HDR(p);
> +
>       switch (proto) {
>       case ETH_P_VLAN:
>           return sizeof(struct eth_header) + sizeof(struct vlan_header);
>       case ETH_P_DVLAN:
> -        if (hvlan->h_proto == ETH_P_VLAN) {
> +        if (be16_to_cpu(hvlan->h_proto) == ETH_P_VLAN) {
>               return sizeof(struct eth_header) + 2 * sizeof(struct vlan_header);
>           } else {
>               return sizeof(struct eth_header) + sizeof(struct vlan_header);
> @@ -290,51 +328,67 @@ eth_get_pkt_tci(const void *p)
>       }
>   }
>   

[...]

  reply	other threads:[~2016-06-01  4:25 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-31  7:20 [Qemu-devel] [PATCH v7 00/17] Introduce Intel 82574 GbE Controller Emulation (e1000e) Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 01/17] pci: fix unaligned access in pci_xxx_quad() Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 02/17] msix: make msix_clr_pending() visible for clients Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 03/17] pci: Introduce define for PM capability version 1.1 Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 04/17] pcie: Add support for PCIe CAP v1 Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 05/17] pcie: Introduce function for DSN capability creation Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 06/17] vmxnet3: Use generic function for DSN capability definition Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 07/17] net: Introduce Toeplitz hash calculator Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 08/17] net: Add macros for MAC address tracing Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 09/17] vmxnet3: Use common MAC address tracing macros Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 10/17] net_pkt: Name vmxnet3 packet abstractions more generic Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 11/17] rtl8139: Move more TCP definitions to common header Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 12/17] net_pkt: Extend packet abstraction as required by e1000e functionality Dmitry Fleytman
2016-06-01  4:25   ` Jason Wang [this message]
2016-06-01  6:54     ` Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 13/17] vmxnet3: Use pci_dma_* API instead of cpu_physical_memory_* Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 14/17] e1000_regs: Add definitions for Intel 82574-specific bits Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 15/17] e1000: Move out code that will be reused in e1000e Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 16/17] net: Introduce e1000e device emulation Dmitry Fleytman
2016-05-31  7:20 ` [Qemu-devel] [PATCH v7 17/17] e1000e: Introduce qtest for e1000e device Dmitry Fleytman
2016-05-31 10:43 ` [Qemu-devel] [PATCH v7 00/17] Introduce Intel 82574 GbE Controller Emulation (e1000e) Michael S. Tsirkin

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=574E63B3.1090000@redhat.com \
    --to=jasowang@redhat.com \
    --cc=dmitry@daynix.com \
    --cc=leonid@daynix.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=shmulik.ladkani@ravellosystems.com \
    --cc=yan@daynix.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).