This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via cbc020f35245f21c2ea9cb3d3be55114322d3201 (commit) via 54c7061b88f8b1ecac300f31c8ea4f5e4f6752ec (commit) via 2a913b6531651d030b3e34731505846ff4e3aa6c (commit) from 6b5254d30a5cc51b213a570e106ff5d866ee9db2 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit cbc020f35245f21c2ea9cb3d3be55114322d3201 Author: Petri Savolainen petri.savolainen@nokia.com Date: Fri Dec 13 13:28:28 2019 +0200
example: packet_dump: add VLAN support
Print TPID and TCI fields of first two VLAN headers.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Reviewed-by: Matias Elo matias.elo@nokia.com
diff --git a/example/packet/odp_packet_dump.c b/example/packet/odp_packet_dump.c index 69987c596..e1ef7e14d 100644 --- a/example/packet/odp_packet_dump.c +++ b/example/packet/odp_packet_dump.c @@ -502,18 +502,59 @@ static int print_packet(test_global_t *global, odp_packet_t pkt,
/* L2 */ if (odp_packet_has_eth(pkt)) { + uint8_t *eth = data + l2_offset; + printf(" Ethernet offset: %u bytes\n", l2_offset); - offset = l2_offset; - if (offset + 6 <= seg_len) { + if (l2_offset + 6 <= seg_len) { printf(" dst address: "); - print_mac_addr(data + offset); + print_mac_addr(eth); }
- offset = l2_offset + 6; - if (offset + 6 <= seg_len) { + if (l2_offset + 12 <= seg_len) { printf(" src address: "); - print_mac_addr(data + offset); + print_mac_addr(eth + 6); } + + /* VLAN */ + if (odp_packet_has_vlan(pkt)) { + int qinq = odp_packet_has_vlan_qinq(pkt); + uint16_t *tpid = (uint16_t *)(uintptr_t)(eth + 12); + uint16_t *tci = tpid + 1; + + if (qinq) + printf(" VLAN (outer):\n"); + else + printf(" VLAN:\n"); + + if (l2_offset + 14 <= seg_len) { + printf(" TPID: 0x%04x\n", + odp_be_to_cpu_16(*tpid)); + } + + if (l2_offset + 16 <= seg_len) { + printf(" TCI: 0x%04x (VID: %u)\n", + odp_be_to_cpu_16(*tci), + odp_be_to_cpu_16(*tci) & 0x0fff); + } + + if (qinq) { + printf(" VLAN (inner):\n"); + tpid += 2; + tci += 2; + + if (l2_offset + 18 <= seg_len) { + printf(" TPID: 0x%04x\n", + odp_be_to_cpu_16(*tpid)); + } + + if (l2_offset + 20 <= seg_len) { + printf(" TCI: 0x%04x (VID: %u)\n", + odp_be_to_cpu_16(*tci), + odp_be_to_cpu_16(*tci) & 0x0fff); + } + } + } + } else if (odp_packet_has_l2(pkt)) { printf(" L2 (%i) offset: %u bytes\n", odp_packet_l2_type(pkt), l2_offset);
commit 54c7061b88f8b1ecac300f31c8ea4f5e4f6752ec Author: Petri Savolainen petri.savolainen@nokia.com Date: Fri Dec 13 12:43:23 2019 +0200
linux-gen: socket_mmap: recreate VLAN header
Socket mmap interface in Linux may strip a VLAN header and copy its TPID and TCI fields into tpacket2_hdr structure. Insert VLAN header back into the packet when this happens.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Reviewed-by: Matias Elo matias.elo@nokia.com Reported-by: Jari Mustajärvi jari.mustajarvi@nokia-bell-labs.com
diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index 2cceb5648..97677bfce 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -41,6 +41,9 @@ #include <protocols/eth.h> #include <protocols/ip.h>
+/* VLAN flags in tpacket2_hdr status */ +#define VLAN_VALID (TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID) + /* Reserve 4MB memory for frames in a RX/TX ring */ #define FRAME_MEM_SIZE (4 * 1024 * 1024) #define BLOCK_SIZE (4 * 1024) @@ -163,12 +166,14 @@ static inline unsigned pkt_mmap_v2_rx(pktio_entry_t *pktio_entry, unsigned frame_num, next_frame_num; uint8_t *pkt_buf, *next_ptr; int pkt_len; + uint32_t alloc_len; struct ethhdr *eth_hdr; unsigned i; unsigned nb_rx; struct ring *ring; odp_pool_t pool = pkt_sock->pool; uint16_t frame_offset = pktio_entry->s.pktin_frame_offset; + uint16_t vlan_len = 0;
if (pktio_entry->s.config.pktin.bit.ts_all || pktio_entry->s.config.pktin.bit.ts_ptp) @@ -208,7 +213,12 @@ static inline unsigned pkt_mmap_v2_rx(pktio_entry_t *pktio_entry, continue; }
- ret = packet_alloc_multi(pool, pkt_len + frame_offset, &pkt, 1); + /* Check if packet had a VLAN header */ + if ((tp_hdr->tp_status & VLAN_VALID) == VLAN_VALID) + vlan_len = 4; + + alloc_len = pkt_len + frame_offset + vlan_len; + ret = packet_alloc_multi(pool, alloc_len, &pkt, 1);
if (odp_unlikely(ret != 1)) { /* Stop receiving packets when pool is empty. Leave @@ -241,6 +251,9 @@ static inline unsigned pkt_mmap_v2_rx(pktio_entry_t *pktio_entry, if (frame_offset) pull_head(hdr, frame_offset);
+ if (vlan_len) + pull_head(hdr, vlan_len); + ret = odp_packet_copy_from_mem(pkt, 0, pkt_len, pkt_buf); if (ret != 0) { odp_packet_free(pkt); @@ -248,6 +261,24 @@ static inline unsigned pkt_mmap_v2_rx(pktio_entry_t *pktio_entry, frame_num = next_frame_num; continue; } + + if (vlan_len) { + /* Recreate VLAN header. Move MAC addresses and + * insert a VLAN header in between source MAC address + * and Ethernet type. */ + uint8_t *mac; + uint16_t *type, *tci; + + push_head(hdr, vlan_len); + mac = packet_data(hdr); + memmove(mac, mac + vlan_len, 2 * _ODP_ETHADDR_LEN); + type = (uint16_t *)(uintptr_t) + (mac + 2 * _ODP_ETHADDR_LEN); + *type = odp_cpu_to_be_16(tp_hdr->tp_vlan_tpid); + tci = type + 1; + *tci = odp_cpu_to_be_16(tp_hdr->tp_vlan_tci); + } + hdr->input = pktio_entry->s.handle;
if (pktio_cls_enabled(pktio_entry))
commit 2a913b6531651d030b3e34731505846ff4e3aa6c Author: Petri Savolainen petri.savolainen@nokia.com Date: Fri Dec 13 12:16:39 2019 +0200
linux-gen: packet: move push_head and packet_data header
Moved inline functions into header, so that those can be used from socket mmap file.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Reviewed-by: Matias Elo matias.elo@nokia.com
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 3ba76449d..ef9b3ba89 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -235,6 +235,19 @@ static inline void copy_packet_cls_metadata(odp_packet_hdr_t *src_hdr, dst_hdr->timestamp = src_hdr->timestamp; }
+static inline void *packet_data(odp_packet_hdr_t *pkt_hdr) +{ + return pkt_hdr->seg_data; +} + +static inline void push_head(odp_packet_hdr_t *pkt_hdr, uint32_t len) +{ + pkt_hdr->headroom -= len; + pkt_hdr->frame_len += len; + pkt_hdr->seg_data -= len; + pkt_hdr->seg_len += len; +} + static inline void pull_head(odp_packet_hdr_t *pkt_hdr, uint32_t len) { pkt_hdr->headroom += len; diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index d17674f43..9e3f3a2b8 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -123,11 +123,6 @@ static inline uint32_t packet_first_seg_len(odp_packet_hdr_t *pkt_hdr) return pkt_hdr->seg_len; }
-static inline void *packet_data(odp_packet_hdr_t *pkt_hdr) -{ - return pkt_hdr->seg_data; -} - static inline void *packet_tail(odp_packet_hdr_t *pkt_hdr) { odp_packet_hdr_t *last_seg = packet_last_seg(pkt_hdr); @@ -152,14 +147,6 @@ static inline uint32_t seg_tailroom(odp_packet_hdr_t *pkt_seg) return hdr->buf_end - tail; }
-static inline void push_head(odp_packet_hdr_t *pkt_hdr, uint32_t len) -{ - pkt_hdr->headroom -= len; - pkt_hdr->frame_len += len; - pkt_hdr->seg_data -= len; - pkt_hdr->seg_len += len; -} - static inline void push_tail(odp_packet_hdr_t *pkt_hdr, uint32_t len) { odp_packet_hdr_t *last_seg = packet_last_seg(pkt_hdr);
-----------------------------------------------------------------------
Summary of changes: example/packet/odp_packet_dump.c | 53 +++++++++++++++++++--- .../linux-generic/include/odp_packet_internal.h | 13 ++++++ platform/linux-generic/odp_packet.c | 13 ------ platform/linux-generic/pktio/socket_mmap.c | 33 +++++++++++++- 4 files changed, 92 insertions(+), 20 deletions(-)
hooks/post-receive