Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | #include <vnet/vnet.h> |
| 16 | #include <vppinfra/vec.h> |
| 17 | #include <vppinfra/format.h> |
| 18 | #include <vlib/unix/cj.h> |
| 19 | #include <assert.h> |
| 20 | |
| 21 | #include <vnet/ethernet/ethernet.h> |
| 22 | #include <vnet/devices/dpdk/dpdk.h> |
| 23 | |
| 24 | #include "dpdk_priv.h" |
| 25 | #include <vppinfra/error.h> |
| 26 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 27 | #define foreach_dpdk_counter \ |
| 28 | _ (tx_frames_ok, opackets) \ |
| 29 | _ (tx_bytes_ok, obytes) \ |
| 30 | _ (tx_errors, oerrors) \ |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 31 | _ (rx_frames_ok, ipackets) \ |
| 32 | _ (rx_bytes_ok, ibytes) \ |
| 33 | _ (rx_errors, ierrors) \ |
| 34 | _ (rx_missed, imissed) \ |
Damjan Marion | 1f0da17 | 2016-07-13 22:44:18 +0200 | [diff] [blame] | 35 | _ (rx_no_bufs, rx_nombuf) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 36 | |
| 37 | #define foreach_dpdk_q_counter \ |
| 38 | _ (rx_frames_ok, q_ipackets) \ |
| 39 | _ (tx_frames_ok, q_opackets) \ |
| 40 | _ (rx_bytes_ok, q_ibytes) \ |
| 41 | _ (tx_bytes_ok, q_obytes) \ |
| 42 | _ (rx_errors, q_errors) |
| 43 | |
| 44 | #define foreach_dpdk_rss_hf \ |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 45 | _(ETH_RSS_FRAG_IPV4, "ipv4-frag") \ |
| 46 | _(ETH_RSS_NONFRAG_IPV4_TCP, "ipv4-tcp") \ |
| 47 | _(ETH_RSS_NONFRAG_IPV4_UDP, "ipv4-udp") \ |
| 48 | _(ETH_RSS_NONFRAG_IPV4_SCTP, "ipv4-sctp") \ |
| 49 | _(ETH_RSS_NONFRAG_IPV4_OTHER, "ipv4-other") \ |
Srivatsa Sangli | 820e363 | 2016-06-14 13:10:55 -0700 | [diff] [blame] | 50 | _(ETH_RSS_IPV4, "ipv4") \ |
| 51 | _(ETH_RSS_IPV6_TCP_EX, "ipv6-tcp-ex") \ |
| 52 | _(ETH_RSS_IPV6_UDP_EX, "ipv6-udp-ex") \ |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 53 | _(ETH_RSS_FRAG_IPV6, "ipv6-frag") \ |
| 54 | _(ETH_RSS_NONFRAG_IPV6_TCP, "ipv6-tcp") \ |
| 55 | _(ETH_RSS_NONFRAG_IPV6_UDP, "ipv6-udp") \ |
| 56 | _(ETH_RSS_NONFRAG_IPV6_SCTP, "ipv6-sctp") \ |
| 57 | _(ETH_RSS_NONFRAG_IPV6_OTHER, "ipv6-other") \ |
| 58 | _(ETH_RSS_L2_PAYLOAD, "l2-payload") \ |
| 59 | _(ETH_RSS_IPV6_EX, "ipv6-ex") \ |
Srivatsa Sangli | 820e363 | 2016-06-14 13:10:55 -0700 | [diff] [blame] | 60 | _(ETH_RSS_IPV6, "ipv6") |
| 61 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 62 | |
| 63 | #define foreach_dpdk_rx_offload_caps \ |
| 64 | _(DEV_RX_OFFLOAD_VLAN_STRIP, "vlan-strip") \ |
| 65 | _(DEV_RX_OFFLOAD_IPV4_CKSUM, "ipv4-cksum") \ |
| 66 | _(DEV_RX_OFFLOAD_UDP_CKSUM , "udp-cksum") \ |
| 67 | _(DEV_RX_OFFLOAD_TCP_CKSUM , "tcp-cksum") \ |
| 68 | _(DEV_RX_OFFLOAD_TCP_LRO , "rcp-lro") \ |
| 69 | _(DEV_RX_OFFLOAD_QINQ_STRIP, "qinq-strip") |
| 70 | |
| 71 | #define foreach_dpdk_tx_offload_caps \ |
| 72 | _(DEV_TX_OFFLOAD_VLAN_INSERT, "vlan-insert") \ |
| 73 | _(DEV_TX_OFFLOAD_IPV4_CKSUM, "ipv4-cksum") \ |
| 74 | _(DEV_TX_OFFLOAD_UDP_CKSUM , "udp-cksum") \ |
| 75 | _(DEV_TX_OFFLOAD_TCP_CKSUM , "tcp-cksum") \ |
| 76 | _(DEV_TX_OFFLOAD_SCTP_CKSUM , "sctp-cksum") \ |
| 77 | _(DEV_TX_OFFLOAD_TCP_TSO , "tcp-tso") \ |
| 78 | _(DEV_TX_OFFLOAD_UDP_TSO , "udp-tso") \ |
| 79 | _(DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM, "outer-ipv4-cksum") \ |
| 80 | _(DEV_TX_OFFLOAD_QINQ_INSERT, "qinq-insert") |
| 81 | |
John Lo | a60d4cb | 2016-12-17 03:09:58 -0500 | [diff] [blame] | 82 | #if RTE_VERSION < RTE_VERSION_NUM(16, 11, 0, 0) |
| 83 | /* New ol_flags bits added in DPDK-16.11 */ |
| 84 | #define PKT_RX_IP_CKSUM_GOOD (1ULL << 7) |
| 85 | #define PKT_RX_L4_CKSUM_GOOD (1ULL << 8) |
| 86 | #endif |
| 87 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 88 | #define foreach_dpdk_pkt_rx_offload_flag \ |
| 89 | _ (PKT_RX_VLAN_PKT, "RX packet is a 802.1q VLAN packet") \ |
| 90 | _ (PKT_RX_RSS_HASH, "RX packet with RSS hash result") \ |
| 91 | _ (PKT_RX_FDIR, "RX packet with FDIR infos") \ |
| 92 | _ (PKT_RX_L4_CKSUM_BAD, "L4 cksum of RX pkt. is not OK") \ |
| 93 | _ (PKT_RX_IP_CKSUM_BAD, "IP cksum of RX pkt. is not OK") \ |
John Lo | a60d4cb | 2016-12-17 03:09:58 -0500 | [diff] [blame] | 94 | _ (PKT_RX_VLAN_STRIPPED, "RX packet VLAN tag stripped") \ |
| 95 | _ (PKT_RX_IP_CKSUM_GOOD, "IP cksum of RX pkt. is valid") \ |
| 96 | _ (PKT_RX_L4_CKSUM_GOOD, "L4 cksum of RX pkt. is valid") \ |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 97 | _ (PKT_RX_IEEE1588_PTP, "RX IEEE1588 L2 Ethernet PT Packet") \ |
John Lo | a60d4cb | 2016-12-17 03:09:58 -0500 | [diff] [blame] | 98 | _ (PKT_RX_IEEE1588_TMST, "RX IEEE1588 L2/L4 timestamped packet") \ |
| 99 | _ (PKT_RX_QINQ_STRIPPED, "RX packet QinQ tags stripped") |
| 100 | |
| 101 | #if RTE_VERSION < RTE_VERSION_NUM(16, 11, 0, 0) |
| 102 | /* PTYPE added in DPDK-16.11 */ |
| 103 | #define RTE_PTYPE_L2_ETHER_VLAN 0x00000006 |
| 104 | #define RTE_PTYPE_L2_ETHER_QINQ 0x00000007 |
| 105 | #endif |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 106 | |
| 107 | #define foreach_dpdk_pkt_type \ |
| 108 | _ (L2, ETHER, "Ethernet packet") \ |
| 109 | _ (L2, ETHER_TIMESYNC, "Ethernet packet for time sync") \ |
| 110 | _ (L2, ETHER_ARP, "ARP packet") \ |
| 111 | _ (L2, ETHER_LLDP, "LLDP (Link Layer Discovery Protocol) packet") \ |
John Lo | a60d4cb | 2016-12-17 03:09:58 -0500 | [diff] [blame] | 112 | _ (L2, ETHER_NSH, "NSH (Network Service Header) packet") \ |
| 113 | _ (L2, ETHER_VLAN, "VLAN packet") \ |
| 114 | _ (L2, ETHER_QINQ, "QinQ packet") \ |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 115 | _ (L3, IPV4, "IPv4 packet without extension headers") \ |
| 116 | _ (L3, IPV4_EXT, "IPv4 packet with extension headers") \ |
| 117 | _ (L3, IPV4_EXT_UNKNOWN, "IPv4 packet with or without extension headers") \ |
| 118 | _ (L3, IPV6, "IPv6 packet without extension headers") \ |
| 119 | _ (L3, IPV6_EXT, "IPv6 packet with extension headers") \ |
| 120 | _ (L3, IPV6_EXT_UNKNOWN, "IPv6 packet with or without extension headers") \ |
| 121 | _ (L4, TCP, "TCP packet") \ |
| 122 | _ (L4, UDP, "UDP packet") \ |
| 123 | _ (L4, FRAG, "Fragmented IP packet") \ |
| 124 | _ (L4, SCTP, "SCTP (Stream Control Transmission Protocol) packet") \ |
| 125 | _ (L4, ICMP, "ICMP packet") \ |
| 126 | _ (L4, NONFRAG, "Non-fragmented IP packet") \ |
| 127 | _ (TUNNEL, GRE, "GRE tunneling packet") \ |
| 128 | _ (TUNNEL, VXLAN, "VXLAN tunneling packet") \ |
| 129 | _ (TUNNEL, NVGRE, "NVGRE Tunneling packet") \ |
| 130 | _ (TUNNEL, GENEVE, "GENEVE Tunneling packet") \ |
| 131 | _ (TUNNEL, GRENAT, "Teredo, VXLAN or GRE Tunneling packet") \ |
| 132 | _ (INNER_L2, ETHER, "Inner Ethernet packet") \ |
| 133 | _ (INNER_L2, ETHER_VLAN, "Inner Ethernet packet with VLAN") \ |
| 134 | _ (INNER_L3, IPV4, "Inner IPv4 packet without extension headers") \ |
| 135 | _ (INNER_L3, IPV4_EXT, "Inner IPv4 packet with extension headers") \ |
| 136 | _ (INNER_L3, IPV4_EXT_UNKNOWN, "Inner IPv4 packet with or without extension headers") \ |
| 137 | _ (INNER_L3, IPV6, "Inner IPv6 packet without extension headers") \ |
| 138 | _ (INNER_L3, IPV6_EXT, "Inner IPv6 packet with extension headers") \ |
| 139 | _ (INNER_L3, IPV6_EXT_UNKNOWN, "Inner IPv6 packet with or without extension headers") \ |
| 140 | _ (INNER_L4, TCP, "Inner TCP packet") \ |
| 141 | _ (INNER_L4, UDP, "Inner UDP packet") \ |
| 142 | _ (INNER_L4, FRAG, "Inner fagmented IP packet") \ |
| 143 | _ (INNER_L4, SCTP, "Inner SCTP (Stream Control Transmission Protocol) packet") \ |
| 144 | _ (INNER_L4, ICMP, "Inner ICMP packet") \ |
| 145 | _ (INNER_L4, NONFRAG, "Inner non-fragmented IP packet") |
| 146 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 147 | #define foreach_dpdk_pkt_tx_offload_flag \ |
| 148 | _ (PKT_TX_VLAN_PKT, "TX packet is a 802.1q VLAN packet") \ |
| 149 | _ (PKT_TX_IP_CKSUM, "IP cksum of TX pkt. computed by NIC") \ |
| 150 | _ (PKT_TX_TCP_CKSUM, "TCP cksum of TX pkt. computed by NIC") \ |
| 151 | _ (PKT_TX_SCTP_CKSUM, "SCTP cksum of TX pkt. computed by NIC") \ |
| 152 | _ (PKT_TX_IEEE1588_TMST, "TX IEEE1588 packet to timestamp") |
| 153 | |
| 154 | #define foreach_dpdk_pkt_offload_flag \ |
| 155 | foreach_dpdk_pkt_rx_offload_flag \ |
| 156 | foreach_dpdk_pkt_tx_offload_flag |
| 157 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 158 | u8 * |
| 159 | format_dpdk_device_name (u8 * s, va_list * args) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 160 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 161 | dpdk_main_t *dm = &dpdk_main; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 162 | char *devname_format; |
| 163 | char *device_name; |
| 164 | u32 i = va_arg (*args, u32); |
| 165 | struct rte_eth_dev_info dev_info; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 166 | u8 *ret; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 167 | |
Damjan Marion | 64ae669 | 2016-05-25 18:40:13 +0200 | [diff] [blame] | 168 | if (dm->conf->interface_name_format_decimal) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 169 | devname_format = "%s%d/%d/%d"; |
| 170 | else |
| 171 | devname_format = "%s%x/%x/%x"; |
| 172 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 173 | switch (dm->devices[i].port_type) |
| 174 | { |
| 175 | case VNET_DPDK_PORT_TYPE_ETH_1G: |
| 176 | device_name = "GigabitEthernet"; |
| 177 | break; |
| 178 | |
| 179 | case VNET_DPDK_PORT_TYPE_ETH_10G: |
| 180 | device_name = "TenGigabitEthernet"; |
| 181 | break; |
| 182 | |
| 183 | case VNET_DPDK_PORT_TYPE_ETH_40G: |
| 184 | device_name = "FortyGigabitEthernet"; |
| 185 | break; |
| 186 | |
Damjan Marion | 696f1ad | 2016-12-23 22:42:41 +0100 | [diff] [blame] | 187 | case VNET_DPDK_PORT_TYPE_ETH_100G: |
| 188 | device_name = "HundredGigabitEthernet"; |
| 189 | break; |
| 190 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 191 | case VNET_DPDK_PORT_TYPE_ETH_BOND: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 192 | return format (s, "BondEthernet%d", dm->devices[i].device_index); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 193 | |
| 194 | case VNET_DPDK_PORT_TYPE_ETH_SWITCH: |
| 195 | device_name = "EthernetSwitch"; |
| 196 | break; |
| 197 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 198 | case VNET_DPDK_PORT_TYPE_AF_PACKET: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 199 | rte_eth_dev_info_get (i, &dev_info); |
| 200 | return format (s, "af_packet%d", dm->devices[i].af_packet_port_id); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 201 | |
| 202 | default: |
| 203 | case VNET_DPDK_PORT_TYPE_UNKNOWN: |
| 204 | device_name = "UnknownEthernet"; |
| 205 | break; |
| 206 | } |
| 207 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 208 | rte_eth_dev_info_get (i, &dev_info); |
Alexander Popovsky | 9dfd338 | 2016-12-04 15:26:58 -0800 | [diff] [blame] | 209 | |
| 210 | if (dev_info.pci_dev) |
| 211 | ret = format (s, devname_format, device_name, dev_info.pci_dev->addr.bus, |
| 212 | dev_info.pci_dev->addr.devid, |
| 213 | dev_info.pci_dev->addr.function); |
| 214 | else |
| 215 | ret = format (s, "%s%d", device_name, dm->devices[i].device_index); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 216 | |
Damjan Marion | 32f7bc1 | 2016-07-21 03:42:37 -0700 | [diff] [blame] | 217 | if (dm->devices[i].interface_name_suffix) |
| 218 | return format (ret, "/%s", dm->devices[i].interface_name_suffix); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 219 | return ret; |
| 220 | } |
| 221 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 222 | static u8 * |
| 223 | format_dpdk_device_type (u8 * s, va_list * args) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 224 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 225 | dpdk_main_t *dm = &dpdk_main; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 226 | char *dev_type; |
| 227 | u32 i = va_arg (*args, u32); |
| 228 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 229 | switch (dm->devices[i].pmd) |
| 230 | { |
| 231 | case VNET_DPDK_PMD_E1000EM: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 232 | dev_type = "Intel 82540EM (e1000)"; |
| 233 | break; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 234 | |
| 235 | case VNET_DPDK_PMD_IGB: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 236 | dev_type = "Intel e1000"; |
| 237 | break; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 238 | |
| 239 | case VNET_DPDK_PMD_I40E: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 240 | dev_type = "Intel X710/XL710 Family"; |
| 241 | break; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 242 | |
| 243 | case VNET_DPDK_PMD_I40EVF: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 244 | dev_type = "Intel X710/XL710 Family VF"; |
| 245 | break; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 246 | |
| 247 | case VNET_DPDK_PMD_FM10K: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 248 | dev_type = "Intel FM10000 Family Ethernet Switch"; |
| 249 | break; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 250 | |
| 251 | case VNET_DPDK_PMD_IGBVF: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 252 | dev_type = "Intel e1000 VF"; |
| 253 | break; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 254 | |
| 255 | case VNET_DPDK_PMD_VIRTIO: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 256 | dev_type = "Red Hat Virtio"; |
| 257 | break; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 258 | |
| 259 | case VNET_DPDK_PMD_IXGBEVF: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 260 | dev_type = "Intel 82599 VF"; |
| 261 | break; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 262 | |
| 263 | case VNET_DPDK_PMD_IXGBE: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 264 | dev_type = "Intel 82599"; |
| 265 | break; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 266 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 267 | case VNET_DPDK_PMD_ENIC: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 268 | dev_type = "Cisco VIC"; |
| 269 | break; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 270 | |
| 271 | case VNET_DPDK_PMD_CXGBE: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 272 | dev_type = "Chelsio T4/T5"; |
| 273 | break; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 274 | |
Damjan Marion | 696f1ad | 2016-12-23 22:42:41 +0100 | [diff] [blame] | 275 | case VNET_DPDK_PMD_MLX5: |
| 276 | dev_type = "Mellanox ConnectX-4 Family"; |
| 277 | break; |
| 278 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 279 | case VNET_DPDK_PMD_VMXNET3: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 280 | dev_type = "VMware VMXNET3"; |
| 281 | break; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 282 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 283 | case VNET_DPDK_PMD_AF_PACKET: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 284 | dev_type = "af_packet"; |
| 285 | break; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 286 | |
| 287 | case VNET_DPDK_PMD_BOND: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 288 | dev_type = "Ethernet Bonding"; |
| 289 | break; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 290 | |
Sachin | a29f200 | 2016-06-17 09:24:20 +0530 | [diff] [blame] | 291 | case VNET_DPDK_PMD_DPAA2: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 292 | dev_type = "NXP DPAA2 Mac"; |
| 293 | break; |
Sachin | a29f200 | 2016-06-17 09:24:20 +0530 | [diff] [blame] | 294 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 295 | default: |
| 296 | case VNET_DPDK_PMD_UNKNOWN: |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 297 | dev_type = "### UNKNOWN ###"; |
| 298 | break; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | return format (s, dev_type); |
| 302 | } |
| 303 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 304 | static u8 * |
| 305 | format_dpdk_link_status (u8 * s, va_list * args) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 306 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 307 | dpdk_device_t *xd = va_arg (*args, dpdk_device_t *); |
| 308 | struct rte_eth_link *l = &xd->link; |
| 309 | vnet_main_t *vnm = vnet_get_main (); |
| 310 | vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, xd->vlib_hw_if_index); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 311 | |
| 312 | s = format (s, "%s ", l->link_status ? "up" : "down"); |
| 313 | if (l->link_status) |
| 314 | { |
| 315 | u32 promisc = rte_eth_promiscuous_get (xd->device_index); |
| 316 | |
| 317 | s = format (s, "%s duplex ", (l->link_duplex == ETH_LINK_FULL_DUPLEX) ? |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 318 | "full" : "half"); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 319 | s = format (s, "speed %u mtu %d %s\n", l->link_speed, |
| 320 | hi->max_packet_bytes, promisc ? " promisc" : ""); |
| 321 | } |
| 322 | else |
| 323 | s = format (s, "\n"); |
| 324 | |
| 325 | return s; |
| 326 | } |
| 327 | |
| 328 | #define _line_len 72 |
| 329 | #define _(v, str) \ |
| 330 | if (bitmap & v) { \ |
| 331 | if (format_get_indent (s) > next_split ) { \ |
| 332 | next_split += _line_len; \ |
| 333 | s = format(s,"\n%U", format_white_space, indent); \ |
| 334 | } \ |
| 335 | s = format(s, "%s ", str); \ |
| 336 | } |
| 337 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 338 | static u8 * |
| 339 | format_dpdk_rss_hf_name (u8 * s, va_list * args) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 340 | { |
| 341 | u64 bitmap = va_arg (*args, u64); |
| 342 | int next_split = _line_len; |
| 343 | int indent = format_get_indent (s); |
| 344 | |
| 345 | if (!bitmap) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 346 | return format (s, "none"); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 347 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 348 | foreach_dpdk_rss_hf return s; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 349 | } |
| 350 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 351 | static u8 * |
| 352 | format_dpdk_rx_offload_caps (u8 * s, va_list * args) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 353 | { |
| 354 | u32 bitmap = va_arg (*args, u32); |
| 355 | int next_split = _line_len; |
| 356 | int indent = format_get_indent (s); |
| 357 | |
| 358 | if (!bitmap) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 359 | return format (s, "none"); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 360 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 361 | foreach_dpdk_rx_offload_caps return s; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 362 | } |
| 363 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 364 | static u8 * |
| 365 | format_dpdk_tx_offload_caps (u8 * s, va_list * args) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 366 | { |
| 367 | u32 bitmap = va_arg (*args, u32); |
| 368 | int next_split = _line_len; |
| 369 | int indent = format_get_indent (s); |
| 370 | if (!bitmap) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 371 | return format (s, "none"); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 372 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 373 | foreach_dpdk_tx_offload_caps return s; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | #undef _line_len |
| 377 | #undef _ |
| 378 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 379 | u8 * |
| 380 | format_dpdk_device (u8 * s, va_list * args) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 381 | { |
| 382 | u32 dev_instance = va_arg (*args, u32); |
| 383 | int verbose = va_arg (*args, int); |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 384 | dpdk_main_t *dm = &dpdk_main; |
| 385 | dpdk_device_t *xd = vec_elt_at_index (dm->devices, dev_instance); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 386 | uword indent = format_get_indent (s); |
| 387 | f64 now = vlib_time_now (dm->vlib_main); |
Damjan Marion | c68b4cb | 2016-05-25 20:11:33 +0200 | [diff] [blame] | 388 | struct rte_eth_dev_info di; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 389 | |
| 390 | dpdk_update_counters (xd, now); |
| 391 | dpdk_update_link_state (xd, now); |
| 392 | |
| 393 | s = format (s, "%U\n%Ucarrier %U", |
| 394 | format_dpdk_device_type, xd->device_index, |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 395 | format_white_space, indent + 2, format_dpdk_link_status, xd); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 396 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 397 | rte_eth_dev_info_get (xd->device_index, &di); |
Damjan Marion | c68b4cb | 2016-05-25 20:11:33 +0200 | [diff] [blame] | 398 | |
Damjan Marion | 5643170 | 2016-09-19 13:18:09 +0200 | [diff] [blame] | 399 | if (verbose > 1 && xd->flags & DPDK_DEVICE_FLAG_PMD) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 400 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 401 | struct rte_pci_device *pci; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 402 | struct rte_eth_rss_conf rss_conf; |
| 403 | int vlan_off; |
Dave Barach | dd522cb | 2016-08-10 16:56:16 -0400 | [diff] [blame] | 404 | int retval; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 405 | |
| 406 | rss_conf.rss_key = 0; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 407 | retval = rte_eth_dev_rss_hash_conf_get (xd->device_index, &rss_conf); |
Dave Barach | dd522cb | 2016-08-10 16:56:16 -0400 | [diff] [blame] | 408 | if (retval < 0) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 409 | clib_warning ("rte_eth_dev_rss_hash_conf_get returned %d", retval); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 410 | pci = di.pci_dev; |
| 411 | |
| 412 | if (pci) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 413 | s = |
| 414 | format (s, |
| 415 | "%Upci id: device %04x:%04x subsystem %04x:%04x\n" |
| 416 | "%Upci address: %04x:%02x:%02x.%02x\n", |
| 417 | format_white_space, indent + 2, pci->id.vendor_id, |
| 418 | pci->id.device_id, pci->id.subsystem_vendor_id, |
| 419 | pci->id.subsystem_device_id, format_white_space, indent + 2, |
| 420 | pci->addr.domain, pci->addr.bus, pci->addr.devid, |
| 421 | pci->addr.function); |
| 422 | s = |
| 423 | format (s, "%Umax rx packet len: %d\n", format_white_space, |
| 424 | indent + 2, di.max_rx_pktlen); |
| 425 | s = |
| 426 | format (s, "%Umax num of queues: rx %d tx %d\n", format_white_space, |
| 427 | indent + 2, di.max_rx_queues, di.max_tx_queues); |
| 428 | s = |
| 429 | format (s, "%Upromiscuous: unicast %s all-multicast %s\n", |
| 430 | format_white_space, indent + 2, |
| 431 | rte_eth_promiscuous_get (xd->device_index) ? "on" : "off", |
| 432 | rte_eth_promiscuous_get (xd->device_index) ? "on" : "off"); |
| 433 | vlan_off = rte_eth_dev_get_vlan_offload (xd->device_index); |
| 434 | s = format (s, "%Uvlan offload: strip %s filter %s qinq %s\n", |
| 435 | format_white_space, indent + 2, |
| 436 | vlan_off & ETH_VLAN_STRIP_OFFLOAD ? "on" : "off", |
| 437 | vlan_off & ETH_VLAN_FILTER_OFFLOAD ? "on" : "off", |
| 438 | vlan_off & ETH_VLAN_EXTEND_OFFLOAD ? "on" : "off"); |
| 439 | s = format (s, "%Urx offload caps: %U\n", |
| 440 | format_white_space, indent + 2, |
| 441 | format_dpdk_rx_offload_caps, di.rx_offload_capa); |
| 442 | s = format (s, "%Utx offload caps: %U\n", |
| 443 | format_white_space, indent + 2, |
| 444 | format_dpdk_tx_offload_caps, di.tx_offload_capa); |
| 445 | s = format (s, "%Urss active: %U\n" |
| 446 | "%Urss supported: %U\n", |
| 447 | format_white_space, indent + 2, |
| 448 | format_dpdk_rss_hf_name, rss_conf.rss_hf, |
| 449 | format_white_space, indent + 2, |
| 450 | format_dpdk_rss_hf_name, di.flow_type_rss_offloads); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 451 | } |
| 452 | |
Damjan Marion | 39da621 | 2016-06-06 13:21:04 +0200 | [diff] [blame] | 453 | s = format (s, "%Urx queues %d, rx desc %d, tx queues %d, tx desc %d\n", |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 454 | format_white_space, indent + 2, |
| 455 | xd->rx_q_used, xd->nb_rx_desc, xd->tx_q_used, xd->nb_tx_desc); |
Damjan Marion | 39da621 | 2016-06-06 13:21:04 +0200 | [diff] [blame] | 456 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 457 | if (xd->cpu_socket > -1) |
Damjan Marion | 39da621 | 2016-06-06 13:21:04 +0200 | [diff] [blame] | 458 | s = format (s, "%Ucpu socket %d\n", |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 459 | format_white_space, indent + 2, xd->cpu_socket); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 460 | |
| 461 | /* $$$ MIB counters */ |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 462 | { |
| 463 | #define _(N, V) \ |
Sean Hope | a4f16a0 | 2016-03-28 13:11:31 -0400 | [diff] [blame] | 464 | if ((xd->stats.V - xd->last_cleared_stats.V) != 0) { \ |
| 465 | s = format (s, "\n%U%-40U%16Ld", \ |
| 466 | format_white_space, indent + 2, \ |
| 467 | format_c_identifier, #N, \ |
| 468 | xd->stats.V - xd->last_cleared_stats.V); \ |
| 469 | } \ |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 470 | |
| 471 | foreach_dpdk_counter |
| 472 | #undef _ |
| 473 | } |
| 474 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 475 | u8 *xs = 0; |
Sean Hope | a4f16a0 | 2016-03-28 13:11:31 -0400 | [diff] [blame] | 476 | u32 i = 0; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 477 | struct rte_eth_xstat *xstat, *last_xstat; |
| 478 | struct rte_eth_xstat_name *xstat_names = 0; |
Damjan Marion | 1f0da17 | 2016-07-13 22:44:18 +0200 | [diff] [blame] | 479 | int len = rte_eth_xstats_get_names (xd->device_index, NULL, 0); |
| 480 | vec_validate (xstat_names, len - 1); |
| 481 | rte_eth_xstats_get_names (xd->device_index, xstat_names, len); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 482 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 483 | ASSERT (vec_len (xd->xstats) == vec_len (xd->last_cleared_xstats)); |
Sean Hope | a4f16a0 | 2016-03-28 13:11:31 -0400 | [diff] [blame] | 484 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 485 | /* *INDENT-OFF* */ |
Sean Hope | a4f16a0 | 2016-03-28 13:11:31 -0400 | [diff] [blame] | 486 | vec_foreach_index(i, xd->xstats) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 487 | { |
Sean Hope | a4f16a0 | 2016-03-28 13:11:31 -0400 | [diff] [blame] | 488 | u64 delta = 0; |
Damjan Marion | 1f0da17 | 2016-07-13 22:44:18 +0200 | [diff] [blame] | 489 | xstat = vec_elt_at_index(xd->xstats, i); |
| 490 | last_xstat = vec_elt_at_index(xd->last_cleared_xstats, i); |
Sean Hope | a4f16a0 | 2016-03-28 13:11:31 -0400 | [diff] [blame] | 491 | |
| 492 | delta = xstat->value - last_xstat->value; |
| 493 | if (verbose == 2 || (verbose && delta)) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 494 | { |
Sean Hope | a4f16a0 | 2016-03-28 13:11:31 -0400 | [diff] [blame] | 495 | /* format_c_identifier doesn't like c strings inside vector */ |
Damjan Marion | 1f0da17 | 2016-07-13 22:44:18 +0200 | [diff] [blame] | 496 | u8 * name = format(0,"%s", xstat_names[i].name); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 497 | xs = format(xs, "\n%U%-38U%16Ld", |
| 498 | format_white_space, indent + 4, |
Sean Hope | a4f16a0 | 2016-03-28 13:11:31 -0400 | [diff] [blame] | 499 | format_c_identifier, name, delta); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 500 | vec_free(name); |
| 501 | } |
| 502 | } |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 503 | /* *INDENT-ON* */ |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 504 | |
Damjan Marion | 1f0da17 | 2016-07-13 22:44:18 +0200 | [diff] [blame] | 505 | vec_free (xstat_names); |
Shesha Sreenivasamurthy | 9455084 | 2016-03-02 10:33:26 -0800 | [diff] [blame] | 506 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 507 | if (xs) |
| 508 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 509 | s = format (s, "\n%Uextended stats:%v", |
| 510 | format_white_space, indent + 2, xs); |
| 511 | vec_free (xs); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | return s; |
| 515 | } |
| 516 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 517 | u8 * |
| 518 | format_dpdk_tx_dma_trace (u8 * s, va_list * va) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 519 | { |
| 520 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *); |
| 521 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *); |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 522 | CLIB_UNUSED (vnet_main_t * vnm) = vnet_get_main (); |
| 523 | dpdk_tx_dma_trace_t *t = va_arg (*va, dpdk_tx_dma_trace_t *); |
| 524 | dpdk_main_t *dm = &dpdk_main; |
| 525 | dpdk_device_t *xd = vec_elt_at_index (dm->devices, t->device_index); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 526 | uword indent = format_get_indent (s); |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 527 | vnet_sw_interface_t *sw = vnet_get_sw_interface (vnm, xd->vlib_sw_if_index); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 528 | |
| 529 | s = format (s, "%U tx queue %d", |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 530 | format_vnet_sw_interface_name, vnm, sw, t->queue_index); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 531 | |
| 532 | s = format (s, "\n%Ubuffer 0x%x: %U", |
| 533 | format_white_space, indent, |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 534 | t->buffer_index, format_vlib_buffer, &t->buffer); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 535 | |
| 536 | s = format (s, "\n%U%U", format_white_space, indent, |
| 537 | format_ethernet_header_with_length, t->buffer.pre_data, |
| 538 | sizeof (t->buffer.pre_data)); |
| 539 | |
| 540 | return s; |
| 541 | } |
| 542 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 543 | u8 * |
| 544 | format_dpdk_rx_dma_trace (u8 * s, va_list * va) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 545 | { |
| 546 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *); |
| 547 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *); |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 548 | CLIB_UNUSED (vnet_main_t * vnm) = vnet_get_main (); |
| 549 | dpdk_rx_dma_trace_t *t = va_arg (*va, dpdk_rx_dma_trace_t *); |
| 550 | dpdk_main_t *dm = &dpdk_main; |
| 551 | dpdk_device_t *xd = vec_elt_at_index (dm->devices, t->device_index); |
| 552 | format_function_t *f; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 553 | uword indent = format_get_indent (s); |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 554 | vnet_sw_interface_t *sw = vnet_get_sw_interface (vnm, xd->vlib_sw_if_index); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 555 | |
| 556 | s = format (s, "%U rx queue %d", |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 557 | format_vnet_sw_interface_name, vnm, sw, t->queue_index); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 558 | |
| 559 | s = format (s, "\n%Ubuffer 0x%x: %U", |
| 560 | format_white_space, indent, |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 561 | t->buffer_index, format_vlib_buffer, &t->buffer); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 562 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 563 | s = format (s, "\n%U%U", |
| 564 | format_white_space, indent, |
marek zavodsky | ad2c9c0 | 2016-07-07 03:16:10 +0200 | [diff] [blame] | 565 | format_dpdk_rte_mbuf, &t->mb, &t->data); |
Damjan Marion | 4fafa62 | 2016-11-18 10:35:35 +0100 | [diff] [blame] | 566 | |
Damjan Marion | db7b269 | 2016-06-09 16:16:27 +0200 | [diff] [blame] | 567 | if (vm->trace_main.verbose) |
| 568 | { |
| 569 | s = format (s, "\n%UPacket Dump%s", format_white_space, indent + 2, |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 570 | t->mb.data_len > sizeof (t->data) ? " (truncated)" : ""); |
Damjan Marion | db7b269 | 2016-06-09 16:16:27 +0200 | [diff] [blame] | 571 | s = format (s, "\n%U%U", format_white_space, indent + 4, |
| 572 | format_hexdump, &t->data, |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 573 | t->mb.data_len > |
| 574 | sizeof (t->data) ? sizeof (t->data) : t->mb.data_len); |
Damjan Marion | db7b269 | 2016-06-09 16:16:27 +0200 | [diff] [blame] | 575 | } |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 576 | f = node->format_buffer; |
| 577 | if (!f) |
| 578 | f = format_hex_bytes; |
| 579 | s = format (s, "\n%U%U", format_white_space, indent, |
| 580 | f, t->buffer.pre_data, sizeof (t->buffer.pre_data)); |
| 581 | |
| 582 | return s; |
| 583 | } |
| 584 | |
| 585 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 586 | static inline u8 * |
| 587 | format_dpdk_pkt_types (u8 * s, va_list * va) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 588 | { |
| 589 | u32 *pkt_types = va_arg (*va, u32 *); |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 590 | uword indent __attribute__ ((unused)) = format_get_indent (s) + 2; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 591 | |
| 592 | if (!*pkt_types) |
| 593 | return s; |
| 594 | |
| 595 | s = format (s, "Packet Types"); |
| 596 | |
| 597 | #define _(L, F, S) \ |
| 598 | if ((*pkt_types & RTE_PTYPE_##L##_MASK) == RTE_PTYPE_##L##_##F) \ |
| 599 | { \ |
| 600 | s = format (s, "\n%U%s (0x%04x) %s", format_white_space, indent, \ |
| 601 | "RTE_PTYPE_" #L "_" #F, RTE_PTYPE_##L##_##F, S); \ |
| 602 | } |
| 603 | |
| 604 | foreach_dpdk_pkt_type |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 605 | #undef _ |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 606 | return s; |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 607 | } |
| 608 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 609 | static inline u8 * |
| 610 | format_dpdk_pkt_offload_flags (u8 * s, va_list * va) |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 611 | { |
Damjan Marion | b022cd1 | 2016-08-16 13:25:59 +0200 | [diff] [blame] | 612 | u64 *ol_flags = va_arg (*va, u64 *); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 613 | uword indent = format_get_indent (s) + 2; |
| 614 | |
| 615 | if (!*ol_flags) |
| 616 | return s; |
| 617 | |
| 618 | s = format (s, "Packet Offload Flags"); |
| 619 | |
| 620 | #define _(F, S) \ |
| 621 | if (*ol_flags & F) \ |
| 622 | { \ |
| 623 | s = format (s, "\n%U%s (0x%04x) %s", \ |
| 624 | format_white_space, indent, #F, F, S); \ |
| 625 | } |
| 626 | |
| 627 | foreach_dpdk_pkt_offload_flag |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 628 | #undef _ |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 629 | return s; |
| 630 | } |
| 631 | |
| 632 | u8 * |
| 633 | format_dpdk_rte_mbuf_vlan (u8 * s, va_list * va) |
| 634 | { |
| 635 | ethernet_vlan_header_tv_t *vlan_hdr = |
| 636 | va_arg (*va, ethernet_vlan_header_tv_t *); |
| 637 | |
| 638 | if (clib_net_to_host_u16 (vlan_hdr->type) == ETHERNET_TYPE_DOT1AD) |
| 639 | { |
| 640 | s = format (s, "%U 802.1q vlan ", |
| 641 | format_ethernet_vlan_tci, |
| 642 | clib_net_to_host_u16 (vlan_hdr->priority_cfi_and_id)); |
| 643 | vlan_hdr++; |
| 644 | } |
| 645 | |
| 646 | s = format (s, "%U", |
| 647 | format_ethernet_vlan_tci, |
| 648 | clib_net_to_host_u16 (vlan_hdr->priority_cfi_and_id)); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 649 | |
| 650 | return s; |
| 651 | } |
| 652 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 653 | u8 * |
| 654 | format_dpdk_rte_mbuf (u8 * s, va_list * va) |
marek zavodsky | ad2c9c0 | 2016-07-07 03:16:10 +0200 | [diff] [blame] | 655 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 656 | struct rte_mbuf *mb = va_arg (*va, struct rte_mbuf *); |
marek zavodsky | ad2c9c0 | 2016-07-07 03:16:10 +0200 | [diff] [blame] | 657 | ethernet_header_t *eth_hdr = va_arg (*va, ethernet_header_t *); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 658 | uword indent = format_get_indent (s) + 2; |
| 659 | |
| 660 | s = format (s, "PKT MBUF: port %d, nb_segs %d, pkt_len %d" |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 661 | "\n%Ubuf_len %d, data_len %d, ol_flags 0x%x, data_off %d, phys_addr 0x%x" |
| 662 | "\n%Upacket_type 0x%x", |
| 663 | mb->port, mb->nb_segs, mb->pkt_len, |
| 664 | format_white_space, indent, |
| 665 | mb->buf_len, mb->data_len, mb->ol_flags, mb->data_off, |
| 666 | mb->buf_physaddr, format_white_space, indent, mb->packet_type); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 667 | |
| 668 | if (mb->ol_flags) |
| 669 | s = format (s, "\n%U%U", format_white_space, indent, |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 670 | format_dpdk_pkt_offload_flags, &mb->ol_flags); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 671 | |
John Lo | a60d4cb | 2016-12-17 03:09:58 -0500 | [diff] [blame] | 672 | if ((mb->ol_flags & PKT_RX_VLAN_PKT) && |
| 673 | ((mb->ol_flags & (PKT_RX_VLAN_STRIPPED | PKT_RX_QINQ_STRIPPED)) == 0)) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 674 | { |
| 675 | ethernet_vlan_header_tv_t *vlan_hdr = |
| 676 | ((ethernet_vlan_header_tv_t *) & (eth_hdr->type)); |
| 677 | s = format (s, " %U", format_dpdk_rte_mbuf_vlan, vlan_hdr); |
| 678 | } |
marek zavodsky | ad2c9c0 | 2016-07-07 03:16:10 +0200 | [diff] [blame] | 679 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 680 | if (mb->packet_type) |
| 681 | s = format (s, "\n%U%U", format_white_space, indent, |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 682 | format_dpdk_pkt_types, &mb->packet_type); |
marek zavodsky | ad2c9c0 | 2016-07-07 03:16:10 +0200 | [diff] [blame] | 683 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 684 | return s; |
| 685 | } |
| 686 | |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 687 | uword |
| 688 | unformat_socket_mem (unformat_input_t * input, va_list * va) |
| 689 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 690 | uword **r = va_arg (*va, uword **); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 691 | int i = 0; |
| 692 | u32 mem; |
| 693 | |
| 694 | while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) |
| 695 | { |
| 696 | if (unformat (input, ",")) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 697 | hash_set (*r, i, 1024); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 698 | else if (unformat (input, "%u,", &mem)) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 699 | hash_set (*r, i, mem); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 700 | else if (unformat (input, "%u", &mem)) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 701 | hash_set (*r, i, mem); |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 702 | else |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 703 | { |
| 704 | unformat_put_input (input); |
| 705 | goto done; |
| 706 | } |
Damjan Marion | 7f62097 | 2016-02-25 16:00:11 +0100 | [diff] [blame] | 707 | i++; |
| 708 | } |
| 709 | |
| 710 | done: |
| 711 | return 1; |
| 712 | } |
Srivatsa Sangli | 820e363 | 2016-06-14 13:10:55 -0700 | [diff] [blame] | 713 | |
| 714 | clib_error_t * |
| 715 | unformat_rss_fn (unformat_input_t * input, uword * rss_fn) |
| 716 | { |
| 717 | while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) |
| 718 | { |
| 719 | if (0) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 720 | ; |
Srivatsa Sangli | 820e363 | 2016-06-14 13:10:55 -0700 | [diff] [blame] | 721 | #undef _ |
| 722 | #define _(f, s) \ |
| 723 | else if (unformat (input, s)) \ |
| 724 | *rss_fn |= f; |
| 725 | |
| 726 | foreach_dpdk_rss_hf |
| 727 | #undef _ |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 728 | else |
| 729 | { |
| 730 | return clib_error_return (0, "unknown input `%U'", |
| 731 | format_unformat_error, input); |
| 732 | } |
Srivatsa Sangli | 820e363 | 2016-06-14 13:10:55 -0700 | [diff] [blame] | 733 | } |
| 734 | return 0; |
| 735 | } |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 736 | |
Jasvinder Singh | 85ecc81 | 2016-07-21 17:02:19 +0100 | [diff] [blame] | 737 | clib_error_t * |
| 738 | unformat_hqos (unformat_input_t * input, dpdk_device_config_hqos_t * hqos) |
| 739 | { |
| 740 | clib_error_t *error = 0; |
| 741 | |
| 742 | while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) |
| 743 | { |
| 744 | if (unformat (input, "hqos-thread %u", &hqos->hqos_thread)) |
| 745 | hqos->hqos_thread_valid = 1; |
| 746 | else |
| 747 | { |
| 748 | error = clib_error_return (0, "unknown input `%U'", |
| 749 | format_unformat_error, input); |
| 750 | break; |
| 751 | } |
| 752 | } |
| 753 | |
| 754 | return error; |
| 755 | } |
| 756 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 757 | /* |
| 758 | * fd.io coding-style-patch-verification: ON |
| 759 | * |
| 760 | * Local Variables: |
| 761 | * eval: (c-set-style "gnu") |
| 762 | * End: |
| 763 | */ |