diff options
-rw-r--r-- | vnet/vnet/devices/af_packet/node.c | 8 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/format.c | 36 | ||||
-rw-r--r-- | vnet/vnet/ethernet/ethernet.h | 1 | ||||
-rw-r--r-- | vnet/vnet/ethernet/format.c | 34 |
4 files changed, 63 insertions, 16 deletions
diff --git a/vnet/vnet/devices/af_packet/node.c b/vnet/vnet/devices/af_packet/node.c index 6e2ec46e7ef..c5daf64c72e 100644 --- a/vnet/vnet/devices/af_packet/node.c +++ b/vnet/vnet/devices/af_packet/node.c @@ -65,7 +65,7 @@ static u8 * format_af_packet_input_trace (u8 * s, va_list * args) t->hw_if_index, t->next_index); s = format (s, "\n%Utpacket2_hdr:\n%Ustatus 0x%x len %u snaplen %u mac %u net %u" - "\n%Usec 0x%x nsec 0x%x vlan_tci %u" + "\n%Usec 0x%x nsec 0x%x vlan %U" #ifdef TP_STATUS_VLAN_TPID_VALID " vlan_tpid %u" #endif @@ -80,11 +80,11 @@ static u8 * format_af_packet_input_trace (u8 * s, va_list * args) format_white_space, indent + 4, t->tph.tp_sec, t->tph.tp_nsec, - t->tph.tp_vlan_tci, + format_ethernet_vlan_tci, t->tph.tp_vlan_tci #ifdef TP_STATUS_VLAN_TPID_VALID - t->tph.tp_vlan_tpid, + , t->tph.tp_vlan_tpid #endif - t->tph.tp_net); + ); return s; } diff --git a/vnet/vnet/devices/dpdk/format.c b/vnet/vnet/devices/dpdk/format.c index c3ccc90a479..a8b0363317d 100644 --- a/vnet/vnet/devices/dpdk/format.c +++ b/vnet/vnet/devices/dpdk/format.c @@ -604,11 +604,11 @@ u8 * format_dpdk_rx_dma_trace (u8 * s, va_list * va) #ifdef RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS s = format (s, "\n%U%U", format_white_space, indent, - format_dpdk_rx_rte_mbuf, &t->mb); + format_dpdk_rx_rte_mbuf, &t->mb, &t->data); #else s = format (s, "\n%U%U", format_white_space, indent, - format_dpdk_rte_mbuf, &t->mb); + format_dpdk_rte_mbuf, &t->mb, &t->data); #endif /* RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS */ if (vm->trace_main.verbose) { @@ -676,9 +676,28 @@ static inline u8 * format_dpdk_pkt_offload_flags (u8 * s, va_list * va) return s; } +u8 * format_dpdk_rte_mbuf_vlan (u8 * s, va_list * va) +{ + ethernet_vlan_header_tv_t * vlan_hdr = va_arg (*va, ethernet_vlan_header_tv_t *); + + if (clib_net_to_host_u16(vlan_hdr->type) == ETHERNET_TYPE_DOT1AD) { + s = format (s, "%U vlan 802.1q ", + format_ethernet_vlan_tci, + clib_net_to_host_u16(vlan_hdr->priority_cfi_and_id)); + vlan_hdr++; + } + + s = format (s, "%U", + format_ethernet_vlan_tci, + clib_net_to_host_u16(vlan_hdr->priority_cfi_and_id)); + + return s; +} + u8 * format_dpdk_rte_mbuf (u8 * s, va_list * va) { struct rte_mbuf * mb = va_arg (*va, struct rte_mbuf *); + ethernet_header_t *eth_hdr = va_arg (*va, ethernet_header_t *); uword indent = format_get_indent (s) + 2; s = format (s, "PKT MBUF: port %d, nb_segs %d, pkt_len %d" @@ -694,9 +713,15 @@ u8 * format_dpdk_rte_mbuf (u8 * s, va_list * va) s = format (s, "\n%U%U", format_white_space, indent, format_dpdk_pkt_offload_flags, &mb->ol_flags); + if (mb->ol_flags & PKT_RX_VLAN_PKT) { + ethernet_vlan_header_tv_t * vlan_hdr = ((ethernet_vlan_header_tv_t *)&(eth_hdr->type)); + s = format (s, " %U", format_dpdk_rte_mbuf_vlan, vlan_hdr); + } + if (mb->packet_type) s = format (s, "\n%U%U", format_white_space, indent, format_dpdk_pkt_types, &mb->packet_type); + return s; } @@ -729,6 +754,7 @@ static inline u8 * format_dpdk_pkt_rx_offload_flags (u8 * s, va_list * va) u8 * format_dpdk_rx_rte_mbuf (u8 * s, va_list * va) { struct rte_mbuf * mb = va_arg (*va, struct rte_mbuf *); + ethernet_header_t *eth_hdr = va_arg (*args, ethernet_header_t *); uword indent = format_get_indent (s) + 2; /* @@ -748,9 +774,15 @@ u8 * format_dpdk_rx_rte_mbuf (u8 * s, va_list * va) s = format (s, "\n%U%U", format_white_space, indent, format_dpdk_pkt_rx_offload_flags, &mb->ol_flags); + if (mb->ol_flags & PKT_RX_VLAN_PKT) { + ethernet_vlan_header_tv_t * vlan_hdr = ((ethernet_vlan_header_tv_t *)&(eth_hdr->type)); + s = format (s, " %U", format_dpdk_rte_mbuf_vlan, vlan_hdr); + } + if (mb->packet_type) s = format (s, "\n%U%U", format_white_space, indent, format_dpdk_pkt_types, &mb->packet_type); + return s; } #endif /* RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS */ diff --git a/vnet/vnet/ethernet/ethernet.h b/vnet/vnet/ethernet/ethernet.h index 97c66e7593a..4735e20b851 100644 --- a/vnet/vnet/ethernet/ethernet.h +++ b/vnet/vnet/ethernet/ethernet.h @@ -264,6 +264,7 @@ ethernet_register_l3_redirect (vlib_main_t * vm, /* Formats ethernet address X:X:X:X:X:X */ u8 * format_ethernet_address (u8 * s, va_list * args); u8 * format_ethernet_type (u8 * s, va_list * args); +u8 * format_ethernet_vlan_tci (u8 * s, va_list * va); u8 * format_ethernet_header (u8 * s, va_list * args); u8 * format_ethernet_header_with_length (u8 * s, va_list * args); diff --git a/vnet/vnet/ethernet/format.c b/vnet/vnet/ethernet/format.c index f6fc6e21456..0e581ff9fa4 100644 --- a/vnet/vnet/ethernet/format.c +++ b/vnet/vnet/ethernet/format.c @@ -67,6 +67,23 @@ u8 * format_ethernet_type (u8 * s, va_list * args) return s; } +u8 * format_ethernet_vlan_tci (u8 * s, va_list * va) +{ + u32 vlan_tci = va_arg (*va, u32); + + u32 vid = (vlan_tci & 0xfff); + u32 cfi = (vlan_tci >> 12) & 1; + u32 pri = (vlan_tci >> 13); + + s = format (s, "id %d", vid); + if (pri != 0) + s = format (s, " priority %d", pri); + if (cfi != 0) + s = format (s, " cfi"); + + return s; +} + u8 * format_ethernet_header_with_length (u8 * s, va_list * args) { ethernet_max_header_t * m = va_arg (*args, ethernet_max_header_t *); @@ -75,12 +92,14 @@ u8 * format_ethernet_header_with_length (u8 * s, va_list * args) ethernet_header_t * e = &m->ethernet; ethernet_vlan_header_t * v; ethernet_type_t type = clib_net_to_host_u16 (e->type); + ethernet_type_t vlan_type[ARRAY_LEN(m->vlan)]; u32 n_vlan = 0, i, header_bytes; uword indent; - while (type == ETHERNET_TYPE_VLAN + while ((type == ETHERNET_TYPE_VLAN || type == ETHERNET_TYPE_DOT1AD) && n_vlan < ARRAY_LEN (m->vlan)) { + vlan_type[n_vlan] = type; v = m->vlan + n_vlan; type = clib_net_to_host_u16 (v->type); n_vlan++; @@ -100,15 +119,10 @@ u8 * format_ethernet_header_with_length (u8 * s, va_list * args) for (i = 0; i < n_vlan; i++) { u32 v = clib_net_to_host_u16 (m->vlan[i].priority_cfi_and_id); - u32 vid = (v & 0xfff); - u32 cfi = (v >> 12) & 1; - u32 pri = (v >> 13); - - s = format (s, " vlan %d", vid); - if (pri != 0) - s = format (s, " priority %d", pri); - if (cfi != 0) - s = format (s, " cfi"); + if (*vlan_type == ETHERNET_TYPE_VLAN) + s = format (s, " vlan 802.1q %U", format_ethernet_vlan_tci, v); + else + s = format (s, " vlan 802.1ad %U", format_ethernet_vlan_tci, v); } if (max_header_bytes != 0 && header_bytes < max_header_bytes) |