diff options
author | Christian Ehrhardt <christian.ehrhardt@canonical.com> | 2018-06-01 09:09:08 +0200 |
---|---|---|
committer | Christian Ehrhardt <christian.ehrhardt@canonical.com> | 2018-06-01 09:12:07 +0200 |
commit | 1bd9b61222f3a81ffe770fc00b70ded6e760c42b (patch) | |
tree | 0bf7d996cf0664796687c1be6d22958fcf6a8096 /lib/librte_net | |
parent | bb4e158029645f37809fcf81a3acddd6fa11f88a (diff) |
New upstream version 18.05
Change-Id: Icd4170ddc4f63aeae5d0559490e5195b5349f9c2
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Diffstat (limited to 'lib/librte_net')
-rw-r--r-- | lib/librte_net/Makefile | 1 | ||||
-rw-r--r-- | lib/librte_net/meson.build | 1 | ||||
-rw-r--r-- | lib/librte_net/rte_esp.h | 2 | ||||
-rw-r--r-- | lib/librte_net/rte_ether.h | 31 | ||||
-rw-r--r-- | lib/librte_net/rte_ip.h | 14 | ||||
-rw-r--r-- | lib/librte_net/rte_net.c | 21 | ||||
-rw-r--r-- | lib/librte_net/rte_net.h | 27 | ||||
-rw-r--r-- | lib/librte_net/rte_net_version.map | 3 |
8 files changed, 82 insertions, 18 deletions
diff --git a/lib/librte_net/Makefile b/lib/librte_net/Makefile index 95ff5490..85e403f4 100644 --- a/lib/librte_net/Makefile +++ b/lib/librte_net/Makefile @@ -5,6 +5,7 @@ include $(RTE_SDK)/mk/rte.vars.mk LIB = librte_net.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 LDLIBS += -lrte_mbuf -lrte_eal -lrte_mempool diff --git a/lib/librte_net/meson.build b/lib/librte_net/meson.build index 78c0f03e..d3ea1feb 100644 --- a/lib/librte_net/meson.build +++ b/lib/librte_net/meson.build @@ -2,6 +2,7 @@ # Copyright(c) 2017 Intel Corporation version = 1 +allow_experimental_apis = true headers = files('rte_ip.h', 'rte_tcp.h', 'rte_udp.h', diff --git a/lib/librte_net/rte_esp.h b/lib/librte_net/rte_esp.h index 0fc99ac6..f77ec2eb 100644 --- a/lib/librte_net/rte_esp.h +++ b/lib/librte_net/rte_esp.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright (c) 2016-2017, Mellanox Technologies. + * Copyright 2016 Mellanox Technologies, Ltd */ #ifndef _RTE_ESP_H_ diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index 45daa911..bee2b34f 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -210,7 +210,7 @@ static inline void eth_random_addr(uint8_t *addr) uint8_t *p = (uint8_t *)&rand; rte_memcpy(addr, p, ETHER_ADDR_LEN); - addr[0] &= ~ETHER_GROUP_ADDR; /* clear multicast bit */ + addr[0] &= (uint8_t)~ETHER_GROUP_ADDR; /* clear multicast bit */ addr[0] |= ETHER_LOCAL_ADMIN_ADDR; /* set local assignment bit */ } @@ -301,6 +301,7 @@ struct vxlan_hdr { #define ETHER_TYPE_RARP 0x8035 /**< Reverse Arp Protocol. */ #define ETHER_TYPE_VLAN 0x8100 /**< IEEE 802.1Q VLAN tagging. */ #define ETHER_TYPE_QINQ 0x88A8 /**< IEEE 802.1ad QinQ tagging. */ +#define ETHER_TYPE_ETAG 0x893F /**< IEEE 802.1BR E-Tag. */ #define ETHER_TYPE_1588 0x88F7 /**< IEEE 802.1AS 1588 Precise Time Protocol. */ #define ETHER_TYPE_SLOW 0x8809 /**< Slow protocols (LACP and Marker). */ #define ETHER_TYPE_TEB 0x6558 /**< Transparent Ethernet Bridging. */ @@ -310,6 +311,31 @@ struct vxlan_hdr { /**< VXLAN tunnel header length. */ /** + * VXLAN-GPE protocol header (draft-ietf-nvo3-vxlan-gpe-05). + * Contains the 8-bit flag, 8-bit next-protocol, 24-bit VXLAN Network + * Identifier and Reserved fields (16 bits and 8 bits). + */ +struct vxlan_gpe_hdr { + uint8_t vx_flags; /**< flag (8). */ + uint8_t reserved[2]; /**< Reserved (16). */ + uint8_t proto; /**< next-protocol (8). */ + uint32_t vx_vni; /**< VNI (24) + Reserved (8). */ +} __attribute__((__packed__)); + +/* VXLAN-GPE next protocol types */ +#define VXLAN_GPE_TYPE_IPV4 1 /**< IPv4 Protocol. */ +#define VXLAN_GPE_TYPE_IPV6 2 /**< IPv6 Protocol. */ +#define VXLAN_GPE_TYPE_ETH 3 /**< Ethernet Protocol. */ +#define VXLAN_GPE_TYPE_NSH 4 /**< NSH Protocol. */ +#define VXLAN_GPE_TYPE_MPLS 5 /**< MPLS Protocol. */ +#define VXLAN_GPE_TYPE_GBP 6 /**< GBP Protocol. */ +#define VXLAN_GPE_TYPE_VBNG 7 /**< vBNG Protocol. */ + +#define ETHER_VXLAN_GPE_HLEN (sizeof(struct udp_hdr) + \ + sizeof(struct vxlan_gpe_hdr)) +/**< VXLAN-GPE tunnel header length. */ + +/** * Extract VLAN tag information into mbuf * * Software version of VLAN stripping @@ -324,11 +350,12 @@ static inline int rte_vlan_strip(struct rte_mbuf *m) { struct ether_hdr *eh = rte_pktmbuf_mtod(m, struct ether_hdr *); + struct vlan_hdr *vh; if (eh->ether_type != rte_cpu_to_be_16(ETHER_TYPE_VLAN)) return -1; - struct vlan_hdr *vh = (struct vlan_hdr *)(eh + 1); + vh = (struct vlan_hdr *)(eh + 1); m->ol_flags |= PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED; m->vlan_tci = rte_be_to_cpu_16(vh->vlan_tci); diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h index f32684c6..72dc2456 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -222,7 +222,7 @@ rte_raw_cksum_mbuf(const struct rte_mbuf *m, uint32_t off, uint32_t len, for (;;) { tmp = __rte_raw_cksum(buf, seglen, 0); if (done & 1) - tmp = rte_bswap16(tmp); + tmp = rte_bswap16((uint16_t)tmp); sum += tmp; done += seglen; if (done == len) @@ -253,7 +253,7 @@ rte_ipv4_cksum(const struct ipv4_hdr *ipv4_hdr) { uint16_t cksum; cksum = rte_raw_cksum(ipv4_hdr, sizeof(struct ipv4_hdr)); - return (cksum == 0xffff) ? cksum : ~cksum; + return (cksum == 0xffff) ? cksum : (uint16_t)~cksum; } /** @@ -318,8 +318,8 @@ rte_ipv4_udptcp_cksum(const struct ipv4_hdr *ipv4_hdr, const void *l4_hdr) uint32_t cksum; uint32_t l4_len; - l4_len = rte_be_to_cpu_16(ipv4_hdr->total_length) - - sizeof(struct ipv4_hdr); + l4_len = (uint32_t)(rte_be_to_cpu_16(ipv4_hdr->total_length) - + sizeof(struct ipv4_hdr)); cksum = rte_raw_cksum(l4_hdr, l4_len); cksum += rte_ipv4_phdr_cksum(ipv4_hdr, 0); @@ -329,7 +329,7 @@ rte_ipv4_udptcp_cksum(const struct ipv4_hdr *ipv4_hdr, const void *l4_hdr) if (cksum == 0) cksum = 0xffff; - return cksum; + return (uint16_t)cksum; } /** @@ -375,7 +375,7 @@ rte_ipv6_phdr_cksum(const struct ipv6_hdr *ipv6_hdr, uint64_t ol_flags) uint32_t proto; /* L4 protocol - top 3 bytes must be zero */ } psd_hdr; - psd_hdr.proto = (ipv6_hdr->proto << 24); + psd_hdr.proto = (uint32_t)(ipv6_hdr->proto << 24); if (ol_flags & PKT_TX_TCP_SEG) { psd_hdr.len = 0; } else { @@ -418,7 +418,7 @@ rte_ipv6_udptcp_cksum(const struct ipv6_hdr *ipv6_hdr, const void *l4_hdr) if (cksum == 0) cksum = 0xffff; - return cksum; + return (uint16_t)cksum; } #ifdef __cplusplus diff --git a/lib/librte_net/rte_net.c b/lib/librte_net/rte_net.c index 56a13e3c..9eb7c743 100644 --- a/lib/librte_net/rte_net.c +++ b/lib/librte_net/rte_net.c @@ -178,8 +178,8 @@ ip4_hlen(const struct ipv4_hdr *hdr) } /* parse ipv6 extended headers, update offset and return next proto */ -static uint16_t -skip_ip6_ext(uint16_t proto, const struct rte_mbuf *m, uint32_t *off, +int __rte_experimental +rte_net_skip_ip6_ext(uint16_t proto, const struct rte_mbuf *m, uint32_t *off, int *frag) { struct ext_hdr { @@ -201,7 +201,7 @@ skip_ip6_ext(uint16_t proto, const struct rte_mbuf *m, uint32_t *off, xh = rte_pktmbuf_read(m, *off, sizeof(*xh), &xh_copy); if (xh == NULL) - return 0; + return -1; *off += (xh->len + 1) * 8; proto = xh->next_hdr; break; @@ -209,7 +209,7 @@ skip_ip6_ext(uint16_t proto, const struct rte_mbuf *m, uint32_t *off, xh = rte_pktmbuf_read(m, *off, sizeof(*xh), &xh_copy); if (xh == NULL) - return 0; + return -1; *off += 8; proto = xh->next_hdr; *frag = 1; @@ -220,7 +220,7 @@ skip_ip6_ext(uint16_t proto, const struct rte_mbuf *m, uint32_t *off, return proto; } } - return 0; + return -1; } /* parse mbuf data to get packet type */ @@ -233,6 +233,7 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, uint32_t pkt_type = RTE_PTYPE_L2_ETHER; uint32_t off = 0; uint16_t proto; + int ret; if (hdr_lens == NULL) hdr_lens = &local_hdr_lens; @@ -316,7 +317,10 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, off += hdr_lens->l3_len; pkt_type |= ptype_l3_ip6(proto); if ((pkt_type & RTE_PTYPE_L3_MASK) == RTE_PTYPE_L3_IPV6_EXT) { - proto = skip_ip6_ext(proto, m, &off, &frag); + ret = rte_net_skip_ip6_ext(proto, m, &off, &frag); + if (ret < 0) + return pkt_type; + proto = ret; hdr_lens->l3_len = off - hdr_lens->l2_len; } if (proto == 0) @@ -449,7 +453,10 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, uint32_t prev_off; prev_off = off; - proto = skip_ip6_ext(proto, m, &off, &frag); + ret = rte_net_skip_ip6_ext(proto, m, &off, &frag); + if (ret < 0) + return pkt_type; + proto = ret; hdr_lens->inner_l3_len += off - prev_off; } if (proto == 0) diff --git a/lib/librte_net/rte_net.h b/lib/librte_net/rte_net.h index 0e97901f..b6ab6e1d 100644 --- a/lib/librte_net/rte_net.h +++ b/lib/librte_net/rte_net.h @@ -29,6 +29,33 @@ struct rte_net_hdr_lens { }; /** + * Skip IPv6 header extensions. + * + * This function skips all IPv6 extensions, returning size of + * complete header including options and final protocol value. + * + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * @param proto + * Protocol field of IPv6 header. + * @param m + * The packet mbuf to be parsed. + * @param off + * On input, must contain the offset to the first byte following + * IPv6 header, on output, contains offset to the first byte + * of next layer (after any IPv6 extension header) + * @param frag + * Contains 1 in output if packet is an IPv6 fragment. + * @return + * Protocol that follows IPv6 header. + * -1 if an error occurs during mbuf parsing. + */ +int __rte_experimental +rte_net_skip_ip6_ext(uint16_t proto, const struct rte_mbuf *m, uint32_t *off, + int *frag); + +/** * Parse an Ethernet packet to get its packet type. * * This function parses the network headers in mbuf data and return its diff --git a/lib/librte_net/rte_net_version.map b/lib/librte_net/rte_net_version.map index 213e6fd3..26c06e7c 100644 --- a/lib/librte_net/rte_net_version.map +++ b/lib/librte_net/rte_net_version.map @@ -17,4 +17,5 @@ EXPERIMENTAL { global: rte_net_make_rarp_packet; -} DPDK_17.05; + rte_net_skip_ip6_ext; +}; |