1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2016 Intel Corporation. 3 * Copyright(c) 2014 6WIND S.A. 4 */ 5 6 #include <stdarg.h> 7 #include <errno.h> 8 #include <stdio.h> 9 #include <stdint.h> 10 #include <string.h> 11 #include <termios.h> 12 #include <unistd.h> 13 #include <inttypes.h> 14 #ifndef __linux__ 15 #ifndef __FreeBSD__ 16 #include <net/socket.h> 17 #else 18 #include <sys/socket.h> 19 #endif 20 #endif 21 #include <netinet/in.h> 22 23 #include <sys/queue.h> 24 25 #include <rte_common.h> 26 #include <rte_byteorder.h> 27 #include <rte_log.h> 28 #include <rte_debug.h> 29 #include <rte_cycles.h> 30 #include <rte_memory.h> 31 #include <rte_memzone.h> 32 #include <rte_malloc.h> 33 #include <rte_launch.h> 34 #include <rte_eal.h> 35 #include <rte_per_lcore.h> 36 #include <rte_lcore.h> 37 #include <rte_atomic.h> 38 #include <rte_branch_prediction.h> 39 #include <rte_ring.h> 40 #include <rte_mempool.h> 41 #include <rte_interrupts.h> 42 #include <rte_pci.h> 43 #include <rte_ether.h> 44 #include <rte_ethdev.h> 45 #include <rte_string_fns.h> 46 #include <rte_devargs.h> 47 #include <rte_eth_ctrl.h> 48 #include <rte_flow.h> 49 #include <rte_gro.h> 50 51 #include <cmdline_rdline.h> 52 #include <cmdline_parse.h> 53 #include <cmdline_parse_num.h> 54 #include <cmdline_parse_string.h> 55 #include <cmdline_parse_ipaddr.h> 56 #include <cmdline_parse_etheraddr.h> 57 #include <cmdline_socket.h> 58 #include <cmdline.h> 59 #ifdef RTE_LIBRTE_PMD_BOND 60 #include <rte_eth_bond.h> 61 #include <rte_eth_bond_8023ad.h> 62 #endif 63 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 64 #include <rte_pmd_dpaa.h> 65 #endif 66 #ifdef RTE_LIBRTE_IXGBE_PMD 67 #include <rte_pmd_ixgbe.h> 68 #endif 69 #ifdef RTE_LIBRTE_I40E_PMD 70 #include <rte_pmd_i40e.h> 71 #endif 72 #ifdef RTE_LIBRTE_BNXT_PMD 73 #include <rte_pmd_bnxt.h> 74 #endif 75 #include "testpmd.h" 76 #include "cmdline_mtr.h" 77 #include "cmdline_tm.h" 78 79 static struct cmdline *testpmd_cl; 80 81 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); 82 83 /* *** Help command with introduction. *** */ 84 struct cmd_help_brief_result { 85 cmdline_fixed_string_t help; 86 }; 87 88 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result, 89 struct cmdline *cl, 90 __attribute__((unused)) void *data) 91 { 92 cmdline_printf( 93 cl, 94 "\n" 95 "Help is available for the following sections:\n\n" 96 " help control : Start and stop forwarding.\n" 97 " help display : Displaying port, stats and config " 98 "information.\n" 99 " help config : Configuration information.\n" 100 " help ports : Configuring ports.\n" 101 " help registers : Reading and setting port registers.\n" 102 " help filters : Filters configuration help.\n" 103 " help all : All of the above sections.\n\n" 104 ); 105 106 } 107 108 cmdline_parse_token_string_t cmd_help_brief_help = 109 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help"); 110 111 cmdline_parse_inst_t cmd_help_brief = { 112 .f = cmd_help_brief_parsed, 113 .data = NULL, 114 .help_str = "help: Show help", 115 .tokens = { 116 (void *)&cmd_help_brief_help, 117 NULL, 118 }, 119 }; 120 121 /* *** Help command with help sections. *** */ 122 struct cmd_help_long_result { 123 cmdline_fixed_string_t help; 124 cmdline_fixed_string_t section; 125 }; 126 127 static void cmd_help_long_parsed(void *parsed_result, 128 struct cmdline *cl, 129 __attribute__((unused)) void *data) 130 { 131 int show_all = 0; 132 struct cmd_help_long_result *res = parsed_result; 133 134 if (!strcmp(res->section, "all")) 135 show_all = 1; 136 137 if (show_all || !strcmp(res->section, "control")) { 138 139 cmdline_printf( 140 cl, 141 "\n" 142 "Control forwarding:\n" 143 "-------------------\n\n" 144 145 "start\n" 146 " Start packet forwarding with current configuration.\n\n" 147 148 "start tx_first\n" 149 " Start packet forwarding with current config" 150 " after sending one burst of packets.\n\n" 151 152 "stop\n" 153 " Stop packet forwarding, and display accumulated" 154 " statistics.\n\n" 155 156 "quit\n" 157 " Quit to prompt.\n\n" 158 ); 159 } 160 161 if (show_all || !strcmp(res->section, "display")) { 162 163 cmdline_printf( 164 cl, 165 "\n" 166 "Display:\n" 167 "--------\n\n" 168 169 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n" 170 " Display information for port_id, or all.\n\n" 171 172 "show port X rss reta (size) (mask0,mask1,...)\n" 173 " Display the rss redirection table entry indicated" 174 " by masks on port X. size is used to indicate the" 175 " hardware supported reta size\n\n" 176 177 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|" 178 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 179 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n" 180 " Display the RSS hash functions and RSS hash key" 181 " of port X\n\n" 182 183 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n" 184 " Clear information for port_id, or all.\n\n" 185 186 "show (rxq|txq) info (port_id) (queue_id)\n" 187 " Display information for configured RX/TX queue.\n\n" 188 189 "show config (rxtx|cores|fwd|txpkts)\n" 190 " Display the given configuration.\n\n" 191 192 "read rxd (port_id) (queue_id) (rxd_id)\n" 193 " Display an RX descriptor of a port RX queue.\n\n" 194 195 "read txd (port_id) (queue_id) (txd_id)\n" 196 " Display a TX descriptor of a port TX queue.\n\n" 197 198 "ddp get list (port_id)\n" 199 " Get ddp profile info list\n\n" 200 201 "ddp get info (profile_path)\n" 202 " Get ddp profile information.\n\n" 203 204 "show vf stats (port_id) (vf_id)\n" 205 " Display a VF's statistics.\n\n" 206 207 "clear vf stats (port_id) (vf_id)\n" 208 " Reset a VF's statistics.\n\n" 209 210 "show port (port_id) pctype mapping\n" 211 " Get flow ptype to pctype mapping on a port\n\n" 212 213 "show port meter stats (port_id) (meter_id) (clear)\n" 214 " Get meter stats on a port\n\n" 215 "show port tm cap (port_id)\n" 216 " Display the port TM capability.\n\n" 217 218 "show port tm level cap (port_id) (level_id)\n" 219 " Display the port TM hierarchical level capability.\n\n" 220 221 "show port tm node cap (port_id) (node_id)\n" 222 " Display the port TM node capability.\n\n" 223 224 "show port tm node type (port_id) (node_id)\n" 225 " Display the port TM node type.\n\n" 226 227 "show port tm node stats (port_id) (node_id) (clear)\n" 228 " Display the port TM node stats.\n\n" 229 230 ); 231 } 232 233 if (show_all || !strcmp(res->section, "config")) { 234 cmdline_printf( 235 cl, 236 "\n" 237 "Configuration:\n" 238 "--------------\n" 239 "Configuration changes only become active when" 240 " forwarding is started/restarted.\n\n" 241 242 "set default\n" 243 " Reset forwarding to the default configuration.\n\n" 244 245 "set verbose (level)\n" 246 " Set the debug verbosity level X.\n\n" 247 248 "set log global|(type) (level)\n" 249 " Set the log level.\n\n" 250 251 "set nbport (num)\n" 252 " Set number of ports.\n\n" 253 254 "set nbcore (num)\n" 255 " Set number of cores.\n\n" 256 257 "set coremask (mask)\n" 258 " Set the forwarding cores hexadecimal mask.\n\n" 259 260 "set portmask (mask)\n" 261 " Set the forwarding ports hexadecimal mask.\n\n" 262 263 "set burst (num)\n" 264 " Set number of packets per burst.\n\n" 265 266 "set burst tx delay (microseconds) retry (num)\n" 267 " Set the transmit delay time and number of retries," 268 " effective when retry is enabled.\n\n" 269 270 "set txpkts (x[,y]*)\n" 271 " Set the length of each segment of TXONLY" 272 " and optionally CSUM packets.\n\n" 273 274 "set txsplit (off|on|rand)\n" 275 " Set the split policy for the TX packets." 276 " Right now only applicable for CSUM and TXONLY" 277 " modes\n\n" 278 279 "set corelist (x[,y]*)\n" 280 " Set the list of forwarding cores.\n\n" 281 282 "set portlist (x[,y]*)\n" 283 " Set the list of forwarding ports.\n\n" 284 285 "set tx loopback (port_id) (on|off)\n" 286 " Enable or disable tx loopback.\n\n" 287 288 "set all queues drop (port_id) (on|off)\n" 289 " Set drop enable bit for all queues.\n\n" 290 291 "set vf split drop (port_id) (vf_id) (on|off)\n" 292 " Set split drop enable bit for a VF from the PF.\n\n" 293 294 "set vf mac antispoof (port_id) (vf_id) (on|off).\n" 295 " Set MAC antispoof for a VF from the PF.\n\n" 296 297 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" 298 " Enable MACsec offload.\n\n" 299 300 "set macsec offload (port_id) off\n" 301 " Disable MACsec offload.\n\n" 302 303 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" 304 " Configure MACsec secure connection (SC).\n\n" 305 306 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" 307 " Configure MACsec secure association (SA).\n\n" 308 309 "set vf broadcast (port_id) (vf_id) (on|off)\n" 310 " Set VF broadcast for a VF from the PF.\n\n" 311 312 "vlan set strip (on|off) (port_id)\n" 313 " Set the VLAN strip on a port.\n\n" 314 315 "vlan set stripq (on|off) (port_id,queue_id)\n" 316 " Set the VLAN strip for a queue on a port.\n\n" 317 318 "set vf vlan stripq (port_id) (vf_id) (on|off)\n" 319 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" 320 321 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" 322 " Set VLAN insert for a VF from the PF.\n\n" 323 324 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" 325 " Set VLAN antispoof for a VF from the PF.\n\n" 326 327 "set vf vlan tag (port_id) (vf_id) (on|off)\n" 328 " Set VLAN tag for a VF from the PF.\n\n" 329 330 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n" 331 " Set a VF's max bandwidth(Mbps).\n\n" 332 333 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n" 334 " Set all TCs' min bandwidth(%%) on a VF.\n\n" 335 336 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n" 337 " Set a TC's max bandwidth(Mbps) on a VF.\n\n" 338 339 "set tx strict-link-priority (port_id) (tc_bitmap)\n" 340 " Set some TCs' strict link priority mode on a physical port.\n\n" 341 342 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" 343 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n" 344 345 "vlan set filter (on|off) (port_id)\n" 346 " Set the VLAN filter on a port.\n\n" 347 348 "vlan set qinq (on|off) (port_id)\n" 349 " Set the VLAN QinQ (extended queue in queue)" 350 " on a port.\n\n" 351 352 "vlan set (inner|outer) tpid (value) (port_id)\n" 353 " Set the VLAN TPID for Packet Filtering on" 354 " a port\n\n" 355 356 "rx_vlan add (vlan_id|all) (port_id)\n" 357 " Add a vlan_id, or all identifiers, to the set" 358 " of VLAN identifiers filtered by port_id.\n\n" 359 360 "rx_vlan rm (vlan_id|all) (port_id)\n" 361 " Remove a vlan_id, or all identifiers, from the set" 362 " of VLAN identifiers filtered by port_id.\n\n" 363 364 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n" 365 " Add a vlan_id, to the set of VLAN identifiers" 366 "filtered for VF(s) from port_id.\n\n" 367 368 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n" 369 " Remove a vlan_id, to the set of VLAN identifiers" 370 "filtered for VF(s) from port_id.\n\n" 371 372 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) " 373 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|" 374 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 375 " add a tunnel filter of a port.\n\n" 376 377 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) " 378 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|" 379 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 380 " remove a tunnel filter of a port.\n\n" 381 382 "rx_vxlan_port add (udp_port) (port_id)\n" 383 " Add an UDP port for VXLAN packet filter on a port\n\n" 384 385 "rx_vxlan_port rm (udp_port) (port_id)\n" 386 " Remove an UDP port for VXLAN packet filter on a port\n\n" 387 388 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" 389 " Set hardware insertion of VLAN IDs (single or double VLAN " 390 "depends on the number of VLAN IDs) in packets sent on a port.\n\n" 391 392 "tx_vlan set pvid port_id vlan_id (on|off)\n" 393 " Set port based TX VLAN insertion.\n\n" 394 395 "tx_vlan reset (port_id)\n" 396 " Disable hardware insertion of a VLAN header in" 397 " packets sent on a port.\n\n" 398 399 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n" 400 " Select hardware or software calculation of the" 401 " checksum when transmitting a packet using the" 402 " csum forward engine.\n" 403 " ip|udp|tcp|sctp always concern the inner layer.\n" 404 " outer-ip concerns the outer IP layer in" 405 " case the packet is recognized as a tunnel packet by" 406 " the forward engine (vxlan, gre and ipip are supported)\n" 407 " Please check the NIC datasheet for HW limits.\n\n" 408 409 "csum parse-tunnel (on|off) (tx_port_id)\n" 410 " If disabled, treat tunnel packets as non-tunneled" 411 " packets (treat inner headers as payload). The port\n" 412 " argument is the port used for TX in csum forward" 413 " engine.\n\n" 414 415 "csum show (port_id)\n" 416 " Display tx checksum offload configuration\n\n" 417 418 "tso set (segsize) (portid)\n" 419 " Enable TCP Segmentation Offload in csum forward" 420 " engine.\n" 421 " Please check the NIC datasheet for HW limits.\n\n" 422 423 "tso show (portid)" 424 " Display the status of TCP Segmentation Offload.\n\n" 425 426 "set port (port_id) gro on|off\n" 427 " Enable or disable Generic Receive Offload in" 428 " csum forwarding engine.\n\n" 429 430 "show port (port_id) gro\n" 431 " Display GRO configuration.\n\n" 432 433 "set gro flush (cycles)\n" 434 " Set the cycle to flush GROed packets from" 435 " reassembly tables.\n\n" 436 437 "set port (port_id) gso (on|off)" 438 " Enable or disable Generic Segmentation Offload in" 439 " csum forwarding engine.\n\n" 440 441 "set gso segsz (length)\n" 442 " Set max packet length for output GSO segments," 443 " including packet header and payload.\n\n" 444 445 "show port (port_id) gso\n" 446 " Show GSO configuration.\n\n" 447 448 "set fwd (%s)\n" 449 " Set packet forwarding mode.\n\n" 450 451 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" 452 " Add a MAC address on port_id.\n\n" 453 454 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n" 455 " Remove a MAC address from port_id.\n\n" 456 457 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n" 458 " Set the default MAC address for port_id.\n\n" 459 460 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n" 461 " Add a MAC address for a VF on the port.\n\n" 462 463 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n" 464 " Set the MAC address for a VF from the PF.\n\n" 465 466 "set eth-peer (port_id) (peer_addr)\n" 467 " set the peer address for certain port.\n\n" 468 469 "set port (port_id) uta (mac_address|all) (on|off)\n" 470 " Add/Remove a or all unicast hash filter(s)" 471 "from port X.\n\n" 472 473 "set promisc (port_id|all) (on|off)\n" 474 " Set the promiscuous mode on port_id, or all.\n\n" 475 476 "set allmulti (port_id|all) (on|off)\n" 477 " Set the allmulti mode on port_id, or all.\n\n" 478 479 "set vf promisc (port_id) (vf_id) (on|off)\n" 480 " Set unicast promiscuous mode for a VF from the PF.\n\n" 481 482 "set vf allmulti (port_id) (vf_id) (on|off)\n" 483 " Set multicast promiscuous mode for a VF from the PF.\n\n" 484 485 "set flow_ctrl rx (on|off) tx (on|off) (high_water)" 486 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" 487 " (on|off) autoneg (on|off) (port_id)\n" 488 "set flow_ctrl rx (on|off) (portid)\n" 489 "set flow_ctrl tx (on|off) (portid)\n" 490 "set flow_ctrl high_water (high_water) (portid)\n" 491 "set flow_ctrl low_water (low_water) (portid)\n" 492 "set flow_ctrl pause_time (pause_time) (portid)\n" 493 "set flow_ctrl send_xon (send_xon) (portid)\n" 494 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n" 495 "set flow_ctrl autoneg (on|off) (port_id)\n" 496 " Set the link flow control parameter on a port.\n\n" 497 498 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)" 499 " (low_water) (pause_time) (priority) (port_id)\n" 500 " Set the priority flow control parameter on a" 501 " port.\n\n" 502 503 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n" 504 " Set statistics mapping (qmapping 0..15) for RX/TX" 505 " queue on port.\n" 506 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2" 507 " on port 0 to mapping 5.\n\n" 508 509 "set xstats-hide-zero on|off\n" 510 " Set the option to hide the zero values" 511 " for xstats display.\n" 512 513 "set port (port_id) vf (vf_id) rx|tx on|off\n" 514 " Enable/Disable a VF receive/tranmit from a port\n\n" 515 516 "set port (port_id) vf (vf_id) (mac_addr)" 517 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n" 518 " Add/Remove unicast or multicast MAC addr filter" 519 " for a VF.\n\n" 520 521 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" 522 "|MPE) (on|off)\n" 523 " AUPE:accepts untagged VLAN;" 524 "ROPE:accept unicast hash\n\n" 525 " BAM:accepts broadcast packets;" 526 "MPE:accepts all multicast packets\n\n" 527 " Enable/Disable a VF receive mode of a port\n\n" 528 529 "set port (port_id) queue (queue_id) rate (rate_num)\n" 530 " Set rate limit for a queue of a port\n\n" 531 532 "set port (port_id) vf (vf_id) rate (rate_num) " 533 "queue_mask (queue_mask_value)\n" 534 " Set rate limit for queues in VF of a port\n\n" 535 536 "set port (port_id) mirror-rule (rule_id)" 537 " (pool-mirror-up|pool-mirror-down|vlan-mirror)" 538 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n" 539 " Set pool or vlan type mirror rule on a port.\n" 540 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1" 541 " dst-pool 0 on' enable mirror traffic with vlan 0,1" 542 " to pool 0.\n\n" 543 544 "set port (port_id) mirror-rule (rule_id)" 545 " (uplink-mirror|downlink-mirror) dst-pool" 546 " (pool_id) (on|off)\n" 547 " Set uplink or downlink type mirror rule on a port.\n" 548 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool" 549 " 0 on' enable mirror income traffic to pool 0.\n\n" 550 551 "reset port (port_id) mirror-rule (rule_id)\n" 552 " Reset a mirror rule.\n\n" 553 554 "set flush_rx (on|off)\n" 555 " Flush (default) or don't flush RX streams before" 556 " forwarding. Mainly used with PCAP drivers.\n\n" 557 558 "set bypass mode (normal|bypass|isolate) (port_id)\n" 559 " Set the bypass mode for the lowest port on bypass enabled" 560 " NIC.\n\n" 561 562 "set bypass event (timeout|os_on|os_off|power_on|power_off) " 563 "mode (normal|bypass|isolate) (port_id)\n" 564 " Set the event required to initiate specified bypass mode for" 565 " the lowest port on a bypass enabled NIC where:\n" 566 " timeout = enable bypass after watchdog timeout.\n" 567 " os_on = enable bypass when OS/board is powered on.\n" 568 " os_off = enable bypass when OS/board is powered off.\n" 569 " power_on = enable bypass when power supply is turned on.\n" 570 " power_off = enable bypass when power supply is turned off." 571 "\n\n" 572 573 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" 574 " Set the bypass watchdog timeout to 'n' seconds" 575 " where 0 = instant.\n\n" 576 577 "show bypass config (port_id)\n" 578 " Show the bypass configuration for a bypass enabled NIC" 579 " using the lowest port on the NIC.\n\n" 580 581 #ifdef RTE_LIBRTE_PMD_BOND 582 "create bonded device (mode) (socket)\n" 583 " Create a new bonded device with specific bonding mode and socket.\n\n" 584 585 "add bonding slave (slave_id) (port_id)\n" 586 " Add a slave device to a bonded device.\n\n" 587 588 "remove bonding slave (slave_id) (port_id)\n" 589 " Remove a slave device from a bonded device.\n\n" 590 591 "set bonding mode (value) (port_id)\n" 592 " Set the bonding mode on a bonded device.\n\n" 593 594 "set bonding primary (slave_id) (port_id)\n" 595 " Set the primary slave for a bonded device.\n\n" 596 597 "show bonding config (port_id)\n" 598 " Show the bonding config for port_id.\n\n" 599 600 "set bonding mac_addr (port_id) (address)\n" 601 " Set the MAC address of a bonded device.\n\n" 602 603 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)" 604 " Set Aggregation mode for IEEE802.3AD (mode 4)" 605 606 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n" 607 " Set the transmit balance policy for bonded device running in balance mode.\n\n" 608 609 "set bonding mon_period (port_id) (value)\n" 610 " Set the bonding link status monitoring polling period in ms.\n\n" 611 612 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n" 613 " Enable/disable dedicated queues for LACP control traffic.\n\n" 614 615 #endif 616 "set link-up port (port_id)\n" 617 " Set link up for a port.\n\n" 618 619 "set link-down port (port_id)\n" 620 " Set link down for a port.\n\n" 621 622 "E-tag set insertion on port-tag-id (value)" 623 " port (port_id) vf (vf_id)\n" 624 " Enable E-tag insertion for a VF on a port\n\n" 625 626 "E-tag set insertion off port (port_id) vf (vf_id)\n" 627 " Disable E-tag insertion for a VF on a port\n\n" 628 629 "E-tag set stripping (on|off) port (port_id)\n" 630 " Enable/disable E-tag stripping on a port\n\n" 631 632 "E-tag set forwarding (on|off) port (port_id)\n" 633 " Enable/disable E-tag based forwarding" 634 " on a port\n\n" 635 636 "E-tag set filter add e-tag-id (value) dst-pool" 637 " (pool_id) port (port_id)\n" 638 " Add an E-tag forwarding filter on a port\n\n" 639 640 "E-tag set filter del e-tag-id (value) port (port_id)\n" 641 " Delete an E-tag forwarding filter on a port\n\n" 642 643 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 644 "set port tm hierarchy default (port_id)\n" 645 " Set default traffic Management hierarchy on a port\n\n" 646 647 #endif 648 "ddp add (port_id) (profile_path[,backup_profile_path])\n" 649 " Load a profile package on a port\n\n" 650 651 "ddp del (port_id) (backup_profile_path)\n" 652 " Delete a profile package from a port\n\n" 653 654 "ptype mapping get (port_id) (valid_only)\n" 655 " Get ptype mapping on a port\n\n" 656 657 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n" 658 " Replace target with the pkt_type in ptype mapping\n\n" 659 660 "ptype mapping reset (port_id)\n" 661 " Reset ptype mapping on a port\n\n" 662 663 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" 664 " Update a ptype mapping item on a port\n\n" 665 666 "set port (port_id) queue-region region_id (value) " 667 "queue_start_index (value) queue_num (value)\n" 668 " Set a queue region on a port\n\n" 669 670 "set port (port_id) queue-region region_id (value) " 671 "flowtype (value)\n" 672 " Set a flowtype region index on a port\n\n" 673 674 "set port (port_id) queue-region UP (value) region_id (value)\n" 675 " Set the mapping of User Priority to " 676 "queue region on a port\n\n" 677 678 "set port (port_id) queue-region flush (on|off)\n" 679 " flush all queue region related configuration\n\n" 680 681 "show port meter cap (port_id)\n" 682 " Show port meter capability information\n\n" 683 684 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n" 685 " meter profile add - srtcm rfc 2697\n\n" 686 687 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n" 688 " meter profile add - trtcm rfc 2698\n\n" 689 690 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n" 691 " meter profile add - trtcm rfc 4115\n\n" 692 693 "del port meter profile (port_id) (profile_id)\n" 694 " meter profile delete\n\n" 695 696 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" 697 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n" 698 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 699 "(dscp_tbl_entry63)]\n" 700 " meter create\n\n" 701 702 "enable port meter (port_id) (mtr_id)\n" 703 " meter enable\n\n" 704 705 "disable port meter (port_id) (mtr_id)\n" 706 " meter disable\n\n" 707 708 "del port meter (port_id) (mtr_id)\n" 709 " meter delete\n\n" 710 711 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 712 " meter update meter profile\n\n" 713 714 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 715 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 716 " update meter dscp table entries\n\n" 717 718 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 719 "(action0) [(action1) (action2)]\n" 720 " meter update policer action\n\n" 721 722 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 723 " meter update stats\n\n" 724 725 "show port (port_id) queue-region\n" 726 " show all queue region related configuration info\n\n" 727 728 "add port tm node shaper profile (port_id) (shaper_profile_id)" 729 " (tb_rate) (tb_size) (packet_length_adjust)\n" 730 " Add port tm node private shaper profile.\n\n" 731 732 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 733 " Delete port tm node private shaper profile.\n\n" 734 735 "add port tm node shared shaper (port_id) (shared_shaper_id)" 736 " (shaper_profile_id)\n" 737 " Add/update port tm node shared shaper.\n\n" 738 739 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 740 " Delete port tm node shared shaper.\n\n" 741 742 "set port tm node shaper profile (port_id) (node_id)" 743 " (shaper_profile_id)\n" 744 " Set port tm node shaper profile.\n\n" 745 746 "add port tm node wred profile (port_id) (wred_profile_id)" 747 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 748 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 749 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 750 " Add port tm node wred profile.\n\n" 751 752 "del port tm node wred profile (port_id) (wred_profile_id)\n" 753 " Delete port tm node wred profile.\n\n" 754 755 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 756 " (priority) (weight) (level_id) (shaper_profile_id)" 757 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 758 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 759 " Add port tm nonleaf node.\n\n" 760 761 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 762 " (priority) (weight) (level_id) (shaper_profile_id)" 763 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 764 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 765 " Add port tm leaf node.\n\n" 766 767 "del port tm node (port_id) (node_id)\n" 768 " Delete port tm node.\n\n" 769 770 "set port tm node parent (port_id) (node_id) (parent_node_id)" 771 " (priority) (weight)\n" 772 " Set port tm node parent.\n\n" 773 774 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 775 " Commit tm hierarchy.\n\n" 776 777 , list_pkt_forwarding_modes() 778 ); 779 } 780 781 if (show_all || !strcmp(res->section, "ports")) { 782 783 cmdline_printf( 784 cl, 785 "\n" 786 "Port Operations:\n" 787 "----------------\n\n" 788 789 "port start (port_id|all)\n" 790 " Start all ports or port_id.\n\n" 791 792 "port stop (port_id|all)\n" 793 " Stop all ports or port_id.\n\n" 794 795 "port close (port_id|all)\n" 796 " Close all ports or port_id.\n\n" 797 798 "port attach (ident)\n" 799 " Attach physical or virtual dev by pci address or virtual device name\n\n" 800 801 "port detach (port_id)\n" 802 " Detach physical or virtual dev by port_id\n\n" 803 804 "port config (port_id|all)" 805 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)" 806 " duplex (half|full|auto)\n" 807 " Set speed and duplex for all ports or port_id\n\n" 808 809 "port config (port_id|all) loopback (mode)\n" 810 " Set loopback mode for all ports or port_id\n\n" 811 812 "port config all (rxq|txq|rxd|txd) (value)\n" 813 " Set number for rxq/txq/rxd/txd.\n\n" 814 815 "port config all max-pkt-len (value)\n" 816 " Set the max packet length.\n\n" 817 818 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|" 819 "hw-vlan-strip|hw-vlan-extend|drop-en)" 820 " (on|off)\n" 821 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en" 822 " for ports.\n\n" 823 824 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|" 825 "geneve|nvgre|none|<flowtype_id>)\n" 826 " Set the RSS mode.\n\n" 827 828 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 829 " Set the RSS redirection table.\n\n" 830 831 "port config (port_id) dcb vt (on|off) (traffic_class)" 832 " pfc (on|off)\n" 833 " Set the DCB mode.\n\n" 834 835 "port config all burst (value)\n" 836 " Set the number of packets per burst.\n\n" 837 838 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 839 " (value)\n" 840 " Set the ring prefetch/host/writeback threshold" 841 " for tx/rx queue.\n\n" 842 843 "port config all (txfreet|txrst|rxfreet) (value)\n" 844 " Set free threshold for rx/tx, or set" 845 " tx rs bit threshold.\n\n" 846 "port config mtu X value\n" 847 " Set the MTU of port X to a given value\n\n" 848 849 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 850 " Start/stop a rx/tx queue of port X. Only take effect" 851 " when port X is started\n\n" 852 853 "port config (port_id|all) l2-tunnel E-tag ether-type" 854 " (value)\n" 855 " Set the value of E-tag ether-type.\n\n" 856 857 "port config (port_id|all) l2-tunnel E-tag" 858 " (enable|disable)\n" 859 " Enable/disable the E-tag support.\n\n" 860 861 "port config (port_id) pctype mapping reset\n" 862 " Reset flow type to pctype mapping on a port\n\n" 863 864 "port config (port_id) pctype mapping update" 865 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 866 " Update a flow type to pctype mapping item on a port\n\n" 867 868 "port config (port_id) pctype (pctype_id) hash_inset|" 869 "fdir_inset|fdir_flx_inset get|set|clear field\n" 870 " (field_idx)\n" 871 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n" 872 873 "port config (port_id) pctype (pctype_id) hash_inset|" 874 "fdir_inset|fdir_flx_inset clear all" 875 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n" 876 ); 877 } 878 879 if (show_all || !strcmp(res->section, "registers")) { 880 881 cmdline_printf( 882 cl, 883 "\n" 884 "Registers:\n" 885 "----------\n\n" 886 887 "read reg (port_id) (address)\n" 888 " Display value of a port register.\n\n" 889 890 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 891 " Display a port register bit field.\n\n" 892 893 "read regbit (port_id) (address) (bit_x)\n" 894 " Display a single port register bit.\n\n" 895 896 "write reg (port_id) (address) (value)\n" 897 " Set value of a port register.\n\n" 898 899 "write regfield (port_id) (address) (bit_x) (bit_y)" 900 " (value)\n" 901 " Set bit field of a port register.\n\n" 902 903 "write regbit (port_id) (address) (bit_x) (value)\n" 904 " Set single bit value of a port register.\n\n" 905 ); 906 } 907 if (show_all || !strcmp(res->section, "filters")) { 908 909 cmdline_printf( 910 cl, 911 "\n" 912 "filters:\n" 913 "--------\n\n" 914 915 "ethertype_filter (port_id) (add|del)" 916 " (mac_addr|mac_ignr) (mac_address) ethertype" 917 " (ether_type) (drop|fwd) queue (queue_id)\n" 918 " Add/Del an ethertype filter.\n\n" 919 920 "2tuple_filter (port_id) (add|del)" 921 " dst_port (dst_port_value) protocol (protocol_value)" 922 " mask (mask_value) tcp_flags (tcp_flags_value)" 923 " priority (prio_value) queue (queue_id)\n" 924 " Add/Del a 2tuple filter.\n\n" 925 926 "5tuple_filter (port_id) (add|del)" 927 " dst_ip (dst_address) src_ip (src_address)" 928 " dst_port (dst_port_value) src_port (src_port_value)" 929 " protocol (protocol_value)" 930 " mask (mask_value) tcp_flags (tcp_flags_value)" 931 " priority (prio_value) queue (queue_id)\n" 932 " Add/Del a 5tuple filter.\n\n" 933 934 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)" 935 " Add/Del syn filter.\n\n" 936 937 "flex_filter (port_id) (add|del) len (len_value)" 938 " bytes (bytes_value) mask (mask_value)" 939 " priority (prio_value) queue (queue_id)\n" 940 " Add/Del a flex filter.\n\n" 941 942 "flow_director_filter (port_id) mode IP (add|del|update)" 943 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)" 944 " src (src_ip_address) dst (dst_ip_address)" 945 " tos (tos_value) proto (proto_value) ttl (ttl_value)" 946 " vlan (vlan_value) flexbytes (flexbytes_value)" 947 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 948 " fd_id (fd_id_value)\n" 949 " Add/Del an IP type flow director filter.\n\n" 950 951 "flow_director_filter (port_id) mode IP (add|del|update)" 952 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)" 953 " src (src_ip_address) (src_port)" 954 " dst (dst_ip_address) (dst_port)" 955 " tos (tos_value) ttl (ttl_value)" 956 " vlan (vlan_value) flexbytes (flexbytes_value)" 957 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 958 " fd_id (fd_id_value)\n" 959 " Add/Del an UDP/TCP type flow director filter.\n\n" 960 961 "flow_director_filter (port_id) mode IP (add|del|update)" 962 " flow (ipv4-sctp|ipv6-sctp)" 963 " src (src_ip_address) (src_port)" 964 " dst (dst_ip_address) (dst_port)" 965 " tag (verification_tag) " 966 " tos (tos_value) ttl (ttl_value)" 967 " vlan (vlan_value)" 968 " flexbytes (flexbytes_value) (drop|fwd)" 969 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 970 " Add/Del a SCTP type flow director filter.\n\n" 971 972 "flow_director_filter (port_id) mode IP (add|del|update)" 973 " flow l2_payload ether (ethertype)" 974 " flexbytes (flexbytes_value) (drop|fwd)" 975 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 976 " Add/Del a l2 payload type flow director filter.\n\n" 977 978 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)" 979 " mac (mac_address) vlan (vlan_value)" 980 " flexbytes (flexbytes_value) (drop|fwd)" 981 " queue (queue_id) fd_id (fd_id_value)\n" 982 " Add/Del a MAC-VLAN flow director filter.\n\n" 983 984 "flow_director_filter (port_id) mode Tunnel (add|del|update)" 985 " mac (mac_address) vlan (vlan_value)" 986 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)" 987 " flexbytes (flexbytes_value) (drop|fwd)" 988 " queue (queue_id) fd_id (fd_id_value)\n" 989 " Add/Del a Tunnel flow director filter.\n\n" 990 991 "flow_director_filter (port_id) mode raw (add|del|update)" 992 " flow (flow_id) (drop|fwd) queue (queue_id)" 993 " fd_id (fd_id_value) packet (packet file name)\n" 994 " Add/Del a raw type flow director filter.\n\n" 995 996 "flush_flow_director (port_id)\n" 997 " Flush all flow director entries of a device.\n\n" 998 999 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 1000 " src_mask (ipv4_src) (ipv6_src) (src_port)" 1001 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 1002 " Set flow director IP mask.\n\n" 1003 1004 "flow_director_mask (port_id) mode MAC-VLAN" 1005 " vlan (vlan_value)\n" 1006 " Set flow director MAC-VLAN mask.\n\n" 1007 1008 "flow_director_mask (port_id) mode Tunnel" 1009 " vlan (vlan_value) mac (mac_value)" 1010 " tunnel-type (tunnel_type_value)" 1011 " tunnel-id (tunnel_id_value)\n" 1012 " Set flow director Tunnel mask.\n\n" 1013 1014 "flow_director_flex_mask (port_id)" 1015 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 1016 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)" 1017 " (mask)\n" 1018 " Configure mask of flex payload.\n\n" 1019 1020 "flow_director_flex_payload (port_id)" 1021 " (raw|l2|l3|l4) (config)\n" 1022 " Configure flex payload selection.\n\n" 1023 1024 "get_sym_hash_ena_per_port (port_id)\n" 1025 " get symmetric hash enable configuration per port.\n\n" 1026 1027 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n" 1028 " set symmetric hash enable configuration per port" 1029 " to enable or disable.\n\n" 1030 1031 "get_hash_global_config (port_id)\n" 1032 " Get the global configurations of hash filters.\n\n" 1033 1034 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)" 1035 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1036 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)" 1037 " (enable|disable)\n" 1038 " Set the global configurations of hash filters.\n\n" 1039 1040 "set_hash_input_set (port_id) (ipv4|ipv4-frag|" 1041 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1042 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1043 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|" 1044 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|" 1045 "ipv6-next-header|udp-src-port|udp-dst-port|" 1046 "tcp-src-port|tcp-dst-port|sctp-src-port|" 1047 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|" 1048 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|" 1049 "fld-8th|none) (select|add)\n" 1050 " Set the input set for hash.\n\n" 1051 1052 "set_fdir_input_set (port_id) " 1053 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 1054 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1055 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|" 1056 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|" 1057 "ipv6-next-header|ipv6-hop-limits|udp-src-port|" 1058 "udp-dst-port|tcp-src-port|tcp-dst-port|" 1059 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)" 1060 " (select|add)\n" 1061 " Set the input set for FDir.\n\n" 1062 1063 "flow validate {port_id}" 1064 " [group {group_id}] [priority {level}]" 1065 " [ingress] [egress]" 1066 " pattern {item} [/ {item} [...]] / end" 1067 " actions {action} [/ {action} [...]] / end\n" 1068 " Check whether a flow rule can be created.\n\n" 1069 1070 "flow create {port_id}" 1071 " [group {group_id}] [priority {level}]" 1072 " [ingress] [egress]" 1073 " pattern {item} [/ {item} [...]] / end" 1074 " actions {action} [/ {action} [...]] / end\n" 1075 " Create a flow rule.\n\n" 1076 1077 "flow destroy {port_id} rule {rule_id} [...]\n" 1078 " Destroy specific flow rules.\n\n" 1079 1080 "flow flush {port_id}\n" 1081 " Destroy all flow rules.\n\n" 1082 1083 "flow query {port_id} {rule_id} {action}\n" 1084 " Query an existing flow rule.\n\n" 1085 1086 "flow list {port_id} [group {group_id}] [...]\n" 1087 " List existing flow rules sorted by priority," 1088 " filtered by group identifiers.\n\n" 1089 1090 "flow isolate {port_id} {boolean}\n" 1091 " Restrict ingress traffic to the defined" 1092 " flow rules\n\n" 1093 ); 1094 } 1095 } 1096 1097 cmdline_parse_token_string_t cmd_help_long_help = 1098 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1099 1100 cmdline_parse_token_string_t cmd_help_long_section = 1101 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1102 "all#control#display#config#" 1103 "ports#registers#filters"); 1104 1105 cmdline_parse_inst_t cmd_help_long = { 1106 .f = cmd_help_long_parsed, 1107 .data = NULL, 1108 .help_str = "help all|control|display|config|ports|register|filters: " 1109 "Show help", 1110 .tokens = { 1111 (void *)&cmd_help_long_help, 1112 (void *)&cmd_help_long_section, 1113 NULL, 1114 }, 1115 }; 1116 1117 1118 /* *** start/stop/close all ports *** */ 1119 struct cmd_operate_port_result { 1120 cmdline_fixed_string_t keyword; 1121 cmdline_fixed_string_t name; 1122 cmdline_fixed_string_t value; 1123 }; 1124 1125 static void cmd_operate_port_parsed(void *parsed_result, 1126 __attribute__((unused)) struct cmdline *cl, 1127 __attribute__((unused)) void *data) 1128 { 1129 struct cmd_operate_port_result *res = parsed_result; 1130 1131 if (!strcmp(res->name, "start")) 1132 start_port(RTE_PORT_ALL); 1133 else if (!strcmp(res->name, "stop")) 1134 stop_port(RTE_PORT_ALL); 1135 else if (!strcmp(res->name, "close")) 1136 close_port(RTE_PORT_ALL); 1137 else if (!strcmp(res->name, "reset")) 1138 reset_port(RTE_PORT_ALL); 1139 else 1140 printf("Unknown parameter\n"); 1141 } 1142 1143 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1144 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1145 "port"); 1146 cmdline_parse_token_string_t cmd_operate_port_all_port = 1147 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1148 "start#stop#close#reset"); 1149 cmdline_parse_token_string_t cmd_operate_port_all_all = 1150 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1151 1152 cmdline_parse_inst_t cmd_operate_port = { 1153 .f = cmd_operate_port_parsed, 1154 .data = NULL, 1155 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports", 1156 .tokens = { 1157 (void *)&cmd_operate_port_all_cmd, 1158 (void *)&cmd_operate_port_all_port, 1159 (void *)&cmd_operate_port_all_all, 1160 NULL, 1161 }, 1162 }; 1163 1164 /* *** start/stop/close specific port *** */ 1165 struct cmd_operate_specific_port_result { 1166 cmdline_fixed_string_t keyword; 1167 cmdline_fixed_string_t name; 1168 uint8_t value; 1169 }; 1170 1171 static void cmd_operate_specific_port_parsed(void *parsed_result, 1172 __attribute__((unused)) struct cmdline *cl, 1173 __attribute__((unused)) void *data) 1174 { 1175 struct cmd_operate_specific_port_result *res = parsed_result; 1176 1177 if (!strcmp(res->name, "start")) 1178 start_port(res->value); 1179 else if (!strcmp(res->name, "stop")) 1180 stop_port(res->value); 1181 else if (!strcmp(res->name, "close")) 1182 close_port(res->value); 1183 else if (!strcmp(res->name, "reset")) 1184 reset_port(res->value); 1185 else 1186 printf("Unknown parameter\n"); 1187 } 1188 1189 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1190 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1191 keyword, "port"); 1192 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1193 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1194 name, "start#stop#close#reset"); 1195 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1196 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1197 value, UINT8); 1198 1199 cmdline_parse_inst_t cmd_operate_specific_port = { 1200 .f = cmd_operate_specific_port_parsed, 1201 .data = NULL, 1202 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id", 1203 .tokens = { 1204 (void *)&cmd_operate_specific_port_cmd, 1205 (void *)&cmd_operate_specific_port_port, 1206 (void *)&cmd_operate_specific_port_id, 1207 NULL, 1208 }, 1209 }; 1210 1211 /* *** attach a specified port *** */ 1212 struct cmd_operate_attach_port_result { 1213 cmdline_fixed_string_t port; 1214 cmdline_fixed_string_t keyword; 1215 cmdline_fixed_string_t identifier; 1216 }; 1217 1218 static void cmd_operate_attach_port_parsed(void *parsed_result, 1219 __attribute__((unused)) struct cmdline *cl, 1220 __attribute__((unused)) void *data) 1221 { 1222 struct cmd_operate_attach_port_result *res = parsed_result; 1223 1224 if (!strcmp(res->keyword, "attach")) 1225 attach_port(res->identifier); 1226 else 1227 printf("Unknown parameter\n"); 1228 } 1229 1230 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1231 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1232 port, "port"); 1233 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1234 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1235 keyword, "attach"); 1236 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1237 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1238 identifier, NULL); 1239 1240 cmdline_parse_inst_t cmd_operate_attach_port = { 1241 .f = cmd_operate_attach_port_parsed, 1242 .data = NULL, 1243 .help_str = "port attach <identifier>: " 1244 "(identifier: pci address or virtual dev name)", 1245 .tokens = { 1246 (void *)&cmd_operate_attach_port_port, 1247 (void *)&cmd_operate_attach_port_keyword, 1248 (void *)&cmd_operate_attach_port_identifier, 1249 NULL, 1250 }, 1251 }; 1252 1253 /* *** detach a specified port *** */ 1254 struct cmd_operate_detach_port_result { 1255 cmdline_fixed_string_t port; 1256 cmdline_fixed_string_t keyword; 1257 portid_t port_id; 1258 }; 1259 1260 static void cmd_operate_detach_port_parsed(void *parsed_result, 1261 __attribute__((unused)) struct cmdline *cl, 1262 __attribute__((unused)) void *data) 1263 { 1264 struct cmd_operate_detach_port_result *res = parsed_result; 1265 1266 if (!strcmp(res->keyword, "detach")) 1267 detach_port(res->port_id); 1268 else 1269 printf("Unknown parameter\n"); 1270 } 1271 1272 cmdline_parse_token_string_t cmd_operate_detach_port_port = 1273 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1274 port, "port"); 1275 cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1277 keyword, "detach"); 1278 cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1279 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1280 port_id, UINT16); 1281 1282 cmdline_parse_inst_t cmd_operate_detach_port = { 1283 .f = cmd_operate_detach_port_parsed, 1284 .data = NULL, 1285 .help_str = "port detach <port_id>", 1286 .tokens = { 1287 (void *)&cmd_operate_detach_port_port, 1288 (void *)&cmd_operate_detach_port_keyword, 1289 (void *)&cmd_operate_detach_port_port_id, 1290 NULL, 1291 }, 1292 }; 1293 1294 /* *** configure speed for all ports *** */ 1295 struct cmd_config_speed_all { 1296 cmdline_fixed_string_t port; 1297 cmdline_fixed_string_t keyword; 1298 cmdline_fixed_string_t all; 1299 cmdline_fixed_string_t item1; 1300 cmdline_fixed_string_t item2; 1301 cmdline_fixed_string_t value1; 1302 cmdline_fixed_string_t value2; 1303 }; 1304 1305 static int 1306 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1307 { 1308 1309 int duplex; 1310 1311 if (!strcmp(duplexstr, "half")) { 1312 duplex = ETH_LINK_HALF_DUPLEX; 1313 } else if (!strcmp(duplexstr, "full")) { 1314 duplex = ETH_LINK_FULL_DUPLEX; 1315 } else if (!strcmp(duplexstr, "auto")) { 1316 duplex = ETH_LINK_FULL_DUPLEX; 1317 } else { 1318 printf("Unknown duplex parameter\n"); 1319 return -1; 1320 } 1321 1322 if (!strcmp(speedstr, "10")) { 1323 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1324 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M; 1325 } else if (!strcmp(speedstr, "100")) { 1326 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1327 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M; 1328 } else { 1329 if (duplex != ETH_LINK_FULL_DUPLEX) { 1330 printf("Invalid speed/duplex parameters\n"); 1331 return -1; 1332 } 1333 if (!strcmp(speedstr, "1000")) { 1334 *speed = ETH_LINK_SPEED_1G; 1335 } else if (!strcmp(speedstr, "10000")) { 1336 *speed = ETH_LINK_SPEED_10G; 1337 } else if (!strcmp(speedstr, "25000")) { 1338 *speed = ETH_LINK_SPEED_25G; 1339 } else if (!strcmp(speedstr, "40000")) { 1340 *speed = ETH_LINK_SPEED_40G; 1341 } else if (!strcmp(speedstr, "50000")) { 1342 *speed = ETH_LINK_SPEED_50G; 1343 } else if (!strcmp(speedstr, "100000")) { 1344 *speed = ETH_LINK_SPEED_100G; 1345 } else if (!strcmp(speedstr, "auto")) { 1346 *speed = ETH_LINK_SPEED_AUTONEG; 1347 } else { 1348 printf("Unknown speed parameter\n"); 1349 return -1; 1350 } 1351 } 1352 1353 return 0; 1354 } 1355 1356 static void 1357 cmd_config_speed_all_parsed(void *parsed_result, 1358 __attribute__((unused)) struct cmdline *cl, 1359 __attribute__((unused)) void *data) 1360 { 1361 struct cmd_config_speed_all *res = parsed_result; 1362 uint32_t link_speed; 1363 portid_t pid; 1364 1365 if (!all_ports_stopped()) { 1366 printf("Please stop all ports first\n"); 1367 return; 1368 } 1369 1370 if (parse_and_check_speed_duplex(res->value1, res->value2, 1371 &link_speed) < 0) 1372 return; 1373 1374 RTE_ETH_FOREACH_DEV(pid) { 1375 ports[pid].dev_conf.link_speeds = link_speed; 1376 } 1377 1378 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1379 } 1380 1381 cmdline_parse_token_string_t cmd_config_speed_all_port = 1382 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1383 cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1384 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1385 "config"); 1386 cmdline_parse_token_string_t cmd_config_speed_all_all = 1387 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1388 cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1389 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1390 cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1391 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1392 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1393 cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1394 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1395 cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1396 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1397 "half#full#auto"); 1398 1399 cmdline_parse_inst_t cmd_config_speed_all = { 1400 .f = cmd_config_speed_all_parsed, 1401 .data = NULL, 1402 .help_str = "port config all speed " 1403 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1404 "half|full|auto", 1405 .tokens = { 1406 (void *)&cmd_config_speed_all_port, 1407 (void *)&cmd_config_speed_all_keyword, 1408 (void *)&cmd_config_speed_all_all, 1409 (void *)&cmd_config_speed_all_item1, 1410 (void *)&cmd_config_speed_all_value1, 1411 (void *)&cmd_config_speed_all_item2, 1412 (void *)&cmd_config_speed_all_value2, 1413 NULL, 1414 }, 1415 }; 1416 1417 /* *** configure speed for specific port *** */ 1418 struct cmd_config_speed_specific { 1419 cmdline_fixed_string_t port; 1420 cmdline_fixed_string_t keyword; 1421 uint8_t id; 1422 cmdline_fixed_string_t item1; 1423 cmdline_fixed_string_t item2; 1424 cmdline_fixed_string_t value1; 1425 cmdline_fixed_string_t value2; 1426 }; 1427 1428 static void 1429 cmd_config_speed_specific_parsed(void *parsed_result, 1430 __attribute__((unused)) struct cmdline *cl, 1431 __attribute__((unused)) void *data) 1432 { 1433 struct cmd_config_speed_specific *res = parsed_result; 1434 uint32_t link_speed; 1435 1436 if (!all_ports_stopped()) { 1437 printf("Please stop all ports first\n"); 1438 return; 1439 } 1440 1441 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1442 return; 1443 1444 if (parse_and_check_speed_duplex(res->value1, res->value2, 1445 &link_speed) < 0) 1446 return; 1447 1448 ports[res->id].dev_conf.link_speeds = link_speed; 1449 1450 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1451 } 1452 1453 1454 cmdline_parse_token_string_t cmd_config_speed_specific_port = 1455 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1456 "port"); 1457 cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1458 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1459 "config"); 1460 cmdline_parse_token_num_t cmd_config_speed_specific_id = 1461 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8); 1462 cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1463 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1464 "speed"); 1465 cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1466 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1467 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1468 cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1470 "duplex"); 1471 cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1473 "half#full#auto"); 1474 1475 cmdline_parse_inst_t cmd_config_speed_specific = { 1476 .f = cmd_config_speed_specific_parsed, 1477 .data = NULL, 1478 .help_str = "port config <port_id> speed " 1479 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1480 "half|full|auto", 1481 .tokens = { 1482 (void *)&cmd_config_speed_specific_port, 1483 (void *)&cmd_config_speed_specific_keyword, 1484 (void *)&cmd_config_speed_specific_id, 1485 (void *)&cmd_config_speed_specific_item1, 1486 (void *)&cmd_config_speed_specific_value1, 1487 (void *)&cmd_config_speed_specific_item2, 1488 (void *)&cmd_config_speed_specific_value2, 1489 NULL, 1490 }, 1491 }; 1492 1493 /* *** configure loopback for all ports *** */ 1494 struct cmd_config_loopback_all { 1495 cmdline_fixed_string_t port; 1496 cmdline_fixed_string_t keyword; 1497 cmdline_fixed_string_t all; 1498 cmdline_fixed_string_t item; 1499 uint32_t mode; 1500 }; 1501 1502 static void 1503 cmd_config_loopback_all_parsed(void *parsed_result, 1504 __attribute__((unused)) struct cmdline *cl, 1505 __attribute__((unused)) void *data) 1506 { 1507 struct cmd_config_loopback_all *res = parsed_result; 1508 portid_t pid; 1509 1510 if (!all_ports_stopped()) { 1511 printf("Please stop all ports first\n"); 1512 return; 1513 } 1514 1515 RTE_ETH_FOREACH_DEV(pid) { 1516 ports[pid].dev_conf.lpbk_mode = res->mode; 1517 } 1518 1519 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1520 } 1521 1522 cmdline_parse_token_string_t cmd_config_loopback_all_port = 1523 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port"); 1524 cmdline_parse_token_string_t cmd_config_loopback_all_keyword = 1525 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword, 1526 "config"); 1527 cmdline_parse_token_string_t cmd_config_loopback_all_all = 1528 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all"); 1529 cmdline_parse_token_string_t cmd_config_loopback_all_item = 1530 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item, 1531 "loopback"); 1532 cmdline_parse_token_num_t cmd_config_loopback_all_mode = 1533 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32); 1534 1535 cmdline_parse_inst_t cmd_config_loopback_all = { 1536 .f = cmd_config_loopback_all_parsed, 1537 .data = NULL, 1538 .help_str = "port config all loopback <mode>", 1539 .tokens = { 1540 (void *)&cmd_config_loopback_all_port, 1541 (void *)&cmd_config_loopback_all_keyword, 1542 (void *)&cmd_config_loopback_all_all, 1543 (void *)&cmd_config_loopback_all_item, 1544 (void *)&cmd_config_loopback_all_mode, 1545 NULL, 1546 }, 1547 }; 1548 1549 /* *** configure loopback for specific port *** */ 1550 struct cmd_config_loopback_specific { 1551 cmdline_fixed_string_t port; 1552 cmdline_fixed_string_t keyword; 1553 uint16_t port_id; 1554 cmdline_fixed_string_t item; 1555 uint32_t mode; 1556 }; 1557 1558 static void 1559 cmd_config_loopback_specific_parsed(void *parsed_result, 1560 __attribute__((unused)) struct cmdline *cl, 1561 __attribute__((unused)) void *data) 1562 { 1563 struct cmd_config_loopback_specific *res = parsed_result; 1564 1565 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 1566 return; 1567 1568 if (!port_is_stopped(res->port_id)) { 1569 printf("Please stop port %u first\n", res->port_id); 1570 return; 1571 } 1572 1573 ports[res->port_id].dev_conf.lpbk_mode = res->mode; 1574 1575 cmd_reconfig_device_queue(res->port_id, 1, 1); 1576 } 1577 1578 1579 cmdline_parse_token_string_t cmd_config_loopback_specific_port = 1580 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port, 1581 "port"); 1582 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword = 1583 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword, 1584 "config"); 1585 cmdline_parse_token_num_t cmd_config_loopback_specific_id = 1586 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id, 1587 UINT16); 1588 cmdline_parse_token_string_t cmd_config_loopback_specific_item = 1589 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item, 1590 "loopback"); 1591 cmdline_parse_token_num_t cmd_config_loopback_specific_mode = 1592 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode, 1593 UINT32); 1594 1595 cmdline_parse_inst_t cmd_config_loopback_specific = { 1596 .f = cmd_config_loopback_specific_parsed, 1597 .data = NULL, 1598 .help_str = "port config <port_id> loopback <mode>", 1599 .tokens = { 1600 (void *)&cmd_config_loopback_specific_port, 1601 (void *)&cmd_config_loopback_specific_keyword, 1602 (void *)&cmd_config_loopback_specific_id, 1603 (void *)&cmd_config_loopback_specific_item, 1604 (void *)&cmd_config_loopback_specific_mode, 1605 NULL, 1606 }, 1607 }; 1608 1609 /* *** configure txq/rxq, txd/rxd *** */ 1610 struct cmd_config_rx_tx { 1611 cmdline_fixed_string_t port; 1612 cmdline_fixed_string_t keyword; 1613 cmdline_fixed_string_t all; 1614 cmdline_fixed_string_t name; 1615 uint16_t value; 1616 }; 1617 1618 static void 1619 cmd_config_rx_tx_parsed(void *parsed_result, 1620 __attribute__((unused)) struct cmdline *cl, 1621 __attribute__((unused)) void *data) 1622 { 1623 struct cmd_config_rx_tx *res = parsed_result; 1624 1625 if (!all_ports_stopped()) { 1626 printf("Please stop all ports first\n"); 1627 return; 1628 } 1629 if (!strcmp(res->name, "rxq")) { 1630 if (!res->value && !nb_txq) { 1631 printf("Warning: Either rx or tx queues should be non zero\n"); 1632 return; 1633 } 1634 if (check_nb_rxq(res->value) != 0) 1635 return; 1636 nb_rxq = res->value; 1637 } 1638 else if (!strcmp(res->name, "txq")) { 1639 if (!res->value && !nb_rxq) { 1640 printf("Warning: Either rx or tx queues should be non zero\n"); 1641 return; 1642 } 1643 if (check_nb_txq(res->value) != 0) 1644 return; 1645 nb_txq = res->value; 1646 } 1647 else if (!strcmp(res->name, "rxd")) { 1648 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) { 1649 printf("rxd %d invalid - must be > 0 && <= %d\n", 1650 res->value, RTE_TEST_RX_DESC_MAX); 1651 return; 1652 } 1653 nb_rxd = res->value; 1654 } else if (!strcmp(res->name, "txd")) { 1655 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) { 1656 printf("txd %d invalid - must be > 0 && <= %d\n", 1657 res->value, RTE_TEST_TX_DESC_MAX); 1658 return; 1659 } 1660 nb_txd = res->value; 1661 } else { 1662 printf("Unknown parameter\n"); 1663 return; 1664 } 1665 1666 fwd_config_setup(); 1667 1668 init_port_config(); 1669 1670 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1671 } 1672 1673 cmdline_parse_token_string_t cmd_config_rx_tx_port = 1674 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1675 cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1676 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1677 cmdline_parse_token_string_t cmd_config_rx_tx_all = 1678 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1679 cmdline_parse_token_string_t cmd_config_rx_tx_name = 1680 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1681 "rxq#txq#rxd#txd"); 1682 cmdline_parse_token_num_t cmd_config_rx_tx_value = 1683 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16); 1684 1685 cmdline_parse_inst_t cmd_config_rx_tx = { 1686 .f = cmd_config_rx_tx_parsed, 1687 .data = NULL, 1688 .help_str = "port config all rxq|txq|rxd|txd <value>", 1689 .tokens = { 1690 (void *)&cmd_config_rx_tx_port, 1691 (void *)&cmd_config_rx_tx_keyword, 1692 (void *)&cmd_config_rx_tx_all, 1693 (void *)&cmd_config_rx_tx_name, 1694 (void *)&cmd_config_rx_tx_value, 1695 NULL, 1696 }, 1697 }; 1698 1699 /* *** config max packet length *** */ 1700 struct cmd_config_max_pkt_len_result { 1701 cmdline_fixed_string_t port; 1702 cmdline_fixed_string_t keyword; 1703 cmdline_fixed_string_t all; 1704 cmdline_fixed_string_t name; 1705 uint32_t value; 1706 }; 1707 1708 static void 1709 cmd_config_max_pkt_len_parsed(void *parsed_result, 1710 __attribute__((unused)) struct cmdline *cl, 1711 __attribute__((unused)) void *data) 1712 { 1713 struct cmd_config_max_pkt_len_result *res = parsed_result; 1714 portid_t pid; 1715 1716 if (!all_ports_stopped()) { 1717 printf("Please stop all ports first\n"); 1718 return; 1719 } 1720 1721 RTE_ETH_FOREACH_DEV(pid) { 1722 struct rte_port *port = &ports[pid]; 1723 uint64_t rx_offloads = port->dev_conf.rxmode.offloads; 1724 1725 if (!strcmp(res->name, "max-pkt-len")) { 1726 if (res->value < ETHER_MIN_LEN) { 1727 printf("max-pkt-len can not be less than %d\n", 1728 ETHER_MIN_LEN); 1729 return; 1730 } 1731 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len) 1732 return; 1733 1734 port->dev_conf.rxmode.max_rx_pkt_len = res->value; 1735 if (res->value > ETHER_MAX_LEN) 1736 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; 1737 else 1738 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; 1739 port->dev_conf.rxmode.offloads = rx_offloads; 1740 } else { 1741 printf("Unknown parameter\n"); 1742 return; 1743 } 1744 } 1745 1746 init_port_config(); 1747 1748 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1749 } 1750 1751 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 1752 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 1753 "port"); 1754 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 1755 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 1756 "config"); 1757 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 1758 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 1759 "all"); 1760 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 1761 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 1762 "max-pkt-len"); 1763 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 1764 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 1765 UINT32); 1766 1767 cmdline_parse_inst_t cmd_config_max_pkt_len = { 1768 .f = cmd_config_max_pkt_len_parsed, 1769 .data = NULL, 1770 .help_str = "port config all max-pkt-len <value>", 1771 .tokens = { 1772 (void *)&cmd_config_max_pkt_len_port, 1773 (void *)&cmd_config_max_pkt_len_keyword, 1774 (void *)&cmd_config_max_pkt_len_all, 1775 (void *)&cmd_config_max_pkt_len_name, 1776 (void *)&cmd_config_max_pkt_len_value, 1777 NULL, 1778 }, 1779 }; 1780 1781 /* *** configure port MTU *** */ 1782 struct cmd_config_mtu_result { 1783 cmdline_fixed_string_t port; 1784 cmdline_fixed_string_t keyword; 1785 cmdline_fixed_string_t mtu; 1786 portid_t port_id; 1787 uint16_t value; 1788 }; 1789 1790 static void 1791 cmd_config_mtu_parsed(void *parsed_result, 1792 __attribute__((unused)) struct cmdline *cl, 1793 __attribute__((unused)) void *data) 1794 { 1795 struct cmd_config_mtu_result *res = parsed_result; 1796 1797 if (res->value < ETHER_MIN_LEN) { 1798 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN); 1799 return; 1800 } 1801 port_mtu_set(res->port_id, res->value); 1802 } 1803 1804 cmdline_parse_token_string_t cmd_config_mtu_port = 1805 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 1806 "port"); 1807 cmdline_parse_token_string_t cmd_config_mtu_keyword = 1808 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 1809 "config"); 1810 cmdline_parse_token_string_t cmd_config_mtu_mtu = 1811 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 1812 "mtu"); 1813 cmdline_parse_token_num_t cmd_config_mtu_port_id = 1814 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16); 1815 cmdline_parse_token_num_t cmd_config_mtu_value = 1816 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16); 1817 1818 cmdline_parse_inst_t cmd_config_mtu = { 1819 .f = cmd_config_mtu_parsed, 1820 .data = NULL, 1821 .help_str = "port config mtu <port_id> <value>", 1822 .tokens = { 1823 (void *)&cmd_config_mtu_port, 1824 (void *)&cmd_config_mtu_keyword, 1825 (void *)&cmd_config_mtu_mtu, 1826 (void *)&cmd_config_mtu_port_id, 1827 (void *)&cmd_config_mtu_value, 1828 NULL, 1829 }, 1830 }; 1831 1832 /* *** configure rx mode *** */ 1833 struct cmd_config_rx_mode_flag { 1834 cmdline_fixed_string_t port; 1835 cmdline_fixed_string_t keyword; 1836 cmdline_fixed_string_t all; 1837 cmdline_fixed_string_t name; 1838 cmdline_fixed_string_t value; 1839 }; 1840 1841 static void 1842 cmd_config_rx_mode_flag_parsed(void *parsed_result, 1843 __attribute__((unused)) struct cmdline *cl, 1844 __attribute__((unused)) void *data) 1845 { 1846 struct cmd_config_rx_mode_flag *res = parsed_result; 1847 portid_t pid; 1848 1849 if (!all_ports_stopped()) { 1850 printf("Please stop all ports first\n"); 1851 return; 1852 } 1853 1854 RTE_ETH_FOREACH_DEV(pid) { 1855 struct rte_port *port; 1856 uint64_t rx_offloads; 1857 1858 port = &ports[pid]; 1859 rx_offloads = port->dev_conf.rxmode.offloads; 1860 if (!strcmp(res->name, "crc-strip")) { 1861 if (!strcmp(res->value, "on")) 1862 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP; 1863 else if (!strcmp(res->value, "off")) 1864 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP; 1865 else { 1866 printf("Unknown parameter\n"); 1867 return; 1868 } 1869 } else if (!strcmp(res->name, "scatter")) { 1870 if (!strcmp(res->value, "on")) { 1871 rx_offloads |= DEV_RX_OFFLOAD_SCATTER; 1872 } else if (!strcmp(res->value, "off")) { 1873 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER; 1874 } else { 1875 printf("Unknown parameter\n"); 1876 return; 1877 } 1878 } else if (!strcmp(res->name, "rx-cksum")) { 1879 if (!strcmp(res->value, "on")) 1880 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM; 1881 else if (!strcmp(res->value, "off")) 1882 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM; 1883 else { 1884 printf("Unknown parameter\n"); 1885 return; 1886 } 1887 } else if (!strcmp(res->name, "rx-timestamp")) { 1888 if (!strcmp(res->value, "on")) 1889 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP; 1890 else if (!strcmp(res->value, "off")) 1891 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP; 1892 else { 1893 printf("Unknown parameter\n"); 1894 return; 1895 } 1896 } else if (!strcmp(res->name, "hw-vlan")) { 1897 if (!strcmp(res->value, "on")) { 1898 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER | 1899 DEV_RX_OFFLOAD_VLAN_STRIP); 1900 } else if (!strcmp(res->value, "off")) { 1901 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER | 1902 DEV_RX_OFFLOAD_VLAN_STRIP); 1903 } else { 1904 printf("Unknown parameter\n"); 1905 return; 1906 } 1907 } else if (!strcmp(res->name, "hw-vlan-filter")) { 1908 if (!strcmp(res->value, "on")) 1909 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER; 1910 else if (!strcmp(res->value, "off")) 1911 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER; 1912 else { 1913 printf("Unknown parameter\n"); 1914 return; 1915 } 1916 } else if (!strcmp(res->name, "hw-vlan-strip")) { 1917 if (!strcmp(res->value, "on")) 1918 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; 1919 else if (!strcmp(res->value, "off")) 1920 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; 1921 else { 1922 printf("Unknown parameter\n"); 1923 return; 1924 } 1925 } else if (!strcmp(res->name, "hw-vlan-extend")) { 1926 if (!strcmp(res->value, "on")) 1927 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND; 1928 else if (!strcmp(res->value, "off")) 1929 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND; 1930 else { 1931 printf("Unknown parameter\n"); 1932 return; 1933 } 1934 } else if (!strcmp(res->name, "drop-en")) { 1935 if (!strcmp(res->value, "on")) 1936 rx_drop_en = 1; 1937 else if (!strcmp(res->value, "off")) 1938 rx_drop_en = 0; 1939 else { 1940 printf("Unknown parameter\n"); 1941 return; 1942 } 1943 } else { 1944 printf("Unknown parameter\n"); 1945 return; 1946 } 1947 port->dev_conf.rxmode.offloads = rx_offloads; 1948 } 1949 1950 init_port_config(); 1951 1952 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1953 } 1954 1955 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 1956 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 1957 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 1958 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 1959 "config"); 1960 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 1961 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 1962 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 1963 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 1964 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#" 1965 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend"); 1966 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 1967 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 1968 "on#off"); 1969 1970 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 1971 .f = cmd_config_rx_mode_flag_parsed, 1972 .data = NULL, 1973 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|" 1974 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off", 1975 .tokens = { 1976 (void *)&cmd_config_rx_mode_flag_port, 1977 (void *)&cmd_config_rx_mode_flag_keyword, 1978 (void *)&cmd_config_rx_mode_flag_all, 1979 (void *)&cmd_config_rx_mode_flag_name, 1980 (void *)&cmd_config_rx_mode_flag_value, 1981 NULL, 1982 }, 1983 }; 1984 1985 /* *** configure rss *** */ 1986 struct cmd_config_rss { 1987 cmdline_fixed_string_t port; 1988 cmdline_fixed_string_t keyword; 1989 cmdline_fixed_string_t all; 1990 cmdline_fixed_string_t name; 1991 cmdline_fixed_string_t value; 1992 }; 1993 1994 static void 1995 cmd_config_rss_parsed(void *parsed_result, 1996 __attribute__((unused)) struct cmdline *cl, 1997 __attribute__((unused)) void *data) 1998 { 1999 struct cmd_config_rss *res = parsed_result; 2000 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2001 int diag; 2002 uint16_t i; 2003 2004 if (!strcmp(res->value, "all")) 2005 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP | 2006 ETH_RSS_UDP | ETH_RSS_SCTP | 2007 ETH_RSS_L2_PAYLOAD; 2008 else if (!strcmp(res->value, "ip")) 2009 rss_conf.rss_hf = ETH_RSS_IP; 2010 else if (!strcmp(res->value, "udp")) 2011 rss_conf.rss_hf = ETH_RSS_UDP; 2012 else if (!strcmp(res->value, "tcp")) 2013 rss_conf.rss_hf = ETH_RSS_TCP; 2014 else if (!strcmp(res->value, "sctp")) 2015 rss_conf.rss_hf = ETH_RSS_SCTP; 2016 else if (!strcmp(res->value, "ether")) 2017 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 2018 else if (!strcmp(res->value, "port")) 2019 rss_conf.rss_hf = ETH_RSS_PORT; 2020 else if (!strcmp(res->value, "vxlan")) 2021 rss_conf.rss_hf = ETH_RSS_VXLAN; 2022 else if (!strcmp(res->value, "geneve")) 2023 rss_conf.rss_hf = ETH_RSS_GENEVE; 2024 else if (!strcmp(res->value, "nvgre")) 2025 rss_conf.rss_hf = ETH_RSS_NVGRE; 2026 else if (!strcmp(res->value, "none")) 2027 rss_conf.rss_hf = 0; 2028 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 2029 atoi(res->value) < 64) 2030 rss_conf.rss_hf = 1ULL << atoi(res->value); 2031 else { 2032 printf("Unknown parameter\n"); 2033 return; 2034 } 2035 rss_conf.rss_key = NULL; 2036 RTE_ETH_FOREACH_DEV(i) { 2037 diag = rte_eth_dev_rss_hash_update(i, &rss_conf); 2038 if (diag < 0) 2039 printf("Configuration of RSS hash at ethernet port %d " 2040 "failed with error (%d): %s.\n", 2041 i, -diag, strerror(-diag)); 2042 } 2043 } 2044 2045 cmdline_parse_token_string_t cmd_config_rss_port = 2046 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2047 cmdline_parse_token_string_t cmd_config_rss_keyword = 2048 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2049 cmdline_parse_token_string_t cmd_config_rss_all = 2050 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2051 cmdline_parse_token_string_t cmd_config_rss_name = 2052 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2053 cmdline_parse_token_string_t cmd_config_rss_value = 2054 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2055 2056 cmdline_parse_inst_t cmd_config_rss = { 2057 .f = cmd_config_rss_parsed, 2058 .data = NULL, 2059 .help_str = "port config all rss " 2060 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>", 2061 .tokens = { 2062 (void *)&cmd_config_rss_port, 2063 (void *)&cmd_config_rss_keyword, 2064 (void *)&cmd_config_rss_all, 2065 (void *)&cmd_config_rss_name, 2066 (void *)&cmd_config_rss_value, 2067 NULL, 2068 }, 2069 }; 2070 2071 /* *** configure rss hash key *** */ 2072 struct cmd_config_rss_hash_key { 2073 cmdline_fixed_string_t port; 2074 cmdline_fixed_string_t config; 2075 portid_t port_id; 2076 cmdline_fixed_string_t rss_hash_key; 2077 cmdline_fixed_string_t rss_type; 2078 cmdline_fixed_string_t key; 2079 }; 2080 2081 static uint8_t 2082 hexa_digit_to_value(char hexa_digit) 2083 { 2084 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2085 return (uint8_t) (hexa_digit - '0'); 2086 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2087 return (uint8_t) ((hexa_digit - 'a') + 10); 2088 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2089 return (uint8_t) ((hexa_digit - 'A') + 10); 2090 /* Invalid hexa digit */ 2091 return 0xFF; 2092 } 2093 2094 static uint8_t 2095 parse_and_check_key_hexa_digit(char *key, int idx) 2096 { 2097 uint8_t hexa_v; 2098 2099 hexa_v = hexa_digit_to_value(key[idx]); 2100 if (hexa_v == 0xFF) 2101 printf("invalid key: character %c at position %d is not a " 2102 "valid hexa digit\n", key[idx], idx); 2103 return hexa_v; 2104 } 2105 2106 static void 2107 cmd_config_rss_hash_key_parsed(void *parsed_result, 2108 __attribute__((unused)) struct cmdline *cl, 2109 __attribute__((unused)) void *data) 2110 { 2111 struct cmd_config_rss_hash_key *res = parsed_result; 2112 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2113 uint8_t xdgt0; 2114 uint8_t xdgt1; 2115 int i; 2116 struct rte_eth_dev_info dev_info; 2117 uint8_t hash_key_size; 2118 uint32_t key_len; 2119 2120 memset(&dev_info, 0, sizeof(dev_info)); 2121 rte_eth_dev_info_get(res->port_id, &dev_info); 2122 if (dev_info.hash_key_size > 0 && 2123 dev_info.hash_key_size <= sizeof(hash_key)) 2124 hash_key_size = dev_info.hash_key_size; 2125 else { 2126 printf("dev_info did not provide a valid hash key size\n"); 2127 return; 2128 } 2129 /* Check the length of the RSS hash key */ 2130 key_len = strlen(res->key); 2131 if (key_len != (hash_key_size * 2)) { 2132 printf("key length: %d invalid - key must be a string of %d" 2133 " hexa-decimal numbers\n", 2134 (int) key_len, hash_key_size * 2); 2135 return; 2136 } 2137 /* Translate RSS hash key into binary representation */ 2138 for (i = 0; i < hash_key_size; i++) { 2139 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2140 if (xdgt0 == 0xFF) 2141 return; 2142 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2143 if (xdgt1 == 0xFF) 2144 return; 2145 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2146 } 2147 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2148 hash_key_size); 2149 } 2150 2151 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2152 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2153 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2154 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2155 "config"); 2156 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2157 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16); 2158 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2159 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2160 rss_hash_key, "rss-hash-key"); 2161 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2162 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2163 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2164 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2165 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2166 "ipv6-tcp-ex#ipv6-udp-ex"); 2167 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2168 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2169 2170 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2171 .f = cmd_config_rss_hash_key_parsed, 2172 .data = NULL, 2173 .help_str = "port config <port_id> rss-hash-key " 2174 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2175 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2176 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex " 2177 "<string of hex digits (variable length, NIC dependent)>", 2178 .tokens = { 2179 (void *)&cmd_config_rss_hash_key_port, 2180 (void *)&cmd_config_rss_hash_key_config, 2181 (void *)&cmd_config_rss_hash_key_port_id, 2182 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2183 (void *)&cmd_config_rss_hash_key_rss_type, 2184 (void *)&cmd_config_rss_hash_key_value, 2185 NULL, 2186 }, 2187 }; 2188 2189 /* *** configure port rxq/txq start/stop *** */ 2190 struct cmd_config_rxtx_queue { 2191 cmdline_fixed_string_t port; 2192 portid_t portid; 2193 cmdline_fixed_string_t rxtxq; 2194 uint16_t qid; 2195 cmdline_fixed_string_t opname; 2196 }; 2197 2198 static void 2199 cmd_config_rxtx_queue_parsed(void *parsed_result, 2200 __attribute__((unused)) struct cmdline *cl, 2201 __attribute__((unused)) void *data) 2202 { 2203 struct cmd_config_rxtx_queue *res = parsed_result; 2204 uint8_t isrx; 2205 uint8_t isstart; 2206 int ret = 0; 2207 2208 if (test_done == 0) { 2209 printf("Please stop forwarding first\n"); 2210 return; 2211 } 2212 2213 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2214 return; 2215 2216 if (port_is_started(res->portid) != 1) { 2217 printf("Please start port %u first\n", res->portid); 2218 return; 2219 } 2220 2221 if (!strcmp(res->rxtxq, "rxq")) 2222 isrx = 1; 2223 else if (!strcmp(res->rxtxq, "txq")) 2224 isrx = 0; 2225 else { 2226 printf("Unknown parameter\n"); 2227 return; 2228 } 2229 2230 if (isrx && rx_queue_id_is_invalid(res->qid)) 2231 return; 2232 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2233 return; 2234 2235 if (!strcmp(res->opname, "start")) 2236 isstart = 1; 2237 else if (!strcmp(res->opname, "stop")) 2238 isstart = 0; 2239 else { 2240 printf("Unknown parameter\n"); 2241 return; 2242 } 2243 2244 if (isstart && isrx) 2245 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2246 else if (!isstart && isrx) 2247 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2248 else if (isstart && !isrx) 2249 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2250 else 2251 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2252 2253 if (ret == -ENOTSUP) 2254 printf("Function not supported in PMD driver\n"); 2255 } 2256 2257 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2258 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2259 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2260 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16); 2261 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2262 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2263 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2264 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16); 2265 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2266 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2267 "start#stop"); 2268 2269 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2270 .f = cmd_config_rxtx_queue_parsed, 2271 .data = NULL, 2272 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2273 .tokens = { 2274 (void *)&cmd_config_speed_all_port, 2275 (void *)&cmd_config_rxtx_queue_portid, 2276 (void *)&cmd_config_rxtx_queue_rxtxq, 2277 (void *)&cmd_config_rxtx_queue_qid, 2278 (void *)&cmd_config_rxtx_queue_opname, 2279 NULL, 2280 }, 2281 }; 2282 2283 /* *** Configure RSS RETA *** */ 2284 struct cmd_config_rss_reta { 2285 cmdline_fixed_string_t port; 2286 cmdline_fixed_string_t keyword; 2287 portid_t port_id; 2288 cmdline_fixed_string_t name; 2289 cmdline_fixed_string_t list_name; 2290 cmdline_fixed_string_t list_of_items; 2291 }; 2292 2293 static int 2294 parse_reta_config(const char *str, 2295 struct rte_eth_rss_reta_entry64 *reta_conf, 2296 uint16_t nb_entries) 2297 { 2298 int i; 2299 unsigned size; 2300 uint16_t hash_index, idx, shift; 2301 uint16_t nb_queue; 2302 char s[256]; 2303 const char *p, *p0 = str; 2304 char *end; 2305 enum fieldnames { 2306 FLD_HASH_INDEX = 0, 2307 FLD_QUEUE, 2308 _NUM_FLD 2309 }; 2310 unsigned long int_fld[_NUM_FLD]; 2311 char *str_fld[_NUM_FLD]; 2312 2313 while ((p = strchr(p0,'(')) != NULL) { 2314 ++p; 2315 if((p0 = strchr(p,')')) == NULL) 2316 return -1; 2317 2318 size = p0 - p; 2319 if(size >= sizeof(s)) 2320 return -1; 2321 2322 snprintf(s, sizeof(s), "%.*s", size, p); 2323 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2324 return -1; 2325 for (i = 0; i < _NUM_FLD; i++) { 2326 errno = 0; 2327 int_fld[i] = strtoul(str_fld[i], &end, 0); 2328 if (errno != 0 || end == str_fld[i] || 2329 int_fld[i] > 65535) 2330 return -1; 2331 } 2332 2333 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2334 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2335 2336 if (hash_index >= nb_entries) { 2337 printf("Invalid RETA hash index=%d\n", hash_index); 2338 return -1; 2339 } 2340 2341 idx = hash_index / RTE_RETA_GROUP_SIZE; 2342 shift = hash_index % RTE_RETA_GROUP_SIZE; 2343 reta_conf[idx].mask |= (1ULL << shift); 2344 reta_conf[idx].reta[shift] = nb_queue; 2345 } 2346 2347 return 0; 2348 } 2349 2350 static void 2351 cmd_set_rss_reta_parsed(void *parsed_result, 2352 __attribute__((unused)) struct cmdline *cl, 2353 __attribute__((unused)) void *data) 2354 { 2355 int ret; 2356 struct rte_eth_dev_info dev_info; 2357 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2358 struct cmd_config_rss_reta *res = parsed_result; 2359 2360 memset(&dev_info, 0, sizeof(dev_info)); 2361 rte_eth_dev_info_get(res->port_id, &dev_info); 2362 if (dev_info.reta_size == 0) { 2363 printf("Redirection table size is 0 which is " 2364 "invalid for RSS\n"); 2365 return; 2366 } else 2367 printf("The reta size of port %d is %u\n", 2368 res->port_id, dev_info.reta_size); 2369 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 2370 printf("Currently do not support more than %u entries of " 2371 "redirection table\n", ETH_RSS_RETA_SIZE_512); 2372 return; 2373 } 2374 2375 memset(reta_conf, 0, sizeof(reta_conf)); 2376 if (!strcmp(res->list_name, "reta")) { 2377 if (parse_reta_config(res->list_of_items, reta_conf, 2378 dev_info.reta_size)) { 2379 printf("Invalid RSS Redirection Table " 2380 "config entered\n"); 2381 return; 2382 } 2383 ret = rte_eth_dev_rss_reta_update(res->port_id, 2384 reta_conf, dev_info.reta_size); 2385 if (ret != 0) 2386 printf("Bad redirection table parameter, " 2387 "return code = %d \n", ret); 2388 } 2389 } 2390 2391 cmdline_parse_token_string_t cmd_config_rss_reta_port = 2392 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 2393 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 2394 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 2395 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 2396 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16); 2397 cmdline_parse_token_string_t cmd_config_rss_reta_name = 2398 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 2399 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 2400 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 2401 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 2402 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 2403 NULL); 2404 cmdline_parse_inst_t cmd_config_rss_reta = { 2405 .f = cmd_set_rss_reta_parsed, 2406 .data = NULL, 2407 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 2408 .tokens = { 2409 (void *)&cmd_config_rss_reta_port, 2410 (void *)&cmd_config_rss_reta_keyword, 2411 (void *)&cmd_config_rss_reta_port_id, 2412 (void *)&cmd_config_rss_reta_name, 2413 (void *)&cmd_config_rss_reta_list_name, 2414 (void *)&cmd_config_rss_reta_list_of_items, 2415 NULL, 2416 }, 2417 }; 2418 2419 /* *** SHOW PORT RETA INFO *** */ 2420 struct cmd_showport_reta { 2421 cmdline_fixed_string_t show; 2422 cmdline_fixed_string_t port; 2423 portid_t port_id; 2424 cmdline_fixed_string_t rss; 2425 cmdline_fixed_string_t reta; 2426 uint16_t size; 2427 cmdline_fixed_string_t list_of_items; 2428 }; 2429 2430 static int 2431 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 2432 uint16_t nb_entries, 2433 char *str) 2434 { 2435 uint32_t size; 2436 const char *p, *p0 = str; 2437 char s[256]; 2438 char *end; 2439 char *str_fld[8]; 2440 uint16_t i; 2441 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 2442 RTE_RETA_GROUP_SIZE; 2443 int ret; 2444 2445 p = strchr(p0, '('); 2446 if (p == NULL) 2447 return -1; 2448 p++; 2449 p0 = strchr(p, ')'); 2450 if (p0 == NULL) 2451 return -1; 2452 size = p0 - p; 2453 if (size >= sizeof(s)) { 2454 printf("The string size exceeds the internal buffer size\n"); 2455 return -1; 2456 } 2457 snprintf(s, sizeof(s), "%.*s", size, p); 2458 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 2459 if (ret <= 0 || ret != num) { 2460 printf("The bits of masks do not match the number of " 2461 "reta entries: %u\n", num); 2462 return -1; 2463 } 2464 for (i = 0; i < ret; i++) 2465 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 2466 2467 return 0; 2468 } 2469 2470 static void 2471 cmd_showport_reta_parsed(void *parsed_result, 2472 __attribute__((unused)) struct cmdline *cl, 2473 __attribute__((unused)) void *data) 2474 { 2475 struct cmd_showport_reta *res = parsed_result; 2476 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2477 struct rte_eth_dev_info dev_info; 2478 uint16_t max_reta_size; 2479 2480 memset(&dev_info, 0, sizeof(dev_info)); 2481 rte_eth_dev_info_get(res->port_id, &dev_info); 2482 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 2483 if (res->size == 0 || res->size > max_reta_size) { 2484 printf("Invalid redirection table size: %u (1-%u)\n", 2485 res->size, max_reta_size); 2486 return; 2487 } 2488 2489 memset(reta_conf, 0, sizeof(reta_conf)); 2490 if (showport_parse_reta_config(reta_conf, res->size, 2491 res->list_of_items) < 0) { 2492 printf("Invalid string: %s for reta masks\n", 2493 res->list_of_items); 2494 return; 2495 } 2496 port_rss_reta_info(res->port_id, reta_conf, res->size); 2497 } 2498 2499 cmdline_parse_token_string_t cmd_showport_reta_show = 2500 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 2501 cmdline_parse_token_string_t cmd_showport_reta_port = 2502 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 2503 cmdline_parse_token_num_t cmd_showport_reta_port_id = 2504 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16); 2505 cmdline_parse_token_string_t cmd_showport_reta_rss = 2506 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 2507 cmdline_parse_token_string_t cmd_showport_reta_reta = 2508 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 2509 cmdline_parse_token_num_t cmd_showport_reta_size = 2510 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16); 2511 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 2512 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 2513 list_of_items, NULL); 2514 2515 cmdline_parse_inst_t cmd_showport_reta = { 2516 .f = cmd_showport_reta_parsed, 2517 .data = NULL, 2518 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 2519 .tokens = { 2520 (void *)&cmd_showport_reta_show, 2521 (void *)&cmd_showport_reta_port, 2522 (void *)&cmd_showport_reta_port_id, 2523 (void *)&cmd_showport_reta_rss, 2524 (void *)&cmd_showport_reta_reta, 2525 (void *)&cmd_showport_reta_size, 2526 (void *)&cmd_showport_reta_list_of_items, 2527 NULL, 2528 }, 2529 }; 2530 2531 /* *** Show RSS hash configuration *** */ 2532 struct cmd_showport_rss_hash { 2533 cmdline_fixed_string_t show; 2534 cmdline_fixed_string_t port; 2535 portid_t port_id; 2536 cmdline_fixed_string_t rss_hash; 2537 cmdline_fixed_string_t rss_type; 2538 cmdline_fixed_string_t key; /* optional argument */ 2539 }; 2540 2541 static void cmd_showport_rss_hash_parsed(void *parsed_result, 2542 __attribute__((unused)) struct cmdline *cl, 2543 void *show_rss_key) 2544 { 2545 struct cmd_showport_rss_hash *res = parsed_result; 2546 2547 port_rss_hash_conf_show(res->port_id, res->rss_type, 2548 show_rss_key != NULL); 2549 } 2550 2551 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 2552 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 2553 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 2554 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 2555 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 2556 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16); 2557 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 2558 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 2559 "rss-hash"); 2560 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info = 2561 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type, 2562 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2563 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2564 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2565 "ipv6-tcp-ex#ipv6-udp-ex"); 2566 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 2567 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 2568 2569 cmdline_parse_inst_t cmd_showport_rss_hash = { 2570 .f = cmd_showport_rss_hash_parsed, 2571 .data = NULL, 2572 .help_str = "show port <port_id> rss-hash " 2573 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2574 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2575 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex", 2576 .tokens = { 2577 (void *)&cmd_showport_rss_hash_show, 2578 (void *)&cmd_showport_rss_hash_port, 2579 (void *)&cmd_showport_rss_hash_port_id, 2580 (void *)&cmd_showport_rss_hash_rss_hash, 2581 (void *)&cmd_showport_rss_hash_rss_hash_info, 2582 NULL, 2583 }, 2584 }; 2585 2586 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 2587 .f = cmd_showport_rss_hash_parsed, 2588 .data = (void *)1, 2589 .help_str = "show port <port_id> rss-hash " 2590 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2591 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2592 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key", 2593 .tokens = { 2594 (void *)&cmd_showport_rss_hash_show, 2595 (void *)&cmd_showport_rss_hash_port, 2596 (void *)&cmd_showport_rss_hash_port_id, 2597 (void *)&cmd_showport_rss_hash_rss_hash, 2598 (void *)&cmd_showport_rss_hash_rss_hash_info, 2599 (void *)&cmd_showport_rss_hash_rss_key, 2600 NULL, 2601 }, 2602 }; 2603 2604 /* *** Configure DCB *** */ 2605 struct cmd_config_dcb { 2606 cmdline_fixed_string_t port; 2607 cmdline_fixed_string_t config; 2608 portid_t port_id; 2609 cmdline_fixed_string_t dcb; 2610 cmdline_fixed_string_t vt; 2611 cmdline_fixed_string_t vt_en; 2612 uint8_t num_tcs; 2613 cmdline_fixed_string_t pfc; 2614 cmdline_fixed_string_t pfc_en; 2615 }; 2616 2617 static void 2618 cmd_config_dcb_parsed(void *parsed_result, 2619 __attribute__((unused)) struct cmdline *cl, 2620 __attribute__((unused)) void *data) 2621 { 2622 struct cmd_config_dcb *res = parsed_result; 2623 portid_t port_id = res->port_id; 2624 struct rte_port *port; 2625 uint8_t pfc_en; 2626 int ret; 2627 2628 port = &ports[port_id]; 2629 /** Check if the port is not started **/ 2630 if (port->port_status != RTE_PORT_STOPPED) { 2631 printf("Please stop port %d first\n", port_id); 2632 return; 2633 } 2634 2635 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 2636 printf("The invalid number of traffic class," 2637 " only 4 or 8 allowed.\n"); 2638 return; 2639 } 2640 2641 if (nb_fwd_lcores < res->num_tcs) { 2642 printf("nb_cores shouldn't be less than number of TCs.\n"); 2643 return; 2644 } 2645 if (!strncmp(res->pfc_en, "on", 2)) 2646 pfc_en = 1; 2647 else 2648 pfc_en = 0; 2649 2650 /* DCB in VT mode */ 2651 if (!strncmp(res->vt_en, "on", 2)) 2652 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 2653 (enum rte_eth_nb_tcs)res->num_tcs, 2654 pfc_en); 2655 else 2656 ret = init_port_dcb_config(port_id, DCB_ENABLED, 2657 (enum rte_eth_nb_tcs)res->num_tcs, 2658 pfc_en); 2659 2660 2661 if (ret != 0) { 2662 printf("Cannot initialize network ports.\n"); 2663 return; 2664 } 2665 2666 cmd_reconfig_device_queue(port_id, 1, 1); 2667 } 2668 2669 cmdline_parse_token_string_t cmd_config_dcb_port = 2670 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 2671 cmdline_parse_token_string_t cmd_config_dcb_config = 2672 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 2673 cmdline_parse_token_num_t cmd_config_dcb_port_id = 2674 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16); 2675 cmdline_parse_token_string_t cmd_config_dcb_dcb = 2676 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 2677 cmdline_parse_token_string_t cmd_config_dcb_vt = 2678 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 2679 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 2680 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 2681 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 2682 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8); 2683 cmdline_parse_token_string_t cmd_config_dcb_pfc= 2684 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 2685 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 2686 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 2687 2688 cmdline_parse_inst_t cmd_config_dcb = { 2689 .f = cmd_config_dcb_parsed, 2690 .data = NULL, 2691 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 2692 .tokens = { 2693 (void *)&cmd_config_dcb_port, 2694 (void *)&cmd_config_dcb_config, 2695 (void *)&cmd_config_dcb_port_id, 2696 (void *)&cmd_config_dcb_dcb, 2697 (void *)&cmd_config_dcb_vt, 2698 (void *)&cmd_config_dcb_vt_en, 2699 (void *)&cmd_config_dcb_num_tcs, 2700 (void *)&cmd_config_dcb_pfc, 2701 (void *)&cmd_config_dcb_pfc_en, 2702 NULL, 2703 }, 2704 }; 2705 2706 /* *** configure number of packets per burst *** */ 2707 struct cmd_config_burst { 2708 cmdline_fixed_string_t port; 2709 cmdline_fixed_string_t keyword; 2710 cmdline_fixed_string_t all; 2711 cmdline_fixed_string_t name; 2712 uint16_t value; 2713 }; 2714 2715 static void 2716 cmd_config_burst_parsed(void *parsed_result, 2717 __attribute__((unused)) struct cmdline *cl, 2718 __attribute__((unused)) void *data) 2719 { 2720 struct cmd_config_burst *res = parsed_result; 2721 struct rte_eth_dev_info dev_info; 2722 uint16_t rec_nb_pkts; 2723 2724 if (!all_ports_stopped()) { 2725 printf("Please stop all ports first\n"); 2726 return; 2727 } 2728 2729 if (!strcmp(res->name, "burst")) { 2730 if (res->value == 0) { 2731 /* If user gives a value of zero, query the PMD for 2732 * its recommended Rx burst size. Testpmd uses a single 2733 * size for all ports, so assume all ports are the same 2734 * NIC model and use the values from Port 0. 2735 */ 2736 rte_eth_dev_info_get(0, &dev_info); 2737 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 2738 2739 if (rec_nb_pkts == 0) { 2740 printf("PMD does not recommend a burst size.\n" 2741 "User provided value must be between" 2742 " 1 and %d\n", MAX_PKT_BURST); 2743 return; 2744 } else if (rec_nb_pkts > MAX_PKT_BURST) { 2745 printf("PMD recommended burst size of %d" 2746 " exceeds maximum value of %d\n", 2747 rec_nb_pkts, MAX_PKT_BURST); 2748 return; 2749 } 2750 printf("Using PMD-provided burst value of %d\n", 2751 rec_nb_pkts); 2752 nb_pkt_per_burst = rec_nb_pkts; 2753 } else if (res->value > MAX_PKT_BURST) { 2754 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST); 2755 return; 2756 } else 2757 nb_pkt_per_burst = res->value; 2758 } else { 2759 printf("Unknown parameter\n"); 2760 return; 2761 } 2762 2763 init_port_config(); 2764 2765 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2766 } 2767 2768 cmdline_parse_token_string_t cmd_config_burst_port = 2769 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 2770 cmdline_parse_token_string_t cmd_config_burst_keyword = 2771 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 2772 cmdline_parse_token_string_t cmd_config_burst_all = 2773 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 2774 cmdline_parse_token_string_t cmd_config_burst_name = 2775 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 2776 cmdline_parse_token_num_t cmd_config_burst_value = 2777 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16); 2778 2779 cmdline_parse_inst_t cmd_config_burst = { 2780 .f = cmd_config_burst_parsed, 2781 .data = NULL, 2782 .help_str = "port config all burst <value>", 2783 .tokens = { 2784 (void *)&cmd_config_burst_port, 2785 (void *)&cmd_config_burst_keyword, 2786 (void *)&cmd_config_burst_all, 2787 (void *)&cmd_config_burst_name, 2788 (void *)&cmd_config_burst_value, 2789 NULL, 2790 }, 2791 }; 2792 2793 /* *** configure rx/tx queues *** */ 2794 struct cmd_config_thresh { 2795 cmdline_fixed_string_t port; 2796 cmdline_fixed_string_t keyword; 2797 cmdline_fixed_string_t all; 2798 cmdline_fixed_string_t name; 2799 uint8_t value; 2800 }; 2801 2802 static void 2803 cmd_config_thresh_parsed(void *parsed_result, 2804 __attribute__((unused)) struct cmdline *cl, 2805 __attribute__((unused)) void *data) 2806 { 2807 struct cmd_config_thresh *res = parsed_result; 2808 2809 if (!all_ports_stopped()) { 2810 printf("Please stop all ports first\n"); 2811 return; 2812 } 2813 2814 if (!strcmp(res->name, "txpt")) 2815 tx_pthresh = res->value; 2816 else if(!strcmp(res->name, "txht")) 2817 tx_hthresh = res->value; 2818 else if(!strcmp(res->name, "txwt")) 2819 tx_wthresh = res->value; 2820 else if(!strcmp(res->name, "rxpt")) 2821 rx_pthresh = res->value; 2822 else if(!strcmp(res->name, "rxht")) 2823 rx_hthresh = res->value; 2824 else if(!strcmp(res->name, "rxwt")) 2825 rx_wthresh = res->value; 2826 else { 2827 printf("Unknown parameter\n"); 2828 return; 2829 } 2830 2831 init_port_config(); 2832 2833 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2834 } 2835 2836 cmdline_parse_token_string_t cmd_config_thresh_port = 2837 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 2838 cmdline_parse_token_string_t cmd_config_thresh_keyword = 2839 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 2840 cmdline_parse_token_string_t cmd_config_thresh_all = 2841 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 2842 cmdline_parse_token_string_t cmd_config_thresh_name = 2843 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 2844 "txpt#txht#txwt#rxpt#rxht#rxwt"); 2845 cmdline_parse_token_num_t cmd_config_thresh_value = 2846 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8); 2847 2848 cmdline_parse_inst_t cmd_config_thresh = { 2849 .f = cmd_config_thresh_parsed, 2850 .data = NULL, 2851 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 2852 .tokens = { 2853 (void *)&cmd_config_thresh_port, 2854 (void *)&cmd_config_thresh_keyword, 2855 (void *)&cmd_config_thresh_all, 2856 (void *)&cmd_config_thresh_name, 2857 (void *)&cmd_config_thresh_value, 2858 NULL, 2859 }, 2860 }; 2861 2862 /* *** configure free/rs threshold *** */ 2863 struct cmd_config_threshold { 2864 cmdline_fixed_string_t port; 2865 cmdline_fixed_string_t keyword; 2866 cmdline_fixed_string_t all; 2867 cmdline_fixed_string_t name; 2868 uint16_t value; 2869 }; 2870 2871 static void 2872 cmd_config_threshold_parsed(void *parsed_result, 2873 __attribute__((unused)) struct cmdline *cl, 2874 __attribute__((unused)) void *data) 2875 { 2876 struct cmd_config_threshold *res = parsed_result; 2877 2878 if (!all_ports_stopped()) { 2879 printf("Please stop all ports first\n"); 2880 return; 2881 } 2882 2883 if (!strcmp(res->name, "txfreet")) 2884 tx_free_thresh = res->value; 2885 else if (!strcmp(res->name, "txrst")) 2886 tx_rs_thresh = res->value; 2887 else if (!strcmp(res->name, "rxfreet")) 2888 rx_free_thresh = res->value; 2889 else { 2890 printf("Unknown parameter\n"); 2891 return; 2892 } 2893 2894 init_port_config(); 2895 2896 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2897 } 2898 2899 cmdline_parse_token_string_t cmd_config_threshold_port = 2900 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 2901 cmdline_parse_token_string_t cmd_config_threshold_keyword = 2902 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 2903 "config"); 2904 cmdline_parse_token_string_t cmd_config_threshold_all = 2905 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 2906 cmdline_parse_token_string_t cmd_config_threshold_name = 2907 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 2908 "txfreet#txrst#rxfreet"); 2909 cmdline_parse_token_num_t cmd_config_threshold_value = 2910 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16); 2911 2912 cmdline_parse_inst_t cmd_config_threshold = { 2913 .f = cmd_config_threshold_parsed, 2914 .data = NULL, 2915 .help_str = "port config all txfreet|txrst|rxfreet <value>", 2916 .tokens = { 2917 (void *)&cmd_config_threshold_port, 2918 (void *)&cmd_config_threshold_keyword, 2919 (void *)&cmd_config_threshold_all, 2920 (void *)&cmd_config_threshold_name, 2921 (void *)&cmd_config_threshold_value, 2922 NULL, 2923 }, 2924 }; 2925 2926 /* *** stop *** */ 2927 struct cmd_stop_result { 2928 cmdline_fixed_string_t stop; 2929 }; 2930 2931 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result, 2932 __attribute__((unused)) struct cmdline *cl, 2933 __attribute__((unused)) void *data) 2934 { 2935 stop_packet_forwarding(); 2936 } 2937 2938 cmdline_parse_token_string_t cmd_stop_stop = 2939 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 2940 2941 cmdline_parse_inst_t cmd_stop = { 2942 .f = cmd_stop_parsed, 2943 .data = NULL, 2944 .help_str = "stop: Stop packet forwarding", 2945 .tokens = { 2946 (void *)&cmd_stop_stop, 2947 NULL, 2948 }, 2949 }; 2950 2951 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 2952 2953 unsigned int 2954 parse_item_list(char* str, const char* item_name, unsigned int max_items, 2955 unsigned int *parsed_items, int check_unique_values) 2956 { 2957 unsigned int nb_item; 2958 unsigned int value; 2959 unsigned int i; 2960 unsigned int j; 2961 int value_ok; 2962 char c; 2963 2964 /* 2965 * First parse all items in the list and store their value. 2966 */ 2967 value = 0; 2968 nb_item = 0; 2969 value_ok = 0; 2970 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 2971 c = str[i]; 2972 if ((c >= '0') && (c <= '9')) { 2973 value = (unsigned int) (value * 10 + (c - '0')); 2974 value_ok = 1; 2975 continue; 2976 } 2977 if (c != ',') { 2978 printf("character %c is not a decimal digit\n", c); 2979 return 0; 2980 } 2981 if (! value_ok) { 2982 printf("No valid value before comma\n"); 2983 return 0; 2984 } 2985 if (nb_item < max_items) { 2986 parsed_items[nb_item] = value; 2987 value_ok = 0; 2988 value = 0; 2989 } 2990 nb_item++; 2991 } 2992 if (nb_item >= max_items) { 2993 printf("Number of %s = %u > %u (maximum items)\n", 2994 item_name, nb_item + 1, max_items); 2995 return 0; 2996 } 2997 parsed_items[nb_item++] = value; 2998 if (! check_unique_values) 2999 return nb_item; 3000 3001 /* 3002 * Then, check that all values in the list are differents. 3003 * No optimization here... 3004 */ 3005 for (i = 0; i < nb_item; i++) { 3006 for (j = i + 1; j < nb_item; j++) { 3007 if (parsed_items[j] == parsed_items[i]) { 3008 printf("duplicated %s %u at index %u and %u\n", 3009 item_name, parsed_items[i], i, j); 3010 return 0; 3011 } 3012 } 3013 } 3014 return nb_item; 3015 } 3016 3017 struct cmd_set_list_result { 3018 cmdline_fixed_string_t cmd_keyword; 3019 cmdline_fixed_string_t list_name; 3020 cmdline_fixed_string_t list_of_items; 3021 }; 3022 3023 static void cmd_set_list_parsed(void *parsed_result, 3024 __attribute__((unused)) struct cmdline *cl, 3025 __attribute__((unused)) void *data) 3026 { 3027 struct cmd_set_list_result *res; 3028 union { 3029 unsigned int lcorelist[RTE_MAX_LCORE]; 3030 unsigned int portlist[RTE_MAX_ETHPORTS]; 3031 } parsed_items; 3032 unsigned int nb_item; 3033 3034 if (test_done == 0) { 3035 printf("Please stop forwarding first\n"); 3036 return; 3037 } 3038 3039 res = parsed_result; 3040 if (!strcmp(res->list_name, "corelist")) { 3041 nb_item = parse_item_list(res->list_of_items, "core", 3042 RTE_MAX_LCORE, 3043 parsed_items.lcorelist, 1); 3044 if (nb_item > 0) { 3045 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3046 fwd_config_setup(); 3047 } 3048 return; 3049 } 3050 if (!strcmp(res->list_name, "portlist")) { 3051 nb_item = parse_item_list(res->list_of_items, "port", 3052 RTE_MAX_ETHPORTS, 3053 parsed_items.portlist, 1); 3054 if (nb_item > 0) { 3055 set_fwd_ports_list(parsed_items.portlist, nb_item); 3056 fwd_config_setup(); 3057 } 3058 } 3059 } 3060 3061 cmdline_parse_token_string_t cmd_set_list_keyword = 3062 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3063 "set"); 3064 cmdline_parse_token_string_t cmd_set_list_name = 3065 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3066 "corelist#portlist"); 3067 cmdline_parse_token_string_t cmd_set_list_of_items = 3068 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3069 NULL); 3070 3071 cmdline_parse_inst_t cmd_set_fwd_list = { 3072 .f = cmd_set_list_parsed, 3073 .data = NULL, 3074 .help_str = "set corelist|portlist <list0[,list1]*>", 3075 .tokens = { 3076 (void *)&cmd_set_list_keyword, 3077 (void *)&cmd_set_list_name, 3078 (void *)&cmd_set_list_of_items, 3079 NULL, 3080 }, 3081 }; 3082 3083 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3084 3085 struct cmd_setmask_result { 3086 cmdline_fixed_string_t set; 3087 cmdline_fixed_string_t mask; 3088 uint64_t hexavalue; 3089 }; 3090 3091 static void cmd_set_mask_parsed(void *parsed_result, 3092 __attribute__((unused)) struct cmdline *cl, 3093 __attribute__((unused)) void *data) 3094 { 3095 struct cmd_setmask_result *res = parsed_result; 3096 3097 if (test_done == 0) { 3098 printf("Please stop forwarding first\n"); 3099 return; 3100 } 3101 if (!strcmp(res->mask, "coremask")) { 3102 set_fwd_lcores_mask(res->hexavalue); 3103 fwd_config_setup(); 3104 } else if (!strcmp(res->mask, "portmask")) { 3105 set_fwd_ports_mask(res->hexavalue); 3106 fwd_config_setup(); 3107 } 3108 } 3109 3110 cmdline_parse_token_string_t cmd_setmask_set = 3111 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3112 cmdline_parse_token_string_t cmd_setmask_mask = 3113 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3114 "coremask#portmask"); 3115 cmdline_parse_token_num_t cmd_setmask_value = 3116 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64); 3117 3118 cmdline_parse_inst_t cmd_set_fwd_mask = { 3119 .f = cmd_set_mask_parsed, 3120 .data = NULL, 3121 .help_str = "set coremask|portmask <hexadecimal value>", 3122 .tokens = { 3123 (void *)&cmd_setmask_set, 3124 (void *)&cmd_setmask_mask, 3125 (void *)&cmd_setmask_value, 3126 NULL, 3127 }, 3128 }; 3129 3130 /* 3131 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3132 */ 3133 struct cmd_set_result { 3134 cmdline_fixed_string_t set; 3135 cmdline_fixed_string_t what; 3136 uint16_t value; 3137 }; 3138 3139 static void cmd_set_parsed(void *parsed_result, 3140 __attribute__((unused)) struct cmdline *cl, 3141 __attribute__((unused)) void *data) 3142 { 3143 struct cmd_set_result *res = parsed_result; 3144 if (!strcmp(res->what, "nbport")) { 3145 set_fwd_ports_number(res->value); 3146 fwd_config_setup(); 3147 } else if (!strcmp(res->what, "nbcore")) { 3148 set_fwd_lcores_number(res->value); 3149 fwd_config_setup(); 3150 } else if (!strcmp(res->what, "burst")) 3151 set_nb_pkt_per_burst(res->value); 3152 else if (!strcmp(res->what, "verbose")) 3153 set_verbose_level(res->value); 3154 } 3155 3156 cmdline_parse_token_string_t cmd_set_set = 3157 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3158 cmdline_parse_token_string_t cmd_set_what = 3159 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3160 "nbport#nbcore#burst#verbose"); 3161 cmdline_parse_token_num_t cmd_set_value = 3162 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16); 3163 3164 cmdline_parse_inst_t cmd_set_numbers = { 3165 .f = cmd_set_parsed, 3166 .data = NULL, 3167 .help_str = "set nbport|nbcore|burst|verbose <value>", 3168 .tokens = { 3169 (void *)&cmd_set_set, 3170 (void *)&cmd_set_what, 3171 (void *)&cmd_set_value, 3172 NULL, 3173 }, 3174 }; 3175 3176 /* *** SET LOG LEVEL CONFIGURATION *** */ 3177 3178 struct cmd_set_log_result { 3179 cmdline_fixed_string_t set; 3180 cmdline_fixed_string_t log; 3181 cmdline_fixed_string_t type; 3182 uint32_t level; 3183 }; 3184 3185 static void 3186 cmd_set_log_parsed(void *parsed_result, 3187 __attribute__((unused)) struct cmdline *cl, 3188 __attribute__((unused)) void *data) 3189 { 3190 struct cmd_set_log_result *res; 3191 int ret; 3192 3193 res = parsed_result; 3194 if (!strcmp(res->type, "global")) 3195 rte_log_set_global_level(res->level); 3196 else { 3197 ret = rte_log_set_level_regexp(res->type, res->level); 3198 if (ret < 0) 3199 printf("Unable to set log level\n"); 3200 } 3201 } 3202 3203 cmdline_parse_token_string_t cmd_set_log_set = 3204 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3205 cmdline_parse_token_string_t cmd_set_log_log = 3206 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3207 cmdline_parse_token_string_t cmd_set_log_type = 3208 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3209 cmdline_parse_token_num_t cmd_set_log_level = 3210 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32); 3211 3212 cmdline_parse_inst_t cmd_set_log = { 3213 .f = cmd_set_log_parsed, 3214 .data = NULL, 3215 .help_str = "set log global|<type> <level>", 3216 .tokens = { 3217 (void *)&cmd_set_log_set, 3218 (void *)&cmd_set_log_log, 3219 (void *)&cmd_set_log_type, 3220 (void *)&cmd_set_log_level, 3221 NULL, 3222 }, 3223 }; 3224 3225 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3226 3227 struct cmd_set_txpkts_result { 3228 cmdline_fixed_string_t cmd_keyword; 3229 cmdline_fixed_string_t txpkts; 3230 cmdline_fixed_string_t seg_lengths; 3231 }; 3232 3233 static void 3234 cmd_set_txpkts_parsed(void *parsed_result, 3235 __attribute__((unused)) struct cmdline *cl, 3236 __attribute__((unused)) void *data) 3237 { 3238 struct cmd_set_txpkts_result *res; 3239 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3240 unsigned int nb_segs; 3241 3242 res = parsed_result; 3243 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3244 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3245 if (nb_segs > 0) 3246 set_tx_pkt_segments(seg_lengths, nb_segs); 3247 } 3248 3249 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 3250 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3251 cmd_keyword, "set"); 3252 cmdline_parse_token_string_t cmd_set_txpkts_name = 3253 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3254 txpkts, "txpkts"); 3255 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 3256 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3257 seg_lengths, NULL); 3258 3259 cmdline_parse_inst_t cmd_set_txpkts = { 3260 .f = cmd_set_txpkts_parsed, 3261 .data = NULL, 3262 .help_str = "set txpkts <len0[,len1]*>", 3263 .tokens = { 3264 (void *)&cmd_set_txpkts_keyword, 3265 (void *)&cmd_set_txpkts_name, 3266 (void *)&cmd_set_txpkts_lengths, 3267 NULL, 3268 }, 3269 }; 3270 3271 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 3272 3273 struct cmd_set_txsplit_result { 3274 cmdline_fixed_string_t cmd_keyword; 3275 cmdline_fixed_string_t txsplit; 3276 cmdline_fixed_string_t mode; 3277 }; 3278 3279 static void 3280 cmd_set_txsplit_parsed(void *parsed_result, 3281 __attribute__((unused)) struct cmdline *cl, 3282 __attribute__((unused)) void *data) 3283 { 3284 struct cmd_set_txsplit_result *res; 3285 3286 res = parsed_result; 3287 set_tx_pkt_split(res->mode); 3288 } 3289 3290 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 3291 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3292 cmd_keyword, "set"); 3293 cmdline_parse_token_string_t cmd_set_txsplit_name = 3294 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3295 txsplit, "txsplit"); 3296 cmdline_parse_token_string_t cmd_set_txsplit_mode = 3297 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3298 mode, NULL); 3299 3300 cmdline_parse_inst_t cmd_set_txsplit = { 3301 .f = cmd_set_txsplit_parsed, 3302 .data = NULL, 3303 .help_str = "set txsplit on|off|rand", 3304 .tokens = { 3305 (void *)&cmd_set_txsplit_keyword, 3306 (void *)&cmd_set_txsplit_name, 3307 (void *)&cmd_set_txsplit_mode, 3308 NULL, 3309 }, 3310 }; 3311 3312 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 3313 struct cmd_rx_vlan_filter_all_result { 3314 cmdline_fixed_string_t rx_vlan; 3315 cmdline_fixed_string_t what; 3316 cmdline_fixed_string_t all; 3317 portid_t port_id; 3318 }; 3319 3320 static void 3321 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 3322 __attribute__((unused)) struct cmdline *cl, 3323 __attribute__((unused)) void *data) 3324 { 3325 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 3326 3327 if (!strcmp(res->what, "add")) 3328 rx_vlan_all_filter_set(res->port_id, 1); 3329 else 3330 rx_vlan_all_filter_set(res->port_id, 0); 3331 } 3332 3333 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 3334 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3335 rx_vlan, "rx_vlan"); 3336 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 3337 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3338 what, "add#rm"); 3339 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 3340 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3341 all, "all"); 3342 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 3343 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3344 port_id, UINT16); 3345 3346 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 3347 .f = cmd_rx_vlan_filter_all_parsed, 3348 .data = NULL, 3349 .help_str = "rx_vlan add|rm all <port_id>: " 3350 "Add/Remove all identifiers to/from the set of VLAN " 3351 "identifiers filtered by a port", 3352 .tokens = { 3353 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 3354 (void *)&cmd_rx_vlan_filter_all_what, 3355 (void *)&cmd_rx_vlan_filter_all_all, 3356 (void *)&cmd_rx_vlan_filter_all_portid, 3357 NULL, 3358 }, 3359 }; 3360 3361 /* *** VLAN OFFLOAD SET ON A PORT *** */ 3362 struct cmd_vlan_offload_result { 3363 cmdline_fixed_string_t vlan; 3364 cmdline_fixed_string_t set; 3365 cmdline_fixed_string_t vlan_type; 3366 cmdline_fixed_string_t what; 3367 cmdline_fixed_string_t on; 3368 cmdline_fixed_string_t port_id; 3369 }; 3370 3371 static void 3372 cmd_vlan_offload_parsed(void *parsed_result, 3373 __attribute__((unused)) struct cmdline *cl, 3374 __attribute__((unused)) void *data) 3375 { 3376 int on; 3377 struct cmd_vlan_offload_result *res = parsed_result; 3378 char *str; 3379 int i, len = 0; 3380 portid_t port_id = 0; 3381 unsigned int tmp; 3382 3383 str = res->port_id; 3384 len = strnlen(str, STR_TOKEN_SIZE); 3385 i = 0; 3386 /* Get port_id first */ 3387 while(i < len){ 3388 if(str[i] == ',') 3389 break; 3390 3391 i++; 3392 } 3393 str[i]='\0'; 3394 tmp = strtoul(str, NULL, 0); 3395 /* If port_id greater that what portid_t can represent, return */ 3396 if(tmp >= RTE_MAX_ETHPORTS) 3397 return; 3398 port_id = (portid_t)tmp; 3399 3400 if (!strcmp(res->on, "on")) 3401 on = 1; 3402 else 3403 on = 0; 3404 3405 if (!strcmp(res->what, "strip")) 3406 rx_vlan_strip_set(port_id, on); 3407 else if(!strcmp(res->what, "stripq")){ 3408 uint16_t queue_id = 0; 3409 3410 /* No queue_id, return */ 3411 if(i + 1 >= len) { 3412 printf("must specify (port,queue_id)\n"); 3413 return; 3414 } 3415 tmp = strtoul(str + i + 1, NULL, 0); 3416 /* If queue_id greater that what 16-bits can represent, return */ 3417 if(tmp > 0xffff) 3418 return; 3419 3420 queue_id = (uint16_t)tmp; 3421 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 3422 } 3423 else if (!strcmp(res->what, "filter")) 3424 rx_vlan_filter_set(port_id, on); 3425 else 3426 vlan_extend_set(port_id, on); 3427 3428 return; 3429 } 3430 3431 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 3432 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3433 vlan, "vlan"); 3434 cmdline_parse_token_string_t cmd_vlan_offload_set = 3435 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3436 set, "set"); 3437 cmdline_parse_token_string_t cmd_vlan_offload_what = 3438 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3439 what, "strip#filter#qinq#stripq"); 3440 cmdline_parse_token_string_t cmd_vlan_offload_on = 3441 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3442 on, "on#off"); 3443 cmdline_parse_token_string_t cmd_vlan_offload_portid = 3444 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3445 port_id, NULL); 3446 3447 cmdline_parse_inst_t cmd_vlan_offload = { 3448 .f = cmd_vlan_offload_parsed, 3449 .data = NULL, 3450 .help_str = "vlan set strip|filter|qinq|stripq on|off " 3451 "<port_id[,queue_id]>: " 3452 "Filter/Strip for rx side qinq(extended) for both rx/tx sides", 3453 .tokens = { 3454 (void *)&cmd_vlan_offload_vlan, 3455 (void *)&cmd_vlan_offload_set, 3456 (void *)&cmd_vlan_offload_what, 3457 (void *)&cmd_vlan_offload_on, 3458 (void *)&cmd_vlan_offload_portid, 3459 NULL, 3460 }, 3461 }; 3462 3463 /* *** VLAN TPID SET ON A PORT *** */ 3464 struct cmd_vlan_tpid_result { 3465 cmdline_fixed_string_t vlan; 3466 cmdline_fixed_string_t set; 3467 cmdline_fixed_string_t vlan_type; 3468 cmdline_fixed_string_t what; 3469 uint16_t tp_id; 3470 portid_t port_id; 3471 }; 3472 3473 static void 3474 cmd_vlan_tpid_parsed(void *parsed_result, 3475 __attribute__((unused)) struct cmdline *cl, 3476 __attribute__((unused)) void *data) 3477 { 3478 struct cmd_vlan_tpid_result *res = parsed_result; 3479 enum rte_vlan_type vlan_type; 3480 3481 if (!strcmp(res->vlan_type, "inner")) 3482 vlan_type = ETH_VLAN_TYPE_INNER; 3483 else if (!strcmp(res->vlan_type, "outer")) 3484 vlan_type = ETH_VLAN_TYPE_OUTER; 3485 else { 3486 printf("Unknown vlan type\n"); 3487 return; 3488 } 3489 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 3490 } 3491 3492 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 3493 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3494 vlan, "vlan"); 3495 cmdline_parse_token_string_t cmd_vlan_tpid_set = 3496 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3497 set, "set"); 3498 cmdline_parse_token_string_t cmd_vlan_type = 3499 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3500 vlan_type, "inner#outer"); 3501 cmdline_parse_token_string_t cmd_vlan_tpid_what = 3502 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3503 what, "tpid"); 3504 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 3505 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 3506 tp_id, UINT16); 3507 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 3508 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 3509 port_id, UINT16); 3510 3511 cmdline_parse_inst_t cmd_vlan_tpid = { 3512 .f = cmd_vlan_tpid_parsed, 3513 .data = NULL, 3514 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 3515 "Set the VLAN Ether type", 3516 .tokens = { 3517 (void *)&cmd_vlan_tpid_vlan, 3518 (void *)&cmd_vlan_tpid_set, 3519 (void *)&cmd_vlan_type, 3520 (void *)&cmd_vlan_tpid_what, 3521 (void *)&cmd_vlan_tpid_tpid, 3522 (void *)&cmd_vlan_tpid_portid, 3523 NULL, 3524 }, 3525 }; 3526 3527 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 3528 struct cmd_rx_vlan_filter_result { 3529 cmdline_fixed_string_t rx_vlan; 3530 cmdline_fixed_string_t what; 3531 uint16_t vlan_id; 3532 portid_t port_id; 3533 }; 3534 3535 static void 3536 cmd_rx_vlan_filter_parsed(void *parsed_result, 3537 __attribute__((unused)) struct cmdline *cl, 3538 __attribute__((unused)) void *data) 3539 { 3540 struct cmd_rx_vlan_filter_result *res = parsed_result; 3541 3542 if (!strcmp(res->what, "add")) 3543 rx_vft_set(res->port_id, res->vlan_id, 1); 3544 else 3545 rx_vft_set(res->port_id, res->vlan_id, 0); 3546 } 3547 3548 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 3549 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 3550 rx_vlan, "rx_vlan"); 3551 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 3552 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 3553 what, "add#rm"); 3554 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 3555 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 3556 vlan_id, UINT16); 3557 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 3558 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 3559 port_id, UINT16); 3560 3561 cmdline_parse_inst_t cmd_rx_vlan_filter = { 3562 .f = cmd_rx_vlan_filter_parsed, 3563 .data = NULL, 3564 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 3565 "Add/Remove a VLAN identifier to/from the set of VLAN " 3566 "identifiers filtered by a port", 3567 .tokens = { 3568 (void *)&cmd_rx_vlan_filter_rx_vlan, 3569 (void *)&cmd_rx_vlan_filter_what, 3570 (void *)&cmd_rx_vlan_filter_vlanid, 3571 (void *)&cmd_rx_vlan_filter_portid, 3572 NULL, 3573 }, 3574 }; 3575 3576 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 3577 struct cmd_tx_vlan_set_result { 3578 cmdline_fixed_string_t tx_vlan; 3579 cmdline_fixed_string_t set; 3580 portid_t port_id; 3581 uint16_t vlan_id; 3582 }; 3583 3584 static void 3585 cmd_tx_vlan_set_parsed(void *parsed_result, 3586 __attribute__((unused)) struct cmdline *cl, 3587 __attribute__((unused)) void *data) 3588 { 3589 struct cmd_tx_vlan_set_result *res = parsed_result; 3590 3591 if (!port_is_stopped(res->port_id)) { 3592 printf("Please stop port %d first\n", res->port_id); 3593 return; 3594 } 3595 3596 tx_vlan_set(res->port_id, res->vlan_id); 3597 3598 cmd_reconfig_device_queue(res->port_id, 1, 1); 3599 } 3600 3601 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 3602 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 3603 tx_vlan, "tx_vlan"); 3604 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 3605 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 3606 set, "set"); 3607 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 3608 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 3609 port_id, UINT16); 3610 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 3611 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 3612 vlan_id, UINT16); 3613 3614 cmdline_parse_inst_t cmd_tx_vlan_set = { 3615 .f = cmd_tx_vlan_set_parsed, 3616 .data = NULL, 3617 .help_str = "tx_vlan set <port_id> <vlan_id>: " 3618 "Enable hardware insertion of a single VLAN header " 3619 "with a given TAG Identifier in packets sent on a port", 3620 .tokens = { 3621 (void *)&cmd_tx_vlan_set_tx_vlan, 3622 (void *)&cmd_tx_vlan_set_set, 3623 (void *)&cmd_tx_vlan_set_portid, 3624 (void *)&cmd_tx_vlan_set_vlanid, 3625 NULL, 3626 }, 3627 }; 3628 3629 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 3630 struct cmd_tx_vlan_set_qinq_result { 3631 cmdline_fixed_string_t tx_vlan; 3632 cmdline_fixed_string_t set; 3633 portid_t port_id; 3634 uint16_t vlan_id; 3635 uint16_t vlan_id_outer; 3636 }; 3637 3638 static void 3639 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 3640 __attribute__((unused)) struct cmdline *cl, 3641 __attribute__((unused)) void *data) 3642 { 3643 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 3644 3645 if (!port_is_stopped(res->port_id)) { 3646 printf("Please stop port %d first\n", res->port_id); 3647 return; 3648 } 3649 3650 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 3651 3652 cmd_reconfig_device_queue(res->port_id, 1, 1); 3653 } 3654 3655 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 3656 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 3657 tx_vlan, "tx_vlan"); 3658 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 3659 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 3660 set, "set"); 3661 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 3662 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 3663 port_id, UINT16); 3664 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 3665 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 3666 vlan_id, UINT16); 3667 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 3668 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 3669 vlan_id_outer, UINT16); 3670 3671 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 3672 .f = cmd_tx_vlan_set_qinq_parsed, 3673 .data = NULL, 3674 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 3675 "Enable hardware insertion of double VLAN header " 3676 "with given TAG Identifiers in packets sent on a port", 3677 .tokens = { 3678 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 3679 (void *)&cmd_tx_vlan_set_qinq_set, 3680 (void *)&cmd_tx_vlan_set_qinq_portid, 3681 (void *)&cmd_tx_vlan_set_qinq_vlanid, 3682 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 3683 NULL, 3684 }, 3685 }; 3686 3687 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 3688 struct cmd_tx_vlan_set_pvid_result { 3689 cmdline_fixed_string_t tx_vlan; 3690 cmdline_fixed_string_t set; 3691 cmdline_fixed_string_t pvid; 3692 portid_t port_id; 3693 uint16_t vlan_id; 3694 cmdline_fixed_string_t mode; 3695 }; 3696 3697 static void 3698 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 3699 __attribute__((unused)) struct cmdline *cl, 3700 __attribute__((unused)) void *data) 3701 { 3702 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 3703 3704 if (strcmp(res->mode, "on") == 0) 3705 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 3706 else 3707 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 3708 } 3709 3710 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 3711 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3712 tx_vlan, "tx_vlan"); 3713 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 3714 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3715 set, "set"); 3716 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 3717 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3718 pvid, "pvid"); 3719 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 3720 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3721 port_id, UINT16); 3722 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 3723 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3724 vlan_id, UINT16); 3725 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 3726 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3727 mode, "on#off"); 3728 3729 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 3730 .f = cmd_tx_vlan_set_pvid_parsed, 3731 .data = NULL, 3732 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 3733 .tokens = { 3734 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 3735 (void *)&cmd_tx_vlan_set_pvid_set, 3736 (void *)&cmd_tx_vlan_set_pvid_pvid, 3737 (void *)&cmd_tx_vlan_set_pvid_port_id, 3738 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 3739 (void *)&cmd_tx_vlan_set_pvid_mode, 3740 NULL, 3741 }, 3742 }; 3743 3744 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 3745 struct cmd_tx_vlan_reset_result { 3746 cmdline_fixed_string_t tx_vlan; 3747 cmdline_fixed_string_t reset; 3748 portid_t port_id; 3749 }; 3750 3751 static void 3752 cmd_tx_vlan_reset_parsed(void *parsed_result, 3753 __attribute__((unused)) struct cmdline *cl, 3754 __attribute__((unused)) void *data) 3755 { 3756 struct cmd_tx_vlan_reset_result *res = parsed_result; 3757 3758 if (!port_is_stopped(res->port_id)) { 3759 printf("Please stop port %d first\n", res->port_id); 3760 return; 3761 } 3762 3763 tx_vlan_reset(res->port_id); 3764 3765 cmd_reconfig_device_queue(res->port_id, 1, 1); 3766 } 3767 3768 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 3769 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 3770 tx_vlan, "tx_vlan"); 3771 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 3772 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 3773 reset, "reset"); 3774 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 3775 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 3776 port_id, UINT16); 3777 3778 cmdline_parse_inst_t cmd_tx_vlan_reset = { 3779 .f = cmd_tx_vlan_reset_parsed, 3780 .data = NULL, 3781 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 3782 "VLAN header in packets sent on a port", 3783 .tokens = { 3784 (void *)&cmd_tx_vlan_reset_tx_vlan, 3785 (void *)&cmd_tx_vlan_reset_reset, 3786 (void *)&cmd_tx_vlan_reset_portid, 3787 NULL, 3788 }, 3789 }; 3790 3791 3792 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 3793 struct cmd_csum_result { 3794 cmdline_fixed_string_t csum; 3795 cmdline_fixed_string_t mode; 3796 cmdline_fixed_string_t proto; 3797 cmdline_fixed_string_t hwsw; 3798 portid_t port_id; 3799 }; 3800 3801 static void 3802 csum_show(int port_id) 3803 { 3804 struct rte_eth_dev_info dev_info; 3805 uint64_t tx_offloads; 3806 3807 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 3808 printf("Parse tunnel is %s\n", 3809 (ports[port_id].parse_tunnel) ? "on" : "off"); 3810 printf("IP checksum offload is %s\n", 3811 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 3812 printf("UDP checksum offload is %s\n", 3813 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 3814 printf("TCP checksum offload is %s\n", 3815 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 3816 printf("SCTP checksum offload is %s\n", 3817 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 3818 printf("Outer-Ip checksum offload is %s\n", 3819 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 3820 3821 /* display warnings if configuration is not supported by the NIC */ 3822 rte_eth_dev_info_get(port_id, &dev_info); 3823 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 3824 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 3825 printf("Warning: hardware IP checksum enabled but not " 3826 "supported by port %d\n", port_id); 3827 } 3828 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 3829 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 3830 printf("Warning: hardware UDP checksum enabled but not " 3831 "supported by port %d\n", port_id); 3832 } 3833 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 3834 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 3835 printf("Warning: hardware TCP checksum enabled but not " 3836 "supported by port %d\n", port_id); 3837 } 3838 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 3839 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 3840 printf("Warning: hardware SCTP checksum enabled but not " 3841 "supported by port %d\n", port_id); 3842 } 3843 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 3844 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 3845 printf("Warning: hardware outer IP checksum enabled but not " 3846 "supported by port %d\n", port_id); 3847 } 3848 } 3849 3850 static void 3851 cmd_csum_parsed(void *parsed_result, 3852 __attribute__((unused)) struct cmdline *cl, 3853 __attribute__((unused)) void *data) 3854 { 3855 struct cmd_csum_result *res = parsed_result; 3856 int hw = 0; 3857 uint64_t csum_offloads = 0; 3858 struct rte_eth_dev_info dev_info; 3859 3860 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 3861 printf("invalid port %d\n", res->port_id); 3862 return; 3863 } 3864 if (!port_is_stopped(res->port_id)) { 3865 printf("Please stop port %d first\n", res->port_id); 3866 return; 3867 } 3868 3869 rte_eth_dev_info_get(res->port_id, &dev_info); 3870 if (!strcmp(res->mode, "set")) { 3871 3872 if (!strcmp(res->hwsw, "hw")) 3873 hw = 1; 3874 3875 if (!strcmp(res->proto, "ip")) { 3876 if (hw == 0 || (dev_info.tx_offload_capa & 3877 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 3878 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 3879 } else { 3880 printf("IP checksum offload is not supported " 3881 "by port %u\n", res->port_id); 3882 } 3883 } else if (!strcmp(res->proto, "udp")) { 3884 if (hw == 0 || (dev_info.tx_offload_capa & 3885 DEV_TX_OFFLOAD_UDP_CKSUM)) { 3886 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 3887 } else { 3888 printf("UDP checksum offload is not supported " 3889 "by port %u\n", res->port_id); 3890 } 3891 } else if (!strcmp(res->proto, "tcp")) { 3892 if (hw == 0 || (dev_info.tx_offload_capa & 3893 DEV_TX_OFFLOAD_TCP_CKSUM)) { 3894 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 3895 } else { 3896 printf("TCP checksum offload is not supported " 3897 "by port %u\n", res->port_id); 3898 } 3899 } else if (!strcmp(res->proto, "sctp")) { 3900 if (hw == 0 || (dev_info.tx_offload_capa & 3901 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 3902 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 3903 } else { 3904 printf("SCTP checksum offload is not supported " 3905 "by port %u\n", res->port_id); 3906 } 3907 } else if (!strcmp(res->proto, "outer-ip")) { 3908 if (hw == 0 || (dev_info.tx_offload_capa & 3909 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 3910 csum_offloads |= 3911 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 3912 } else { 3913 printf("Outer IP checksum offload is not " 3914 "supported by port %u\n", res->port_id); 3915 } 3916 } 3917 3918 if (hw) { 3919 ports[res->port_id].dev_conf.txmode.offloads |= 3920 csum_offloads; 3921 } else { 3922 ports[res->port_id].dev_conf.txmode.offloads &= 3923 (~csum_offloads); 3924 } 3925 } 3926 csum_show(res->port_id); 3927 3928 cmd_reconfig_device_queue(res->port_id, 1, 1); 3929 } 3930 3931 cmdline_parse_token_string_t cmd_csum_csum = 3932 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 3933 csum, "csum"); 3934 cmdline_parse_token_string_t cmd_csum_mode = 3935 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 3936 mode, "set"); 3937 cmdline_parse_token_string_t cmd_csum_proto = 3938 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 3939 proto, "ip#tcp#udp#sctp#outer-ip"); 3940 cmdline_parse_token_string_t cmd_csum_hwsw = 3941 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 3942 hwsw, "hw#sw"); 3943 cmdline_parse_token_num_t cmd_csum_portid = 3944 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 3945 port_id, UINT16); 3946 3947 cmdline_parse_inst_t cmd_csum_set = { 3948 .f = cmd_csum_parsed, 3949 .data = NULL, 3950 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: " 3951 "Enable/Disable hardware calculation of L3/L4 checksum when " 3952 "using csum forward engine", 3953 .tokens = { 3954 (void *)&cmd_csum_csum, 3955 (void *)&cmd_csum_mode, 3956 (void *)&cmd_csum_proto, 3957 (void *)&cmd_csum_hwsw, 3958 (void *)&cmd_csum_portid, 3959 NULL, 3960 }, 3961 }; 3962 3963 cmdline_parse_token_string_t cmd_csum_mode_show = 3964 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 3965 mode, "show"); 3966 3967 cmdline_parse_inst_t cmd_csum_show = { 3968 .f = cmd_csum_parsed, 3969 .data = NULL, 3970 .help_str = "csum show <port_id>: Show checksum offload configuration", 3971 .tokens = { 3972 (void *)&cmd_csum_csum, 3973 (void *)&cmd_csum_mode_show, 3974 (void *)&cmd_csum_portid, 3975 NULL, 3976 }, 3977 }; 3978 3979 /* Enable/disable tunnel parsing */ 3980 struct cmd_csum_tunnel_result { 3981 cmdline_fixed_string_t csum; 3982 cmdline_fixed_string_t parse; 3983 cmdline_fixed_string_t onoff; 3984 portid_t port_id; 3985 }; 3986 3987 static void 3988 cmd_csum_tunnel_parsed(void *parsed_result, 3989 __attribute__((unused)) struct cmdline *cl, 3990 __attribute__((unused)) void *data) 3991 { 3992 struct cmd_csum_tunnel_result *res = parsed_result; 3993 3994 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 3995 return; 3996 3997 if (!strcmp(res->onoff, "on")) 3998 ports[res->port_id].parse_tunnel = 1; 3999 else 4000 ports[res->port_id].parse_tunnel = 0; 4001 4002 csum_show(res->port_id); 4003 } 4004 4005 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4006 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4007 csum, "csum"); 4008 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4009 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4010 parse, "parse_tunnel"); 4011 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4012 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4013 onoff, "on#off"); 4014 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4015 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4016 port_id, UINT16); 4017 4018 cmdline_parse_inst_t cmd_csum_tunnel = { 4019 .f = cmd_csum_tunnel_parsed, 4020 .data = NULL, 4021 .help_str = "csum parse_tunnel on|off <port_id>: " 4022 "Enable/Disable parsing of tunnels for csum engine", 4023 .tokens = { 4024 (void *)&cmd_csum_tunnel_csum, 4025 (void *)&cmd_csum_tunnel_parse, 4026 (void *)&cmd_csum_tunnel_onoff, 4027 (void *)&cmd_csum_tunnel_portid, 4028 NULL, 4029 }, 4030 }; 4031 4032 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4033 struct cmd_tso_set_result { 4034 cmdline_fixed_string_t tso; 4035 cmdline_fixed_string_t mode; 4036 uint16_t tso_segsz; 4037 portid_t port_id; 4038 }; 4039 4040 static void 4041 cmd_tso_set_parsed(void *parsed_result, 4042 __attribute__((unused)) struct cmdline *cl, 4043 __attribute__((unused)) void *data) 4044 { 4045 struct cmd_tso_set_result *res = parsed_result; 4046 struct rte_eth_dev_info dev_info; 4047 4048 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4049 return; 4050 if (!port_is_stopped(res->port_id)) { 4051 printf("Please stop port %d first\n", res->port_id); 4052 return; 4053 } 4054 4055 if (!strcmp(res->mode, "set")) 4056 ports[res->port_id].tso_segsz = res->tso_segsz; 4057 4058 rte_eth_dev_info_get(res->port_id, &dev_info); 4059 if ((ports[res->port_id].tso_segsz != 0) && 4060 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4061 printf("Error: TSO is not supported by port %d\n", 4062 res->port_id); 4063 return; 4064 } 4065 4066 if (ports[res->port_id].tso_segsz == 0) { 4067 ports[res->port_id].dev_conf.txmode.offloads &= 4068 ~DEV_TX_OFFLOAD_TCP_TSO; 4069 printf("TSO for non-tunneled packets is disabled\n"); 4070 } else { 4071 ports[res->port_id].dev_conf.txmode.offloads |= 4072 DEV_TX_OFFLOAD_TCP_TSO; 4073 printf("TSO segment size for non-tunneled packets is %d\n", 4074 ports[res->port_id].tso_segsz); 4075 } 4076 4077 /* display warnings if configuration is not supported by the NIC */ 4078 rte_eth_dev_info_get(res->port_id, &dev_info); 4079 if ((ports[res->port_id].tso_segsz != 0) && 4080 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4081 printf("Warning: TSO enabled but not " 4082 "supported by port %d\n", res->port_id); 4083 } 4084 4085 cmd_reconfig_device_queue(res->port_id, 1, 1); 4086 } 4087 4088 cmdline_parse_token_string_t cmd_tso_set_tso = 4089 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4090 tso, "tso"); 4091 cmdline_parse_token_string_t cmd_tso_set_mode = 4092 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4093 mode, "set"); 4094 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4095 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4096 tso_segsz, UINT16); 4097 cmdline_parse_token_num_t cmd_tso_set_portid = 4098 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4099 port_id, UINT16); 4100 4101 cmdline_parse_inst_t cmd_tso_set = { 4102 .f = cmd_tso_set_parsed, 4103 .data = NULL, 4104 .help_str = "tso set <tso_segsz> <port_id>: " 4105 "Set TSO segment size of non-tunneled packets for csum engine " 4106 "(0 to disable)", 4107 .tokens = { 4108 (void *)&cmd_tso_set_tso, 4109 (void *)&cmd_tso_set_mode, 4110 (void *)&cmd_tso_set_tso_segsz, 4111 (void *)&cmd_tso_set_portid, 4112 NULL, 4113 }, 4114 }; 4115 4116 cmdline_parse_token_string_t cmd_tso_show_mode = 4117 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4118 mode, "show"); 4119 4120 4121 cmdline_parse_inst_t cmd_tso_show = { 4122 .f = cmd_tso_set_parsed, 4123 .data = NULL, 4124 .help_str = "tso show <port_id>: " 4125 "Show TSO segment size of non-tunneled packets for csum engine", 4126 .tokens = { 4127 (void *)&cmd_tso_set_tso, 4128 (void *)&cmd_tso_show_mode, 4129 (void *)&cmd_tso_set_portid, 4130 NULL, 4131 }, 4132 }; 4133 4134 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 4135 struct cmd_tunnel_tso_set_result { 4136 cmdline_fixed_string_t tso; 4137 cmdline_fixed_string_t mode; 4138 uint16_t tso_segsz; 4139 portid_t port_id; 4140 }; 4141 4142 static struct rte_eth_dev_info 4143 check_tunnel_tso_nic_support(portid_t port_id) 4144 { 4145 struct rte_eth_dev_info dev_info; 4146 4147 rte_eth_dev_info_get(port_id, &dev_info); 4148 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 4149 printf("Warning: VXLAN TUNNEL TSO not supported therefore " 4150 "not enabled for port %d\n", port_id); 4151 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 4152 printf("Warning: GRE TUNNEL TSO not supported therefore " 4153 "not enabled for port %d\n", port_id); 4154 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 4155 printf("Warning: IPIP TUNNEL TSO not supported therefore " 4156 "not enabled for port %d\n", port_id); 4157 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 4158 printf("Warning: GENEVE TUNNEL TSO not supported therefore " 4159 "not enabled for port %d\n", port_id); 4160 return dev_info; 4161 } 4162 4163 static void 4164 cmd_tunnel_tso_set_parsed(void *parsed_result, 4165 __attribute__((unused)) struct cmdline *cl, 4166 __attribute__((unused)) void *data) 4167 { 4168 struct cmd_tunnel_tso_set_result *res = parsed_result; 4169 struct rte_eth_dev_info dev_info; 4170 4171 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4172 return; 4173 if (!port_is_stopped(res->port_id)) { 4174 printf("Please stop port %d first\n", res->port_id); 4175 return; 4176 } 4177 4178 if (!strcmp(res->mode, "set")) 4179 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 4180 4181 dev_info = check_tunnel_tso_nic_support(res->port_id); 4182 if (ports[res->port_id].tunnel_tso_segsz == 0) { 4183 ports[res->port_id].dev_conf.txmode.offloads &= 4184 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4185 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4186 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4187 DEV_TX_OFFLOAD_GENEVE_TNL_TSO); 4188 printf("TSO for tunneled packets is disabled\n"); 4189 } else { 4190 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4191 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4192 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4193 DEV_TX_OFFLOAD_GENEVE_TNL_TSO); 4194 4195 ports[res->port_id].dev_conf.txmode.offloads |= 4196 (tso_offloads & dev_info.tx_offload_capa); 4197 printf("TSO segment size for tunneled packets is %d\n", 4198 ports[res->port_id].tunnel_tso_segsz); 4199 4200 /* Below conditions are needed to make it work: 4201 * (1) tunnel TSO is supported by the NIC; 4202 * (2) "csum parse_tunnel" must be set so that tunneled pkts 4203 * are recognized; 4204 * (3) for tunneled pkts with outer L3 of IPv4, 4205 * "csum set outer-ip" must be set to hw, because after tso, 4206 * total_len of outer IP header is changed, and the checksum 4207 * of outer IP header calculated by sw should be wrong; that 4208 * is not necessary for IPv6 tunneled pkts because there's no 4209 * checksum in IP header anymore. 4210 */ 4211 4212 if (!ports[res->port_id].parse_tunnel) 4213 printf("Warning: csum parse_tunnel must be set " 4214 "so that tunneled packets are recognized\n"); 4215 if (!(ports[res->port_id].dev_conf.txmode.offloads & 4216 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 4217 printf("Warning: csum set outer-ip must be set to hw " 4218 "if outer L3 is IPv4; not necessary for IPv6\n"); 4219 } 4220 4221 cmd_reconfig_device_queue(res->port_id, 1, 1); 4222 } 4223 4224 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 4225 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4226 tso, "tunnel_tso"); 4227 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 4228 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4229 mode, "set"); 4230 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 4231 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4232 tso_segsz, UINT16); 4233 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 4234 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4235 port_id, UINT16); 4236 4237 cmdline_parse_inst_t cmd_tunnel_tso_set = { 4238 .f = cmd_tunnel_tso_set_parsed, 4239 .data = NULL, 4240 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 4241 "Set TSO segment size of tunneled packets for csum engine " 4242 "(0 to disable)", 4243 .tokens = { 4244 (void *)&cmd_tunnel_tso_set_tso, 4245 (void *)&cmd_tunnel_tso_set_mode, 4246 (void *)&cmd_tunnel_tso_set_tso_segsz, 4247 (void *)&cmd_tunnel_tso_set_portid, 4248 NULL, 4249 }, 4250 }; 4251 4252 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 4253 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4254 mode, "show"); 4255 4256 4257 cmdline_parse_inst_t cmd_tunnel_tso_show = { 4258 .f = cmd_tunnel_tso_set_parsed, 4259 .data = NULL, 4260 .help_str = "tunnel_tso show <port_id> " 4261 "Show TSO segment size of tunneled packets for csum engine", 4262 .tokens = { 4263 (void *)&cmd_tunnel_tso_set_tso, 4264 (void *)&cmd_tunnel_tso_show_mode, 4265 (void *)&cmd_tunnel_tso_set_portid, 4266 NULL, 4267 }, 4268 }; 4269 4270 /* *** SET GRO FOR A PORT *** */ 4271 struct cmd_gro_enable_result { 4272 cmdline_fixed_string_t cmd_set; 4273 cmdline_fixed_string_t cmd_port; 4274 cmdline_fixed_string_t cmd_keyword; 4275 cmdline_fixed_string_t cmd_onoff; 4276 portid_t cmd_pid; 4277 }; 4278 4279 static void 4280 cmd_gro_enable_parsed(void *parsed_result, 4281 __attribute__((unused)) struct cmdline *cl, 4282 __attribute__((unused)) void *data) 4283 { 4284 struct cmd_gro_enable_result *res; 4285 4286 res = parsed_result; 4287 if (!strcmp(res->cmd_keyword, "gro")) 4288 setup_gro(res->cmd_onoff, res->cmd_pid); 4289 } 4290 4291 cmdline_parse_token_string_t cmd_gro_enable_set = 4292 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4293 cmd_set, "set"); 4294 cmdline_parse_token_string_t cmd_gro_enable_port = 4295 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4296 cmd_keyword, "port"); 4297 cmdline_parse_token_num_t cmd_gro_enable_pid = 4298 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 4299 cmd_pid, UINT16); 4300 cmdline_parse_token_string_t cmd_gro_enable_keyword = 4301 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4302 cmd_keyword, "gro"); 4303 cmdline_parse_token_string_t cmd_gro_enable_onoff = 4304 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4305 cmd_onoff, "on#off"); 4306 4307 cmdline_parse_inst_t cmd_gro_enable = { 4308 .f = cmd_gro_enable_parsed, 4309 .data = NULL, 4310 .help_str = "set port <port_id> gro on|off", 4311 .tokens = { 4312 (void *)&cmd_gro_enable_set, 4313 (void *)&cmd_gro_enable_port, 4314 (void *)&cmd_gro_enable_pid, 4315 (void *)&cmd_gro_enable_keyword, 4316 (void *)&cmd_gro_enable_onoff, 4317 NULL, 4318 }, 4319 }; 4320 4321 /* *** DISPLAY GRO CONFIGURATION *** */ 4322 struct cmd_gro_show_result { 4323 cmdline_fixed_string_t cmd_show; 4324 cmdline_fixed_string_t cmd_port; 4325 cmdline_fixed_string_t cmd_keyword; 4326 portid_t cmd_pid; 4327 }; 4328 4329 static void 4330 cmd_gro_show_parsed(void *parsed_result, 4331 __attribute__((unused)) struct cmdline *cl, 4332 __attribute__((unused)) void *data) 4333 { 4334 struct cmd_gro_show_result *res; 4335 4336 res = parsed_result; 4337 if (!strcmp(res->cmd_keyword, "gro")) 4338 show_gro(res->cmd_pid); 4339 } 4340 4341 cmdline_parse_token_string_t cmd_gro_show_show = 4342 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4343 cmd_show, "show"); 4344 cmdline_parse_token_string_t cmd_gro_show_port = 4345 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4346 cmd_port, "port"); 4347 cmdline_parse_token_num_t cmd_gro_show_pid = 4348 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 4349 cmd_pid, UINT16); 4350 cmdline_parse_token_string_t cmd_gro_show_keyword = 4351 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4352 cmd_keyword, "gro"); 4353 4354 cmdline_parse_inst_t cmd_gro_show = { 4355 .f = cmd_gro_show_parsed, 4356 .data = NULL, 4357 .help_str = "show port <port_id> gro", 4358 .tokens = { 4359 (void *)&cmd_gro_show_show, 4360 (void *)&cmd_gro_show_port, 4361 (void *)&cmd_gro_show_pid, 4362 (void *)&cmd_gro_show_keyword, 4363 NULL, 4364 }, 4365 }; 4366 4367 /* *** SET FLUSH CYCLES FOR GRO *** */ 4368 struct cmd_gro_flush_result { 4369 cmdline_fixed_string_t cmd_set; 4370 cmdline_fixed_string_t cmd_keyword; 4371 cmdline_fixed_string_t cmd_flush; 4372 uint8_t cmd_cycles; 4373 }; 4374 4375 static void 4376 cmd_gro_flush_parsed(void *parsed_result, 4377 __attribute__((unused)) struct cmdline *cl, 4378 __attribute__((unused)) void *data) 4379 { 4380 struct cmd_gro_flush_result *res; 4381 4382 res = parsed_result; 4383 if ((!strcmp(res->cmd_keyword, "gro")) && 4384 (!strcmp(res->cmd_flush, "flush"))) 4385 setup_gro_flush_cycles(res->cmd_cycles); 4386 } 4387 4388 cmdline_parse_token_string_t cmd_gro_flush_set = 4389 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4390 cmd_set, "set"); 4391 cmdline_parse_token_string_t cmd_gro_flush_keyword = 4392 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4393 cmd_keyword, "gro"); 4394 cmdline_parse_token_string_t cmd_gro_flush_flush = 4395 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4396 cmd_flush, "flush"); 4397 cmdline_parse_token_num_t cmd_gro_flush_cycles = 4398 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 4399 cmd_cycles, UINT8); 4400 4401 cmdline_parse_inst_t cmd_gro_flush = { 4402 .f = cmd_gro_flush_parsed, 4403 .data = NULL, 4404 .help_str = "set gro flush <cycles>", 4405 .tokens = { 4406 (void *)&cmd_gro_flush_set, 4407 (void *)&cmd_gro_flush_keyword, 4408 (void *)&cmd_gro_flush_flush, 4409 (void *)&cmd_gro_flush_cycles, 4410 NULL, 4411 }, 4412 }; 4413 4414 /* *** ENABLE/DISABLE GSO *** */ 4415 struct cmd_gso_enable_result { 4416 cmdline_fixed_string_t cmd_set; 4417 cmdline_fixed_string_t cmd_port; 4418 cmdline_fixed_string_t cmd_keyword; 4419 cmdline_fixed_string_t cmd_mode; 4420 portid_t cmd_pid; 4421 }; 4422 4423 static void 4424 cmd_gso_enable_parsed(void *parsed_result, 4425 __attribute__((unused)) struct cmdline *cl, 4426 __attribute__((unused)) void *data) 4427 { 4428 struct cmd_gso_enable_result *res; 4429 4430 res = parsed_result; 4431 if (!strcmp(res->cmd_keyword, "gso")) 4432 setup_gso(res->cmd_mode, res->cmd_pid); 4433 } 4434 4435 cmdline_parse_token_string_t cmd_gso_enable_set = 4436 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4437 cmd_set, "set"); 4438 cmdline_parse_token_string_t cmd_gso_enable_port = 4439 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4440 cmd_port, "port"); 4441 cmdline_parse_token_string_t cmd_gso_enable_keyword = 4442 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4443 cmd_keyword, "gso"); 4444 cmdline_parse_token_string_t cmd_gso_enable_mode = 4445 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4446 cmd_mode, "on#off"); 4447 cmdline_parse_token_num_t cmd_gso_enable_pid = 4448 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 4449 cmd_pid, UINT16); 4450 4451 cmdline_parse_inst_t cmd_gso_enable = { 4452 .f = cmd_gso_enable_parsed, 4453 .data = NULL, 4454 .help_str = "set port <port_id> gso on|off", 4455 .tokens = { 4456 (void *)&cmd_gso_enable_set, 4457 (void *)&cmd_gso_enable_port, 4458 (void *)&cmd_gso_enable_pid, 4459 (void *)&cmd_gso_enable_keyword, 4460 (void *)&cmd_gso_enable_mode, 4461 NULL, 4462 }, 4463 }; 4464 4465 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 4466 struct cmd_gso_size_result { 4467 cmdline_fixed_string_t cmd_set; 4468 cmdline_fixed_string_t cmd_keyword; 4469 cmdline_fixed_string_t cmd_segsz; 4470 uint16_t cmd_size; 4471 }; 4472 4473 static void 4474 cmd_gso_size_parsed(void *parsed_result, 4475 __attribute__((unused)) struct cmdline *cl, 4476 __attribute__((unused)) void *data) 4477 { 4478 struct cmd_gso_size_result *res = parsed_result; 4479 4480 if (test_done == 0) { 4481 printf("Before setting GSO segsz, please first" 4482 " stop fowarding\n"); 4483 return; 4484 } 4485 4486 if (!strcmp(res->cmd_keyword, "gso") && 4487 !strcmp(res->cmd_segsz, "segsz")) { 4488 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 4489 printf("gso_size should be larger than %zu." 4490 " Please input a legal value\n", 4491 RTE_GSO_SEG_SIZE_MIN); 4492 else 4493 gso_max_segment_size = res->cmd_size; 4494 } 4495 } 4496 4497 cmdline_parse_token_string_t cmd_gso_size_set = 4498 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 4499 cmd_set, "set"); 4500 cmdline_parse_token_string_t cmd_gso_size_keyword = 4501 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 4502 cmd_keyword, "gso"); 4503 cmdline_parse_token_string_t cmd_gso_size_segsz = 4504 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 4505 cmd_segsz, "segsz"); 4506 cmdline_parse_token_num_t cmd_gso_size_size = 4507 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 4508 cmd_size, UINT16); 4509 4510 cmdline_parse_inst_t cmd_gso_size = { 4511 .f = cmd_gso_size_parsed, 4512 .data = NULL, 4513 .help_str = "set gso segsz <length>", 4514 .tokens = { 4515 (void *)&cmd_gso_size_set, 4516 (void *)&cmd_gso_size_keyword, 4517 (void *)&cmd_gso_size_segsz, 4518 (void *)&cmd_gso_size_size, 4519 NULL, 4520 }, 4521 }; 4522 4523 /* *** SHOW GSO CONFIGURATION *** */ 4524 struct cmd_gso_show_result { 4525 cmdline_fixed_string_t cmd_show; 4526 cmdline_fixed_string_t cmd_port; 4527 cmdline_fixed_string_t cmd_keyword; 4528 portid_t cmd_pid; 4529 }; 4530 4531 static void 4532 cmd_gso_show_parsed(void *parsed_result, 4533 __attribute__((unused)) struct cmdline *cl, 4534 __attribute__((unused)) void *data) 4535 { 4536 struct cmd_gso_show_result *res = parsed_result; 4537 4538 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 4539 printf("invalid port id %u\n", res->cmd_pid); 4540 return; 4541 } 4542 if (!strcmp(res->cmd_keyword, "gso")) { 4543 if (gso_ports[res->cmd_pid].enable) { 4544 printf("Max GSO'd packet size: %uB\n" 4545 "Supported GSO types: TCP/IPv4, " 4546 "VxLAN with inner TCP/IPv4 packet, " 4547 "GRE with inner TCP/IPv4 packet\n", 4548 gso_max_segment_size); 4549 } else 4550 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 4551 } 4552 } 4553 4554 cmdline_parse_token_string_t cmd_gso_show_show = 4555 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 4556 cmd_show, "show"); 4557 cmdline_parse_token_string_t cmd_gso_show_port = 4558 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 4559 cmd_port, "port"); 4560 cmdline_parse_token_string_t cmd_gso_show_keyword = 4561 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 4562 cmd_keyword, "gso"); 4563 cmdline_parse_token_num_t cmd_gso_show_pid = 4564 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 4565 cmd_pid, UINT16); 4566 4567 cmdline_parse_inst_t cmd_gso_show = { 4568 .f = cmd_gso_show_parsed, 4569 .data = NULL, 4570 .help_str = "show port <port_id> gso", 4571 .tokens = { 4572 (void *)&cmd_gso_show_show, 4573 (void *)&cmd_gso_show_port, 4574 (void *)&cmd_gso_show_pid, 4575 (void *)&cmd_gso_show_keyword, 4576 NULL, 4577 }, 4578 }; 4579 4580 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 4581 struct cmd_set_flush_rx { 4582 cmdline_fixed_string_t set; 4583 cmdline_fixed_string_t flush_rx; 4584 cmdline_fixed_string_t mode; 4585 }; 4586 4587 static void 4588 cmd_set_flush_rx_parsed(void *parsed_result, 4589 __attribute__((unused)) struct cmdline *cl, 4590 __attribute__((unused)) void *data) 4591 { 4592 struct cmd_set_flush_rx *res = parsed_result; 4593 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 4594 } 4595 4596 cmdline_parse_token_string_t cmd_setflushrx_set = 4597 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 4598 set, "set"); 4599 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 4600 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 4601 flush_rx, "flush_rx"); 4602 cmdline_parse_token_string_t cmd_setflushrx_mode = 4603 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 4604 mode, "on#off"); 4605 4606 4607 cmdline_parse_inst_t cmd_set_flush_rx = { 4608 .f = cmd_set_flush_rx_parsed, 4609 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 4610 .data = NULL, 4611 .tokens = { 4612 (void *)&cmd_setflushrx_set, 4613 (void *)&cmd_setflushrx_flush_rx, 4614 (void *)&cmd_setflushrx_mode, 4615 NULL, 4616 }, 4617 }; 4618 4619 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 4620 struct cmd_set_link_check { 4621 cmdline_fixed_string_t set; 4622 cmdline_fixed_string_t link_check; 4623 cmdline_fixed_string_t mode; 4624 }; 4625 4626 static void 4627 cmd_set_link_check_parsed(void *parsed_result, 4628 __attribute__((unused)) struct cmdline *cl, 4629 __attribute__((unused)) void *data) 4630 { 4631 struct cmd_set_link_check *res = parsed_result; 4632 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 4633 } 4634 4635 cmdline_parse_token_string_t cmd_setlinkcheck_set = 4636 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 4637 set, "set"); 4638 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 4639 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 4640 link_check, "link_check"); 4641 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 4642 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 4643 mode, "on#off"); 4644 4645 4646 cmdline_parse_inst_t cmd_set_link_check = { 4647 .f = cmd_set_link_check_parsed, 4648 .help_str = "set link_check on|off: Enable/Disable link status check " 4649 "when starting/stopping a port", 4650 .data = NULL, 4651 .tokens = { 4652 (void *)&cmd_setlinkcheck_set, 4653 (void *)&cmd_setlinkcheck_link_check, 4654 (void *)&cmd_setlinkcheck_mode, 4655 NULL, 4656 }, 4657 }; 4658 4659 /* *** SET NIC BYPASS MODE *** */ 4660 struct cmd_set_bypass_mode_result { 4661 cmdline_fixed_string_t set; 4662 cmdline_fixed_string_t bypass; 4663 cmdline_fixed_string_t mode; 4664 cmdline_fixed_string_t value; 4665 portid_t port_id; 4666 }; 4667 4668 static void 4669 cmd_set_bypass_mode_parsed(void *parsed_result, 4670 __attribute__((unused)) struct cmdline *cl, 4671 __attribute__((unused)) void *data) 4672 { 4673 struct cmd_set_bypass_mode_result *res = parsed_result; 4674 portid_t port_id = res->port_id; 4675 int32_t rc = -EINVAL; 4676 4677 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 4678 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 4679 4680 if (!strcmp(res->value, "bypass")) 4681 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 4682 else if (!strcmp(res->value, "isolate")) 4683 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 4684 else 4685 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 4686 4687 /* Set the bypass mode for the relevant port. */ 4688 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 4689 #endif 4690 if (rc != 0) 4691 printf("\t Failed to set bypass mode for port = %d.\n", port_id); 4692 } 4693 4694 cmdline_parse_token_string_t cmd_setbypass_mode_set = 4695 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 4696 set, "set"); 4697 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 4698 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 4699 bypass, "bypass"); 4700 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 4701 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 4702 mode, "mode"); 4703 cmdline_parse_token_string_t cmd_setbypass_mode_value = 4704 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 4705 value, "normal#bypass#isolate"); 4706 cmdline_parse_token_num_t cmd_setbypass_mode_port = 4707 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 4708 port_id, UINT16); 4709 4710 cmdline_parse_inst_t cmd_set_bypass_mode = { 4711 .f = cmd_set_bypass_mode_parsed, 4712 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 4713 "Set the NIC bypass mode for port_id", 4714 .data = NULL, 4715 .tokens = { 4716 (void *)&cmd_setbypass_mode_set, 4717 (void *)&cmd_setbypass_mode_bypass, 4718 (void *)&cmd_setbypass_mode_mode, 4719 (void *)&cmd_setbypass_mode_value, 4720 (void *)&cmd_setbypass_mode_port, 4721 NULL, 4722 }, 4723 }; 4724 4725 /* *** SET NIC BYPASS EVENT *** */ 4726 struct cmd_set_bypass_event_result { 4727 cmdline_fixed_string_t set; 4728 cmdline_fixed_string_t bypass; 4729 cmdline_fixed_string_t event; 4730 cmdline_fixed_string_t event_value; 4731 cmdline_fixed_string_t mode; 4732 cmdline_fixed_string_t mode_value; 4733 portid_t port_id; 4734 }; 4735 4736 static void 4737 cmd_set_bypass_event_parsed(void *parsed_result, 4738 __attribute__((unused)) struct cmdline *cl, 4739 __attribute__((unused)) void *data) 4740 { 4741 int32_t rc = -EINVAL; 4742 struct cmd_set_bypass_event_result *res = parsed_result; 4743 portid_t port_id = res->port_id; 4744 4745 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 4746 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 4747 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 4748 4749 if (!strcmp(res->event_value, "timeout")) 4750 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 4751 else if (!strcmp(res->event_value, "os_on")) 4752 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 4753 else if (!strcmp(res->event_value, "os_off")) 4754 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 4755 else if (!strcmp(res->event_value, "power_on")) 4756 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 4757 else if (!strcmp(res->event_value, "power_off")) 4758 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 4759 else 4760 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 4761 4762 if (!strcmp(res->mode_value, "bypass")) 4763 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 4764 else if (!strcmp(res->mode_value, "isolate")) 4765 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 4766 else 4767 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 4768 4769 /* Set the watchdog timeout. */ 4770 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 4771 4772 rc = -EINVAL; 4773 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 4774 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 4775 bypass_timeout); 4776 } 4777 if (rc != 0) { 4778 printf("Failed to set timeout value %u " 4779 "for port %d, errto code: %d.\n", 4780 bypass_timeout, port_id, rc); 4781 } 4782 } 4783 4784 /* Set the bypass event to transition to bypass mode. */ 4785 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 4786 bypass_mode); 4787 #endif 4788 4789 if (rc != 0) 4790 printf("\t Failed to set bypass event for port = %d.\n", 4791 port_id); 4792 } 4793 4794 cmdline_parse_token_string_t cmd_setbypass_event_set = 4795 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 4796 set, "set"); 4797 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 4798 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 4799 bypass, "bypass"); 4800 cmdline_parse_token_string_t cmd_setbypass_event_event = 4801 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 4802 event, "event"); 4803 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 4804 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 4805 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 4806 cmdline_parse_token_string_t cmd_setbypass_event_mode = 4807 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 4808 mode, "mode"); 4809 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 4810 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 4811 mode_value, "normal#bypass#isolate"); 4812 cmdline_parse_token_num_t cmd_setbypass_event_port = 4813 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 4814 port_id, UINT16); 4815 4816 cmdline_parse_inst_t cmd_set_bypass_event = { 4817 .f = cmd_set_bypass_event_parsed, 4818 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 4819 "power_off mode normal|bypass|isolate <port_id>: " 4820 "Set the NIC bypass event mode for port_id", 4821 .data = NULL, 4822 .tokens = { 4823 (void *)&cmd_setbypass_event_set, 4824 (void *)&cmd_setbypass_event_bypass, 4825 (void *)&cmd_setbypass_event_event, 4826 (void *)&cmd_setbypass_event_event_value, 4827 (void *)&cmd_setbypass_event_mode, 4828 (void *)&cmd_setbypass_event_mode_value, 4829 (void *)&cmd_setbypass_event_port, 4830 NULL, 4831 }, 4832 }; 4833 4834 4835 /* *** SET NIC BYPASS TIMEOUT *** */ 4836 struct cmd_set_bypass_timeout_result { 4837 cmdline_fixed_string_t set; 4838 cmdline_fixed_string_t bypass; 4839 cmdline_fixed_string_t timeout; 4840 cmdline_fixed_string_t value; 4841 }; 4842 4843 static void 4844 cmd_set_bypass_timeout_parsed(void *parsed_result, 4845 __attribute__((unused)) struct cmdline *cl, 4846 __attribute__((unused)) void *data) 4847 { 4848 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 4849 4850 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 4851 if (!strcmp(res->value, "1.5")) 4852 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 4853 else if (!strcmp(res->value, "2")) 4854 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 4855 else if (!strcmp(res->value, "3")) 4856 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 4857 else if (!strcmp(res->value, "4")) 4858 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 4859 else if (!strcmp(res->value, "8")) 4860 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 4861 else if (!strcmp(res->value, "16")) 4862 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 4863 else if (!strcmp(res->value, "32")) 4864 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 4865 else 4866 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 4867 #endif 4868 } 4869 4870 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 4871 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 4872 set, "set"); 4873 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 4874 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 4875 bypass, "bypass"); 4876 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 4877 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 4878 timeout, "timeout"); 4879 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 4880 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 4881 value, "0#1.5#2#3#4#8#16#32"); 4882 4883 cmdline_parse_inst_t cmd_set_bypass_timeout = { 4884 .f = cmd_set_bypass_timeout_parsed, 4885 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 4886 "Set the NIC bypass watchdog timeout in seconds", 4887 .data = NULL, 4888 .tokens = { 4889 (void *)&cmd_setbypass_timeout_set, 4890 (void *)&cmd_setbypass_timeout_bypass, 4891 (void *)&cmd_setbypass_timeout_timeout, 4892 (void *)&cmd_setbypass_timeout_value, 4893 NULL, 4894 }, 4895 }; 4896 4897 /* *** SHOW NIC BYPASS MODE *** */ 4898 struct cmd_show_bypass_config_result { 4899 cmdline_fixed_string_t show; 4900 cmdline_fixed_string_t bypass; 4901 cmdline_fixed_string_t config; 4902 portid_t port_id; 4903 }; 4904 4905 static void 4906 cmd_show_bypass_config_parsed(void *parsed_result, 4907 __attribute__((unused)) struct cmdline *cl, 4908 __attribute__((unused)) void *data) 4909 { 4910 struct cmd_show_bypass_config_result *res = parsed_result; 4911 portid_t port_id = res->port_id; 4912 int rc = -EINVAL; 4913 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 4914 uint32_t event_mode; 4915 uint32_t bypass_mode; 4916 uint32_t timeout = bypass_timeout; 4917 int i; 4918 4919 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 4920 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 4921 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 4922 {"UNKNOWN", "normal", "bypass", "isolate"}; 4923 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 4924 "NONE", 4925 "OS/board on", 4926 "power supply on", 4927 "OS/board off", 4928 "power supply off", 4929 "timeout"}; 4930 int num_events = (sizeof events) / (sizeof events[0]); 4931 4932 /* Display the bypass mode.*/ 4933 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 4934 printf("\tFailed to get bypass mode for port = %d\n", port_id); 4935 return; 4936 } 4937 else { 4938 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 4939 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 4940 4941 printf("\tbypass mode = %s\n", modes[bypass_mode]); 4942 } 4943 4944 /* Display the bypass timeout.*/ 4945 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 4946 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 4947 4948 printf("\tbypass timeout = %s\n", timeouts[timeout]); 4949 4950 /* Display the bypass events and associated modes. */ 4951 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) { 4952 4953 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 4954 printf("\tFailed to get bypass mode for event = %s\n", 4955 events[i]); 4956 } else { 4957 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 4958 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 4959 4960 printf("\tbypass event: %-16s = %s\n", events[i], 4961 modes[event_mode]); 4962 } 4963 } 4964 #endif 4965 if (rc != 0) 4966 printf("\tFailed to get bypass configuration for port = %d\n", 4967 port_id); 4968 } 4969 4970 cmdline_parse_token_string_t cmd_showbypass_config_show = 4971 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 4972 show, "show"); 4973 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 4974 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 4975 bypass, "bypass"); 4976 cmdline_parse_token_string_t cmd_showbypass_config_config = 4977 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 4978 config, "config"); 4979 cmdline_parse_token_num_t cmd_showbypass_config_port = 4980 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 4981 port_id, UINT16); 4982 4983 cmdline_parse_inst_t cmd_show_bypass_config = { 4984 .f = cmd_show_bypass_config_parsed, 4985 .help_str = "show bypass config <port_id>: " 4986 "Show the NIC bypass config for port_id", 4987 .data = NULL, 4988 .tokens = { 4989 (void *)&cmd_showbypass_config_show, 4990 (void *)&cmd_showbypass_config_bypass, 4991 (void *)&cmd_showbypass_config_config, 4992 (void *)&cmd_showbypass_config_port, 4993 NULL, 4994 }, 4995 }; 4996 4997 #ifdef RTE_LIBRTE_PMD_BOND 4998 /* *** SET BONDING MODE *** */ 4999 struct cmd_set_bonding_mode_result { 5000 cmdline_fixed_string_t set; 5001 cmdline_fixed_string_t bonding; 5002 cmdline_fixed_string_t mode; 5003 uint8_t value; 5004 portid_t port_id; 5005 }; 5006 5007 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5008 __attribute__((unused)) struct cmdline *cl, 5009 __attribute__((unused)) void *data) 5010 { 5011 struct cmd_set_bonding_mode_result *res = parsed_result; 5012 portid_t port_id = res->port_id; 5013 5014 /* Set the bonding mode for the relevant port. */ 5015 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5016 printf("\t Failed to set bonding mode for port = %d.\n", port_id); 5017 } 5018 5019 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5020 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5021 set, "set"); 5022 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5023 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5024 bonding, "bonding"); 5025 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5026 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5027 mode, "mode"); 5028 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5029 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5030 value, UINT8); 5031 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5032 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5033 port_id, UINT16); 5034 5035 cmdline_parse_inst_t cmd_set_bonding_mode = { 5036 .f = cmd_set_bonding_mode_parsed, 5037 .help_str = "set bonding mode <mode_value> <port_id>: " 5038 "Set the bonding mode for port_id", 5039 .data = NULL, 5040 .tokens = { 5041 (void *) &cmd_setbonding_mode_set, 5042 (void *) &cmd_setbonding_mode_bonding, 5043 (void *) &cmd_setbonding_mode_mode, 5044 (void *) &cmd_setbonding_mode_value, 5045 (void *) &cmd_setbonding_mode_port, 5046 NULL 5047 } 5048 }; 5049 5050 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5051 struct cmd_set_bonding_lacp_dedicated_queues_result { 5052 cmdline_fixed_string_t set; 5053 cmdline_fixed_string_t bonding; 5054 cmdline_fixed_string_t lacp; 5055 cmdline_fixed_string_t dedicated_queues; 5056 portid_t port_id; 5057 cmdline_fixed_string_t mode; 5058 }; 5059 5060 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5061 __attribute__((unused)) struct cmdline *cl, 5062 __attribute__((unused)) void *data) 5063 { 5064 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5065 portid_t port_id = res->port_id; 5066 struct rte_port *port; 5067 5068 port = &ports[port_id]; 5069 5070 /** Check if the port is not started **/ 5071 if (port->port_status != RTE_PORT_STOPPED) { 5072 printf("Please stop port %d first\n", port_id); 5073 return; 5074 } 5075 5076 if (!strcmp(res->mode, "enable")) { 5077 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5078 printf("Dedicate queues for LACP control packets" 5079 " enabled\n"); 5080 else 5081 printf("Enabling dedicate queues for LACP control " 5082 "packets on port %d failed\n", port_id); 5083 } else if (!strcmp(res->mode, "disable")) { 5084 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5085 printf("Dedicated queues for LACP control packets " 5086 "disabled\n"); 5087 else 5088 printf("Disabling dedicated queues for LACP control " 5089 "traffic on port %d failed\n", port_id); 5090 } 5091 } 5092 5093 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 5094 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5095 set, "set"); 5096 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 5097 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5098 bonding, "bonding"); 5099 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 5100 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5101 lacp, "lacp"); 5102 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 5103 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5104 dedicated_queues, "dedicated_queues"); 5105 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 5106 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5107 port_id, UINT16); 5108 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 5109 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5110 mode, "enable#disable"); 5111 5112 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 5113 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 5114 .help_str = "set bonding lacp dedicated_queues <port_id> " 5115 "enable|disable: " 5116 "Enable/disable dedicated queues for LACP control traffic for port_id", 5117 .data = NULL, 5118 .tokens = { 5119 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 5120 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 5121 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 5122 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 5123 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 5124 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 5125 NULL 5126 } 5127 }; 5128 5129 /* *** SET BALANCE XMIT POLICY *** */ 5130 struct cmd_set_bonding_balance_xmit_policy_result { 5131 cmdline_fixed_string_t set; 5132 cmdline_fixed_string_t bonding; 5133 cmdline_fixed_string_t balance_xmit_policy; 5134 portid_t port_id; 5135 cmdline_fixed_string_t policy; 5136 }; 5137 5138 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 5139 __attribute__((unused)) struct cmdline *cl, 5140 __attribute__((unused)) void *data) 5141 { 5142 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 5143 portid_t port_id = res->port_id; 5144 uint8_t policy; 5145 5146 if (!strcmp(res->policy, "l2")) { 5147 policy = BALANCE_XMIT_POLICY_LAYER2; 5148 } else if (!strcmp(res->policy, "l23")) { 5149 policy = BALANCE_XMIT_POLICY_LAYER23; 5150 } else if (!strcmp(res->policy, "l34")) { 5151 policy = BALANCE_XMIT_POLICY_LAYER34; 5152 } else { 5153 printf("\t Invalid xmit policy selection"); 5154 return; 5155 } 5156 5157 /* Set the bonding mode for the relevant port. */ 5158 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 5159 printf("\t Failed to set bonding balance xmit policy for port = %d.\n", 5160 port_id); 5161 } 5162 } 5163 5164 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 5165 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5166 set, "set"); 5167 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 5168 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5169 bonding, "bonding"); 5170 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 5171 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5172 balance_xmit_policy, "balance_xmit_policy"); 5173 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 5174 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5175 port_id, UINT16); 5176 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 5177 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5178 policy, "l2#l23#l34"); 5179 5180 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 5181 .f = cmd_set_bonding_balance_xmit_policy_parsed, 5182 .help_str = "set bonding balance_xmit_policy <port_id> " 5183 "l2|l23|l34: " 5184 "Set the bonding balance_xmit_policy for port_id", 5185 .data = NULL, 5186 .tokens = { 5187 (void *)&cmd_setbonding_balance_xmit_policy_set, 5188 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 5189 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 5190 (void *)&cmd_setbonding_balance_xmit_policy_port, 5191 (void *)&cmd_setbonding_balance_xmit_policy_policy, 5192 NULL 5193 } 5194 }; 5195 5196 /* *** SHOW NIC BONDING CONFIGURATION *** */ 5197 struct cmd_show_bonding_config_result { 5198 cmdline_fixed_string_t show; 5199 cmdline_fixed_string_t bonding; 5200 cmdline_fixed_string_t config; 5201 portid_t port_id; 5202 }; 5203 5204 static void cmd_show_bonding_config_parsed(void *parsed_result, 5205 __attribute__((unused)) struct cmdline *cl, 5206 __attribute__((unused)) void *data) 5207 { 5208 struct cmd_show_bonding_config_result *res = parsed_result; 5209 int bonding_mode, agg_mode; 5210 portid_t slaves[RTE_MAX_ETHPORTS]; 5211 int num_slaves, num_active_slaves; 5212 int primary_id; 5213 int i; 5214 portid_t port_id = res->port_id; 5215 5216 /* Display the bonding mode.*/ 5217 bonding_mode = rte_eth_bond_mode_get(port_id); 5218 if (bonding_mode < 0) { 5219 printf("\tFailed to get bonding mode for port = %d\n", port_id); 5220 return; 5221 } else 5222 printf("\tBonding mode: %d\n", bonding_mode); 5223 5224 if (bonding_mode == BONDING_MODE_BALANCE) { 5225 int balance_xmit_policy; 5226 5227 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 5228 if (balance_xmit_policy < 0) { 5229 printf("\tFailed to get balance xmit policy for port = %d\n", 5230 port_id); 5231 return; 5232 } else { 5233 printf("\tBalance Xmit Policy: "); 5234 5235 switch (balance_xmit_policy) { 5236 case BALANCE_XMIT_POLICY_LAYER2: 5237 printf("BALANCE_XMIT_POLICY_LAYER2"); 5238 break; 5239 case BALANCE_XMIT_POLICY_LAYER23: 5240 printf("BALANCE_XMIT_POLICY_LAYER23"); 5241 break; 5242 case BALANCE_XMIT_POLICY_LAYER34: 5243 printf("BALANCE_XMIT_POLICY_LAYER34"); 5244 break; 5245 } 5246 printf("\n"); 5247 } 5248 } 5249 5250 if (bonding_mode == BONDING_MODE_8023AD) { 5251 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 5252 printf("\tIEEE802.3AD Aggregator Mode: "); 5253 switch (agg_mode) { 5254 case AGG_BANDWIDTH: 5255 printf("bandwidth"); 5256 break; 5257 case AGG_STABLE: 5258 printf("stable"); 5259 break; 5260 case AGG_COUNT: 5261 printf("count"); 5262 break; 5263 } 5264 printf("\n"); 5265 } 5266 5267 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 5268 5269 if (num_slaves < 0) { 5270 printf("\tFailed to get slave list for port = %d\n", port_id); 5271 return; 5272 } 5273 if (num_slaves > 0) { 5274 printf("\tSlaves (%d): [", num_slaves); 5275 for (i = 0; i < num_slaves - 1; i++) 5276 printf("%d ", slaves[i]); 5277 5278 printf("%d]\n", slaves[num_slaves - 1]); 5279 } else { 5280 printf("\tSlaves: []\n"); 5281 5282 } 5283 5284 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 5285 RTE_MAX_ETHPORTS); 5286 5287 if (num_active_slaves < 0) { 5288 printf("\tFailed to get active slave list for port = %d\n", port_id); 5289 return; 5290 } 5291 if (num_active_slaves > 0) { 5292 printf("\tActive Slaves (%d): [", num_active_slaves); 5293 for (i = 0; i < num_active_slaves - 1; i++) 5294 printf("%d ", slaves[i]); 5295 5296 printf("%d]\n", slaves[num_active_slaves - 1]); 5297 5298 } else { 5299 printf("\tActive Slaves: []\n"); 5300 5301 } 5302 5303 primary_id = rte_eth_bond_primary_get(port_id); 5304 if (primary_id < 0) { 5305 printf("\tFailed to get primary slave for port = %d\n", port_id); 5306 return; 5307 } else 5308 printf("\tPrimary: [%d]\n", primary_id); 5309 5310 } 5311 5312 cmdline_parse_token_string_t cmd_showbonding_config_show = 5313 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5314 show, "show"); 5315 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 5316 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5317 bonding, "bonding"); 5318 cmdline_parse_token_string_t cmd_showbonding_config_config = 5319 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5320 config, "config"); 5321 cmdline_parse_token_num_t cmd_showbonding_config_port = 5322 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 5323 port_id, UINT16); 5324 5325 cmdline_parse_inst_t cmd_show_bonding_config = { 5326 .f = cmd_show_bonding_config_parsed, 5327 .help_str = "show bonding config <port_id>: " 5328 "Show the bonding config for port_id", 5329 .data = NULL, 5330 .tokens = { 5331 (void *)&cmd_showbonding_config_show, 5332 (void *)&cmd_showbonding_config_bonding, 5333 (void *)&cmd_showbonding_config_config, 5334 (void *)&cmd_showbonding_config_port, 5335 NULL 5336 } 5337 }; 5338 5339 /* *** SET BONDING PRIMARY *** */ 5340 struct cmd_set_bonding_primary_result { 5341 cmdline_fixed_string_t set; 5342 cmdline_fixed_string_t bonding; 5343 cmdline_fixed_string_t primary; 5344 portid_t slave_id; 5345 portid_t port_id; 5346 }; 5347 5348 static void cmd_set_bonding_primary_parsed(void *parsed_result, 5349 __attribute__((unused)) struct cmdline *cl, 5350 __attribute__((unused)) void *data) 5351 { 5352 struct cmd_set_bonding_primary_result *res = parsed_result; 5353 portid_t master_port_id = res->port_id; 5354 portid_t slave_port_id = res->slave_id; 5355 5356 /* Set the primary slave for a bonded device. */ 5357 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 5358 printf("\t Failed to set primary slave for port = %d.\n", 5359 master_port_id); 5360 return; 5361 } 5362 init_port_config(); 5363 } 5364 5365 cmdline_parse_token_string_t cmd_setbonding_primary_set = 5366 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5367 set, "set"); 5368 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 5369 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5370 bonding, "bonding"); 5371 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 5372 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5373 primary, "primary"); 5374 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 5375 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5376 slave_id, UINT16); 5377 cmdline_parse_token_num_t cmd_setbonding_primary_port = 5378 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5379 port_id, UINT16); 5380 5381 cmdline_parse_inst_t cmd_set_bonding_primary = { 5382 .f = cmd_set_bonding_primary_parsed, 5383 .help_str = "set bonding primary <slave_id> <port_id>: " 5384 "Set the primary slave for port_id", 5385 .data = NULL, 5386 .tokens = { 5387 (void *)&cmd_setbonding_primary_set, 5388 (void *)&cmd_setbonding_primary_bonding, 5389 (void *)&cmd_setbonding_primary_primary, 5390 (void *)&cmd_setbonding_primary_slave, 5391 (void *)&cmd_setbonding_primary_port, 5392 NULL 5393 } 5394 }; 5395 5396 /* *** ADD SLAVE *** */ 5397 struct cmd_add_bonding_slave_result { 5398 cmdline_fixed_string_t add; 5399 cmdline_fixed_string_t bonding; 5400 cmdline_fixed_string_t slave; 5401 portid_t slave_id; 5402 portid_t port_id; 5403 }; 5404 5405 static void cmd_add_bonding_slave_parsed(void *parsed_result, 5406 __attribute__((unused)) struct cmdline *cl, 5407 __attribute__((unused)) void *data) 5408 { 5409 struct cmd_add_bonding_slave_result *res = parsed_result; 5410 portid_t master_port_id = res->port_id; 5411 portid_t slave_port_id = res->slave_id; 5412 5413 /* add the slave for a bonded device. */ 5414 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 5415 printf("\t Failed to add slave %d to master port = %d.\n", 5416 slave_port_id, master_port_id); 5417 return; 5418 } 5419 init_port_config(); 5420 set_port_slave_flag(slave_port_id); 5421 } 5422 5423 cmdline_parse_token_string_t cmd_addbonding_slave_add = 5424 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5425 add, "add"); 5426 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 5427 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5428 bonding, "bonding"); 5429 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 5430 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5431 slave, "slave"); 5432 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 5433 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5434 slave_id, UINT16); 5435 cmdline_parse_token_num_t cmd_addbonding_slave_port = 5436 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5437 port_id, UINT16); 5438 5439 cmdline_parse_inst_t cmd_add_bonding_slave = { 5440 .f = cmd_add_bonding_slave_parsed, 5441 .help_str = "add bonding slave <slave_id> <port_id>: " 5442 "Add a slave device to a bonded device", 5443 .data = NULL, 5444 .tokens = { 5445 (void *)&cmd_addbonding_slave_add, 5446 (void *)&cmd_addbonding_slave_bonding, 5447 (void *)&cmd_addbonding_slave_slave, 5448 (void *)&cmd_addbonding_slave_slaveid, 5449 (void *)&cmd_addbonding_slave_port, 5450 NULL 5451 } 5452 }; 5453 5454 /* *** REMOVE SLAVE *** */ 5455 struct cmd_remove_bonding_slave_result { 5456 cmdline_fixed_string_t remove; 5457 cmdline_fixed_string_t bonding; 5458 cmdline_fixed_string_t slave; 5459 portid_t slave_id; 5460 portid_t port_id; 5461 }; 5462 5463 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 5464 __attribute__((unused)) struct cmdline *cl, 5465 __attribute__((unused)) void *data) 5466 { 5467 struct cmd_remove_bonding_slave_result *res = parsed_result; 5468 portid_t master_port_id = res->port_id; 5469 portid_t slave_port_id = res->slave_id; 5470 5471 /* remove the slave from a bonded device. */ 5472 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 5473 printf("\t Failed to remove slave %d from master port = %d.\n", 5474 slave_port_id, master_port_id); 5475 return; 5476 } 5477 init_port_config(); 5478 clear_port_slave_flag(slave_port_id); 5479 } 5480 5481 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 5482 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 5483 remove, "remove"); 5484 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 5485 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 5486 bonding, "bonding"); 5487 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 5488 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 5489 slave, "slave"); 5490 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 5491 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 5492 slave_id, UINT16); 5493 cmdline_parse_token_num_t cmd_removebonding_slave_port = 5494 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 5495 port_id, UINT16); 5496 5497 cmdline_parse_inst_t cmd_remove_bonding_slave = { 5498 .f = cmd_remove_bonding_slave_parsed, 5499 .help_str = "remove bonding slave <slave_id> <port_id>: " 5500 "Remove a slave device from a bonded device", 5501 .data = NULL, 5502 .tokens = { 5503 (void *)&cmd_removebonding_slave_remove, 5504 (void *)&cmd_removebonding_slave_bonding, 5505 (void *)&cmd_removebonding_slave_slave, 5506 (void *)&cmd_removebonding_slave_slaveid, 5507 (void *)&cmd_removebonding_slave_port, 5508 NULL 5509 } 5510 }; 5511 5512 /* *** CREATE BONDED DEVICE *** */ 5513 struct cmd_create_bonded_device_result { 5514 cmdline_fixed_string_t create; 5515 cmdline_fixed_string_t bonded; 5516 cmdline_fixed_string_t device; 5517 uint8_t mode; 5518 uint8_t socket; 5519 }; 5520 5521 static int bond_dev_num = 0; 5522 5523 static void cmd_create_bonded_device_parsed(void *parsed_result, 5524 __attribute__((unused)) struct cmdline *cl, 5525 __attribute__((unused)) void *data) 5526 { 5527 struct cmd_create_bonded_device_result *res = parsed_result; 5528 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 5529 int port_id; 5530 5531 if (test_done == 0) { 5532 printf("Please stop forwarding first\n"); 5533 return; 5534 } 5535 5536 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 5537 bond_dev_num++); 5538 5539 /* Create a new bonded device. */ 5540 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 5541 if (port_id < 0) { 5542 printf("\t Failed to create bonded device.\n"); 5543 return; 5544 } else { 5545 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 5546 port_id); 5547 5548 /* Update number of ports */ 5549 nb_ports = rte_eth_dev_count_avail(); 5550 reconfig(port_id, res->socket); 5551 rte_eth_promiscuous_enable(port_id); 5552 } 5553 5554 } 5555 5556 cmdline_parse_token_string_t cmd_createbonded_device_create = 5557 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 5558 create, "create"); 5559 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 5560 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 5561 bonded, "bonded"); 5562 cmdline_parse_token_string_t cmd_createbonded_device_device = 5563 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 5564 device, "device"); 5565 cmdline_parse_token_num_t cmd_createbonded_device_mode = 5566 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 5567 mode, UINT8); 5568 cmdline_parse_token_num_t cmd_createbonded_device_socket = 5569 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 5570 socket, UINT8); 5571 5572 cmdline_parse_inst_t cmd_create_bonded_device = { 5573 .f = cmd_create_bonded_device_parsed, 5574 .help_str = "create bonded device <mode> <socket>: " 5575 "Create a new bonded device with specific bonding mode and socket", 5576 .data = NULL, 5577 .tokens = { 5578 (void *)&cmd_createbonded_device_create, 5579 (void *)&cmd_createbonded_device_bonded, 5580 (void *)&cmd_createbonded_device_device, 5581 (void *)&cmd_createbonded_device_mode, 5582 (void *)&cmd_createbonded_device_socket, 5583 NULL 5584 } 5585 }; 5586 5587 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 5588 struct cmd_set_bond_mac_addr_result { 5589 cmdline_fixed_string_t set; 5590 cmdline_fixed_string_t bonding; 5591 cmdline_fixed_string_t mac_addr; 5592 uint16_t port_num; 5593 struct ether_addr address; 5594 }; 5595 5596 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 5597 __attribute__((unused)) struct cmdline *cl, 5598 __attribute__((unused)) void *data) 5599 { 5600 struct cmd_set_bond_mac_addr_result *res = parsed_result; 5601 int ret; 5602 5603 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 5604 return; 5605 5606 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 5607 5608 /* check the return value and print it if is < 0 */ 5609 if (ret < 0) 5610 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 5611 } 5612 5613 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 5614 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 5615 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 5616 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 5617 "bonding"); 5618 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 5619 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 5620 "mac_addr"); 5621 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 5622 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 5623 port_num, UINT16); 5624 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 5625 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 5626 5627 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 5628 .f = cmd_set_bond_mac_addr_parsed, 5629 .data = (void *) 0, 5630 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 5631 .tokens = { 5632 (void *)&cmd_set_bond_mac_addr_set, 5633 (void *)&cmd_set_bond_mac_addr_bonding, 5634 (void *)&cmd_set_bond_mac_addr_mac, 5635 (void *)&cmd_set_bond_mac_addr_portnum, 5636 (void *)&cmd_set_bond_mac_addr_addr, 5637 NULL 5638 } 5639 }; 5640 5641 5642 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 5643 struct cmd_set_bond_mon_period_result { 5644 cmdline_fixed_string_t set; 5645 cmdline_fixed_string_t bonding; 5646 cmdline_fixed_string_t mon_period; 5647 uint16_t port_num; 5648 uint32_t period_ms; 5649 }; 5650 5651 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 5652 __attribute__((unused)) struct cmdline *cl, 5653 __attribute__((unused)) void *data) 5654 { 5655 struct cmd_set_bond_mon_period_result *res = parsed_result; 5656 int ret; 5657 5658 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 5659 5660 /* check the return value and print it if is < 0 */ 5661 if (ret < 0) 5662 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 5663 } 5664 5665 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 5666 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 5667 set, "set"); 5668 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 5669 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 5670 bonding, "bonding"); 5671 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 5672 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 5673 mon_period, "mon_period"); 5674 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 5675 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 5676 port_num, UINT16); 5677 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 5678 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 5679 period_ms, UINT32); 5680 5681 cmdline_parse_inst_t cmd_set_bond_mon_period = { 5682 .f = cmd_set_bond_mon_period_parsed, 5683 .data = (void *) 0, 5684 .help_str = "set bonding mon_period <port_id> <period_ms>", 5685 .tokens = { 5686 (void *)&cmd_set_bond_mon_period_set, 5687 (void *)&cmd_set_bond_mon_period_bonding, 5688 (void *)&cmd_set_bond_mon_period_mon_period, 5689 (void *)&cmd_set_bond_mon_period_portnum, 5690 (void *)&cmd_set_bond_mon_period_period_ms, 5691 NULL 5692 } 5693 }; 5694 5695 5696 5697 struct cmd_set_bonding_agg_mode_policy_result { 5698 cmdline_fixed_string_t set; 5699 cmdline_fixed_string_t bonding; 5700 cmdline_fixed_string_t agg_mode; 5701 uint16_t port_num; 5702 cmdline_fixed_string_t policy; 5703 }; 5704 5705 5706 static void 5707 cmd_set_bonding_agg_mode(void *parsed_result, 5708 __attribute__((unused)) struct cmdline *cl, 5709 __attribute__((unused)) void *data) 5710 { 5711 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 5712 uint8_t policy = AGG_BANDWIDTH; 5713 5714 if (!strcmp(res->policy, "bandwidth")) 5715 policy = AGG_BANDWIDTH; 5716 else if (!strcmp(res->policy, "stable")) 5717 policy = AGG_STABLE; 5718 else if (!strcmp(res->policy, "count")) 5719 policy = AGG_COUNT; 5720 5721 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 5722 } 5723 5724 5725 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 5726 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 5727 set, "set"); 5728 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 5729 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 5730 bonding, "bonding"); 5731 5732 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 5733 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 5734 agg_mode, "agg_mode"); 5735 5736 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 5737 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 5738 port_num, UINT16); 5739 5740 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 5741 TOKEN_STRING_INITIALIZER( 5742 struct cmd_set_bonding_balance_xmit_policy_result, 5743 policy, "stable#bandwidth#count"); 5744 5745 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 5746 .f = cmd_set_bonding_agg_mode, 5747 .data = (void *) 0, 5748 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 5749 .tokens = { 5750 (void *)&cmd_set_bonding_agg_mode_set, 5751 (void *)&cmd_set_bonding_agg_mode_bonding, 5752 (void *)&cmd_set_bonding_agg_mode_agg_mode, 5753 (void *)&cmd_set_bonding_agg_mode_portnum, 5754 (void *)&cmd_set_bonding_agg_mode_policy_string, 5755 NULL 5756 } 5757 }; 5758 5759 5760 #endif /* RTE_LIBRTE_PMD_BOND */ 5761 5762 /* *** SET FORWARDING MODE *** */ 5763 struct cmd_set_fwd_mode_result { 5764 cmdline_fixed_string_t set; 5765 cmdline_fixed_string_t fwd; 5766 cmdline_fixed_string_t mode; 5767 }; 5768 5769 static void cmd_set_fwd_mode_parsed(void *parsed_result, 5770 __attribute__((unused)) struct cmdline *cl, 5771 __attribute__((unused)) void *data) 5772 { 5773 struct cmd_set_fwd_mode_result *res = parsed_result; 5774 5775 retry_enabled = 0; 5776 set_pkt_forwarding_mode(res->mode); 5777 } 5778 5779 cmdline_parse_token_string_t cmd_setfwd_set = 5780 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 5781 cmdline_parse_token_string_t cmd_setfwd_fwd = 5782 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 5783 cmdline_parse_token_string_t cmd_setfwd_mode = 5784 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 5785 "" /* defined at init */); 5786 5787 cmdline_parse_inst_t cmd_set_fwd_mode = { 5788 .f = cmd_set_fwd_mode_parsed, 5789 .data = NULL, 5790 .help_str = NULL, /* defined at init */ 5791 .tokens = { 5792 (void *)&cmd_setfwd_set, 5793 (void *)&cmd_setfwd_fwd, 5794 (void *)&cmd_setfwd_mode, 5795 NULL, 5796 }, 5797 }; 5798 5799 static void cmd_set_fwd_mode_init(void) 5800 { 5801 char *modes, *c; 5802 static char token[128]; 5803 static char help[256]; 5804 cmdline_parse_token_string_t *token_struct; 5805 5806 modes = list_pkt_forwarding_modes(); 5807 snprintf(help, sizeof(help), "set fwd %s: " 5808 "Set packet forwarding mode", modes); 5809 cmd_set_fwd_mode.help_str = help; 5810 5811 /* string token separator is # */ 5812 for (c = token; *modes != '\0'; modes++) 5813 if (*modes == '|') 5814 *c++ = '#'; 5815 else 5816 *c++ = *modes; 5817 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 5818 token_struct->string_data.str = token; 5819 } 5820 5821 /* *** SET RETRY FORWARDING MODE *** */ 5822 struct cmd_set_fwd_retry_mode_result { 5823 cmdline_fixed_string_t set; 5824 cmdline_fixed_string_t fwd; 5825 cmdline_fixed_string_t mode; 5826 cmdline_fixed_string_t retry; 5827 }; 5828 5829 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 5830 __attribute__((unused)) struct cmdline *cl, 5831 __attribute__((unused)) void *data) 5832 { 5833 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 5834 5835 retry_enabled = 1; 5836 set_pkt_forwarding_mode(res->mode); 5837 } 5838 5839 cmdline_parse_token_string_t cmd_setfwd_retry_set = 5840 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 5841 set, "set"); 5842 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 5843 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 5844 fwd, "fwd"); 5845 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 5846 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 5847 mode, 5848 "" /* defined at init */); 5849 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 5850 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 5851 retry, "retry"); 5852 5853 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 5854 .f = cmd_set_fwd_retry_mode_parsed, 5855 .data = NULL, 5856 .help_str = NULL, /* defined at init */ 5857 .tokens = { 5858 (void *)&cmd_setfwd_retry_set, 5859 (void *)&cmd_setfwd_retry_fwd, 5860 (void *)&cmd_setfwd_retry_mode, 5861 (void *)&cmd_setfwd_retry_retry, 5862 NULL, 5863 }, 5864 }; 5865 5866 static void cmd_set_fwd_retry_mode_init(void) 5867 { 5868 char *modes, *c; 5869 static char token[128]; 5870 static char help[256]; 5871 cmdline_parse_token_string_t *token_struct; 5872 5873 modes = list_pkt_forwarding_retry_modes(); 5874 snprintf(help, sizeof(help), "set fwd %s retry: " 5875 "Set packet forwarding mode with retry", modes); 5876 cmd_set_fwd_retry_mode.help_str = help; 5877 5878 /* string token separator is # */ 5879 for (c = token; *modes != '\0'; modes++) 5880 if (*modes == '|') 5881 *c++ = '#'; 5882 else 5883 *c++ = *modes; 5884 token_struct = (cmdline_parse_token_string_t *) 5885 cmd_set_fwd_retry_mode.tokens[2]; 5886 token_struct->string_data.str = token; 5887 } 5888 5889 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 5890 struct cmd_set_burst_tx_retry_result { 5891 cmdline_fixed_string_t set; 5892 cmdline_fixed_string_t burst; 5893 cmdline_fixed_string_t tx; 5894 cmdline_fixed_string_t delay; 5895 uint32_t time; 5896 cmdline_fixed_string_t retry; 5897 uint32_t retry_num; 5898 }; 5899 5900 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 5901 __attribute__((unused)) struct cmdline *cl, 5902 __attribute__((unused)) void *data) 5903 { 5904 struct cmd_set_burst_tx_retry_result *res = parsed_result; 5905 5906 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 5907 && !strcmp(res->tx, "tx")) { 5908 if (!strcmp(res->delay, "delay")) 5909 burst_tx_delay_time = res->time; 5910 if (!strcmp(res->retry, "retry")) 5911 burst_tx_retry_num = res->retry_num; 5912 } 5913 5914 } 5915 5916 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 5917 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 5918 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 5919 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 5920 "burst"); 5921 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 5922 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 5923 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 5924 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 5925 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 5926 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32); 5927 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 5928 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 5929 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 5930 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32); 5931 5932 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 5933 .f = cmd_set_burst_tx_retry_parsed, 5934 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 5935 .tokens = { 5936 (void *)&cmd_set_burst_tx_retry_set, 5937 (void *)&cmd_set_burst_tx_retry_burst, 5938 (void *)&cmd_set_burst_tx_retry_tx, 5939 (void *)&cmd_set_burst_tx_retry_delay, 5940 (void *)&cmd_set_burst_tx_retry_time, 5941 (void *)&cmd_set_burst_tx_retry_retry, 5942 (void *)&cmd_set_burst_tx_retry_retry_num, 5943 NULL, 5944 }, 5945 }; 5946 5947 /* *** SET PROMISC MODE *** */ 5948 struct cmd_set_promisc_mode_result { 5949 cmdline_fixed_string_t set; 5950 cmdline_fixed_string_t promisc; 5951 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 5952 uint16_t port_num; /* valid if "allports" argument == 0 */ 5953 cmdline_fixed_string_t mode; 5954 }; 5955 5956 static void cmd_set_promisc_mode_parsed(void *parsed_result, 5957 __attribute__((unused)) struct cmdline *cl, 5958 void *allports) 5959 { 5960 struct cmd_set_promisc_mode_result *res = parsed_result; 5961 int enable; 5962 portid_t i; 5963 5964 if (!strcmp(res->mode, "on")) 5965 enable = 1; 5966 else 5967 enable = 0; 5968 5969 /* all ports */ 5970 if (allports) { 5971 RTE_ETH_FOREACH_DEV(i) { 5972 if (enable) 5973 rte_eth_promiscuous_enable(i); 5974 else 5975 rte_eth_promiscuous_disable(i); 5976 } 5977 } 5978 else { 5979 if (enable) 5980 rte_eth_promiscuous_enable(res->port_num); 5981 else 5982 rte_eth_promiscuous_disable(res->port_num); 5983 } 5984 } 5985 5986 cmdline_parse_token_string_t cmd_setpromisc_set = 5987 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 5988 cmdline_parse_token_string_t cmd_setpromisc_promisc = 5989 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 5990 "promisc"); 5991 cmdline_parse_token_string_t cmd_setpromisc_portall = 5992 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 5993 "all"); 5994 cmdline_parse_token_num_t cmd_setpromisc_portnum = 5995 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 5996 UINT16); 5997 cmdline_parse_token_string_t cmd_setpromisc_mode = 5998 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 5999 "on#off"); 6000 6001 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 6002 .f = cmd_set_promisc_mode_parsed, 6003 .data = (void *)1, 6004 .help_str = "set promisc all on|off: Set promisc mode for all ports", 6005 .tokens = { 6006 (void *)&cmd_setpromisc_set, 6007 (void *)&cmd_setpromisc_promisc, 6008 (void *)&cmd_setpromisc_portall, 6009 (void *)&cmd_setpromisc_mode, 6010 NULL, 6011 }, 6012 }; 6013 6014 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 6015 .f = cmd_set_promisc_mode_parsed, 6016 .data = (void *)0, 6017 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 6018 .tokens = { 6019 (void *)&cmd_setpromisc_set, 6020 (void *)&cmd_setpromisc_promisc, 6021 (void *)&cmd_setpromisc_portnum, 6022 (void *)&cmd_setpromisc_mode, 6023 NULL, 6024 }, 6025 }; 6026 6027 /* *** SET ALLMULTI MODE *** */ 6028 struct cmd_set_allmulti_mode_result { 6029 cmdline_fixed_string_t set; 6030 cmdline_fixed_string_t allmulti; 6031 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6032 uint16_t port_num; /* valid if "allports" argument == 0 */ 6033 cmdline_fixed_string_t mode; 6034 }; 6035 6036 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 6037 __attribute__((unused)) struct cmdline *cl, 6038 void *allports) 6039 { 6040 struct cmd_set_allmulti_mode_result *res = parsed_result; 6041 int enable; 6042 portid_t i; 6043 6044 if (!strcmp(res->mode, "on")) 6045 enable = 1; 6046 else 6047 enable = 0; 6048 6049 /* all ports */ 6050 if (allports) { 6051 RTE_ETH_FOREACH_DEV(i) { 6052 if (enable) 6053 rte_eth_allmulticast_enable(i); 6054 else 6055 rte_eth_allmulticast_disable(i); 6056 } 6057 } 6058 else { 6059 if (enable) 6060 rte_eth_allmulticast_enable(res->port_num); 6061 else 6062 rte_eth_allmulticast_disable(res->port_num); 6063 } 6064 } 6065 6066 cmdline_parse_token_string_t cmd_setallmulti_set = 6067 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 6068 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 6069 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 6070 "allmulti"); 6071 cmdline_parse_token_string_t cmd_setallmulti_portall = 6072 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 6073 "all"); 6074 cmdline_parse_token_num_t cmd_setallmulti_portnum = 6075 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 6076 UINT16); 6077 cmdline_parse_token_string_t cmd_setallmulti_mode = 6078 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 6079 "on#off"); 6080 6081 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 6082 .f = cmd_set_allmulti_mode_parsed, 6083 .data = (void *)1, 6084 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 6085 .tokens = { 6086 (void *)&cmd_setallmulti_set, 6087 (void *)&cmd_setallmulti_allmulti, 6088 (void *)&cmd_setallmulti_portall, 6089 (void *)&cmd_setallmulti_mode, 6090 NULL, 6091 }, 6092 }; 6093 6094 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 6095 .f = cmd_set_allmulti_mode_parsed, 6096 .data = (void *)0, 6097 .help_str = "set allmulti <port_id> on|off: " 6098 "Set allmulti mode on port_id", 6099 .tokens = { 6100 (void *)&cmd_setallmulti_set, 6101 (void *)&cmd_setallmulti_allmulti, 6102 (void *)&cmd_setallmulti_portnum, 6103 (void *)&cmd_setallmulti_mode, 6104 NULL, 6105 }, 6106 }; 6107 6108 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 6109 struct cmd_link_flow_ctrl_set_result { 6110 cmdline_fixed_string_t set; 6111 cmdline_fixed_string_t flow_ctrl; 6112 cmdline_fixed_string_t rx; 6113 cmdline_fixed_string_t rx_lfc_mode; 6114 cmdline_fixed_string_t tx; 6115 cmdline_fixed_string_t tx_lfc_mode; 6116 cmdline_fixed_string_t mac_ctrl_frame_fwd; 6117 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 6118 cmdline_fixed_string_t autoneg_str; 6119 cmdline_fixed_string_t autoneg; 6120 cmdline_fixed_string_t hw_str; 6121 uint32_t high_water; 6122 cmdline_fixed_string_t lw_str; 6123 uint32_t low_water; 6124 cmdline_fixed_string_t pt_str; 6125 uint16_t pause_time; 6126 cmdline_fixed_string_t xon_str; 6127 uint16_t send_xon; 6128 portid_t port_id; 6129 }; 6130 6131 cmdline_parse_token_string_t cmd_lfc_set_set = 6132 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6133 set, "set"); 6134 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 6135 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6136 flow_ctrl, "flow_ctrl"); 6137 cmdline_parse_token_string_t cmd_lfc_set_rx = 6138 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6139 rx, "rx"); 6140 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 6141 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6142 rx_lfc_mode, "on#off"); 6143 cmdline_parse_token_string_t cmd_lfc_set_tx = 6144 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6145 tx, "tx"); 6146 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 6147 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6148 tx_lfc_mode, "on#off"); 6149 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 6150 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6151 hw_str, "high_water"); 6152 cmdline_parse_token_num_t cmd_lfc_set_high_water = 6153 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6154 high_water, UINT32); 6155 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 6156 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6157 lw_str, "low_water"); 6158 cmdline_parse_token_num_t cmd_lfc_set_low_water = 6159 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6160 low_water, UINT32); 6161 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 6162 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6163 pt_str, "pause_time"); 6164 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 6165 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6166 pause_time, UINT16); 6167 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 6168 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6169 xon_str, "send_xon"); 6170 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 6171 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6172 send_xon, UINT16); 6173 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 6174 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6175 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 6176 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 6177 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6178 mac_ctrl_frame_fwd_mode, "on#off"); 6179 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 6180 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6181 autoneg_str, "autoneg"); 6182 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 6183 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6184 autoneg, "on#off"); 6185 cmdline_parse_token_num_t cmd_lfc_set_portid = 6186 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6187 port_id, UINT16); 6188 6189 /* forward declaration */ 6190 static void 6191 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 6192 void *data); 6193 6194 cmdline_parse_inst_t cmd_link_flow_control_set = { 6195 .f = cmd_link_flow_ctrl_set_parsed, 6196 .data = NULL, 6197 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 6198 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 6199 "autoneg on|off <port_id>: Configure the Ethernet flow control", 6200 .tokens = { 6201 (void *)&cmd_lfc_set_set, 6202 (void *)&cmd_lfc_set_flow_ctrl, 6203 (void *)&cmd_lfc_set_rx, 6204 (void *)&cmd_lfc_set_rx_mode, 6205 (void *)&cmd_lfc_set_tx, 6206 (void *)&cmd_lfc_set_tx_mode, 6207 (void *)&cmd_lfc_set_high_water, 6208 (void *)&cmd_lfc_set_low_water, 6209 (void *)&cmd_lfc_set_pause_time, 6210 (void *)&cmd_lfc_set_send_xon, 6211 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6212 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6213 (void *)&cmd_lfc_set_autoneg_str, 6214 (void *)&cmd_lfc_set_autoneg, 6215 (void *)&cmd_lfc_set_portid, 6216 NULL, 6217 }, 6218 }; 6219 6220 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 6221 .f = cmd_link_flow_ctrl_set_parsed, 6222 .data = (void *)&cmd_link_flow_control_set_rx, 6223 .help_str = "set flow_ctrl rx on|off <port_id>: " 6224 "Change rx flow control parameter", 6225 .tokens = { 6226 (void *)&cmd_lfc_set_set, 6227 (void *)&cmd_lfc_set_flow_ctrl, 6228 (void *)&cmd_lfc_set_rx, 6229 (void *)&cmd_lfc_set_rx_mode, 6230 (void *)&cmd_lfc_set_portid, 6231 NULL, 6232 }, 6233 }; 6234 6235 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 6236 .f = cmd_link_flow_ctrl_set_parsed, 6237 .data = (void *)&cmd_link_flow_control_set_tx, 6238 .help_str = "set flow_ctrl tx on|off <port_id>: " 6239 "Change tx flow control parameter", 6240 .tokens = { 6241 (void *)&cmd_lfc_set_set, 6242 (void *)&cmd_lfc_set_flow_ctrl, 6243 (void *)&cmd_lfc_set_tx, 6244 (void *)&cmd_lfc_set_tx_mode, 6245 (void *)&cmd_lfc_set_portid, 6246 NULL, 6247 }, 6248 }; 6249 6250 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 6251 .f = cmd_link_flow_ctrl_set_parsed, 6252 .data = (void *)&cmd_link_flow_control_set_hw, 6253 .help_str = "set flow_ctrl high_water <value> <port_id>: " 6254 "Change high water flow control parameter", 6255 .tokens = { 6256 (void *)&cmd_lfc_set_set, 6257 (void *)&cmd_lfc_set_flow_ctrl, 6258 (void *)&cmd_lfc_set_high_water_str, 6259 (void *)&cmd_lfc_set_high_water, 6260 (void *)&cmd_lfc_set_portid, 6261 NULL, 6262 }, 6263 }; 6264 6265 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 6266 .f = cmd_link_flow_ctrl_set_parsed, 6267 .data = (void *)&cmd_link_flow_control_set_lw, 6268 .help_str = "set flow_ctrl low_water <value> <port_id>: " 6269 "Change low water flow control parameter", 6270 .tokens = { 6271 (void *)&cmd_lfc_set_set, 6272 (void *)&cmd_lfc_set_flow_ctrl, 6273 (void *)&cmd_lfc_set_low_water_str, 6274 (void *)&cmd_lfc_set_low_water, 6275 (void *)&cmd_lfc_set_portid, 6276 NULL, 6277 }, 6278 }; 6279 6280 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 6281 .f = cmd_link_flow_ctrl_set_parsed, 6282 .data = (void *)&cmd_link_flow_control_set_pt, 6283 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 6284 "Change pause time flow control parameter", 6285 .tokens = { 6286 (void *)&cmd_lfc_set_set, 6287 (void *)&cmd_lfc_set_flow_ctrl, 6288 (void *)&cmd_lfc_set_pause_time_str, 6289 (void *)&cmd_lfc_set_pause_time, 6290 (void *)&cmd_lfc_set_portid, 6291 NULL, 6292 }, 6293 }; 6294 6295 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 6296 .f = cmd_link_flow_ctrl_set_parsed, 6297 .data = (void *)&cmd_link_flow_control_set_xon, 6298 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 6299 "Change send_xon flow control parameter", 6300 .tokens = { 6301 (void *)&cmd_lfc_set_set, 6302 (void *)&cmd_lfc_set_flow_ctrl, 6303 (void *)&cmd_lfc_set_send_xon_str, 6304 (void *)&cmd_lfc_set_send_xon, 6305 (void *)&cmd_lfc_set_portid, 6306 NULL, 6307 }, 6308 }; 6309 6310 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 6311 .f = cmd_link_flow_ctrl_set_parsed, 6312 .data = (void *)&cmd_link_flow_control_set_macfwd, 6313 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 6314 "Change mac ctrl fwd flow control parameter", 6315 .tokens = { 6316 (void *)&cmd_lfc_set_set, 6317 (void *)&cmd_lfc_set_flow_ctrl, 6318 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6319 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6320 (void *)&cmd_lfc_set_portid, 6321 NULL, 6322 }, 6323 }; 6324 6325 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 6326 .f = cmd_link_flow_ctrl_set_parsed, 6327 .data = (void *)&cmd_link_flow_control_set_autoneg, 6328 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 6329 "Change autoneg flow control parameter", 6330 .tokens = { 6331 (void *)&cmd_lfc_set_set, 6332 (void *)&cmd_lfc_set_flow_ctrl, 6333 (void *)&cmd_lfc_set_autoneg_str, 6334 (void *)&cmd_lfc_set_autoneg, 6335 (void *)&cmd_lfc_set_portid, 6336 NULL, 6337 }, 6338 }; 6339 6340 static void 6341 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 6342 __attribute__((unused)) struct cmdline *cl, 6343 void *data) 6344 { 6345 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 6346 cmdline_parse_inst_t *cmd = data; 6347 struct rte_eth_fc_conf fc_conf; 6348 int rx_fc_en = 0; 6349 int tx_fc_en = 0; 6350 int ret; 6351 6352 /* 6353 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6354 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6355 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6356 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6357 */ 6358 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 6359 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 6360 }; 6361 6362 /* Partial command line, retrieve current configuration */ 6363 if (cmd) { 6364 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 6365 if (ret != 0) { 6366 printf("cannot get current flow ctrl parameters, return" 6367 "code = %d\n", ret); 6368 return; 6369 } 6370 6371 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 6372 (fc_conf.mode == RTE_FC_FULL)) 6373 rx_fc_en = 1; 6374 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 6375 (fc_conf.mode == RTE_FC_FULL)) 6376 tx_fc_en = 1; 6377 } 6378 6379 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 6380 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 6381 6382 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 6383 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 6384 6385 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 6386 6387 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 6388 fc_conf.high_water = res->high_water; 6389 6390 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 6391 fc_conf.low_water = res->low_water; 6392 6393 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 6394 fc_conf.pause_time = res->pause_time; 6395 6396 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 6397 fc_conf.send_xon = res->send_xon; 6398 6399 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 6400 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 6401 fc_conf.mac_ctrl_frame_fwd = 1; 6402 else 6403 fc_conf.mac_ctrl_frame_fwd = 0; 6404 } 6405 6406 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 6407 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 6408 6409 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 6410 if (ret != 0) 6411 printf("bad flow contrl parameter, return code = %d \n", ret); 6412 } 6413 6414 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 6415 struct cmd_priority_flow_ctrl_set_result { 6416 cmdline_fixed_string_t set; 6417 cmdline_fixed_string_t pfc_ctrl; 6418 cmdline_fixed_string_t rx; 6419 cmdline_fixed_string_t rx_pfc_mode; 6420 cmdline_fixed_string_t tx; 6421 cmdline_fixed_string_t tx_pfc_mode; 6422 uint32_t high_water; 6423 uint32_t low_water; 6424 uint16_t pause_time; 6425 uint8_t priority; 6426 portid_t port_id; 6427 }; 6428 6429 static void 6430 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 6431 __attribute__((unused)) struct cmdline *cl, 6432 __attribute__((unused)) void *data) 6433 { 6434 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 6435 struct rte_eth_pfc_conf pfc_conf; 6436 int rx_fc_enable, tx_fc_enable; 6437 int ret; 6438 6439 /* 6440 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6441 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6442 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6443 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6444 */ 6445 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 6446 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL} 6447 }; 6448 6449 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 6450 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 6451 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 6452 pfc_conf.fc.high_water = res->high_water; 6453 pfc_conf.fc.low_water = res->low_water; 6454 pfc_conf.fc.pause_time = res->pause_time; 6455 pfc_conf.priority = res->priority; 6456 6457 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 6458 if (ret != 0) 6459 printf("bad priority flow contrl parameter, return code = %d \n", ret); 6460 } 6461 6462 cmdline_parse_token_string_t cmd_pfc_set_set = 6463 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6464 set, "set"); 6465 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 6466 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6467 pfc_ctrl, "pfc_ctrl"); 6468 cmdline_parse_token_string_t cmd_pfc_set_rx = 6469 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6470 rx, "rx"); 6471 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 6472 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6473 rx_pfc_mode, "on#off"); 6474 cmdline_parse_token_string_t cmd_pfc_set_tx = 6475 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6476 tx, "tx"); 6477 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 6478 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6479 tx_pfc_mode, "on#off"); 6480 cmdline_parse_token_num_t cmd_pfc_set_high_water = 6481 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6482 high_water, UINT32); 6483 cmdline_parse_token_num_t cmd_pfc_set_low_water = 6484 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6485 low_water, UINT32); 6486 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 6487 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6488 pause_time, UINT16); 6489 cmdline_parse_token_num_t cmd_pfc_set_priority = 6490 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6491 priority, UINT8); 6492 cmdline_parse_token_num_t cmd_pfc_set_portid = 6493 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6494 port_id, UINT16); 6495 6496 cmdline_parse_inst_t cmd_priority_flow_control_set = { 6497 .f = cmd_priority_flow_ctrl_set_parsed, 6498 .data = NULL, 6499 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 6500 "<pause_time> <priority> <port_id>: " 6501 "Configure the Ethernet priority flow control", 6502 .tokens = { 6503 (void *)&cmd_pfc_set_set, 6504 (void *)&cmd_pfc_set_flow_ctrl, 6505 (void *)&cmd_pfc_set_rx, 6506 (void *)&cmd_pfc_set_rx_mode, 6507 (void *)&cmd_pfc_set_tx, 6508 (void *)&cmd_pfc_set_tx_mode, 6509 (void *)&cmd_pfc_set_high_water, 6510 (void *)&cmd_pfc_set_low_water, 6511 (void *)&cmd_pfc_set_pause_time, 6512 (void *)&cmd_pfc_set_priority, 6513 (void *)&cmd_pfc_set_portid, 6514 NULL, 6515 }, 6516 }; 6517 6518 /* *** RESET CONFIGURATION *** */ 6519 struct cmd_reset_result { 6520 cmdline_fixed_string_t reset; 6521 cmdline_fixed_string_t def; 6522 }; 6523 6524 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result, 6525 struct cmdline *cl, 6526 __attribute__((unused)) void *data) 6527 { 6528 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 6529 set_def_fwd_config(); 6530 } 6531 6532 cmdline_parse_token_string_t cmd_reset_set = 6533 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 6534 cmdline_parse_token_string_t cmd_reset_def = 6535 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 6536 "default"); 6537 6538 cmdline_parse_inst_t cmd_reset = { 6539 .f = cmd_reset_parsed, 6540 .data = NULL, 6541 .help_str = "set default: Reset default forwarding configuration", 6542 .tokens = { 6543 (void *)&cmd_reset_set, 6544 (void *)&cmd_reset_def, 6545 NULL, 6546 }, 6547 }; 6548 6549 /* *** START FORWARDING *** */ 6550 struct cmd_start_result { 6551 cmdline_fixed_string_t start; 6552 }; 6553 6554 cmdline_parse_token_string_t cmd_start_start = 6555 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 6556 6557 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result, 6558 __attribute__((unused)) struct cmdline *cl, 6559 __attribute__((unused)) void *data) 6560 { 6561 start_packet_forwarding(0); 6562 } 6563 6564 cmdline_parse_inst_t cmd_start = { 6565 .f = cmd_start_parsed, 6566 .data = NULL, 6567 .help_str = "start: Start packet forwarding", 6568 .tokens = { 6569 (void *)&cmd_start_start, 6570 NULL, 6571 }, 6572 }; 6573 6574 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 6575 struct cmd_start_tx_first_result { 6576 cmdline_fixed_string_t start; 6577 cmdline_fixed_string_t tx_first; 6578 }; 6579 6580 static void 6581 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result, 6582 __attribute__((unused)) struct cmdline *cl, 6583 __attribute__((unused)) void *data) 6584 { 6585 start_packet_forwarding(1); 6586 } 6587 6588 cmdline_parse_token_string_t cmd_start_tx_first_start = 6589 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 6590 "start"); 6591 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 6592 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 6593 tx_first, "tx_first"); 6594 6595 cmdline_parse_inst_t cmd_start_tx_first = { 6596 .f = cmd_start_tx_first_parsed, 6597 .data = NULL, 6598 .help_str = "start tx_first: Start packet forwarding, " 6599 "after sending 1 burst of packets", 6600 .tokens = { 6601 (void *)&cmd_start_tx_first_start, 6602 (void *)&cmd_start_tx_first_tx_first, 6603 NULL, 6604 }, 6605 }; 6606 6607 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 6608 struct cmd_start_tx_first_n_result { 6609 cmdline_fixed_string_t start; 6610 cmdline_fixed_string_t tx_first; 6611 uint32_t tx_num; 6612 }; 6613 6614 static void 6615 cmd_start_tx_first_n_parsed(void *parsed_result, 6616 __attribute__((unused)) struct cmdline *cl, 6617 __attribute__((unused)) void *data) 6618 { 6619 struct cmd_start_tx_first_n_result *res = parsed_result; 6620 6621 start_packet_forwarding(res->tx_num); 6622 } 6623 6624 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 6625 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 6626 start, "start"); 6627 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 6628 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 6629 tx_first, "tx_first"); 6630 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 6631 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 6632 tx_num, UINT32); 6633 6634 cmdline_parse_inst_t cmd_start_tx_first_n = { 6635 .f = cmd_start_tx_first_n_parsed, 6636 .data = NULL, 6637 .help_str = "start tx_first <num>: " 6638 "packet forwarding, after sending <num> bursts of packets", 6639 .tokens = { 6640 (void *)&cmd_start_tx_first_n_start, 6641 (void *)&cmd_start_tx_first_n_tx_first, 6642 (void *)&cmd_start_tx_first_n_tx_num, 6643 NULL, 6644 }, 6645 }; 6646 6647 /* *** SET LINK UP *** */ 6648 struct cmd_set_link_up_result { 6649 cmdline_fixed_string_t set; 6650 cmdline_fixed_string_t link_up; 6651 cmdline_fixed_string_t port; 6652 portid_t port_id; 6653 }; 6654 6655 cmdline_parse_token_string_t cmd_set_link_up_set = 6656 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 6657 cmdline_parse_token_string_t cmd_set_link_up_link_up = 6658 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 6659 "link-up"); 6660 cmdline_parse_token_string_t cmd_set_link_up_port = 6661 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 6662 cmdline_parse_token_num_t cmd_set_link_up_port_id = 6663 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16); 6664 6665 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result, 6666 __attribute__((unused)) struct cmdline *cl, 6667 __attribute__((unused)) void *data) 6668 { 6669 struct cmd_set_link_up_result *res = parsed_result; 6670 dev_set_link_up(res->port_id); 6671 } 6672 6673 cmdline_parse_inst_t cmd_set_link_up = { 6674 .f = cmd_set_link_up_parsed, 6675 .data = NULL, 6676 .help_str = "set link-up port <port id>", 6677 .tokens = { 6678 (void *)&cmd_set_link_up_set, 6679 (void *)&cmd_set_link_up_link_up, 6680 (void *)&cmd_set_link_up_port, 6681 (void *)&cmd_set_link_up_port_id, 6682 NULL, 6683 }, 6684 }; 6685 6686 /* *** SET LINK DOWN *** */ 6687 struct cmd_set_link_down_result { 6688 cmdline_fixed_string_t set; 6689 cmdline_fixed_string_t link_down; 6690 cmdline_fixed_string_t port; 6691 portid_t port_id; 6692 }; 6693 6694 cmdline_parse_token_string_t cmd_set_link_down_set = 6695 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 6696 cmdline_parse_token_string_t cmd_set_link_down_link_down = 6697 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 6698 "link-down"); 6699 cmdline_parse_token_string_t cmd_set_link_down_port = 6700 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 6701 cmdline_parse_token_num_t cmd_set_link_down_port_id = 6702 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16); 6703 6704 static void cmd_set_link_down_parsed( 6705 __attribute__((unused)) void *parsed_result, 6706 __attribute__((unused)) struct cmdline *cl, 6707 __attribute__((unused)) void *data) 6708 { 6709 struct cmd_set_link_down_result *res = parsed_result; 6710 dev_set_link_down(res->port_id); 6711 } 6712 6713 cmdline_parse_inst_t cmd_set_link_down = { 6714 .f = cmd_set_link_down_parsed, 6715 .data = NULL, 6716 .help_str = "set link-down port <port id>", 6717 .tokens = { 6718 (void *)&cmd_set_link_down_set, 6719 (void *)&cmd_set_link_down_link_down, 6720 (void *)&cmd_set_link_down_port, 6721 (void *)&cmd_set_link_down_port_id, 6722 NULL, 6723 }, 6724 }; 6725 6726 /* *** SHOW CFG *** */ 6727 struct cmd_showcfg_result { 6728 cmdline_fixed_string_t show; 6729 cmdline_fixed_string_t cfg; 6730 cmdline_fixed_string_t what; 6731 }; 6732 6733 static void cmd_showcfg_parsed(void *parsed_result, 6734 __attribute__((unused)) struct cmdline *cl, 6735 __attribute__((unused)) void *data) 6736 { 6737 struct cmd_showcfg_result *res = parsed_result; 6738 if (!strcmp(res->what, "rxtx")) 6739 rxtx_config_display(); 6740 else if (!strcmp(res->what, "cores")) 6741 fwd_lcores_config_display(); 6742 else if (!strcmp(res->what, "fwd")) 6743 pkt_fwd_config_display(&cur_fwd_config); 6744 else if (!strcmp(res->what, "txpkts")) 6745 show_tx_pkt_segments(); 6746 } 6747 6748 cmdline_parse_token_string_t cmd_showcfg_show = 6749 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 6750 cmdline_parse_token_string_t cmd_showcfg_port = 6751 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 6752 cmdline_parse_token_string_t cmd_showcfg_what = 6753 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 6754 "rxtx#cores#fwd#txpkts"); 6755 6756 cmdline_parse_inst_t cmd_showcfg = { 6757 .f = cmd_showcfg_parsed, 6758 .data = NULL, 6759 .help_str = "show config rxtx|cores|fwd|txpkts", 6760 .tokens = { 6761 (void *)&cmd_showcfg_show, 6762 (void *)&cmd_showcfg_port, 6763 (void *)&cmd_showcfg_what, 6764 NULL, 6765 }, 6766 }; 6767 6768 /* *** SHOW ALL PORT INFO *** */ 6769 struct cmd_showportall_result { 6770 cmdline_fixed_string_t show; 6771 cmdline_fixed_string_t port; 6772 cmdline_fixed_string_t what; 6773 cmdline_fixed_string_t all; 6774 }; 6775 6776 static void cmd_showportall_parsed(void *parsed_result, 6777 __attribute__((unused)) struct cmdline *cl, 6778 __attribute__((unused)) void *data) 6779 { 6780 portid_t i; 6781 6782 struct cmd_showportall_result *res = parsed_result; 6783 if (!strcmp(res->show, "clear")) { 6784 if (!strcmp(res->what, "stats")) 6785 RTE_ETH_FOREACH_DEV(i) 6786 nic_stats_clear(i); 6787 else if (!strcmp(res->what, "xstats")) 6788 RTE_ETH_FOREACH_DEV(i) 6789 nic_xstats_clear(i); 6790 } else if (!strcmp(res->what, "info")) 6791 RTE_ETH_FOREACH_DEV(i) 6792 port_infos_display(i); 6793 else if (!strcmp(res->what, "stats")) 6794 RTE_ETH_FOREACH_DEV(i) 6795 nic_stats_display(i); 6796 else if (!strcmp(res->what, "xstats")) 6797 RTE_ETH_FOREACH_DEV(i) 6798 nic_xstats_display(i); 6799 else if (!strcmp(res->what, "fdir")) 6800 RTE_ETH_FOREACH_DEV(i) 6801 fdir_get_infos(i); 6802 else if (!strcmp(res->what, "stat_qmap")) 6803 RTE_ETH_FOREACH_DEV(i) 6804 nic_stats_mapping_display(i); 6805 else if (!strcmp(res->what, "dcb_tc")) 6806 RTE_ETH_FOREACH_DEV(i) 6807 port_dcb_info_display(i); 6808 else if (!strcmp(res->what, "cap")) 6809 RTE_ETH_FOREACH_DEV(i) 6810 port_offload_cap_display(i); 6811 } 6812 6813 cmdline_parse_token_string_t cmd_showportall_show = 6814 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 6815 "show#clear"); 6816 cmdline_parse_token_string_t cmd_showportall_port = 6817 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 6818 cmdline_parse_token_string_t cmd_showportall_what = 6819 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 6820 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 6821 cmdline_parse_token_string_t cmd_showportall_all = 6822 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 6823 cmdline_parse_inst_t cmd_showportall = { 6824 .f = cmd_showportall_parsed, 6825 .data = NULL, 6826 .help_str = "show|clear port " 6827 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", 6828 .tokens = { 6829 (void *)&cmd_showportall_show, 6830 (void *)&cmd_showportall_port, 6831 (void *)&cmd_showportall_what, 6832 (void *)&cmd_showportall_all, 6833 NULL, 6834 }, 6835 }; 6836 6837 /* *** SHOW PORT INFO *** */ 6838 struct cmd_showport_result { 6839 cmdline_fixed_string_t show; 6840 cmdline_fixed_string_t port; 6841 cmdline_fixed_string_t what; 6842 uint16_t portnum; 6843 }; 6844 6845 static void cmd_showport_parsed(void *parsed_result, 6846 __attribute__((unused)) struct cmdline *cl, 6847 __attribute__((unused)) void *data) 6848 { 6849 struct cmd_showport_result *res = parsed_result; 6850 if (!strcmp(res->show, "clear")) { 6851 if (!strcmp(res->what, "stats")) 6852 nic_stats_clear(res->portnum); 6853 else if (!strcmp(res->what, "xstats")) 6854 nic_xstats_clear(res->portnum); 6855 } else if (!strcmp(res->what, "info")) 6856 port_infos_display(res->portnum); 6857 else if (!strcmp(res->what, "stats")) 6858 nic_stats_display(res->portnum); 6859 else if (!strcmp(res->what, "xstats")) 6860 nic_xstats_display(res->portnum); 6861 else if (!strcmp(res->what, "fdir")) 6862 fdir_get_infos(res->portnum); 6863 else if (!strcmp(res->what, "stat_qmap")) 6864 nic_stats_mapping_display(res->portnum); 6865 else if (!strcmp(res->what, "dcb_tc")) 6866 port_dcb_info_display(res->portnum); 6867 else if (!strcmp(res->what, "cap")) 6868 port_offload_cap_display(res->portnum); 6869 } 6870 6871 cmdline_parse_token_string_t cmd_showport_show = 6872 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 6873 "show#clear"); 6874 cmdline_parse_token_string_t cmd_showport_port = 6875 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 6876 cmdline_parse_token_string_t cmd_showport_what = 6877 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 6878 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 6879 cmdline_parse_token_num_t cmd_showport_portnum = 6880 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16); 6881 6882 cmdline_parse_inst_t cmd_showport = { 6883 .f = cmd_showport_parsed, 6884 .data = NULL, 6885 .help_str = "show|clear port " 6886 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap " 6887 "<port_id>", 6888 .tokens = { 6889 (void *)&cmd_showport_show, 6890 (void *)&cmd_showport_port, 6891 (void *)&cmd_showport_what, 6892 (void *)&cmd_showport_portnum, 6893 NULL, 6894 }, 6895 }; 6896 6897 /* *** SHOW QUEUE INFO *** */ 6898 struct cmd_showqueue_result { 6899 cmdline_fixed_string_t show; 6900 cmdline_fixed_string_t type; 6901 cmdline_fixed_string_t what; 6902 uint16_t portnum; 6903 uint16_t queuenum; 6904 }; 6905 6906 static void 6907 cmd_showqueue_parsed(void *parsed_result, 6908 __attribute__((unused)) struct cmdline *cl, 6909 __attribute__((unused)) void *data) 6910 { 6911 struct cmd_showqueue_result *res = parsed_result; 6912 6913 if (!strcmp(res->type, "rxq")) 6914 rx_queue_infos_display(res->portnum, res->queuenum); 6915 else if (!strcmp(res->type, "txq")) 6916 tx_queue_infos_display(res->portnum, res->queuenum); 6917 } 6918 6919 cmdline_parse_token_string_t cmd_showqueue_show = 6920 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 6921 cmdline_parse_token_string_t cmd_showqueue_type = 6922 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 6923 cmdline_parse_token_string_t cmd_showqueue_what = 6924 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 6925 cmdline_parse_token_num_t cmd_showqueue_portnum = 6926 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16); 6927 cmdline_parse_token_num_t cmd_showqueue_queuenum = 6928 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16); 6929 6930 cmdline_parse_inst_t cmd_showqueue = { 6931 .f = cmd_showqueue_parsed, 6932 .data = NULL, 6933 .help_str = "show rxq|txq info <port_id> <queue_id>", 6934 .tokens = { 6935 (void *)&cmd_showqueue_show, 6936 (void *)&cmd_showqueue_type, 6937 (void *)&cmd_showqueue_what, 6938 (void *)&cmd_showqueue_portnum, 6939 (void *)&cmd_showqueue_queuenum, 6940 NULL, 6941 }, 6942 }; 6943 6944 /* *** READ PORT REGISTER *** */ 6945 struct cmd_read_reg_result { 6946 cmdline_fixed_string_t read; 6947 cmdline_fixed_string_t reg; 6948 portid_t port_id; 6949 uint32_t reg_off; 6950 }; 6951 6952 static void 6953 cmd_read_reg_parsed(void *parsed_result, 6954 __attribute__((unused)) struct cmdline *cl, 6955 __attribute__((unused)) void *data) 6956 { 6957 struct cmd_read_reg_result *res = parsed_result; 6958 port_reg_display(res->port_id, res->reg_off); 6959 } 6960 6961 cmdline_parse_token_string_t cmd_read_reg_read = 6962 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 6963 cmdline_parse_token_string_t cmd_read_reg_reg = 6964 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 6965 cmdline_parse_token_num_t cmd_read_reg_port_id = 6966 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16); 6967 cmdline_parse_token_num_t cmd_read_reg_reg_off = 6968 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32); 6969 6970 cmdline_parse_inst_t cmd_read_reg = { 6971 .f = cmd_read_reg_parsed, 6972 .data = NULL, 6973 .help_str = "read reg <port_id> <reg_off>", 6974 .tokens = { 6975 (void *)&cmd_read_reg_read, 6976 (void *)&cmd_read_reg_reg, 6977 (void *)&cmd_read_reg_port_id, 6978 (void *)&cmd_read_reg_reg_off, 6979 NULL, 6980 }, 6981 }; 6982 6983 /* *** READ PORT REGISTER BIT FIELD *** */ 6984 struct cmd_read_reg_bit_field_result { 6985 cmdline_fixed_string_t read; 6986 cmdline_fixed_string_t regfield; 6987 portid_t port_id; 6988 uint32_t reg_off; 6989 uint8_t bit1_pos; 6990 uint8_t bit2_pos; 6991 }; 6992 6993 static void 6994 cmd_read_reg_bit_field_parsed(void *parsed_result, 6995 __attribute__((unused)) struct cmdline *cl, 6996 __attribute__((unused)) void *data) 6997 { 6998 struct cmd_read_reg_bit_field_result *res = parsed_result; 6999 port_reg_bit_field_display(res->port_id, res->reg_off, 7000 res->bit1_pos, res->bit2_pos); 7001 } 7002 7003 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 7004 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 7005 "read"); 7006 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 7007 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 7008 regfield, "regfield"); 7009 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 7010 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 7011 UINT16); 7012 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 7013 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 7014 UINT32); 7015 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 7016 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 7017 UINT8); 7018 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 7019 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 7020 UINT8); 7021 7022 cmdline_parse_inst_t cmd_read_reg_bit_field = { 7023 .f = cmd_read_reg_bit_field_parsed, 7024 .data = NULL, 7025 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 7026 "Read register bit field between bit_x and bit_y included", 7027 .tokens = { 7028 (void *)&cmd_read_reg_bit_field_read, 7029 (void *)&cmd_read_reg_bit_field_regfield, 7030 (void *)&cmd_read_reg_bit_field_port_id, 7031 (void *)&cmd_read_reg_bit_field_reg_off, 7032 (void *)&cmd_read_reg_bit_field_bit1_pos, 7033 (void *)&cmd_read_reg_bit_field_bit2_pos, 7034 NULL, 7035 }, 7036 }; 7037 7038 /* *** READ PORT REGISTER BIT *** */ 7039 struct cmd_read_reg_bit_result { 7040 cmdline_fixed_string_t read; 7041 cmdline_fixed_string_t regbit; 7042 portid_t port_id; 7043 uint32_t reg_off; 7044 uint8_t bit_pos; 7045 }; 7046 7047 static void 7048 cmd_read_reg_bit_parsed(void *parsed_result, 7049 __attribute__((unused)) struct cmdline *cl, 7050 __attribute__((unused)) void *data) 7051 { 7052 struct cmd_read_reg_bit_result *res = parsed_result; 7053 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 7054 } 7055 7056 cmdline_parse_token_string_t cmd_read_reg_bit_read = 7057 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 7058 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 7059 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 7060 regbit, "regbit"); 7061 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 7062 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16); 7063 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 7064 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32); 7065 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 7066 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8); 7067 7068 cmdline_parse_inst_t cmd_read_reg_bit = { 7069 .f = cmd_read_reg_bit_parsed, 7070 .data = NULL, 7071 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 7072 .tokens = { 7073 (void *)&cmd_read_reg_bit_read, 7074 (void *)&cmd_read_reg_bit_regbit, 7075 (void *)&cmd_read_reg_bit_port_id, 7076 (void *)&cmd_read_reg_bit_reg_off, 7077 (void *)&cmd_read_reg_bit_bit_pos, 7078 NULL, 7079 }, 7080 }; 7081 7082 /* *** WRITE PORT REGISTER *** */ 7083 struct cmd_write_reg_result { 7084 cmdline_fixed_string_t write; 7085 cmdline_fixed_string_t reg; 7086 portid_t port_id; 7087 uint32_t reg_off; 7088 uint32_t value; 7089 }; 7090 7091 static void 7092 cmd_write_reg_parsed(void *parsed_result, 7093 __attribute__((unused)) struct cmdline *cl, 7094 __attribute__((unused)) void *data) 7095 { 7096 struct cmd_write_reg_result *res = parsed_result; 7097 port_reg_set(res->port_id, res->reg_off, res->value); 7098 } 7099 7100 cmdline_parse_token_string_t cmd_write_reg_write = 7101 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 7102 cmdline_parse_token_string_t cmd_write_reg_reg = 7103 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 7104 cmdline_parse_token_num_t cmd_write_reg_port_id = 7105 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16); 7106 cmdline_parse_token_num_t cmd_write_reg_reg_off = 7107 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32); 7108 cmdline_parse_token_num_t cmd_write_reg_value = 7109 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32); 7110 7111 cmdline_parse_inst_t cmd_write_reg = { 7112 .f = cmd_write_reg_parsed, 7113 .data = NULL, 7114 .help_str = "write reg <port_id> <reg_off> <reg_value>", 7115 .tokens = { 7116 (void *)&cmd_write_reg_write, 7117 (void *)&cmd_write_reg_reg, 7118 (void *)&cmd_write_reg_port_id, 7119 (void *)&cmd_write_reg_reg_off, 7120 (void *)&cmd_write_reg_value, 7121 NULL, 7122 }, 7123 }; 7124 7125 /* *** WRITE PORT REGISTER BIT FIELD *** */ 7126 struct cmd_write_reg_bit_field_result { 7127 cmdline_fixed_string_t write; 7128 cmdline_fixed_string_t regfield; 7129 portid_t port_id; 7130 uint32_t reg_off; 7131 uint8_t bit1_pos; 7132 uint8_t bit2_pos; 7133 uint32_t value; 7134 }; 7135 7136 static void 7137 cmd_write_reg_bit_field_parsed(void *parsed_result, 7138 __attribute__((unused)) struct cmdline *cl, 7139 __attribute__((unused)) void *data) 7140 { 7141 struct cmd_write_reg_bit_field_result *res = parsed_result; 7142 port_reg_bit_field_set(res->port_id, res->reg_off, 7143 res->bit1_pos, res->bit2_pos, res->value); 7144 } 7145 7146 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 7147 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 7148 "write"); 7149 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 7150 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 7151 regfield, "regfield"); 7152 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 7153 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 7154 UINT16); 7155 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 7156 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 7157 UINT32); 7158 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 7159 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 7160 UINT8); 7161 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 7162 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 7163 UINT8); 7164 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 7165 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 7166 UINT32); 7167 7168 cmdline_parse_inst_t cmd_write_reg_bit_field = { 7169 .f = cmd_write_reg_bit_field_parsed, 7170 .data = NULL, 7171 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 7172 "<reg_value>: " 7173 "Set register bit field between bit_x and bit_y included", 7174 .tokens = { 7175 (void *)&cmd_write_reg_bit_field_write, 7176 (void *)&cmd_write_reg_bit_field_regfield, 7177 (void *)&cmd_write_reg_bit_field_port_id, 7178 (void *)&cmd_write_reg_bit_field_reg_off, 7179 (void *)&cmd_write_reg_bit_field_bit1_pos, 7180 (void *)&cmd_write_reg_bit_field_bit2_pos, 7181 (void *)&cmd_write_reg_bit_field_value, 7182 NULL, 7183 }, 7184 }; 7185 7186 /* *** WRITE PORT REGISTER BIT *** */ 7187 struct cmd_write_reg_bit_result { 7188 cmdline_fixed_string_t write; 7189 cmdline_fixed_string_t regbit; 7190 portid_t port_id; 7191 uint32_t reg_off; 7192 uint8_t bit_pos; 7193 uint8_t value; 7194 }; 7195 7196 static void 7197 cmd_write_reg_bit_parsed(void *parsed_result, 7198 __attribute__((unused)) struct cmdline *cl, 7199 __attribute__((unused)) void *data) 7200 { 7201 struct cmd_write_reg_bit_result *res = parsed_result; 7202 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 7203 } 7204 7205 cmdline_parse_token_string_t cmd_write_reg_bit_write = 7206 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 7207 "write"); 7208 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 7209 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 7210 regbit, "regbit"); 7211 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 7212 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16); 7213 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 7214 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32); 7215 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 7216 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8); 7217 cmdline_parse_token_num_t cmd_write_reg_bit_value = 7218 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8); 7219 7220 cmdline_parse_inst_t cmd_write_reg_bit = { 7221 .f = cmd_write_reg_bit_parsed, 7222 .data = NULL, 7223 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 7224 "0 <= bit_x <= 31", 7225 .tokens = { 7226 (void *)&cmd_write_reg_bit_write, 7227 (void *)&cmd_write_reg_bit_regbit, 7228 (void *)&cmd_write_reg_bit_port_id, 7229 (void *)&cmd_write_reg_bit_reg_off, 7230 (void *)&cmd_write_reg_bit_bit_pos, 7231 (void *)&cmd_write_reg_bit_value, 7232 NULL, 7233 }, 7234 }; 7235 7236 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 7237 struct cmd_read_rxd_txd_result { 7238 cmdline_fixed_string_t read; 7239 cmdline_fixed_string_t rxd_txd; 7240 portid_t port_id; 7241 uint16_t queue_id; 7242 uint16_t desc_id; 7243 }; 7244 7245 static void 7246 cmd_read_rxd_txd_parsed(void *parsed_result, 7247 __attribute__((unused)) struct cmdline *cl, 7248 __attribute__((unused)) void *data) 7249 { 7250 struct cmd_read_rxd_txd_result *res = parsed_result; 7251 7252 if (!strcmp(res->rxd_txd, "rxd")) 7253 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7254 else if (!strcmp(res->rxd_txd, "txd")) 7255 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7256 } 7257 7258 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 7259 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 7260 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 7261 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 7262 "rxd#txd"); 7263 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 7264 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16); 7265 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 7266 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16); 7267 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 7268 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16); 7269 7270 cmdline_parse_inst_t cmd_read_rxd_txd = { 7271 .f = cmd_read_rxd_txd_parsed, 7272 .data = NULL, 7273 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 7274 .tokens = { 7275 (void *)&cmd_read_rxd_txd_read, 7276 (void *)&cmd_read_rxd_txd_rxd_txd, 7277 (void *)&cmd_read_rxd_txd_port_id, 7278 (void *)&cmd_read_rxd_txd_queue_id, 7279 (void *)&cmd_read_rxd_txd_desc_id, 7280 NULL, 7281 }, 7282 }; 7283 7284 /* *** QUIT *** */ 7285 struct cmd_quit_result { 7286 cmdline_fixed_string_t quit; 7287 }; 7288 7289 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result, 7290 struct cmdline *cl, 7291 __attribute__((unused)) void *data) 7292 { 7293 pmd_test_exit(); 7294 cmdline_quit(cl); 7295 } 7296 7297 cmdline_parse_token_string_t cmd_quit_quit = 7298 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 7299 7300 cmdline_parse_inst_t cmd_quit = { 7301 .f = cmd_quit_parsed, 7302 .data = NULL, 7303 .help_str = "quit: Exit application", 7304 .tokens = { 7305 (void *)&cmd_quit_quit, 7306 NULL, 7307 }, 7308 }; 7309 7310 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 7311 struct cmd_mac_addr_result { 7312 cmdline_fixed_string_t mac_addr_cmd; 7313 cmdline_fixed_string_t what; 7314 uint16_t port_num; 7315 struct ether_addr address; 7316 }; 7317 7318 static void cmd_mac_addr_parsed(void *parsed_result, 7319 __attribute__((unused)) struct cmdline *cl, 7320 __attribute__((unused)) void *data) 7321 { 7322 struct cmd_mac_addr_result *res = parsed_result; 7323 int ret; 7324 7325 if (strcmp(res->what, "add") == 0) 7326 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 7327 else if (strcmp(res->what, "set") == 0) 7328 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 7329 &res->address); 7330 else 7331 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 7332 7333 /* check the return value and print it if is < 0 */ 7334 if(ret < 0) 7335 printf("mac_addr_cmd error: (%s)\n", strerror(-ret)); 7336 7337 } 7338 7339 cmdline_parse_token_string_t cmd_mac_addr_cmd = 7340 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 7341 "mac_addr"); 7342 cmdline_parse_token_string_t cmd_mac_addr_what = 7343 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 7344 "add#remove#set"); 7345 cmdline_parse_token_num_t cmd_mac_addr_portnum = 7346 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 7347 UINT16); 7348 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 7349 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 7350 7351 cmdline_parse_inst_t cmd_mac_addr = { 7352 .f = cmd_mac_addr_parsed, 7353 .data = (void *)0, 7354 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 7355 "Add/Remove/Set MAC address on port_id", 7356 .tokens = { 7357 (void *)&cmd_mac_addr_cmd, 7358 (void *)&cmd_mac_addr_what, 7359 (void *)&cmd_mac_addr_portnum, 7360 (void *)&cmd_mac_addr_addr, 7361 NULL, 7362 }, 7363 }; 7364 7365 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 7366 struct cmd_eth_peer_result { 7367 cmdline_fixed_string_t set; 7368 cmdline_fixed_string_t eth_peer; 7369 portid_t port_id; 7370 cmdline_fixed_string_t peer_addr; 7371 }; 7372 7373 static void cmd_set_eth_peer_parsed(void *parsed_result, 7374 __attribute__((unused)) struct cmdline *cl, 7375 __attribute__((unused)) void *data) 7376 { 7377 struct cmd_eth_peer_result *res = parsed_result; 7378 7379 if (test_done == 0) { 7380 printf("Please stop forwarding first\n"); 7381 return; 7382 } 7383 if (!strcmp(res->eth_peer, "eth-peer")) { 7384 set_fwd_eth_peer(res->port_id, res->peer_addr); 7385 fwd_config_setup(); 7386 } 7387 } 7388 cmdline_parse_token_string_t cmd_eth_peer_set = 7389 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 7390 cmdline_parse_token_string_t cmd_eth_peer = 7391 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 7392 cmdline_parse_token_num_t cmd_eth_peer_port_id = 7393 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16); 7394 cmdline_parse_token_string_t cmd_eth_peer_addr = 7395 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 7396 7397 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 7398 .f = cmd_set_eth_peer_parsed, 7399 .data = NULL, 7400 .help_str = "set eth-peer <port_id> <peer_mac>", 7401 .tokens = { 7402 (void *)&cmd_eth_peer_set, 7403 (void *)&cmd_eth_peer, 7404 (void *)&cmd_eth_peer_port_id, 7405 (void *)&cmd_eth_peer_addr, 7406 NULL, 7407 }, 7408 }; 7409 7410 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 7411 struct cmd_set_qmap_result { 7412 cmdline_fixed_string_t set; 7413 cmdline_fixed_string_t qmap; 7414 cmdline_fixed_string_t what; 7415 portid_t port_id; 7416 uint16_t queue_id; 7417 uint8_t map_value; 7418 }; 7419 7420 static void 7421 cmd_set_qmap_parsed(void *parsed_result, 7422 __attribute__((unused)) struct cmdline *cl, 7423 __attribute__((unused)) void *data) 7424 { 7425 struct cmd_set_qmap_result *res = parsed_result; 7426 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 7427 7428 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 7429 } 7430 7431 cmdline_parse_token_string_t cmd_setqmap_set = 7432 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7433 set, "set"); 7434 cmdline_parse_token_string_t cmd_setqmap_qmap = 7435 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7436 qmap, "stat_qmap"); 7437 cmdline_parse_token_string_t cmd_setqmap_what = 7438 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7439 what, "tx#rx"); 7440 cmdline_parse_token_num_t cmd_setqmap_portid = 7441 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7442 port_id, UINT16); 7443 cmdline_parse_token_num_t cmd_setqmap_queueid = 7444 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7445 queue_id, UINT16); 7446 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 7447 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7448 map_value, UINT8); 7449 7450 cmdline_parse_inst_t cmd_set_qmap = { 7451 .f = cmd_set_qmap_parsed, 7452 .data = NULL, 7453 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 7454 "Set statistics mapping value on tx|rx queue_id of port_id", 7455 .tokens = { 7456 (void *)&cmd_setqmap_set, 7457 (void *)&cmd_setqmap_qmap, 7458 (void *)&cmd_setqmap_what, 7459 (void *)&cmd_setqmap_portid, 7460 (void *)&cmd_setqmap_queueid, 7461 (void *)&cmd_setqmap_mapvalue, 7462 NULL, 7463 }, 7464 }; 7465 7466 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 7467 struct cmd_set_xstats_hide_zero_result { 7468 cmdline_fixed_string_t keyword; 7469 cmdline_fixed_string_t name; 7470 cmdline_fixed_string_t on_off; 7471 }; 7472 7473 static void 7474 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 7475 __attribute__((unused)) struct cmdline *cl, 7476 __attribute__((unused)) void *data) 7477 { 7478 struct cmd_set_xstats_hide_zero_result *res; 7479 uint16_t on_off = 0; 7480 7481 res = parsed_result; 7482 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 7483 set_xstats_hide_zero(on_off); 7484 } 7485 7486 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 7487 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7488 keyword, "set"); 7489 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 7490 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7491 name, "xstats-hide-zero"); 7492 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 7493 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7494 on_off, "on#off"); 7495 7496 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 7497 .f = cmd_set_xstats_hide_zero_parsed, 7498 .data = NULL, 7499 .help_str = "set xstats-hide-zero on|off", 7500 .tokens = { 7501 (void *)&cmd_set_xstats_hide_zero_keyword, 7502 (void *)&cmd_set_xstats_hide_zero_name, 7503 (void *)&cmd_set_xstats_hide_zero_on_off, 7504 NULL, 7505 }, 7506 }; 7507 7508 /* *** CONFIGURE UNICAST HASH TABLE *** */ 7509 struct cmd_set_uc_hash_table { 7510 cmdline_fixed_string_t set; 7511 cmdline_fixed_string_t port; 7512 portid_t port_id; 7513 cmdline_fixed_string_t what; 7514 struct ether_addr address; 7515 cmdline_fixed_string_t mode; 7516 }; 7517 7518 static void 7519 cmd_set_uc_hash_parsed(void *parsed_result, 7520 __attribute__((unused)) struct cmdline *cl, 7521 __attribute__((unused)) void *data) 7522 { 7523 int ret=0; 7524 struct cmd_set_uc_hash_table *res = parsed_result; 7525 7526 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7527 7528 if (strcmp(res->what, "uta") == 0) 7529 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 7530 &res->address,(uint8_t)is_on); 7531 if (ret < 0) 7532 printf("bad unicast hash table parameter, return code = %d \n", ret); 7533 7534 } 7535 7536 cmdline_parse_token_string_t cmd_set_uc_hash_set = 7537 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7538 set, "set"); 7539 cmdline_parse_token_string_t cmd_set_uc_hash_port = 7540 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7541 port, "port"); 7542 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 7543 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 7544 port_id, UINT16); 7545 cmdline_parse_token_string_t cmd_set_uc_hash_what = 7546 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7547 what, "uta"); 7548 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 7549 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 7550 address); 7551 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 7552 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7553 mode, "on#off"); 7554 7555 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 7556 .f = cmd_set_uc_hash_parsed, 7557 .data = NULL, 7558 .help_str = "set port <port_id> uta <mac_addr> on|off)", 7559 .tokens = { 7560 (void *)&cmd_set_uc_hash_set, 7561 (void *)&cmd_set_uc_hash_port, 7562 (void *)&cmd_set_uc_hash_portid, 7563 (void *)&cmd_set_uc_hash_what, 7564 (void *)&cmd_set_uc_hash_mac, 7565 (void *)&cmd_set_uc_hash_mode, 7566 NULL, 7567 }, 7568 }; 7569 7570 struct cmd_set_uc_all_hash_table { 7571 cmdline_fixed_string_t set; 7572 cmdline_fixed_string_t port; 7573 portid_t port_id; 7574 cmdline_fixed_string_t what; 7575 cmdline_fixed_string_t value; 7576 cmdline_fixed_string_t mode; 7577 }; 7578 7579 static void 7580 cmd_set_uc_all_hash_parsed(void *parsed_result, 7581 __attribute__((unused)) struct cmdline *cl, 7582 __attribute__((unused)) void *data) 7583 { 7584 int ret=0; 7585 struct cmd_set_uc_all_hash_table *res = parsed_result; 7586 7587 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7588 7589 if ((strcmp(res->what, "uta") == 0) && 7590 (strcmp(res->value, "all") == 0)) 7591 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 7592 if (ret < 0) 7593 printf("bad unicast hash table parameter," 7594 "return code = %d \n", ret); 7595 } 7596 7597 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 7598 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7599 set, "set"); 7600 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 7601 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7602 port, "port"); 7603 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 7604 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 7605 port_id, UINT16); 7606 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 7607 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7608 what, "uta"); 7609 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 7610 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7611 value,"all"); 7612 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 7613 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7614 mode, "on#off"); 7615 7616 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 7617 .f = cmd_set_uc_all_hash_parsed, 7618 .data = NULL, 7619 .help_str = "set port <port_id> uta all on|off", 7620 .tokens = { 7621 (void *)&cmd_set_uc_all_hash_set, 7622 (void *)&cmd_set_uc_all_hash_port, 7623 (void *)&cmd_set_uc_all_hash_portid, 7624 (void *)&cmd_set_uc_all_hash_what, 7625 (void *)&cmd_set_uc_all_hash_value, 7626 (void *)&cmd_set_uc_all_hash_mode, 7627 NULL, 7628 }, 7629 }; 7630 7631 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */ 7632 struct cmd_set_vf_macvlan_filter { 7633 cmdline_fixed_string_t set; 7634 cmdline_fixed_string_t port; 7635 portid_t port_id; 7636 cmdline_fixed_string_t vf; 7637 uint8_t vf_id; 7638 struct ether_addr address; 7639 cmdline_fixed_string_t filter_type; 7640 cmdline_fixed_string_t mode; 7641 }; 7642 7643 static void 7644 cmd_set_vf_macvlan_parsed(void *parsed_result, 7645 __attribute__((unused)) struct cmdline *cl, 7646 __attribute__((unused)) void *data) 7647 { 7648 int is_on, ret = 0; 7649 struct cmd_set_vf_macvlan_filter *res = parsed_result; 7650 struct rte_eth_mac_filter filter; 7651 7652 memset(&filter, 0, sizeof(struct rte_eth_mac_filter)); 7653 7654 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN); 7655 7656 /* set VF MAC filter */ 7657 filter.is_vf = 1; 7658 7659 /* set VF ID */ 7660 filter.dst_id = res->vf_id; 7661 7662 if (!strcmp(res->filter_type, "exact-mac")) 7663 filter.filter_type = RTE_MAC_PERFECT_MATCH; 7664 else if (!strcmp(res->filter_type, "exact-mac-vlan")) 7665 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH; 7666 else if (!strcmp(res->filter_type, "hashmac")) 7667 filter.filter_type = RTE_MAC_HASH_MATCH; 7668 else if (!strcmp(res->filter_type, "hashmac-vlan")) 7669 filter.filter_type = RTE_MACVLAN_HASH_MATCH; 7670 7671 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7672 7673 if (is_on) 7674 ret = rte_eth_dev_filter_ctrl(res->port_id, 7675 RTE_ETH_FILTER_MACVLAN, 7676 RTE_ETH_FILTER_ADD, 7677 &filter); 7678 else 7679 ret = rte_eth_dev_filter_ctrl(res->port_id, 7680 RTE_ETH_FILTER_MACVLAN, 7681 RTE_ETH_FILTER_DELETE, 7682 &filter); 7683 7684 if (ret < 0) 7685 printf("bad set MAC hash parameter, return code = %d\n", ret); 7686 7687 } 7688 7689 cmdline_parse_token_string_t cmd_set_vf_macvlan_set = 7690 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7691 set, "set"); 7692 cmdline_parse_token_string_t cmd_set_vf_macvlan_port = 7693 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7694 port, "port"); 7695 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid = 7696 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7697 port_id, UINT16); 7698 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf = 7699 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7700 vf, "vf"); 7701 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id = 7702 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7703 vf_id, UINT8); 7704 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac = 7705 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7706 address); 7707 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type = 7708 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7709 filter_type, "exact-mac#exact-mac-vlan" 7710 "#hashmac#hashmac-vlan"); 7711 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode = 7712 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7713 mode, "on#off"); 7714 7715 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = { 7716 .f = cmd_set_vf_macvlan_parsed, 7717 .data = NULL, 7718 .help_str = "set port <port_id> vf <vf_id> <mac_addr> " 7719 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: " 7720 "Exact match rule: exact match of MAC or MAC and VLAN; " 7721 "hash match rule: hash match of MAC and exact match of VLAN", 7722 .tokens = { 7723 (void *)&cmd_set_vf_macvlan_set, 7724 (void *)&cmd_set_vf_macvlan_port, 7725 (void *)&cmd_set_vf_macvlan_portid, 7726 (void *)&cmd_set_vf_macvlan_vf, 7727 (void *)&cmd_set_vf_macvlan_vf_id, 7728 (void *)&cmd_set_vf_macvlan_mac, 7729 (void *)&cmd_set_vf_macvlan_filter_type, 7730 (void *)&cmd_set_vf_macvlan_mode, 7731 NULL, 7732 }, 7733 }; 7734 7735 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 7736 struct cmd_set_vf_traffic { 7737 cmdline_fixed_string_t set; 7738 cmdline_fixed_string_t port; 7739 portid_t port_id; 7740 cmdline_fixed_string_t vf; 7741 uint8_t vf_id; 7742 cmdline_fixed_string_t what; 7743 cmdline_fixed_string_t mode; 7744 }; 7745 7746 static void 7747 cmd_set_vf_traffic_parsed(void *parsed_result, 7748 __attribute__((unused)) struct cmdline *cl, 7749 __attribute__((unused)) void *data) 7750 { 7751 struct cmd_set_vf_traffic *res = parsed_result; 7752 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 7753 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7754 7755 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 7756 } 7757 7758 cmdline_parse_token_string_t cmd_setvf_traffic_set = 7759 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 7760 set, "set"); 7761 cmdline_parse_token_string_t cmd_setvf_traffic_port = 7762 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 7763 port, "port"); 7764 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 7765 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 7766 port_id, UINT16); 7767 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 7768 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 7769 vf, "vf"); 7770 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 7771 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 7772 vf_id, UINT8); 7773 cmdline_parse_token_string_t cmd_setvf_traffic_what = 7774 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 7775 what, "tx#rx"); 7776 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 7777 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 7778 mode, "on#off"); 7779 7780 cmdline_parse_inst_t cmd_set_vf_traffic = { 7781 .f = cmd_set_vf_traffic_parsed, 7782 .data = NULL, 7783 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 7784 .tokens = { 7785 (void *)&cmd_setvf_traffic_set, 7786 (void *)&cmd_setvf_traffic_port, 7787 (void *)&cmd_setvf_traffic_portid, 7788 (void *)&cmd_setvf_traffic_vf, 7789 (void *)&cmd_setvf_traffic_vfid, 7790 (void *)&cmd_setvf_traffic_what, 7791 (void *)&cmd_setvf_traffic_mode, 7792 NULL, 7793 }, 7794 }; 7795 7796 /* *** CONFIGURE VF RECEIVE MODE *** */ 7797 struct cmd_set_vf_rxmode { 7798 cmdline_fixed_string_t set; 7799 cmdline_fixed_string_t port; 7800 portid_t port_id; 7801 cmdline_fixed_string_t vf; 7802 uint8_t vf_id; 7803 cmdline_fixed_string_t what; 7804 cmdline_fixed_string_t mode; 7805 cmdline_fixed_string_t on; 7806 }; 7807 7808 static void 7809 cmd_set_vf_rxmode_parsed(void *parsed_result, 7810 __attribute__((unused)) struct cmdline *cl, 7811 __attribute__((unused)) void *data) 7812 { 7813 int ret = -ENOTSUP; 7814 uint16_t rx_mode = 0; 7815 struct cmd_set_vf_rxmode *res = parsed_result; 7816 7817 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 7818 if (!strcmp(res->what,"rxmode")) { 7819 if (!strcmp(res->mode, "AUPE")) 7820 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG; 7821 else if (!strcmp(res->mode, "ROPE")) 7822 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC; 7823 else if (!strcmp(res->mode, "BAM")) 7824 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST; 7825 else if (!strncmp(res->mode, "MPE",3)) 7826 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST; 7827 } 7828 7829 RTE_SET_USED(is_on); 7830 7831 #ifdef RTE_LIBRTE_IXGBE_PMD 7832 if (ret == -ENOTSUP) 7833 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 7834 rx_mode, (uint8_t)is_on); 7835 #endif 7836 #ifdef RTE_LIBRTE_BNXT_PMD 7837 if (ret == -ENOTSUP) 7838 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 7839 rx_mode, (uint8_t)is_on); 7840 #endif 7841 if (ret < 0) 7842 printf("bad VF receive mode parameter, return code = %d \n", 7843 ret); 7844 } 7845 7846 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 7847 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7848 set, "set"); 7849 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 7850 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7851 port, "port"); 7852 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 7853 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 7854 port_id, UINT16); 7855 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 7856 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7857 vf, "vf"); 7858 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 7859 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 7860 vf_id, UINT8); 7861 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 7862 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7863 what, "rxmode"); 7864 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 7865 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7866 mode, "AUPE#ROPE#BAM#MPE"); 7867 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 7868 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7869 on, "on#off"); 7870 7871 cmdline_parse_inst_t cmd_set_vf_rxmode = { 7872 .f = cmd_set_vf_rxmode_parsed, 7873 .data = NULL, 7874 .help_str = "set port <port_id> vf <vf_id> rxmode " 7875 "AUPE|ROPE|BAM|MPE on|off", 7876 .tokens = { 7877 (void *)&cmd_set_vf_rxmode_set, 7878 (void *)&cmd_set_vf_rxmode_port, 7879 (void *)&cmd_set_vf_rxmode_portid, 7880 (void *)&cmd_set_vf_rxmode_vf, 7881 (void *)&cmd_set_vf_rxmode_vfid, 7882 (void *)&cmd_set_vf_rxmode_what, 7883 (void *)&cmd_set_vf_rxmode_mode, 7884 (void *)&cmd_set_vf_rxmode_on, 7885 NULL, 7886 }, 7887 }; 7888 7889 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 7890 struct cmd_vf_mac_addr_result { 7891 cmdline_fixed_string_t mac_addr_cmd; 7892 cmdline_fixed_string_t what; 7893 cmdline_fixed_string_t port; 7894 uint16_t port_num; 7895 cmdline_fixed_string_t vf; 7896 uint8_t vf_num; 7897 struct ether_addr address; 7898 }; 7899 7900 static void cmd_vf_mac_addr_parsed(void *parsed_result, 7901 __attribute__((unused)) struct cmdline *cl, 7902 __attribute__((unused)) void *data) 7903 { 7904 struct cmd_vf_mac_addr_result *res = parsed_result; 7905 int ret = -ENOTSUP; 7906 7907 if (strcmp(res->what, "add") != 0) 7908 return; 7909 7910 #ifdef RTE_LIBRTE_I40E_PMD 7911 if (ret == -ENOTSUP) 7912 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 7913 &res->address); 7914 #endif 7915 #ifdef RTE_LIBRTE_BNXT_PMD 7916 if (ret == -ENOTSUP) 7917 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 7918 res->vf_num); 7919 #endif 7920 7921 if(ret < 0) 7922 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 7923 7924 } 7925 7926 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 7927 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 7928 mac_addr_cmd,"mac_addr"); 7929 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 7930 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 7931 what,"add"); 7932 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 7933 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 7934 port,"port"); 7935 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 7936 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 7937 port_num, UINT16); 7938 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 7939 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 7940 vf,"vf"); 7941 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 7942 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 7943 vf_num, UINT8); 7944 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 7945 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 7946 address); 7947 7948 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 7949 .f = cmd_vf_mac_addr_parsed, 7950 .data = (void *)0, 7951 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 7952 "Add MAC address filtering for a VF on port_id", 7953 .tokens = { 7954 (void *)&cmd_vf_mac_addr_cmd, 7955 (void *)&cmd_vf_mac_addr_what, 7956 (void *)&cmd_vf_mac_addr_port, 7957 (void *)&cmd_vf_mac_addr_portnum, 7958 (void *)&cmd_vf_mac_addr_vf, 7959 (void *)&cmd_vf_mac_addr_vfnum, 7960 (void *)&cmd_vf_mac_addr_addr, 7961 NULL, 7962 }, 7963 }; 7964 7965 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 7966 struct cmd_vf_rx_vlan_filter { 7967 cmdline_fixed_string_t rx_vlan; 7968 cmdline_fixed_string_t what; 7969 uint16_t vlan_id; 7970 cmdline_fixed_string_t port; 7971 portid_t port_id; 7972 cmdline_fixed_string_t vf; 7973 uint64_t vf_mask; 7974 }; 7975 7976 static void 7977 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 7978 __attribute__((unused)) struct cmdline *cl, 7979 __attribute__((unused)) void *data) 7980 { 7981 struct cmd_vf_rx_vlan_filter *res = parsed_result; 7982 int ret = -ENOTSUP; 7983 7984 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 7985 7986 #ifdef RTE_LIBRTE_IXGBE_PMD 7987 if (ret == -ENOTSUP) 7988 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 7989 res->vlan_id, res->vf_mask, is_add); 7990 #endif 7991 #ifdef RTE_LIBRTE_I40E_PMD 7992 if (ret == -ENOTSUP) 7993 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 7994 res->vlan_id, res->vf_mask, is_add); 7995 #endif 7996 #ifdef RTE_LIBRTE_BNXT_PMD 7997 if (ret == -ENOTSUP) 7998 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 7999 res->vlan_id, res->vf_mask, is_add); 8000 #endif 8001 8002 switch (ret) { 8003 case 0: 8004 break; 8005 case -EINVAL: 8006 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n", 8007 res->vlan_id, res->vf_mask); 8008 break; 8009 case -ENODEV: 8010 printf("invalid port_id %d\n", res->port_id); 8011 break; 8012 case -ENOTSUP: 8013 printf("function not implemented or supported\n"); 8014 break; 8015 default: 8016 printf("programming error: (%s)\n", strerror(-ret)); 8017 } 8018 } 8019 8020 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 8021 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8022 rx_vlan, "rx_vlan"); 8023 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 8024 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8025 what, "add#rm"); 8026 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 8027 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8028 vlan_id, UINT16); 8029 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 8030 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8031 port, "port"); 8032 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 8033 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8034 port_id, UINT16); 8035 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 8036 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8037 vf, "vf"); 8038 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 8039 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8040 vf_mask, UINT64); 8041 8042 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 8043 .f = cmd_vf_rx_vlan_filter_parsed, 8044 .data = NULL, 8045 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 8046 "(vf_mask = hexadecimal VF mask)", 8047 .tokens = { 8048 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 8049 (void *)&cmd_vf_rx_vlan_filter_what, 8050 (void *)&cmd_vf_rx_vlan_filter_vlanid, 8051 (void *)&cmd_vf_rx_vlan_filter_port, 8052 (void *)&cmd_vf_rx_vlan_filter_portid, 8053 (void *)&cmd_vf_rx_vlan_filter_vf, 8054 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 8055 NULL, 8056 }, 8057 }; 8058 8059 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 8060 struct cmd_queue_rate_limit_result { 8061 cmdline_fixed_string_t set; 8062 cmdline_fixed_string_t port; 8063 uint16_t port_num; 8064 cmdline_fixed_string_t queue; 8065 uint8_t queue_num; 8066 cmdline_fixed_string_t rate; 8067 uint16_t rate_num; 8068 }; 8069 8070 static void cmd_queue_rate_limit_parsed(void *parsed_result, 8071 __attribute__((unused)) struct cmdline *cl, 8072 __attribute__((unused)) void *data) 8073 { 8074 struct cmd_queue_rate_limit_result *res = parsed_result; 8075 int ret = 0; 8076 8077 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8078 && (strcmp(res->queue, "queue") == 0) 8079 && (strcmp(res->rate, "rate") == 0)) 8080 ret = set_queue_rate_limit(res->port_num, res->queue_num, 8081 res->rate_num); 8082 if (ret < 0) 8083 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8084 8085 } 8086 8087 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 8088 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8089 set, "set"); 8090 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 8091 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8092 port, "port"); 8093 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 8094 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8095 port_num, UINT16); 8096 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 8097 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8098 queue, "queue"); 8099 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 8100 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8101 queue_num, UINT8); 8102 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 8103 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8104 rate, "rate"); 8105 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 8106 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8107 rate_num, UINT16); 8108 8109 cmdline_parse_inst_t cmd_queue_rate_limit = { 8110 .f = cmd_queue_rate_limit_parsed, 8111 .data = (void *)0, 8112 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 8113 "Set rate limit for a queue on port_id", 8114 .tokens = { 8115 (void *)&cmd_queue_rate_limit_set, 8116 (void *)&cmd_queue_rate_limit_port, 8117 (void *)&cmd_queue_rate_limit_portnum, 8118 (void *)&cmd_queue_rate_limit_queue, 8119 (void *)&cmd_queue_rate_limit_queuenum, 8120 (void *)&cmd_queue_rate_limit_rate, 8121 (void *)&cmd_queue_rate_limit_ratenum, 8122 NULL, 8123 }, 8124 }; 8125 8126 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 8127 struct cmd_vf_rate_limit_result { 8128 cmdline_fixed_string_t set; 8129 cmdline_fixed_string_t port; 8130 uint16_t port_num; 8131 cmdline_fixed_string_t vf; 8132 uint8_t vf_num; 8133 cmdline_fixed_string_t rate; 8134 uint16_t rate_num; 8135 cmdline_fixed_string_t q_msk; 8136 uint64_t q_msk_val; 8137 }; 8138 8139 static void cmd_vf_rate_limit_parsed(void *parsed_result, 8140 __attribute__((unused)) struct cmdline *cl, 8141 __attribute__((unused)) void *data) 8142 { 8143 struct cmd_vf_rate_limit_result *res = parsed_result; 8144 int ret = 0; 8145 8146 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8147 && (strcmp(res->vf, "vf") == 0) 8148 && (strcmp(res->rate, "rate") == 0) 8149 && (strcmp(res->q_msk, "queue_mask") == 0)) 8150 ret = set_vf_rate_limit(res->port_num, res->vf_num, 8151 res->rate_num, res->q_msk_val); 8152 if (ret < 0) 8153 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8154 8155 } 8156 8157 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 8158 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8159 set, "set"); 8160 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 8161 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8162 port, "port"); 8163 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 8164 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8165 port_num, UINT16); 8166 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 8167 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8168 vf, "vf"); 8169 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 8170 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8171 vf_num, UINT8); 8172 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 8173 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8174 rate, "rate"); 8175 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 8176 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8177 rate_num, UINT16); 8178 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 8179 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8180 q_msk, "queue_mask"); 8181 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 8182 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8183 q_msk_val, UINT64); 8184 8185 cmdline_parse_inst_t cmd_vf_rate_limit = { 8186 .f = cmd_vf_rate_limit_parsed, 8187 .data = (void *)0, 8188 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 8189 "queue_mask <queue_mask_value>: " 8190 "Set rate limit for queues of VF on port_id", 8191 .tokens = { 8192 (void *)&cmd_vf_rate_limit_set, 8193 (void *)&cmd_vf_rate_limit_port, 8194 (void *)&cmd_vf_rate_limit_portnum, 8195 (void *)&cmd_vf_rate_limit_vf, 8196 (void *)&cmd_vf_rate_limit_vfnum, 8197 (void *)&cmd_vf_rate_limit_rate, 8198 (void *)&cmd_vf_rate_limit_ratenum, 8199 (void *)&cmd_vf_rate_limit_q_msk, 8200 (void *)&cmd_vf_rate_limit_q_msk_val, 8201 NULL, 8202 }, 8203 }; 8204 8205 /* *** ADD TUNNEL FILTER OF A PORT *** */ 8206 struct cmd_tunnel_filter_result { 8207 cmdline_fixed_string_t cmd; 8208 cmdline_fixed_string_t what; 8209 portid_t port_id; 8210 struct ether_addr outer_mac; 8211 struct ether_addr inner_mac; 8212 cmdline_ipaddr_t ip_value; 8213 uint16_t inner_vlan; 8214 cmdline_fixed_string_t tunnel_type; 8215 cmdline_fixed_string_t filter_type; 8216 uint32_t tenant_id; 8217 uint16_t queue_num; 8218 }; 8219 8220 static void 8221 cmd_tunnel_filter_parsed(void *parsed_result, 8222 __attribute__((unused)) struct cmdline *cl, 8223 __attribute__((unused)) void *data) 8224 { 8225 struct cmd_tunnel_filter_result *res = parsed_result; 8226 struct rte_eth_tunnel_filter_conf tunnel_filter_conf; 8227 int ret = 0; 8228 8229 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf)); 8230 8231 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac); 8232 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac); 8233 tunnel_filter_conf.inner_vlan = res->inner_vlan; 8234 8235 if (res->ip_value.family == AF_INET) { 8236 tunnel_filter_conf.ip_addr.ipv4_addr = 8237 res->ip_value.addr.ipv4.s_addr; 8238 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4; 8239 } else { 8240 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr), 8241 &(res->ip_value.addr.ipv6), 8242 sizeof(struct in6_addr)); 8243 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6; 8244 } 8245 8246 if (!strcmp(res->filter_type, "imac-ivlan")) 8247 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN; 8248 else if (!strcmp(res->filter_type, "imac-ivlan-tenid")) 8249 tunnel_filter_conf.filter_type = 8250 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID; 8251 else if (!strcmp(res->filter_type, "imac-tenid")) 8252 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID; 8253 else if (!strcmp(res->filter_type, "imac")) 8254 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC; 8255 else if (!strcmp(res->filter_type, "omac-imac-tenid")) 8256 tunnel_filter_conf.filter_type = 8257 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC; 8258 else if (!strcmp(res->filter_type, "oip")) 8259 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP; 8260 else if (!strcmp(res->filter_type, "iip")) 8261 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP; 8262 else { 8263 printf("The filter type is not supported"); 8264 return; 8265 } 8266 8267 if (!strcmp(res->tunnel_type, "vxlan")) 8268 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; 8269 else if (!strcmp(res->tunnel_type, "nvgre")) 8270 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE; 8271 else if (!strcmp(res->tunnel_type, "ipingre")) 8272 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE; 8273 else { 8274 printf("The tunnel type %s not supported.\n", res->tunnel_type); 8275 return; 8276 } 8277 8278 tunnel_filter_conf.tenant_id = res->tenant_id; 8279 tunnel_filter_conf.queue_id = res->queue_num; 8280 if (!strcmp(res->what, "add")) 8281 ret = rte_eth_dev_filter_ctrl(res->port_id, 8282 RTE_ETH_FILTER_TUNNEL, 8283 RTE_ETH_FILTER_ADD, 8284 &tunnel_filter_conf); 8285 else 8286 ret = rte_eth_dev_filter_ctrl(res->port_id, 8287 RTE_ETH_FILTER_TUNNEL, 8288 RTE_ETH_FILTER_DELETE, 8289 &tunnel_filter_conf); 8290 if (ret < 0) 8291 printf("cmd_tunnel_filter_parsed error: (%s)\n", 8292 strerror(-ret)); 8293 8294 } 8295 cmdline_parse_token_string_t cmd_tunnel_filter_cmd = 8296 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8297 cmd, "tunnel_filter"); 8298 cmdline_parse_token_string_t cmd_tunnel_filter_what = 8299 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8300 what, "add#rm"); 8301 cmdline_parse_token_num_t cmd_tunnel_filter_port_id = 8302 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8303 port_id, UINT16); 8304 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac = 8305 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8306 outer_mac); 8307 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac = 8308 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8309 inner_mac); 8310 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan = 8311 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8312 inner_vlan, UINT16); 8313 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value = 8314 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8315 ip_value); 8316 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type = 8317 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8318 tunnel_type, "vxlan#nvgre#ipingre"); 8319 8320 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type = 8321 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8322 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#" 8323 "imac#omac-imac-tenid"); 8324 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id = 8325 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8326 tenant_id, UINT32); 8327 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num = 8328 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8329 queue_num, UINT16); 8330 8331 cmdline_parse_inst_t cmd_tunnel_filter = { 8332 .f = cmd_tunnel_filter_parsed, 8333 .data = (void *)0, 8334 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> " 8335 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|" 8336 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> " 8337 "<queue_id>: Add/Rm tunnel filter of a port", 8338 .tokens = { 8339 (void *)&cmd_tunnel_filter_cmd, 8340 (void *)&cmd_tunnel_filter_what, 8341 (void *)&cmd_tunnel_filter_port_id, 8342 (void *)&cmd_tunnel_filter_outer_mac, 8343 (void *)&cmd_tunnel_filter_inner_mac, 8344 (void *)&cmd_tunnel_filter_ip_value, 8345 (void *)&cmd_tunnel_filter_innner_vlan, 8346 (void *)&cmd_tunnel_filter_tunnel_type, 8347 (void *)&cmd_tunnel_filter_filter_type, 8348 (void *)&cmd_tunnel_filter_tenant_id, 8349 (void *)&cmd_tunnel_filter_queue_num, 8350 NULL, 8351 }, 8352 }; 8353 8354 /* *** CONFIGURE TUNNEL UDP PORT *** */ 8355 struct cmd_tunnel_udp_config { 8356 cmdline_fixed_string_t cmd; 8357 cmdline_fixed_string_t what; 8358 uint16_t udp_port; 8359 portid_t port_id; 8360 }; 8361 8362 static void 8363 cmd_tunnel_udp_config_parsed(void *parsed_result, 8364 __attribute__((unused)) struct cmdline *cl, 8365 __attribute__((unused)) void *data) 8366 { 8367 struct cmd_tunnel_udp_config *res = parsed_result; 8368 struct rte_eth_udp_tunnel tunnel_udp; 8369 int ret; 8370 8371 tunnel_udp.udp_port = res->udp_port; 8372 8373 if (!strcmp(res->cmd, "rx_vxlan_port")) 8374 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 8375 8376 if (!strcmp(res->what, "add")) 8377 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 8378 &tunnel_udp); 8379 else 8380 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 8381 &tunnel_udp); 8382 8383 if (ret < 0) 8384 printf("udp tunneling add error: (%s)\n", strerror(-ret)); 8385 } 8386 8387 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd = 8388 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8389 cmd, "rx_vxlan_port"); 8390 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 8391 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8392 what, "add#rm"); 8393 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 8394 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8395 udp_port, UINT16); 8396 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 8397 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8398 port_id, UINT16); 8399 8400 cmdline_parse_inst_t cmd_tunnel_udp_config = { 8401 .f = cmd_tunnel_udp_config_parsed, 8402 .data = (void *)0, 8403 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 8404 "Add/Remove a tunneling UDP port filter", 8405 .tokens = { 8406 (void *)&cmd_tunnel_udp_config_cmd, 8407 (void *)&cmd_tunnel_udp_config_what, 8408 (void *)&cmd_tunnel_udp_config_udp_port, 8409 (void *)&cmd_tunnel_udp_config_port_id, 8410 NULL, 8411 }, 8412 }; 8413 8414 /* *** GLOBAL CONFIG *** */ 8415 struct cmd_global_config_result { 8416 cmdline_fixed_string_t cmd; 8417 portid_t port_id; 8418 cmdline_fixed_string_t cfg_type; 8419 uint8_t len; 8420 }; 8421 8422 static void 8423 cmd_global_config_parsed(void *parsed_result, 8424 __attribute__((unused)) struct cmdline *cl, 8425 __attribute__((unused)) void *data) 8426 { 8427 struct cmd_global_config_result *res = parsed_result; 8428 struct rte_eth_global_cfg conf; 8429 int ret; 8430 8431 memset(&conf, 0, sizeof(conf)); 8432 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN; 8433 conf.cfg.gre_key_len = res->len; 8434 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE, 8435 RTE_ETH_FILTER_SET, &conf); 8436 if (ret != 0) 8437 printf("Global config error\n"); 8438 } 8439 8440 cmdline_parse_token_string_t cmd_global_config_cmd = 8441 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd, 8442 "global_config"); 8443 cmdline_parse_token_num_t cmd_global_config_port_id = 8444 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, 8445 UINT16); 8446 cmdline_parse_token_string_t cmd_global_config_type = 8447 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, 8448 cfg_type, "gre-key-len"); 8449 cmdline_parse_token_num_t cmd_global_config_gre_key_len = 8450 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, 8451 len, UINT8); 8452 8453 cmdline_parse_inst_t cmd_global_config = { 8454 .f = cmd_global_config_parsed, 8455 .data = (void *)NULL, 8456 .help_str = "global_config <port_id> gre-key-len <key_len>", 8457 .tokens = { 8458 (void *)&cmd_global_config_cmd, 8459 (void *)&cmd_global_config_port_id, 8460 (void *)&cmd_global_config_type, 8461 (void *)&cmd_global_config_gre_key_len, 8462 NULL, 8463 }, 8464 }; 8465 8466 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 8467 struct cmd_set_mirror_mask_result { 8468 cmdline_fixed_string_t set; 8469 cmdline_fixed_string_t port; 8470 portid_t port_id; 8471 cmdline_fixed_string_t mirror; 8472 uint8_t rule_id; 8473 cmdline_fixed_string_t what; 8474 cmdline_fixed_string_t value; 8475 cmdline_fixed_string_t dstpool; 8476 uint8_t dstpool_id; 8477 cmdline_fixed_string_t on; 8478 }; 8479 8480 cmdline_parse_token_string_t cmd_mirror_mask_set = 8481 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8482 set, "set"); 8483 cmdline_parse_token_string_t cmd_mirror_mask_port = 8484 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8485 port, "port"); 8486 cmdline_parse_token_num_t cmd_mirror_mask_portid = 8487 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 8488 port_id, UINT16); 8489 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 8490 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8491 mirror, "mirror-rule"); 8492 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 8493 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 8494 rule_id, UINT8); 8495 cmdline_parse_token_string_t cmd_mirror_mask_what = 8496 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8497 what, "pool-mirror-up#pool-mirror-down" 8498 "#vlan-mirror"); 8499 cmdline_parse_token_string_t cmd_mirror_mask_value = 8500 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8501 value, NULL); 8502 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 8503 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8504 dstpool, "dst-pool"); 8505 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 8506 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 8507 dstpool_id, UINT8); 8508 cmdline_parse_token_string_t cmd_mirror_mask_on = 8509 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8510 on, "on#off"); 8511 8512 static void 8513 cmd_set_mirror_mask_parsed(void *parsed_result, 8514 __attribute__((unused)) struct cmdline *cl, 8515 __attribute__((unused)) void *data) 8516 { 8517 int ret,nb_item,i; 8518 struct cmd_set_mirror_mask_result *res = parsed_result; 8519 struct rte_eth_mirror_conf mr_conf; 8520 8521 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 8522 8523 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 8524 8525 mr_conf.dst_pool = res->dstpool_id; 8526 8527 if (!strcmp(res->what, "pool-mirror-up")) { 8528 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 8529 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 8530 } else if (!strcmp(res->what, "pool-mirror-down")) { 8531 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 8532 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 8533 } else if (!strcmp(res->what, "vlan-mirror")) { 8534 mr_conf.rule_type = ETH_MIRROR_VLAN; 8535 nb_item = parse_item_list(res->value, "vlan", 8536 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 8537 if (nb_item <= 0) 8538 return; 8539 8540 for (i = 0; i < nb_item; i++) { 8541 if (vlan_list[i] > ETHER_MAX_VLAN_ID) { 8542 printf("Invalid vlan_id: must be < 4096\n"); 8543 return; 8544 } 8545 8546 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 8547 mr_conf.vlan.vlan_mask |= 1ULL << i; 8548 } 8549 } 8550 8551 if (!strcmp(res->on, "on")) 8552 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 8553 res->rule_id, 1); 8554 else 8555 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 8556 res->rule_id, 0); 8557 if (ret < 0) 8558 printf("mirror rule add error: (%s)\n", strerror(-ret)); 8559 } 8560 8561 cmdline_parse_inst_t cmd_set_mirror_mask = { 8562 .f = cmd_set_mirror_mask_parsed, 8563 .data = NULL, 8564 .help_str = "set port <port_id> mirror-rule <rule_id> " 8565 "pool-mirror-up|pool-mirror-down|vlan-mirror " 8566 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 8567 .tokens = { 8568 (void *)&cmd_mirror_mask_set, 8569 (void *)&cmd_mirror_mask_port, 8570 (void *)&cmd_mirror_mask_portid, 8571 (void *)&cmd_mirror_mask_mirror, 8572 (void *)&cmd_mirror_mask_ruleid, 8573 (void *)&cmd_mirror_mask_what, 8574 (void *)&cmd_mirror_mask_value, 8575 (void *)&cmd_mirror_mask_dstpool, 8576 (void *)&cmd_mirror_mask_poolid, 8577 (void *)&cmd_mirror_mask_on, 8578 NULL, 8579 }, 8580 }; 8581 8582 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 8583 struct cmd_set_mirror_link_result { 8584 cmdline_fixed_string_t set; 8585 cmdline_fixed_string_t port; 8586 portid_t port_id; 8587 cmdline_fixed_string_t mirror; 8588 uint8_t rule_id; 8589 cmdline_fixed_string_t what; 8590 cmdline_fixed_string_t dstpool; 8591 uint8_t dstpool_id; 8592 cmdline_fixed_string_t on; 8593 }; 8594 8595 cmdline_parse_token_string_t cmd_mirror_link_set = 8596 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8597 set, "set"); 8598 cmdline_parse_token_string_t cmd_mirror_link_port = 8599 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8600 port, "port"); 8601 cmdline_parse_token_num_t cmd_mirror_link_portid = 8602 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 8603 port_id, UINT16); 8604 cmdline_parse_token_string_t cmd_mirror_link_mirror = 8605 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8606 mirror, "mirror-rule"); 8607 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 8608 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 8609 rule_id, UINT8); 8610 cmdline_parse_token_string_t cmd_mirror_link_what = 8611 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8612 what, "uplink-mirror#downlink-mirror"); 8613 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 8614 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8615 dstpool, "dst-pool"); 8616 cmdline_parse_token_num_t cmd_mirror_link_poolid = 8617 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 8618 dstpool_id, UINT8); 8619 cmdline_parse_token_string_t cmd_mirror_link_on = 8620 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8621 on, "on#off"); 8622 8623 static void 8624 cmd_set_mirror_link_parsed(void *parsed_result, 8625 __attribute__((unused)) struct cmdline *cl, 8626 __attribute__((unused)) void *data) 8627 { 8628 int ret; 8629 struct cmd_set_mirror_link_result *res = parsed_result; 8630 struct rte_eth_mirror_conf mr_conf; 8631 8632 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 8633 if (!strcmp(res->what, "uplink-mirror")) 8634 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 8635 else 8636 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 8637 8638 mr_conf.dst_pool = res->dstpool_id; 8639 8640 if (!strcmp(res->on, "on")) 8641 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 8642 res->rule_id, 1); 8643 else 8644 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 8645 res->rule_id, 0); 8646 8647 /* check the return value and print it if is < 0 */ 8648 if (ret < 0) 8649 printf("mirror rule add error: (%s)\n", strerror(-ret)); 8650 8651 } 8652 8653 cmdline_parse_inst_t cmd_set_mirror_link = { 8654 .f = cmd_set_mirror_link_parsed, 8655 .data = NULL, 8656 .help_str = "set port <port_id> mirror-rule <rule_id> " 8657 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 8658 .tokens = { 8659 (void *)&cmd_mirror_link_set, 8660 (void *)&cmd_mirror_link_port, 8661 (void *)&cmd_mirror_link_portid, 8662 (void *)&cmd_mirror_link_mirror, 8663 (void *)&cmd_mirror_link_ruleid, 8664 (void *)&cmd_mirror_link_what, 8665 (void *)&cmd_mirror_link_dstpool, 8666 (void *)&cmd_mirror_link_poolid, 8667 (void *)&cmd_mirror_link_on, 8668 NULL, 8669 }, 8670 }; 8671 8672 /* *** RESET VM MIRROR RULE *** */ 8673 struct cmd_rm_mirror_rule_result { 8674 cmdline_fixed_string_t reset; 8675 cmdline_fixed_string_t port; 8676 portid_t port_id; 8677 cmdline_fixed_string_t mirror; 8678 uint8_t rule_id; 8679 }; 8680 8681 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 8682 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 8683 reset, "reset"); 8684 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 8685 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 8686 port, "port"); 8687 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 8688 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 8689 port_id, UINT16); 8690 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 8691 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 8692 mirror, "mirror-rule"); 8693 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 8694 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 8695 rule_id, UINT8); 8696 8697 static void 8698 cmd_reset_mirror_rule_parsed(void *parsed_result, 8699 __attribute__((unused)) struct cmdline *cl, 8700 __attribute__((unused)) void *data) 8701 { 8702 int ret; 8703 struct cmd_set_mirror_link_result *res = parsed_result; 8704 /* check rule_id */ 8705 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 8706 if(ret < 0) 8707 printf("mirror rule remove error: (%s)\n", strerror(-ret)); 8708 } 8709 8710 cmdline_parse_inst_t cmd_reset_mirror_rule = { 8711 .f = cmd_reset_mirror_rule_parsed, 8712 .data = NULL, 8713 .help_str = "reset port <port_id> mirror-rule <rule_id>", 8714 .tokens = { 8715 (void *)&cmd_rm_mirror_rule_reset, 8716 (void *)&cmd_rm_mirror_rule_port, 8717 (void *)&cmd_rm_mirror_rule_portid, 8718 (void *)&cmd_rm_mirror_rule_mirror, 8719 (void *)&cmd_rm_mirror_rule_ruleid, 8720 NULL, 8721 }, 8722 }; 8723 8724 /* ******************************************************************************** */ 8725 8726 struct cmd_dump_result { 8727 cmdline_fixed_string_t dump; 8728 }; 8729 8730 static void 8731 dump_struct_sizes(void) 8732 { 8733 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 8734 DUMP_SIZE(struct rte_mbuf); 8735 DUMP_SIZE(struct rte_mempool); 8736 DUMP_SIZE(struct rte_ring); 8737 #undef DUMP_SIZE 8738 } 8739 8740 static void cmd_dump_parsed(void *parsed_result, 8741 __attribute__((unused)) struct cmdline *cl, 8742 __attribute__((unused)) void *data) 8743 { 8744 struct cmd_dump_result *res = parsed_result; 8745 8746 if (!strcmp(res->dump, "dump_physmem")) 8747 rte_dump_physmem_layout(stdout); 8748 else if (!strcmp(res->dump, "dump_memzone")) 8749 rte_memzone_dump(stdout); 8750 else if (!strcmp(res->dump, "dump_struct_sizes")) 8751 dump_struct_sizes(); 8752 else if (!strcmp(res->dump, "dump_ring")) 8753 rte_ring_list_dump(stdout); 8754 else if (!strcmp(res->dump, "dump_mempool")) 8755 rte_mempool_list_dump(stdout); 8756 else if (!strcmp(res->dump, "dump_devargs")) 8757 rte_eal_devargs_dump(stdout); 8758 else if (!strcmp(res->dump, "dump_log_types")) 8759 rte_log_dump(stdout); 8760 } 8761 8762 cmdline_parse_token_string_t cmd_dump_dump = 8763 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 8764 "dump_physmem#" 8765 "dump_memzone#" 8766 "dump_struct_sizes#" 8767 "dump_ring#" 8768 "dump_mempool#" 8769 "dump_devargs#" 8770 "dump_log_types"); 8771 8772 cmdline_parse_inst_t cmd_dump = { 8773 .f = cmd_dump_parsed, /* function to call */ 8774 .data = NULL, /* 2nd arg of func */ 8775 .help_str = "Dump status", 8776 .tokens = { /* token list, NULL terminated */ 8777 (void *)&cmd_dump_dump, 8778 NULL, 8779 }, 8780 }; 8781 8782 /* ******************************************************************************** */ 8783 8784 struct cmd_dump_one_result { 8785 cmdline_fixed_string_t dump; 8786 cmdline_fixed_string_t name; 8787 }; 8788 8789 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 8790 __attribute__((unused)) void *data) 8791 { 8792 struct cmd_dump_one_result *res = parsed_result; 8793 8794 if (!strcmp(res->dump, "dump_ring")) { 8795 struct rte_ring *r; 8796 r = rte_ring_lookup(res->name); 8797 if (r == NULL) { 8798 cmdline_printf(cl, "Cannot find ring\n"); 8799 return; 8800 } 8801 rte_ring_dump(stdout, r); 8802 } else if (!strcmp(res->dump, "dump_mempool")) { 8803 struct rte_mempool *mp; 8804 mp = rte_mempool_lookup(res->name); 8805 if (mp == NULL) { 8806 cmdline_printf(cl, "Cannot find mempool\n"); 8807 return; 8808 } 8809 rte_mempool_dump(stdout, mp); 8810 } 8811 } 8812 8813 cmdline_parse_token_string_t cmd_dump_one_dump = 8814 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 8815 "dump_ring#dump_mempool"); 8816 8817 cmdline_parse_token_string_t cmd_dump_one_name = 8818 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 8819 8820 cmdline_parse_inst_t cmd_dump_one = { 8821 .f = cmd_dump_one_parsed, /* function to call */ 8822 .data = NULL, /* 2nd arg of func */ 8823 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 8824 .tokens = { /* token list, NULL terminated */ 8825 (void *)&cmd_dump_one_dump, 8826 (void *)&cmd_dump_one_name, 8827 NULL, 8828 }, 8829 }; 8830 8831 /* *** Add/Del syn filter *** */ 8832 struct cmd_syn_filter_result { 8833 cmdline_fixed_string_t filter; 8834 portid_t port_id; 8835 cmdline_fixed_string_t ops; 8836 cmdline_fixed_string_t priority; 8837 cmdline_fixed_string_t high; 8838 cmdline_fixed_string_t queue; 8839 uint16_t queue_id; 8840 }; 8841 8842 static void 8843 cmd_syn_filter_parsed(void *parsed_result, 8844 __attribute__((unused)) struct cmdline *cl, 8845 __attribute__((unused)) void *data) 8846 { 8847 struct cmd_syn_filter_result *res = parsed_result; 8848 struct rte_eth_syn_filter syn_filter; 8849 int ret = 0; 8850 8851 ret = rte_eth_dev_filter_supported(res->port_id, 8852 RTE_ETH_FILTER_SYN); 8853 if (ret < 0) { 8854 printf("syn filter is not supported on port %u.\n", 8855 res->port_id); 8856 return; 8857 } 8858 8859 memset(&syn_filter, 0, sizeof(syn_filter)); 8860 8861 if (!strcmp(res->ops, "add")) { 8862 if (!strcmp(res->high, "high")) 8863 syn_filter.hig_pri = 1; 8864 else 8865 syn_filter.hig_pri = 0; 8866 8867 syn_filter.queue = res->queue_id; 8868 ret = rte_eth_dev_filter_ctrl(res->port_id, 8869 RTE_ETH_FILTER_SYN, 8870 RTE_ETH_FILTER_ADD, 8871 &syn_filter); 8872 } else 8873 ret = rte_eth_dev_filter_ctrl(res->port_id, 8874 RTE_ETH_FILTER_SYN, 8875 RTE_ETH_FILTER_DELETE, 8876 &syn_filter); 8877 8878 if (ret < 0) 8879 printf("syn filter programming error: (%s)\n", 8880 strerror(-ret)); 8881 } 8882 8883 cmdline_parse_token_string_t cmd_syn_filter_filter = 8884 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 8885 filter, "syn_filter"); 8886 cmdline_parse_token_num_t cmd_syn_filter_port_id = 8887 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 8888 port_id, UINT16); 8889 cmdline_parse_token_string_t cmd_syn_filter_ops = 8890 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 8891 ops, "add#del"); 8892 cmdline_parse_token_string_t cmd_syn_filter_priority = 8893 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 8894 priority, "priority"); 8895 cmdline_parse_token_string_t cmd_syn_filter_high = 8896 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 8897 high, "high#low"); 8898 cmdline_parse_token_string_t cmd_syn_filter_queue = 8899 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 8900 queue, "queue"); 8901 cmdline_parse_token_num_t cmd_syn_filter_queue_id = 8902 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 8903 queue_id, UINT16); 8904 8905 cmdline_parse_inst_t cmd_syn_filter = { 8906 .f = cmd_syn_filter_parsed, 8907 .data = NULL, 8908 .help_str = "syn_filter <port_id> add|del priority high|low queue " 8909 "<queue_id>: Add/Delete syn filter", 8910 .tokens = { 8911 (void *)&cmd_syn_filter_filter, 8912 (void *)&cmd_syn_filter_port_id, 8913 (void *)&cmd_syn_filter_ops, 8914 (void *)&cmd_syn_filter_priority, 8915 (void *)&cmd_syn_filter_high, 8916 (void *)&cmd_syn_filter_queue, 8917 (void *)&cmd_syn_filter_queue_id, 8918 NULL, 8919 }, 8920 }; 8921 8922 /* *** queue region set *** */ 8923 struct cmd_queue_region_result { 8924 cmdline_fixed_string_t set; 8925 cmdline_fixed_string_t port; 8926 portid_t port_id; 8927 cmdline_fixed_string_t cmd; 8928 cmdline_fixed_string_t region; 8929 uint8_t region_id; 8930 cmdline_fixed_string_t queue_start_index; 8931 uint8_t queue_id; 8932 cmdline_fixed_string_t queue_num; 8933 uint8_t queue_num_value; 8934 }; 8935 8936 static void 8937 cmd_queue_region_parsed(void *parsed_result, 8938 __attribute__((unused)) struct cmdline *cl, 8939 __attribute__((unused)) void *data) 8940 { 8941 struct cmd_queue_region_result *res = parsed_result; 8942 int ret = -ENOTSUP; 8943 #ifdef RTE_LIBRTE_I40E_PMD 8944 struct rte_pmd_i40e_queue_region_conf region_conf; 8945 enum rte_pmd_i40e_queue_region_op op_type; 8946 #endif 8947 8948 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 8949 return; 8950 8951 #ifdef RTE_LIBRTE_I40E_PMD 8952 memset(®ion_conf, 0, sizeof(region_conf)); 8953 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 8954 region_conf.region_id = res->region_id; 8955 region_conf.queue_num = res->queue_num_value; 8956 region_conf.queue_start_index = res->queue_id; 8957 8958 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 8959 op_type, ®ion_conf); 8960 #endif 8961 8962 switch (ret) { 8963 case 0: 8964 break; 8965 case -ENOTSUP: 8966 printf("function not implemented or supported\n"); 8967 break; 8968 default: 8969 printf("queue region config error: (%s)\n", strerror(-ret)); 8970 } 8971 } 8972 8973 cmdline_parse_token_string_t cmd_queue_region_set = 8974 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 8975 set, "set"); 8976 cmdline_parse_token_string_t cmd_queue_region_port = 8977 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 8978 cmdline_parse_token_num_t cmd_queue_region_port_id = 8979 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 8980 port_id, UINT16); 8981 cmdline_parse_token_string_t cmd_queue_region_cmd = 8982 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 8983 cmd, "queue-region"); 8984 cmdline_parse_token_string_t cmd_queue_region_id = 8985 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 8986 region, "region_id"); 8987 cmdline_parse_token_num_t cmd_queue_region_index = 8988 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 8989 region_id, UINT8); 8990 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 8991 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 8992 queue_start_index, "queue_start_index"); 8993 cmdline_parse_token_num_t cmd_queue_region_queue_id = 8994 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 8995 queue_id, UINT8); 8996 cmdline_parse_token_string_t cmd_queue_region_queue_num = 8997 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 8998 queue_num, "queue_num"); 8999 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 9000 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9001 queue_num_value, UINT8); 9002 9003 cmdline_parse_inst_t cmd_queue_region = { 9004 .f = cmd_queue_region_parsed, 9005 .data = NULL, 9006 .help_str = "set port <port_id> queue-region region_id <value> " 9007 "queue_start_index <value> queue_num <value>: Set a queue region", 9008 .tokens = { 9009 (void *)&cmd_queue_region_set, 9010 (void *)&cmd_queue_region_port, 9011 (void *)&cmd_queue_region_port_id, 9012 (void *)&cmd_queue_region_cmd, 9013 (void *)&cmd_queue_region_id, 9014 (void *)&cmd_queue_region_index, 9015 (void *)&cmd_queue_region_queue_start_index, 9016 (void *)&cmd_queue_region_queue_id, 9017 (void *)&cmd_queue_region_queue_num, 9018 (void *)&cmd_queue_region_queue_num_value, 9019 NULL, 9020 }, 9021 }; 9022 9023 /* *** queue region and flowtype set *** */ 9024 struct cmd_region_flowtype_result { 9025 cmdline_fixed_string_t set; 9026 cmdline_fixed_string_t port; 9027 portid_t port_id; 9028 cmdline_fixed_string_t cmd; 9029 cmdline_fixed_string_t region; 9030 uint8_t region_id; 9031 cmdline_fixed_string_t flowtype; 9032 uint8_t flowtype_id; 9033 }; 9034 9035 static void 9036 cmd_region_flowtype_parsed(void *parsed_result, 9037 __attribute__((unused)) struct cmdline *cl, 9038 __attribute__((unused)) void *data) 9039 { 9040 struct cmd_region_flowtype_result *res = parsed_result; 9041 int ret = -ENOTSUP; 9042 #ifdef RTE_LIBRTE_I40E_PMD 9043 struct rte_pmd_i40e_queue_region_conf region_conf; 9044 enum rte_pmd_i40e_queue_region_op op_type; 9045 #endif 9046 9047 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9048 return; 9049 9050 #ifdef RTE_LIBRTE_I40E_PMD 9051 memset(®ion_conf, 0, sizeof(region_conf)); 9052 9053 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 9054 region_conf.region_id = res->region_id; 9055 region_conf.hw_flowtype = res->flowtype_id; 9056 9057 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9058 op_type, ®ion_conf); 9059 #endif 9060 9061 switch (ret) { 9062 case 0: 9063 break; 9064 case -ENOTSUP: 9065 printf("function not implemented or supported\n"); 9066 break; 9067 default: 9068 printf("region flowtype config error: (%s)\n", strerror(-ret)); 9069 } 9070 } 9071 9072 cmdline_parse_token_string_t cmd_region_flowtype_set = 9073 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9074 set, "set"); 9075 cmdline_parse_token_string_t cmd_region_flowtype_port = 9076 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9077 port, "port"); 9078 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 9079 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9080 port_id, UINT16); 9081 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 9082 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9083 cmd, "queue-region"); 9084 cmdline_parse_token_string_t cmd_region_flowtype_index = 9085 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9086 region, "region_id"); 9087 cmdline_parse_token_num_t cmd_region_flowtype_id = 9088 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9089 region_id, UINT8); 9090 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 9091 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9092 flowtype, "flowtype"); 9093 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 9094 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9095 flowtype_id, UINT8); 9096 cmdline_parse_inst_t cmd_region_flowtype = { 9097 .f = cmd_region_flowtype_parsed, 9098 .data = NULL, 9099 .help_str = "set port <port_id> queue-region region_id <value> " 9100 "flowtype <value>: Set a flowtype region index", 9101 .tokens = { 9102 (void *)&cmd_region_flowtype_set, 9103 (void *)&cmd_region_flowtype_port, 9104 (void *)&cmd_region_flowtype_port_index, 9105 (void *)&cmd_region_flowtype_cmd, 9106 (void *)&cmd_region_flowtype_index, 9107 (void *)&cmd_region_flowtype_id, 9108 (void *)&cmd_region_flowtype_flow_index, 9109 (void *)&cmd_region_flowtype_flow_id, 9110 NULL, 9111 }, 9112 }; 9113 9114 /* *** User Priority (UP) to queue region (region_id) set *** */ 9115 struct cmd_user_priority_region_result { 9116 cmdline_fixed_string_t set; 9117 cmdline_fixed_string_t port; 9118 portid_t port_id; 9119 cmdline_fixed_string_t cmd; 9120 cmdline_fixed_string_t user_priority; 9121 uint8_t user_priority_id; 9122 cmdline_fixed_string_t region; 9123 uint8_t region_id; 9124 }; 9125 9126 static void 9127 cmd_user_priority_region_parsed(void *parsed_result, 9128 __attribute__((unused)) struct cmdline *cl, 9129 __attribute__((unused)) void *data) 9130 { 9131 struct cmd_user_priority_region_result *res = parsed_result; 9132 int ret = -ENOTSUP; 9133 #ifdef RTE_LIBRTE_I40E_PMD 9134 struct rte_pmd_i40e_queue_region_conf region_conf; 9135 enum rte_pmd_i40e_queue_region_op op_type; 9136 #endif 9137 9138 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9139 return; 9140 9141 #ifdef RTE_LIBRTE_I40E_PMD 9142 memset(®ion_conf, 0, sizeof(region_conf)); 9143 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 9144 region_conf.user_priority = res->user_priority_id; 9145 region_conf.region_id = res->region_id; 9146 9147 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9148 op_type, ®ion_conf); 9149 #endif 9150 9151 switch (ret) { 9152 case 0: 9153 break; 9154 case -ENOTSUP: 9155 printf("function not implemented or supported\n"); 9156 break; 9157 default: 9158 printf("user_priority region config error: (%s)\n", 9159 strerror(-ret)); 9160 } 9161 } 9162 9163 cmdline_parse_token_string_t cmd_user_priority_region_set = 9164 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9165 set, "set"); 9166 cmdline_parse_token_string_t cmd_user_priority_region_port = 9167 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9168 port, "port"); 9169 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 9170 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9171 port_id, UINT16); 9172 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 9173 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9174 cmd, "queue-region"); 9175 cmdline_parse_token_string_t cmd_user_priority_region_UP = 9176 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9177 user_priority, "UP"); 9178 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 9179 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9180 user_priority_id, UINT8); 9181 cmdline_parse_token_string_t cmd_user_priority_region_region = 9182 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9183 region, "region_id"); 9184 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 9185 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9186 region_id, UINT8); 9187 9188 cmdline_parse_inst_t cmd_user_priority_region = { 9189 .f = cmd_user_priority_region_parsed, 9190 .data = NULL, 9191 .help_str = "set port <port_id> queue-region UP <value> " 9192 "region_id <value>: Set the mapping of User Priority (UP) " 9193 "to queue region (region_id) ", 9194 .tokens = { 9195 (void *)&cmd_user_priority_region_set, 9196 (void *)&cmd_user_priority_region_port, 9197 (void *)&cmd_user_priority_region_port_index, 9198 (void *)&cmd_user_priority_region_cmd, 9199 (void *)&cmd_user_priority_region_UP, 9200 (void *)&cmd_user_priority_region_UP_id, 9201 (void *)&cmd_user_priority_region_region, 9202 (void *)&cmd_user_priority_region_region_id, 9203 NULL, 9204 }, 9205 }; 9206 9207 /* *** flush all queue region related configuration *** */ 9208 struct cmd_flush_queue_region_result { 9209 cmdline_fixed_string_t set; 9210 cmdline_fixed_string_t port; 9211 portid_t port_id; 9212 cmdline_fixed_string_t cmd; 9213 cmdline_fixed_string_t flush; 9214 cmdline_fixed_string_t what; 9215 }; 9216 9217 static void 9218 cmd_flush_queue_region_parsed(void *parsed_result, 9219 __attribute__((unused)) struct cmdline *cl, 9220 __attribute__((unused)) void *data) 9221 { 9222 struct cmd_flush_queue_region_result *res = parsed_result; 9223 int ret = -ENOTSUP; 9224 #ifdef RTE_LIBRTE_I40E_PMD 9225 struct rte_pmd_i40e_queue_region_conf region_conf; 9226 enum rte_pmd_i40e_queue_region_op op_type; 9227 #endif 9228 9229 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9230 return; 9231 9232 #ifdef RTE_LIBRTE_I40E_PMD 9233 memset(®ion_conf, 0, sizeof(region_conf)); 9234 9235 if (strcmp(res->what, "on") == 0) 9236 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 9237 else 9238 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 9239 9240 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9241 op_type, ®ion_conf); 9242 #endif 9243 9244 switch (ret) { 9245 case 0: 9246 break; 9247 case -ENOTSUP: 9248 printf("function not implemented or supported\n"); 9249 break; 9250 default: 9251 printf("queue region config flush error: (%s)\n", 9252 strerror(-ret)); 9253 } 9254 } 9255 9256 cmdline_parse_token_string_t cmd_flush_queue_region_set = 9257 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9258 set, "set"); 9259 cmdline_parse_token_string_t cmd_flush_queue_region_port = 9260 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9261 port, "port"); 9262 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 9263 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 9264 port_id, UINT16); 9265 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 9266 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9267 cmd, "queue-region"); 9268 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 9269 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9270 flush, "flush"); 9271 cmdline_parse_token_string_t cmd_flush_queue_region_what = 9272 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9273 what, "on#off"); 9274 9275 cmdline_parse_inst_t cmd_flush_queue_region = { 9276 .f = cmd_flush_queue_region_parsed, 9277 .data = NULL, 9278 .help_str = "set port <port_id> queue-region flush on|off" 9279 ": flush all queue region related configuration", 9280 .tokens = { 9281 (void *)&cmd_flush_queue_region_set, 9282 (void *)&cmd_flush_queue_region_port, 9283 (void *)&cmd_flush_queue_region_port_index, 9284 (void *)&cmd_flush_queue_region_cmd, 9285 (void *)&cmd_flush_queue_region_flush, 9286 (void *)&cmd_flush_queue_region_what, 9287 NULL, 9288 }, 9289 }; 9290 9291 /* *** get all queue region related configuration info *** */ 9292 struct cmd_show_queue_region_info { 9293 cmdline_fixed_string_t show; 9294 cmdline_fixed_string_t port; 9295 portid_t port_id; 9296 cmdline_fixed_string_t cmd; 9297 }; 9298 9299 static void 9300 cmd_show_queue_region_info_parsed(void *parsed_result, 9301 __attribute__((unused)) struct cmdline *cl, 9302 __attribute__((unused)) void *data) 9303 { 9304 struct cmd_show_queue_region_info *res = parsed_result; 9305 int ret = -ENOTSUP; 9306 #ifdef RTE_LIBRTE_I40E_PMD 9307 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 9308 enum rte_pmd_i40e_queue_region_op op_type; 9309 #endif 9310 9311 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9312 return; 9313 9314 #ifdef RTE_LIBRTE_I40E_PMD 9315 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 9316 9317 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 9318 9319 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9320 op_type, &rte_pmd_regions); 9321 9322 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 9323 #endif 9324 9325 switch (ret) { 9326 case 0: 9327 break; 9328 case -ENOTSUP: 9329 printf("function not implemented or supported\n"); 9330 break; 9331 default: 9332 printf("queue region config info show error: (%s)\n", 9333 strerror(-ret)); 9334 } 9335 } 9336 9337 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 9338 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9339 show, "show"); 9340 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 9341 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9342 port, "port"); 9343 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 9344 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 9345 port_id, UINT16); 9346 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 9347 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9348 cmd, "queue-region"); 9349 9350 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 9351 .f = cmd_show_queue_region_info_parsed, 9352 .data = NULL, 9353 .help_str = "show port <port_id> queue-region" 9354 ": show all queue region related configuration info", 9355 .tokens = { 9356 (void *)&cmd_show_queue_region_info_get, 9357 (void *)&cmd_show_queue_region_info_port, 9358 (void *)&cmd_show_queue_region_info_port_index, 9359 (void *)&cmd_show_queue_region_info_cmd, 9360 NULL, 9361 }, 9362 }; 9363 9364 /* *** ADD/REMOVE A 2tuple FILTER *** */ 9365 struct cmd_2tuple_filter_result { 9366 cmdline_fixed_string_t filter; 9367 portid_t port_id; 9368 cmdline_fixed_string_t ops; 9369 cmdline_fixed_string_t dst_port; 9370 uint16_t dst_port_value; 9371 cmdline_fixed_string_t protocol; 9372 uint8_t protocol_value; 9373 cmdline_fixed_string_t mask; 9374 uint8_t mask_value; 9375 cmdline_fixed_string_t tcp_flags; 9376 uint8_t tcp_flags_value; 9377 cmdline_fixed_string_t priority; 9378 uint8_t priority_value; 9379 cmdline_fixed_string_t queue; 9380 uint16_t queue_id; 9381 }; 9382 9383 static void 9384 cmd_2tuple_filter_parsed(void *parsed_result, 9385 __attribute__((unused)) struct cmdline *cl, 9386 __attribute__((unused)) void *data) 9387 { 9388 struct rte_eth_ntuple_filter filter; 9389 struct cmd_2tuple_filter_result *res = parsed_result; 9390 int ret = 0; 9391 9392 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 9393 if (ret < 0) { 9394 printf("ntuple filter is not supported on port %u.\n", 9395 res->port_id); 9396 return; 9397 } 9398 9399 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 9400 9401 filter.flags = RTE_2TUPLE_FLAGS; 9402 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 9403 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 9404 filter.proto = res->protocol_value; 9405 filter.priority = res->priority_value; 9406 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 9407 printf("nonzero tcp_flags is only meaningful" 9408 " when protocol is TCP.\n"); 9409 return; 9410 } 9411 if (res->tcp_flags_value > TCP_FLAG_ALL) { 9412 printf("invalid TCP flags.\n"); 9413 return; 9414 } 9415 9416 if (res->tcp_flags_value != 0) { 9417 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 9418 filter.tcp_flags = res->tcp_flags_value; 9419 } 9420 9421 /* need convert to big endian. */ 9422 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 9423 filter.queue = res->queue_id; 9424 9425 if (!strcmp(res->ops, "add")) 9426 ret = rte_eth_dev_filter_ctrl(res->port_id, 9427 RTE_ETH_FILTER_NTUPLE, 9428 RTE_ETH_FILTER_ADD, 9429 &filter); 9430 else 9431 ret = rte_eth_dev_filter_ctrl(res->port_id, 9432 RTE_ETH_FILTER_NTUPLE, 9433 RTE_ETH_FILTER_DELETE, 9434 &filter); 9435 if (ret < 0) 9436 printf("2tuple filter programming error: (%s)\n", 9437 strerror(-ret)); 9438 9439 } 9440 9441 cmdline_parse_token_string_t cmd_2tuple_filter_filter = 9442 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9443 filter, "2tuple_filter"); 9444 cmdline_parse_token_num_t cmd_2tuple_filter_port_id = 9445 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9446 port_id, UINT16); 9447 cmdline_parse_token_string_t cmd_2tuple_filter_ops = 9448 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9449 ops, "add#del"); 9450 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port = 9451 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9452 dst_port, "dst_port"); 9453 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value = 9454 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9455 dst_port_value, UINT16); 9456 cmdline_parse_token_string_t cmd_2tuple_filter_protocol = 9457 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9458 protocol, "protocol"); 9459 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value = 9460 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9461 protocol_value, UINT8); 9462 cmdline_parse_token_string_t cmd_2tuple_filter_mask = 9463 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9464 mask, "mask"); 9465 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value = 9466 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9467 mask_value, INT8); 9468 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags = 9469 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9470 tcp_flags, "tcp_flags"); 9471 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value = 9472 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9473 tcp_flags_value, UINT8); 9474 cmdline_parse_token_string_t cmd_2tuple_filter_priority = 9475 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9476 priority, "priority"); 9477 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value = 9478 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9479 priority_value, UINT8); 9480 cmdline_parse_token_string_t cmd_2tuple_filter_queue = 9481 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9482 queue, "queue"); 9483 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id = 9484 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9485 queue_id, UINT16); 9486 9487 cmdline_parse_inst_t cmd_2tuple_filter = { 9488 .f = cmd_2tuple_filter_parsed, 9489 .data = NULL, 9490 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol " 9491 "<value> mask <value> tcp_flags <value> priority <value> queue " 9492 "<queue_id>: Add a 2tuple filter", 9493 .tokens = { 9494 (void *)&cmd_2tuple_filter_filter, 9495 (void *)&cmd_2tuple_filter_port_id, 9496 (void *)&cmd_2tuple_filter_ops, 9497 (void *)&cmd_2tuple_filter_dst_port, 9498 (void *)&cmd_2tuple_filter_dst_port_value, 9499 (void *)&cmd_2tuple_filter_protocol, 9500 (void *)&cmd_2tuple_filter_protocol_value, 9501 (void *)&cmd_2tuple_filter_mask, 9502 (void *)&cmd_2tuple_filter_mask_value, 9503 (void *)&cmd_2tuple_filter_tcp_flags, 9504 (void *)&cmd_2tuple_filter_tcp_flags_value, 9505 (void *)&cmd_2tuple_filter_priority, 9506 (void *)&cmd_2tuple_filter_priority_value, 9507 (void *)&cmd_2tuple_filter_queue, 9508 (void *)&cmd_2tuple_filter_queue_id, 9509 NULL, 9510 }, 9511 }; 9512 9513 /* *** ADD/REMOVE A 5tuple FILTER *** */ 9514 struct cmd_5tuple_filter_result { 9515 cmdline_fixed_string_t filter; 9516 portid_t port_id; 9517 cmdline_fixed_string_t ops; 9518 cmdline_fixed_string_t dst_ip; 9519 cmdline_ipaddr_t dst_ip_value; 9520 cmdline_fixed_string_t src_ip; 9521 cmdline_ipaddr_t src_ip_value; 9522 cmdline_fixed_string_t dst_port; 9523 uint16_t dst_port_value; 9524 cmdline_fixed_string_t src_port; 9525 uint16_t src_port_value; 9526 cmdline_fixed_string_t protocol; 9527 uint8_t protocol_value; 9528 cmdline_fixed_string_t mask; 9529 uint8_t mask_value; 9530 cmdline_fixed_string_t tcp_flags; 9531 uint8_t tcp_flags_value; 9532 cmdline_fixed_string_t priority; 9533 uint8_t priority_value; 9534 cmdline_fixed_string_t queue; 9535 uint16_t queue_id; 9536 }; 9537 9538 static void 9539 cmd_5tuple_filter_parsed(void *parsed_result, 9540 __attribute__((unused)) struct cmdline *cl, 9541 __attribute__((unused)) void *data) 9542 { 9543 struct rte_eth_ntuple_filter filter; 9544 struct cmd_5tuple_filter_result *res = parsed_result; 9545 int ret = 0; 9546 9547 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 9548 if (ret < 0) { 9549 printf("ntuple filter is not supported on port %u.\n", 9550 res->port_id); 9551 return; 9552 } 9553 9554 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 9555 9556 filter.flags = RTE_5TUPLE_FLAGS; 9557 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0; 9558 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0; 9559 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0; 9560 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 9561 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 9562 filter.proto = res->protocol_value; 9563 filter.priority = res->priority_value; 9564 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 9565 printf("nonzero tcp_flags is only meaningful" 9566 " when protocol is TCP.\n"); 9567 return; 9568 } 9569 if (res->tcp_flags_value > TCP_FLAG_ALL) { 9570 printf("invalid TCP flags.\n"); 9571 return; 9572 } 9573 9574 if (res->tcp_flags_value != 0) { 9575 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 9576 filter.tcp_flags = res->tcp_flags_value; 9577 } 9578 9579 if (res->dst_ip_value.family == AF_INET) 9580 /* no need to convert, already big endian. */ 9581 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr; 9582 else { 9583 if (filter.dst_ip_mask == 0) { 9584 printf("can not support ipv6 involved compare.\n"); 9585 return; 9586 } 9587 filter.dst_ip = 0; 9588 } 9589 9590 if (res->src_ip_value.family == AF_INET) 9591 /* no need to convert, already big endian. */ 9592 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr; 9593 else { 9594 if (filter.src_ip_mask == 0) { 9595 printf("can not support ipv6 involved compare.\n"); 9596 return; 9597 } 9598 filter.src_ip = 0; 9599 } 9600 /* need convert to big endian. */ 9601 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 9602 filter.src_port = rte_cpu_to_be_16(res->src_port_value); 9603 filter.queue = res->queue_id; 9604 9605 if (!strcmp(res->ops, "add")) 9606 ret = rte_eth_dev_filter_ctrl(res->port_id, 9607 RTE_ETH_FILTER_NTUPLE, 9608 RTE_ETH_FILTER_ADD, 9609 &filter); 9610 else 9611 ret = rte_eth_dev_filter_ctrl(res->port_id, 9612 RTE_ETH_FILTER_NTUPLE, 9613 RTE_ETH_FILTER_DELETE, 9614 &filter); 9615 if (ret < 0) 9616 printf("5tuple filter programming error: (%s)\n", 9617 strerror(-ret)); 9618 } 9619 9620 cmdline_parse_token_string_t cmd_5tuple_filter_filter = 9621 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9622 filter, "5tuple_filter"); 9623 cmdline_parse_token_num_t cmd_5tuple_filter_port_id = 9624 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9625 port_id, UINT16); 9626 cmdline_parse_token_string_t cmd_5tuple_filter_ops = 9627 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9628 ops, "add#del"); 9629 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip = 9630 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9631 dst_ip, "dst_ip"); 9632 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value = 9633 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 9634 dst_ip_value); 9635 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip = 9636 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9637 src_ip, "src_ip"); 9638 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value = 9639 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 9640 src_ip_value); 9641 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port = 9642 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9643 dst_port, "dst_port"); 9644 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value = 9645 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9646 dst_port_value, UINT16); 9647 cmdline_parse_token_string_t cmd_5tuple_filter_src_port = 9648 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9649 src_port, "src_port"); 9650 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value = 9651 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9652 src_port_value, UINT16); 9653 cmdline_parse_token_string_t cmd_5tuple_filter_protocol = 9654 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9655 protocol, "protocol"); 9656 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value = 9657 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9658 protocol_value, UINT8); 9659 cmdline_parse_token_string_t cmd_5tuple_filter_mask = 9660 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9661 mask, "mask"); 9662 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value = 9663 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9664 mask_value, INT8); 9665 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags = 9666 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9667 tcp_flags, "tcp_flags"); 9668 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value = 9669 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9670 tcp_flags_value, UINT8); 9671 cmdline_parse_token_string_t cmd_5tuple_filter_priority = 9672 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9673 priority, "priority"); 9674 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value = 9675 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9676 priority_value, UINT8); 9677 cmdline_parse_token_string_t cmd_5tuple_filter_queue = 9678 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9679 queue, "queue"); 9680 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id = 9681 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9682 queue_id, UINT16); 9683 9684 cmdline_parse_inst_t cmd_5tuple_filter = { 9685 .f = cmd_5tuple_filter_parsed, 9686 .data = NULL, 9687 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> " 9688 "src_ip <value> dst_port <value> src_port <value> " 9689 "protocol <value> mask <value> tcp_flags <value> " 9690 "priority <value> queue <queue_id>: Add/Del a 5tuple filter", 9691 .tokens = { 9692 (void *)&cmd_5tuple_filter_filter, 9693 (void *)&cmd_5tuple_filter_port_id, 9694 (void *)&cmd_5tuple_filter_ops, 9695 (void *)&cmd_5tuple_filter_dst_ip, 9696 (void *)&cmd_5tuple_filter_dst_ip_value, 9697 (void *)&cmd_5tuple_filter_src_ip, 9698 (void *)&cmd_5tuple_filter_src_ip_value, 9699 (void *)&cmd_5tuple_filter_dst_port, 9700 (void *)&cmd_5tuple_filter_dst_port_value, 9701 (void *)&cmd_5tuple_filter_src_port, 9702 (void *)&cmd_5tuple_filter_src_port_value, 9703 (void *)&cmd_5tuple_filter_protocol, 9704 (void *)&cmd_5tuple_filter_protocol_value, 9705 (void *)&cmd_5tuple_filter_mask, 9706 (void *)&cmd_5tuple_filter_mask_value, 9707 (void *)&cmd_5tuple_filter_tcp_flags, 9708 (void *)&cmd_5tuple_filter_tcp_flags_value, 9709 (void *)&cmd_5tuple_filter_priority, 9710 (void *)&cmd_5tuple_filter_priority_value, 9711 (void *)&cmd_5tuple_filter_queue, 9712 (void *)&cmd_5tuple_filter_queue_id, 9713 NULL, 9714 }, 9715 }; 9716 9717 /* *** ADD/REMOVE A flex FILTER *** */ 9718 struct cmd_flex_filter_result { 9719 cmdline_fixed_string_t filter; 9720 cmdline_fixed_string_t ops; 9721 portid_t port_id; 9722 cmdline_fixed_string_t len; 9723 uint8_t len_value; 9724 cmdline_fixed_string_t bytes; 9725 cmdline_fixed_string_t bytes_value; 9726 cmdline_fixed_string_t mask; 9727 cmdline_fixed_string_t mask_value; 9728 cmdline_fixed_string_t priority; 9729 uint8_t priority_value; 9730 cmdline_fixed_string_t queue; 9731 uint16_t queue_id; 9732 }; 9733 9734 static int xdigit2val(unsigned char c) 9735 { 9736 int val; 9737 if (isdigit(c)) 9738 val = c - '0'; 9739 else if (isupper(c)) 9740 val = c - 'A' + 10; 9741 else 9742 val = c - 'a' + 10; 9743 return val; 9744 } 9745 9746 static void 9747 cmd_flex_filter_parsed(void *parsed_result, 9748 __attribute__((unused)) struct cmdline *cl, 9749 __attribute__((unused)) void *data) 9750 { 9751 int ret = 0; 9752 struct rte_eth_flex_filter filter; 9753 struct cmd_flex_filter_result *res = parsed_result; 9754 char *bytes_ptr, *mask_ptr; 9755 uint16_t len, i, j = 0; 9756 char c; 9757 int val; 9758 uint8_t byte = 0; 9759 9760 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) { 9761 printf("the len exceed the max length 128\n"); 9762 return; 9763 } 9764 memset(&filter, 0, sizeof(struct rte_eth_flex_filter)); 9765 filter.len = res->len_value; 9766 filter.priority = res->priority_value; 9767 filter.queue = res->queue_id; 9768 bytes_ptr = res->bytes_value; 9769 mask_ptr = res->mask_value; 9770 9771 /* translate bytes string to array. */ 9772 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') || 9773 (bytes_ptr[1] == 'X'))) 9774 bytes_ptr += 2; 9775 len = strnlen(bytes_ptr, res->len_value * 2); 9776 if (len == 0 || (len % 8 != 0)) { 9777 printf("please check len and bytes input\n"); 9778 return; 9779 } 9780 for (i = 0; i < len; i++) { 9781 c = bytes_ptr[i]; 9782 if (isxdigit(c) == 0) { 9783 /* invalid characters. */ 9784 printf("invalid input\n"); 9785 return; 9786 } 9787 val = xdigit2val(c); 9788 if (i % 2) { 9789 byte |= val; 9790 filter.bytes[j] = byte; 9791 printf("bytes[%d]:%02x ", j, filter.bytes[j]); 9792 j++; 9793 byte = 0; 9794 } else 9795 byte |= val << 4; 9796 } 9797 printf("\n"); 9798 /* translate mask string to uint8_t array. */ 9799 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') || 9800 (mask_ptr[1] == 'X'))) 9801 mask_ptr += 2; 9802 len = strnlen(mask_ptr, (res->len_value + 3) / 4); 9803 if (len == 0) { 9804 printf("invalid input\n"); 9805 return; 9806 } 9807 j = 0; 9808 byte = 0; 9809 for (i = 0; i < len; i++) { 9810 c = mask_ptr[i]; 9811 if (isxdigit(c) == 0) { 9812 /* invalid characters. */ 9813 printf("invalid input\n"); 9814 return; 9815 } 9816 val = xdigit2val(c); 9817 if (i % 2) { 9818 byte |= val; 9819 filter.mask[j] = byte; 9820 printf("mask[%d]:%02x ", j, filter.mask[j]); 9821 j++; 9822 byte = 0; 9823 } else 9824 byte |= val << 4; 9825 } 9826 printf("\n"); 9827 9828 if (!strcmp(res->ops, "add")) 9829 ret = rte_eth_dev_filter_ctrl(res->port_id, 9830 RTE_ETH_FILTER_FLEXIBLE, 9831 RTE_ETH_FILTER_ADD, 9832 &filter); 9833 else 9834 ret = rte_eth_dev_filter_ctrl(res->port_id, 9835 RTE_ETH_FILTER_FLEXIBLE, 9836 RTE_ETH_FILTER_DELETE, 9837 &filter); 9838 9839 if (ret < 0) 9840 printf("flex filter setting error: (%s)\n", strerror(-ret)); 9841 } 9842 9843 cmdline_parse_token_string_t cmd_flex_filter_filter = 9844 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9845 filter, "flex_filter"); 9846 cmdline_parse_token_num_t cmd_flex_filter_port_id = 9847 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 9848 port_id, UINT16); 9849 cmdline_parse_token_string_t cmd_flex_filter_ops = 9850 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9851 ops, "add#del"); 9852 cmdline_parse_token_string_t cmd_flex_filter_len = 9853 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9854 len, "len"); 9855 cmdline_parse_token_num_t cmd_flex_filter_len_value = 9856 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 9857 len_value, UINT8); 9858 cmdline_parse_token_string_t cmd_flex_filter_bytes = 9859 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9860 bytes, "bytes"); 9861 cmdline_parse_token_string_t cmd_flex_filter_bytes_value = 9862 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9863 bytes_value, NULL); 9864 cmdline_parse_token_string_t cmd_flex_filter_mask = 9865 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9866 mask, "mask"); 9867 cmdline_parse_token_string_t cmd_flex_filter_mask_value = 9868 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9869 mask_value, NULL); 9870 cmdline_parse_token_string_t cmd_flex_filter_priority = 9871 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9872 priority, "priority"); 9873 cmdline_parse_token_num_t cmd_flex_filter_priority_value = 9874 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 9875 priority_value, UINT8); 9876 cmdline_parse_token_string_t cmd_flex_filter_queue = 9877 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9878 queue, "queue"); 9879 cmdline_parse_token_num_t cmd_flex_filter_queue_id = 9880 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 9881 queue_id, UINT16); 9882 cmdline_parse_inst_t cmd_flex_filter = { 9883 .f = cmd_flex_filter_parsed, 9884 .data = NULL, 9885 .help_str = "flex_filter <port_id> add|del len <value> bytes " 9886 "<value> mask <value> priority <value> queue <queue_id>: " 9887 "Add/Del a flex filter", 9888 .tokens = { 9889 (void *)&cmd_flex_filter_filter, 9890 (void *)&cmd_flex_filter_port_id, 9891 (void *)&cmd_flex_filter_ops, 9892 (void *)&cmd_flex_filter_len, 9893 (void *)&cmd_flex_filter_len_value, 9894 (void *)&cmd_flex_filter_bytes, 9895 (void *)&cmd_flex_filter_bytes_value, 9896 (void *)&cmd_flex_filter_mask, 9897 (void *)&cmd_flex_filter_mask_value, 9898 (void *)&cmd_flex_filter_priority, 9899 (void *)&cmd_flex_filter_priority_value, 9900 (void *)&cmd_flex_filter_queue, 9901 (void *)&cmd_flex_filter_queue_id, 9902 NULL, 9903 }, 9904 }; 9905 9906 /* *** Filters Control *** */ 9907 9908 /* *** deal with ethertype filter *** */ 9909 struct cmd_ethertype_filter_result { 9910 cmdline_fixed_string_t filter; 9911 portid_t port_id; 9912 cmdline_fixed_string_t ops; 9913 cmdline_fixed_string_t mac; 9914 struct ether_addr mac_addr; 9915 cmdline_fixed_string_t ethertype; 9916 uint16_t ethertype_value; 9917 cmdline_fixed_string_t drop; 9918 cmdline_fixed_string_t queue; 9919 uint16_t queue_id; 9920 }; 9921 9922 cmdline_parse_token_string_t cmd_ethertype_filter_filter = 9923 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 9924 filter, "ethertype_filter"); 9925 cmdline_parse_token_num_t cmd_ethertype_filter_port_id = 9926 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 9927 port_id, UINT16); 9928 cmdline_parse_token_string_t cmd_ethertype_filter_ops = 9929 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 9930 ops, "add#del"); 9931 cmdline_parse_token_string_t cmd_ethertype_filter_mac = 9932 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 9933 mac, "mac_addr#mac_ignr"); 9934 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr = 9935 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result, 9936 mac_addr); 9937 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype = 9938 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 9939 ethertype, "ethertype"); 9940 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value = 9941 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 9942 ethertype_value, UINT16); 9943 cmdline_parse_token_string_t cmd_ethertype_filter_drop = 9944 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 9945 drop, "drop#fwd"); 9946 cmdline_parse_token_string_t cmd_ethertype_filter_queue = 9947 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 9948 queue, "queue"); 9949 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id = 9950 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 9951 queue_id, UINT16); 9952 9953 static void 9954 cmd_ethertype_filter_parsed(void *parsed_result, 9955 __attribute__((unused)) struct cmdline *cl, 9956 __attribute__((unused)) void *data) 9957 { 9958 struct cmd_ethertype_filter_result *res = parsed_result; 9959 struct rte_eth_ethertype_filter filter; 9960 int ret = 0; 9961 9962 ret = rte_eth_dev_filter_supported(res->port_id, 9963 RTE_ETH_FILTER_ETHERTYPE); 9964 if (ret < 0) { 9965 printf("ethertype filter is not supported on port %u.\n", 9966 res->port_id); 9967 return; 9968 } 9969 9970 memset(&filter, 0, sizeof(filter)); 9971 if (!strcmp(res->mac, "mac_addr")) { 9972 filter.flags |= RTE_ETHTYPE_FLAGS_MAC; 9973 rte_memcpy(&filter.mac_addr, &res->mac_addr, 9974 sizeof(struct ether_addr)); 9975 } 9976 if (!strcmp(res->drop, "drop")) 9977 filter.flags |= RTE_ETHTYPE_FLAGS_DROP; 9978 filter.ether_type = res->ethertype_value; 9979 filter.queue = res->queue_id; 9980 9981 if (!strcmp(res->ops, "add")) 9982 ret = rte_eth_dev_filter_ctrl(res->port_id, 9983 RTE_ETH_FILTER_ETHERTYPE, 9984 RTE_ETH_FILTER_ADD, 9985 &filter); 9986 else 9987 ret = rte_eth_dev_filter_ctrl(res->port_id, 9988 RTE_ETH_FILTER_ETHERTYPE, 9989 RTE_ETH_FILTER_DELETE, 9990 &filter); 9991 if (ret < 0) 9992 printf("ethertype filter programming error: (%s)\n", 9993 strerror(-ret)); 9994 } 9995 9996 cmdline_parse_inst_t cmd_ethertype_filter = { 9997 .f = cmd_ethertype_filter_parsed, 9998 .data = NULL, 9999 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr " 10000 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: " 10001 "Add or delete an ethertype filter entry", 10002 .tokens = { 10003 (void *)&cmd_ethertype_filter_filter, 10004 (void *)&cmd_ethertype_filter_port_id, 10005 (void *)&cmd_ethertype_filter_ops, 10006 (void *)&cmd_ethertype_filter_mac, 10007 (void *)&cmd_ethertype_filter_mac_addr, 10008 (void *)&cmd_ethertype_filter_ethertype, 10009 (void *)&cmd_ethertype_filter_ethertype_value, 10010 (void *)&cmd_ethertype_filter_drop, 10011 (void *)&cmd_ethertype_filter_queue, 10012 (void *)&cmd_ethertype_filter_queue_id, 10013 NULL, 10014 }, 10015 }; 10016 10017 /* *** deal with flow director filter *** */ 10018 struct cmd_flow_director_result { 10019 cmdline_fixed_string_t flow_director_filter; 10020 portid_t port_id; 10021 cmdline_fixed_string_t mode; 10022 cmdline_fixed_string_t mode_value; 10023 cmdline_fixed_string_t ops; 10024 cmdline_fixed_string_t flow; 10025 cmdline_fixed_string_t flow_type; 10026 cmdline_fixed_string_t ether; 10027 uint16_t ether_type; 10028 cmdline_fixed_string_t src; 10029 cmdline_ipaddr_t ip_src; 10030 uint16_t port_src; 10031 cmdline_fixed_string_t dst; 10032 cmdline_ipaddr_t ip_dst; 10033 uint16_t port_dst; 10034 cmdline_fixed_string_t verify_tag; 10035 uint32_t verify_tag_value; 10036 cmdline_fixed_string_t tos; 10037 uint8_t tos_value; 10038 cmdline_fixed_string_t proto; 10039 uint8_t proto_value; 10040 cmdline_fixed_string_t ttl; 10041 uint8_t ttl_value; 10042 cmdline_fixed_string_t vlan; 10043 uint16_t vlan_value; 10044 cmdline_fixed_string_t flexbytes; 10045 cmdline_fixed_string_t flexbytes_value; 10046 cmdline_fixed_string_t pf_vf; 10047 cmdline_fixed_string_t drop; 10048 cmdline_fixed_string_t queue; 10049 uint16_t queue_id; 10050 cmdline_fixed_string_t fd_id; 10051 uint32_t fd_id_value; 10052 cmdline_fixed_string_t mac; 10053 struct ether_addr mac_addr; 10054 cmdline_fixed_string_t tunnel; 10055 cmdline_fixed_string_t tunnel_type; 10056 cmdline_fixed_string_t tunnel_id; 10057 uint32_t tunnel_id_value; 10058 cmdline_fixed_string_t packet; 10059 char filepath[]; 10060 }; 10061 10062 static inline int 10063 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num) 10064 { 10065 char s[256]; 10066 const char *p, *p0 = q_arg; 10067 char *end; 10068 unsigned long int_fld; 10069 char *str_fld[max_num]; 10070 int i; 10071 unsigned size; 10072 int ret = -1; 10073 10074 p = strchr(p0, '('); 10075 if (p == NULL) 10076 return -1; 10077 ++p; 10078 p0 = strchr(p, ')'); 10079 if (p0 == NULL) 10080 return -1; 10081 10082 size = p0 - p; 10083 if (size >= sizeof(s)) 10084 return -1; 10085 10086 snprintf(s, sizeof(s), "%.*s", size, p); 10087 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10088 if (ret < 0 || ret > max_num) 10089 return -1; 10090 for (i = 0; i < ret; i++) { 10091 errno = 0; 10092 int_fld = strtoul(str_fld[i], &end, 0); 10093 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX) 10094 return -1; 10095 flexbytes[i] = (uint8_t)int_fld; 10096 } 10097 return ret; 10098 } 10099 10100 static uint16_t 10101 str2flowtype(char *string) 10102 { 10103 uint8_t i = 0; 10104 static const struct { 10105 char str[32]; 10106 uint16_t type; 10107 } flowtype_str[] = { 10108 {"raw", RTE_ETH_FLOW_RAW}, 10109 {"ipv4", RTE_ETH_FLOW_IPV4}, 10110 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10111 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10112 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10113 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10114 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10115 {"ipv6", RTE_ETH_FLOW_IPV6}, 10116 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10117 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10118 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10119 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10120 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10121 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10122 }; 10123 10124 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10125 if (!strcmp(flowtype_str[i].str, string)) 10126 return flowtype_str[i].type; 10127 } 10128 10129 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10130 return (uint16_t)atoi(string); 10131 10132 return RTE_ETH_FLOW_UNKNOWN; 10133 } 10134 10135 static enum rte_eth_fdir_tunnel_type 10136 str2fdir_tunneltype(char *string) 10137 { 10138 uint8_t i = 0; 10139 10140 static const struct { 10141 char str[32]; 10142 enum rte_eth_fdir_tunnel_type type; 10143 } tunneltype_str[] = { 10144 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE}, 10145 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN}, 10146 }; 10147 10148 for (i = 0; i < RTE_DIM(tunneltype_str); i++) { 10149 if (!strcmp(tunneltype_str[i].str, string)) 10150 return tunneltype_str[i].type; 10151 } 10152 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN; 10153 } 10154 10155 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10156 do { \ 10157 if ((ip_addr).family == AF_INET) \ 10158 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10159 else { \ 10160 printf("invalid parameter.\n"); \ 10161 return; \ 10162 } \ 10163 } while (0) 10164 10165 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10166 do { \ 10167 if ((ip_addr).family == AF_INET6) \ 10168 rte_memcpy(&(ip), \ 10169 &((ip_addr).addr.ipv6), \ 10170 sizeof(struct in6_addr)); \ 10171 else { \ 10172 printf("invalid parameter.\n"); \ 10173 return; \ 10174 } \ 10175 } while (0) 10176 10177 static void 10178 cmd_flow_director_filter_parsed(void *parsed_result, 10179 __attribute__((unused)) struct cmdline *cl, 10180 __attribute__((unused)) void *data) 10181 { 10182 struct cmd_flow_director_result *res = parsed_result; 10183 struct rte_eth_fdir_filter entry; 10184 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; 10185 char *end; 10186 unsigned long vf_id; 10187 int ret = 0; 10188 10189 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 10190 if (ret < 0) { 10191 printf("flow director is not supported on port %u.\n", 10192 res->port_id); 10193 return; 10194 } 10195 memset(flexbytes, 0, sizeof(flexbytes)); 10196 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter)); 10197 10198 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10199 if (strcmp(res->mode_value, "MAC-VLAN")) { 10200 printf("Please set mode to MAC-VLAN.\n"); 10201 return; 10202 } 10203 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10204 if (strcmp(res->mode_value, "Tunnel")) { 10205 printf("Please set mode to Tunnel.\n"); 10206 return; 10207 } 10208 } else { 10209 if (!strcmp(res->mode_value, "raw")) { 10210 #ifdef RTE_LIBRTE_I40E_PMD 10211 struct rte_pmd_i40e_flow_type_mapping 10212 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 10213 struct rte_pmd_i40e_pkt_template_conf conf; 10214 uint16_t flow_type = str2flowtype(res->flow_type); 10215 uint16_t i, port = res->port_id; 10216 uint8_t add; 10217 10218 memset(&conf, 0, sizeof(conf)); 10219 10220 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 10221 printf("Invalid flow type specified.\n"); 10222 return; 10223 } 10224 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 10225 mapping); 10226 if (ret) 10227 return; 10228 if (mapping[flow_type].pctype == 0ULL) { 10229 printf("Invalid flow type specified.\n"); 10230 return; 10231 } 10232 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 10233 if (mapping[flow_type].pctype & (1ULL << i)) { 10234 conf.input.pctype = i; 10235 break; 10236 } 10237 } 10238 10239 conf.input.packet = open_file(res->filepath, 10240 &conf.input.length); 10241 if (!conf.input.packet) 10242 return; 10243 if (!strcmp(res->drop, "drop")) 10244 conf.action.behavior = 10245 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 10246 else 10247 conf.action.behavior = 10248 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 10249 conf.action.report_status = 10250 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 10251 conf.action.rx_queue = res->queue_id; 10252 conf.soft_id = res->fd_id_value; 10253 add = strcmp(res->ops, "del") ? 1 : 0; 10254 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 10255 &conf, 10256 add); 10257 if (ret < 0) 10258 printf("flow director config error: (%s)\n", 10259 strerror(-ret)); 10260 close_file(conf.input.packet); 10261 #endif 10262 return; 10263 } else if (strcmp(res->mode_value, "IP")) { 10264 printf("Please set mode to IP or raw.\n"); 10265 return; 10266 } 10267 entry.input.flow_type = str2flowtype(res->flow_type); 10268 } 10269 10270 ret = parse_flexbytes(res->flexbytes_value, 10271 flexbytes, 10272 RTE_ETH_FDIR_MAX_FLEXLEN); 10273 if (ret < 0) { 10274 printf("error: Cannot parse flexbytes input.\n"); 10275 return; 10276 } 10277 10278 switch (entry.input.flow_type) { 10279 case RTE_ETH_FLOW_FRAG_IPV4: 10280 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: 10281 entry.input.flow.ip4_flow.proto = res->proto_value; 10282 /* fall-through */ 10283 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: 10284 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: 10285 IPV4_ADDR_TO_UINT(res->ip_dst, 10286 entry.input.flow.ip4_flow.dst_ip); 10287 IPV4_ADDR_TO_UINT(res->ip_src, 10288 entry.input.flow.ip4_flow.src_ip); 10289 entry.input.flow.ip4_flow.tos = res->tos_value; 10290 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10291 /* need convert to big endian. */ 10292 entry.input.flow.udp4_flow.dst_port = 10293 rte_cpu_to_be_16(res->port_dst); 10294 entry.input.flow.udp4_flow.src_port = 10295 rte_cpu_to_be_16(res->port_src); 10296 break; 10297 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: 10298 IPV4_ADDR_TO_UINT(res->ip_dst, 10299 entry.input.flow.sctp4_flow.ip.dst_ip); 10300 IPV4_ADDR_TO_UINT(res->ip_src, 10301 entry.input.flow.sctp4_flow.ip.src_ip); 10302 entry.input.flow.ip4_flow.tos = res->tos_value; 10303 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10304 /* need convert to big endian. */ 10305 entry.input.flow.sctp4_flow.dst_port = 10306 rte_cpu_to_be_16(res->port_dst); 10307 entry.input.flow.sctp4_flow.src_port = 10308 rte_cpu_to_be_16(res->port_src); 10309 entry.input.flow.sctp4_flow.verify_tag = 10310 rte_cpu_to_be_32(res->verify_tag_value); 10311 break; 10312 case RTE_ETH_FLOW_FRAG_IPV6: 10313 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: 10314 entry.input.flow.ipv6_flow.proto = res->proto_value; 10315 /* fall-through */ 10316 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP: 10317 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP: 10318 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10319 entry.input.flow.ipv6_flow.dst_ip); 10320 IPV6_ADDR_TO_ARRAY(res->ip_src, 10321 entry.input.flow.ipv6_flow.src_ip); 10322 entry.input.flow.ipv6_flow.tc = res->tos_value; 10323 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10324 /* need convert to big endian. */ 10325 entry.input.flow.udp6_flow.dst_port = 10326 rte_cpu_to_be_16(res->port_dst); 10327 entry.input.flow.udp6_flow.src_port = 10328 rte_cpu_to_be_16(res->port_src); 10329 break; 10330 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: 10331 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10332 entry.input.flow.sctp6_flow.ip.dst_ip); 10333 IPV6_ADDR_TO_ARRAY(res->ip_src, 10334 entry.input.flow.sctp6_flow.ip.src_ip); 10335 entry.input.flow.ipv6_flow.tc = res->tos_value; 10336 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10337 /* need convert to big endian. */ 10338 entry.input.flow.sctp6_flow.dst_port = 10339 rte_cpu_to_be_16(res->port_dst); 10340 entry.input.flow.sctp6_flow.src_port = 10341 rte_cpu_to_be_16(res->port_src); 10342 entry.input.flow.sctp6_flow.verify_tag = 10343 rte_cpu_to_be_32(res->verify_tag_value); 10344 break; 10345 case RTE_ETH_FLOW_L2_PAYLOAD: 10346 entry.input.flow.l2_flow.ether_type = 10347 rte_cpu_to_be_16(res->ether_type); 10348 break; 10349 default: 10350 break; 10351 } 10352 10353 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) 10354 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr, 10355 &res->mac_addr, 10356 sizeof(struct ether_addr)); 10357 10358 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10359 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr, 10360 &res->mac_addr, 10361 sizeof(struct ether_addr)); 10362 entry.input.flow.tunnel_flow.tunnel_type = 10363 str2fdir_tunneltype(res->tunnel_type); 10364 entry.input.flow.tunnel_flow.tunnel_id = 10365 rte_cpu_to_be_32(res->tunnel_id_value); 10366 } 10367 10368 rte_memcpy(entry.input.flow_ext.flexbytes, 10369 flexbytes, 10370 RTE_ETH_FDIR_MAX_FLEXLEN); 10371 10372 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value); 10373 10374 entry.action.flex_off = 0; /*use 0 by default */ 10375 if (!strcmp(res->drop, "drop")) 10376 entry.action.behavior = RTE_ETH_FDIR_REJECT; 10377 else 10378 entry.action.behavior = RTE_ETH_FDIR_ACCEPT; 10379 10380 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN && 10381 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) { 10382 if (!strcmp(res->pf_vf, "pf")) 10383 entry.input.flow_ext.is_vf = 0; 10384 else if (!strncmp(res->pf_vf, "vf", 2)) { 10385 struct rte_eth_dev_info dev_info; 10386 10387 memset(&dev_info, 0, sizeof(dev_info)); 10388 rte_eth_dev_info_get(res->port_id, &dev_info); 10389 errno = 0; 10390 vf_id = strtoul(res->pf_vf + 2, &end, 10); 10391 if (errno != 0 || *end != '\0' || 10392 vf_id >= dev_info.max_vfs) { 10393 printf("invalid parameter %s.\n", res->pf_vf); 10394 return; 10395 } 10396 entry.input.flow_ext.is_vf = 1; 10397 entry.input.flow_ext.dst_id = (uint16_t)vf_id; 10398 } else { 10399 printf("invalid parameter %s.\n", res->pf_vf); 10400 return; 10401 } 10402 } 10403 10404 /* set to report FD ID by default */ 10405 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID; 10406 entry.action.rx_queue = res->queue_id; 10407 entry.soft_id = res->fd_id_value; 10408 if (!strcmp(res->ops, "add")) 10409 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10410 RTE_ETH_FILTER_ADD, &entry); 10411 else if (!strcmp(res->ops, "del")) 10412 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10413 RTE_ETH_FILTER_DELETE, &entry); 10414 else 10415 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10416 RTE_ETH_FILTER_UPDATE, &entry); 10417 if (ret < 0) 10418 printf("flow director programming error: (%s)\n", 10419 strerror(-ret)); 10420 } 10421 10422 cmdline_parse_token_string_t cmd_flow_director_filter = 10423 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10424 flow_director_filter, "flow_director_filter"); 10425 cmdline_parse_token_num_t cmd_flow_director_port_id = 10426 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10427 port_id, UINT16); 10428 cmdline_parse_token_string_t cmd_flow_director_ops = 10429 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10430 ops, "add#del#update"); 10431 cmdline_parse_token_string_t cmd_flow_director_flow = 10432 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10433 flow, "flow"); 10434 cmdline_parse_token_string_t cmd_flow_director_flow_type = 10435 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10436 flow_type, NULL); 10437 cmdline_parse_token_string_t cmd_flow_director_ether = 10438 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10439 ether, "ether"); 10440 cmdline_parse_token_num_t cmd_flow_director_ether_type = 10441 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10442 ether_type, UINT16); 10443 cmdline_parse_token_string_t cmd_flow_director_src = 10444 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10445 src, "src"); 10446 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src = 10447 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 10448 ip_src); 10449 cmdline_parse_token_num_t cmd_flow_director_port_src = 10450 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10451 port_src, UINT16); 10452 cmdline_parse_token_string_t cmd_flow_director_dst = 10453 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10454 dst, "dst"); 10455 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst = 10456 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 10457 ip_dst); 10458 cmdline_parse_token_num_t cmd_flow_director_port_dst = 10459 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10460 port_dst, UINT16); 10461 cmdline_parse_token_string_t cmd_flow_director_verify_tag = 10462 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10463 verify_tag, "verify_tag"); 10464 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value = 10465 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10466 verify_tag_value, UINT32); 10467 cmdline_parse_token_string_t cmd_flow_director_tos = 10468 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10469 tos, "tos"); 10470 cmdline_parse_token_num_t cmd_flow_director_tos_value = 10471 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10472 tos_value, UINT8); 10473 cmdline_parse_token_string_t cmd_flow_director_proto = 10474 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10475 proto, "proto"); 10476 cmdline_parse_token_num_t cmd_flow_director_proto_value = 10477 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10478 proto_value, UINT8); 10479 cmdline_parse_token_string_t cmd_flow_director_ttl = 10480 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10481 ttl, "ttl"); 10482 cmdline_parse_token_num_t cmd_flow_director_ttl_value = 10483 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10484 ttl_value, UINT8); 10485 cmdline_parse_token_string_t cmd_flow_director_vlan = 10486 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10487 vlan, "vlan"); 10488 cmdline_parse_token_num_t cmd_flow_director_vlan_value = 10489 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10490 vlan_value, UINT16); 10491 cmdline_parse_token_string_t cmd_flow_director_flexbytes = 10492 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10493 flexbytes, "flexbytes"); 10494 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value = 10495 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10496 flexbytes_value, NULL); 10497 cmdline_parse_token_string_t cmd_flow_director_drop = 10498 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10499 drop, "drop#fwd"); 10500 cmdline_parse_token_string_t cmd_flow_director_pf_vf = 10501 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10502 pf_vf, NULL); 10503 cmdline_parse_token_string_t cmd_flow_director_queue = 10504 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10505 queue, "queue"); 10506 cmdline_parse_token_num_t cmd_flow_director_queue_id = 10507 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10508 queue_id, UINT16); 10509 cmdline_parse_token_string_t cmd_flow_director_fd_id = 10510 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10511 fd_id, "fd_id"); 10512 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 10513 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10514 fd_id_value, UINT32); 10515 10516 cmdline_parse_token_string_t cmd_flow_director_mode = 10517 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10518 mode, "mode"); 10519 cmdline_parse_token_string_t cmd_flow_director_mode_ip = 10520 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10521 mode_value, "IP"); 10522 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan = 10523 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10524 mode_value, "MAC-VLAN"); 10525 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel = 10526 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10527 mode_value, "Tunnel"); 10528 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 10529 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10530 mode_value, "raw"); 10531 cmdline_parse_token_string_t cmd_flow_director_mac = 10532 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10533 mac, "mac"); 10534 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr = 10535 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result, 10536 mac_addr); 10537 cmdline_parse_token_string_t cmd_flow_director_tunnel = 10538 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10539 tunnel, "tunnel"); 10540 cmdline_parse_token_string_t cmd_flow_director_tunnel_type = 10541 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10542 tunnel_type, "NVGRE#VxLAN"); 10543 cmdline_parse_token_string_t cmd_flow_director_tunnel_id = 10544 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10545 tunnel_id, "tunnel-id"); 10546 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value = 10547 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10548 tunnel_id_value, UINT32); 10549 cmdline_parse_token_string_t cmd_flow_director_packet = 10550 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10551 packet, "packet"); 10552 cmdline_parse_token_string_t cmd_flow_director_filepath = 10553 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10554 filepath, NULL); 10555 10556 cmdline_parse_inst_t cmd_add_del_ip_flow_director = { 10557 .f = cmd_flow_director_filter_parsed, 10558 .data = NULL, 10559 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow" 10560 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 10561 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 10562 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> " 10563 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> " 10564 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> " 10565 "fd_id <fd_id_value>: " 10566 "Add or delete an ip flow director entry on NIC", 10567 .tokens = { 10568 (void *)&cmd_flow_director_filter, 10569 (void *)&cmd_flow_director_port_id, 10570 (void *)&cmd_flow_director_mode, 10571 (void *)&cmd_flow_director_mode_ip, 10572 (void *)&cmd_flow_director_ops, 10573 (void *)&cmd_flow_director_flow, 10574 (void *)&cmd_flow_director_flow_type, 10575 (void *)&cmd_flow_director_src, 10576 (void *)&cmd_flow_director_ip_src, 10577 (void *)&cmd_flow_director_dst, 10578 (void *)&cmd_flow_director_ip_dst, 10579 (void *)&cmd_flow_director_tos, 10580 (void *)&cmd_flow_director_tos_value, 10581 (void *)&cmd_flow_director_proto, 10582 (void *)&cmd_flow_director_proto_value, 10583 (void *)&cmd_flow_director_ttl, 10584 (void *)&cmd_flow_director_ttl_value, 10585 (void *)&cmd_flow_director_vlan, 10586 (void *)&cmd_flow_director_vlan_value, 10587 (void *)&cmd_flow_director_flexbytes, 10588 (void *)&cmd_flow_director_flexbytes_value, 10589 (void *)&cmd_flow_director_drop, 10590 (void *)&cmd_flow_director_pf_vf, 10591 (void *)&cmd_flow_director_queue, 10592 (void *)&cmd_flow_director_queue_id, 10593 (void *)&cmd_flow_director_fd_id, 10594 (void *)&cmd_flow_director_fd_id_value, 10595 NULL, 10596 }, 10597 }; 10598 10599 cmdline_parse_inst_t cmd_add_del_udp_flow_director = { 10600 .f = cmd_flow_director_filter_parsed, 10601 .data = NULL, 10602 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow " 10603 "director entry on NIC", 10604 .tokens = { 10605 (void *)&cmd_flow_director_filter, 10606 (void *)&cmd_flow_director_port_id, 10607 (void *)&cmd_flow_director_mode, 10608 (void *)&cmd_flow_director_mode_ip, 10609 (void *)&cmd_flow_director_ops, 10610 (void *)&cmd_flow_director_flow, 10611 (void *)&cmd_flow_director_flow_type, 10612 (void *)&cmd_flow_director_src, 10613 (void *)&cmd_flow_director_ip_src, 10614 (void *)&cmd_flow_director_port_src, 10615 (void *)&cmd_flow_director_dst, 10616 (void *)&cmd_flow_director_ip_dst, 10617 (void *)&cmd_flow_director_port_dst, 10618 (void *)&cmd_flow_director_tos, 10619 (void *)&cmd_flow_director_tos_value, 10620 (void *)&cmd_flow_director_ttl, 10621 (void *)&cmd_flow_director_ttl_value, 10622 (void *)&cmd_flow_director_vlan, 10623 (void *)&cmd_flow_director_vlan_value, 10624 (void *)&cmd_flow_director_flexbytes, 10625 (void *)&cmd_flow_director_flexbytes_value, 10626 (void *)&cmd_flow_director_drop, 10627 (void *)&cmd_flow_director_pf_vf, 10628 (void *)&cmd_flow_director_queue, 10629 (void *)&cmd_flow_director_queue_id, 10630 (void *)&cmd_flow_director_fd_id, 10631 (void *)&cmd_flow_director_fd_id_value, 10632 NULL, 10633 }, 10634 }; 10635 10636 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = { 10637 .f = cmd_flow_director_filter_parsed, 10638 .data = NULL, 10639 .help_str = "flow_director_filter ... : Add or delete a sctp flow " 10640 "director entry on NIC", 10641 .tokens = { 10642 (void *)&cmd_flow_director_filter, 10643 (void *)&cmd_flow_director_port_id, 10644 (void *)&cmd_flow_director_mode, 10645 (void *)&cmd_flow_director_mode_ip, 10646 (void *)&cmd_flow_director_ops, 10647 (void *)&cmd_flow_director_flow, 10648 (void *)&cmd_flow_director_flow_type, 10649 (void *)&cmd_flow_director_src, 10650 (void *)&cmd_flow_director_ip_src, 10651 (void *)&cmd_flow_director_port_src, 10652 (void *)&cmd_flow_director_dst, 10653 (void *)&cmd_flow_director_ip_dst, 10654 (void *)&cmd_flow_director_port_dst, 10655 (void *)&cmd_flow_director_verify_tag, 10656 (void *)&cmd_flow_director_verify_tag_value, 10657 (void *)&cmd_flow_director_tos, 10658 (void *)&cmd_flow_director_tos_value, 10659 (void *)&cmd_flow_director_ttl, 10660 (void *)&cmd_flow_director_ttl_value, 10661 (void *)&cmd_flow_director_vlan, 10662 (void *)&cmd_flow_director_vlan_value, 10663 (void *)&cmd_flow_director_flexbytes, 10664 (void *)&cmd_flow_director_flexbytes_value, 10665 (void *)&cmd_flow_director_drop, 10666 (void *)&cmd_flow_director_pf_vf, 10667 (void *)&cmd_flow_director_queue, 10668 (void *)&cmd_flow_director_queue_id, 10669 (void *)&cmd_flow_director_fd_id, 10670 (void *)&cmd_flow_director_fd_id_value, 10671 NULL, 10672 }, 10673 }; 10674 10675 cmdline_parse_inst_t cmd_add_del_l2_flow_director = { 10676 .f = cmd_flow_director_filter_parsed, 10677 .data = NULL, 10678 .help_str = "flow_director_filter ... : Add or delete a L2 flow " 10679 "director entry on NIC", 10680 .tokens = { 10681 (void *)&cmd_flow_director_filter, 10682 (void *)&cmd_flow_director_port_id, 10683 (void *)&cmd_flow_director_mode, 10684 (void *)&cmd_flow_director_mode_ip, 10685 (void *)&cmd_flow_director_ops, 10686 (void *)&cmd_flow_director_flow, 10687 (void *)&cmd_flow_director_flow_type, 10688 (void *)&cmd_flow_director_ether, 10689 (void *)&cmd_flow_director_ether_type, 10690 (void *)&cmd_flow_director_flexbytes, 10691 (void *)&cmd_flow_director_flexbytes_value, 10692 (void *)&cmd_flow_director_drop, 10693 (void *)&cmd_flow_director_pf_vf, 10694 (void *)&cmd_flow_director_queue, 10695 (void *)&cmd_flow_director_queue_id, 10696 (void *)&cmd_flow_director_fd_id, 10697 (void *)&cmd_flow_director_fd_id_value, 10698 NULL, 10699 }, 10700 }; 10701 10702 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = { 10703 .f = cmd_flow_director_filter_parsed, 10704 .data = NULL, 10705 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow " 10706 "director entry on NIC", 10707 .tokens = { 10708 (void *)&cmd_flow_director_filter, 10709 (void *)&cmd_flow_director_port_id, 10710 (void *)&cmd_flow_director_mode, 10711 (void *)&cmd_flow_director_mode_mac_vlan, 10712 (void *)&cmd_flow_director_ops, 10713 (void *)&cmd_flow_director_mac, 10714 (void *)&cmd_flow_director_mac_addr, 10715 (void *)&cmd_flow_director_vlan, 10716 (void *)&cmd_flow_director_vlan_value, 10717 (void *)&cmd_flow_director_flexbytes, 10718 (void *)&cmd_flow_director_flexbytes_value, 10719 (void *)&cmd_flow_director_drop, 10720 (void *)&cmd_flow_director_queue, 10721 (void *)&cmd_flow_director_queue_id, 10722 (void *)&cmd_flow_director_fd_id, 10723 (void *)&cmd_flow_director_fd_id_value, 10724 NULL, 10725 }, 10726 }; 10727 10728 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = { 10729 .f = cmd_flow_director_filter_parsed, 10730 .data = NULL, 10731 .help_str = "flow_director_filter ... : Add or delete a tunnel flow " 10732 "director entry on NIC", 10733 .tokens = { 10734 (void *)&cmd_flow_director_filter, 10735 (void *)&cmd_flow_director_port_id, 10736 (void *)&cmd_flow_director_mode, 10737 (void *)&cmd_flow_director_mode_tunnel, 10738 (void *)&cmd_flow_director_ops, 10739 (void *)&cmd_flow_director_mac, 10740 (void *)&cmd_flow_director_mac_addr, 10741 (void *)&cmd_flow_director_vlan, 10742 (void *)&cmd_flow_director_vlan_value, 10743 (void *)&cmd_flow_director_tunnel, 10744 (void *)&cmd_flow_director_tunnel_type, 10745 (void *)&cmd_flow_director_tunnel_id, 10746 (void *)&cmd_flow_director_tunnel_id_value, 10747 (void *)&cmd_flow_director_flexbytes, 10748 (void *)&cmd_flow_director_flexbytes_value, 10749 (void *)&cmd_flow_director_drop, 10750 (void *)&cmd_flow_director_queue, 10751 (void *)&cmd_flow_director_queue_id, 10752 (void *)&cmd_flow_director_fd_id, 10753 (void *)&cmd_flow_director_fd_id_value, 10754 NULL, 10755 }, 10756 }; 10757 10758 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 10759 .f = cmd_flow_director_filter_parsed, 10760 .data = NULL, 10761 .help_str = "flow_director_filter ... : Add or delete a raw flow " 10762 "director entry on NIC", 10763 .tokens = { 10764 (void *)&cmd_flow_director_filter, 10765 (void *)&cmd_flow_director_port_id, 10766 (void *)&cmd_flow_director_mode, 10767 (void *)&cmd_flow_director_mode_raw, 10768 (void *)&cmd_flow_director_ops, 10769 (void *)&cmd_flow_director_flow, 10770 (void *)&cmd_flow_director_flow_type, 10771 (void *)&cmd_flow_director_drop, 10772 (void *)&cmd_flow_director_queue, 10773 (void *)&cmd_flow_director_queue_id, 10774 (void *)&cmd_flow_director_fd_id, 10775 (void *)&cmd_flow_director_fd_id_value, 10776 (void *)&cmd_flow_director_packet, 10777 (void *)&cmd_flow_director_filepath, 10778 NULL, 10779 }, 10780 }; 10781 10782 struct cmd_flush_flow_director_result { 10783 cmdline_fixed_string_t flush_flow_director; 10784 portid_t port_id; 10785 }; 10786 10787 cmdline_parse_token_string_t cmd_flush_flow_director_flush = 10788 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result, 10789 flush_flow_director, "flush_flow_director"); 10790 cmdline_parse_token_num_t cmd_flush_flow_director_port_id = 10791 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result, 10792 port_id, UINT16); 10793 10794 static void 10795 cmd_flush_flow_director_parsed(void *parsed_result, 10796 __attribute__((unused)) struct cmdline *cl, 10797 __attribute__((unused)) void *data) 10798 { 10799 struct cmd_flow_director_result *res = parsed_result; 10800 int ret = 0; 10801 10802 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 10803 if (ret < 0) { 10804 printf("flow director is not supported on port %u.\n", 10805 res->port_id); 10806 return; 10807 } 10808 10809 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10810 RTE_ETH_FILTER_FLUSH, NULL); 10811 if (ret < 0) 10812 printf("flow director table flushing error: (%s)\n", 10813 strerror(-ret)); 10814 } 10815 10816 cmdline_parse_inst_t cmd_flush_flow_director = { 10817 .f = cmd_flush_flow_director_parsed, 10818 .data = NULL, 10819 .help_str = "flush_flow_director <port_id>: " 10820 "Flush all flow director entries of a device on NIC", 10821 .tokens = { 10822 (void *)&cmd_flush_flow_director_flush, 10823 (void *)&cmd_flush_flow_director_port_id, 10824 NULL, 10825 }, 10826 }; 10827 10828 /* *** deal with flow director mask *** */ 10829 struct cmd_flow_director_mask_result { 10830 cmdline_fixed_string_t flow_director_mask; 10831 portid_t port_id; 10832 cmdline_fixed_string_t mode; 10833 cmdline_fixed_string_t mode_value; 10834 cmdline_fixed_string_t vlan; 10835 uint16_t vlan_mask; 10836 cmdline_fixed_string_t src_mask; 10837 cmdline_ipaddr_t ipv4_src; 10838 cmdline_ipaddr_t ipv6_src; 10839 uint16_t port_src; 10840 cmdline_fixed_string_t dst_mask; 10841 cmdline_ipaddr_t ipv4_dst; 10842 cmdline_ipaddr_t ipv6_dst; 10843 uint16_t port_dst; 10844 cmdline_fixed_string_t mac; 10845 uint8_t mac_addr_byte_mask; 10846 cmdline_fixed_string_t tunnel_id; 10847 uint32_t tunnel_id_mask; 10848 cmdline_fixed_string_t tunnel_type; 10849 uint8_t tunnel_type_mask; 10850 }; 10851 10852 static void 10853 cmd_flow_director_mask_parsed(void *parsed_result, 10854 __attribute__((unused)) struct cmdline *cl, 10855 __attribute__((unused)) void *data) 10856 { 10857 struct cmd_flow_director_mask_result *res = parsed_result; 10858 struct rte_eth_fdir_masks *mask; 10859 struct rte_port *port; 10860 10861 port = &ports[res->port_id]; 10862 /** Check if the port is not started **/ 10863 if (port->port_status != RTE_PORT_STOPPED) { 10864 printf("Please stop port %d first\n", res->port_id); 10865 return; 10866 } 10867 10868 mask = &port->dev_conf.fdir_conf.mask; 10869 10870 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10871 if (strcmp(res->mode_value, "MAC-VLAN")) { 10872 printf("Please set mode to MAC-VLAN.\n"); 10873 return; 10874 } 10875 10876 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10877 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10878 if (strcmp(res->mode_value, "Tunnel")) { 10879 printf("Please set mode to Tunnel.\n"); 10880 return; 10881 } 10882 10883 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10884 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 10885 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 10886 mask->tunnel_type_mask = res->tunnel_type_mask; 10887 } else { 10888 if (strcmp(res->mode_value, "IP")) { 10889 printf("Please set mode to IP.\n"); 10890 return; 10891 } 10892 10893 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10894 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 10895 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 10896 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 10897 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 10898 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 10899 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 10900 } 10901 10902 cmd_reconfig_device_queue(res->port_id, 1, 1); 10903 } 10904 10905 cmdline_parse_token_string_t cmd_flow_director_mask = 10906 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10907 flow_director_mask, "flow_director_mask"); 10908 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 10909 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10910 port_id, UINT16); 10911 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 10912 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10913 vlan, "vlan"); 10914 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 10915 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10916 vlan_mask, UINT16); 10917 cmdline_parse_token_string_t cmd_flow_director_mask_src = 10918 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10919 src_mask, "src_mask"); 10920 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 10921 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10922 ipv4_src); 10923 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 10924 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10925 ipv6_src); 10926 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 10927 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10928 port_src, UINT16); 10929 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 10930 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10931 dst_mask, "dst_mask"); 10932 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 10933 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10934 ipv4_dst); 10935 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 10936 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10937 ipv6_dst); 10938 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 10939 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10940 port_dst, UINT16); 10941 10942 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 10943 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10944 mode, "mode"); 10945 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 10946 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10947 mode_value, "IP"); 10948 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 10949 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10950 mode_value, "MAC-VLAN"); 10951 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 10952 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10953 mode_value, "Tunnel"); 10954 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 10955 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10956 mac, "mac"); 10957 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 10958 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10959 mac_addr_byte_mask, UINT8); 10960 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 10961 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10962 tunnel_type, "tunnel-type"); 10963 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 10964 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10965 tunnel_type_mask, UINT8); 10966 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 10967 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10968 tunnel_id, "tunnel-id"); 10969 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 10970 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10971 tunnel_id_mask, UINT32); 10972 10973 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 10974 .f = cmd_flow_director_mask_parsed, 10975 .data = NULL, 10976 .help_str = "flow_director_mask ... : " 10977 "Set IP mode flow director's mask on NIC", 10978 .tokens = { 10979 (void *)&cmd_flow_director_mask, 10980 (void *)&cmd_flow_director_mask_port_id, 10981 (void *)&cmd_flow_director_mask_mode, 10982 (void *)&cmd_flow_director_mask_mode_ip, 10983 (void *)&cmd_flow_director_mask_vlan, 10984 (void *)&cmd_flow_director_mask_vlan_value, 10985 (void *)&cmd_flow_director_mask_src, 10986 (void *)&cmd_flow_director_mask_ipv4_src, 10987 (void *)&cmd_flow_director_mask_ipv6_src, 10988 (void *)&cmd_flow_director_mask_port_src, 10989 (void *)&cmd_flow_director_mask_dst, 10990 (void *)&cmd_flow_director_mask_ipv4_dst, 10991 (void *)&cmd_flow_director_mask_ipv6_dst, 10992 (void *)&cmd_flow_director_mask_port_dst, 10993 NULL, 10994 }, 10995 }; 10996 10997 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 10998 .f = cmd_flow_director_mask_parsed, 10999 .data = NULL, 11000 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 11001 "flow director's mask on NIC", 11002 .tokens = { 11003 (void *)&cmd_flow_director_mask, 11004 (void *)&cmd_flow_director_mask_port_id, 11005 (void *)&cmd_flow_director_mask_mode, 11006 (void *)&cmd_flow_director_mask_mode_mac_vlan, 11007 (void *)&cmd_flow_director_mask_vlan, 11008 (void *)&cmd_flow_director_mask_vlan_value, 11009 NULL, 11010 }, 11011 }; 11012 11013 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 11014 .f = cmd_flow_director_mask_parsed, 11015 .data = NULL, 11016 .help_str = "flow_director_mask ... : Set tunnel mode " 11017 "flow director's mask on NIC", 11018 .tokens = { 11019 (void *)&cmd_flow_director_mask, 11020 (void *)&cmd_flow_director_mask_port_id, 11021 (void *)&cmd_flow_director_mask_mode, 11022 (void *)&cmd_flow_director_mask_mode_tunnel, 11023 (void *)&cmd_flow_director_mask_vlan, 11024 (void *)&cmd_flow_director_mask_vlan_value, 11025 (void *)&cmd_flow_director_mask_mac, 11026 (void *)&cmd_flow_director_mask_mac_value, 11027 (void *)&cmd_flow_director_mask_tunnel_type, 11028 (void *)&cmd_flow_director_mask_tunnel_type_value, 11029 (void *)&cmd_flow_director_mask_tunnel_id, 11030 (void *)&cmd_flow_director_mask_tunnel_id_value, 11031 NULL, 11032 }, 11033 }; 11034 11035 /* *** deal with flow director mask on flexible payload *** */ 11036 struct cmd_flow_director_flex_mask_result { 11037 cmdline_fixed_string_t flow_director_flexmask; 11038 portid_t port_id; 11039 cmdline_fixed_string_t flow; 11040 cmdline_fixed_string_t flow_type; 11041 cmdline_fixed_string_t mask; 11042 }; 11043 11044 static void 11045 cmd_flow_director_flex_mask_parsed(void *parsed_result, 11046 __attribute__((unused)) struct cmdline *cl, 11047 __attribute__((unused)) void *data) 11048 { 11049 struct cmd_flow_director_flex_mask_result *res = parsed_result; 11050 struct rte_eth_fdir_info fdir_info; 11051 struct rte_eth_fdir_flex_mask flex_mask; 11052 struct rte_port *port; 11053 uint64_t flow_type_mask; 11054 uint16_t i; 11055 int ret; 11056 11057 port = &ports[res->port_id]; 11058 /** Check if the port is not started **/ 11059 if (port->port_status != RTE_PORT_STOPPED) { 11060 printf("Please stop port %d first\n", res->port_id); 11061 return; 11062 } 11063 11064 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask)); 11065 ret = parse_flexbytes(res->mask, 11066 flex_mask.mask, 11067 RTE_ETH_FDIR_MAX_FLEXLEN); 11068 if (ret < 0) { 11069 printf("error: Cannot parse mask input.\n"); 11070 return; 11071 } 11072 11073 memset(&fdir_info, 0, sizeof(fdir_info)); 11074 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11075 RTE_ETH_FILTER_INFO, &fdir_info); 11076 if (ret < 0) { 11077 printf("Cannot get FDir filter info\n"); 11078 return; 11079 } 11080 11081 if (!strcmp(res->flow_type, "none")) { 11082 /* means don't specify the flow type */ 11083 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN; 11084 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) 11085 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i], 11086 0, sizeof(struct rte_eth_fdir_flex_mask)); 11087 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1; 11088 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0], 11089 &flex_mask, 11090 sizeof(struct rte_eth_fdir_flex_mask)); 11091 cmd_reconfig_device_queue(res->port_id, 1, 1); 11092 return; 11093 } 11094 flow_type_mask = fdir_info.flow_types_mask[0]; 11095 if (!strcmp(res->flow_type, "all")) { 11096 if (!flow_type_mask) { 11097 printf("No flow type supported\n"); 11098 return; 11099 } 11100 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) { 11101 if (flow_type_mask & (1ULL << i)) { 11102 flex_mask.flow_type = i; 11103 fdir_set_flex_mask(res->port_id, &flex_mask); 11104 } 11105 } 11106 cmd_reconfig_device_queue(res->port_id, 1, 1); 11107 return; 11108 } 11109 flex_mask.flow_type = str2flowtype(res->flow_type); 11110 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) { 11111 printf("Flow type %s not supported on port %d\n", 11112 res->flow_type, res->port_id); 11113 return; 11114 } 11115 fdir_set_flex_mask(res->port_id, &flex_mask); 11116 cmd_reconfig_device_queue(res->port_id, 1, 1); 11117 } 11118 11119 cmdline_parse_token_string_t cmd_flow_director_flexmask = 11120 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11121 flow_director_flexmask, 11122 "flow_director_flex_mask"); 11123 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id = 11124 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11125 port_id, UINT16); 11126 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow = 11127 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11128 flow, "flow"); 11129 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type = 11130 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11131 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 11132 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all"); 11133 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask = 11134 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11135 mask, NULL); 11136 11137 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = { 11138 .f = cmd_flow_director_flex_mask_parsed, 11139 .data = NULL, 11140 .help_str = "flow_director_flex_mask ... : " 11141 "Set flow director's flex mask on NIC", 11142 .tokens = { 11143 (void *)&cmd_flow_director_flexmask, 11144 (void *)&cmd_flow_director_flexmask_port_id, 11145 (void *)&cmd_flow_director_flexmask_flow, 11146 (void *)&cmd_flow_director_flexmask_flow_type, 11147 (void *)&cmd_flow_director_flexmask_mask, 11148 NULL, 11149 }, 11150 }; 11151 11152 /* *** deal with flow director flexible payload configuration *** */ 11153 struct cmd_flow_director_flexpayload_result { 11154 cmdline_fixed_string_t flow_director_flexpayload; 11155 portid_t port_id; 11156 cmdline_fixed_string_t payload_layer; 11157 cmdline_fixed_string_t payload_cfg; 11158 }; 11159 11160 static inline int 11161 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 11162 { 11163 char s[256]; 11164 const char *p, *p0 = q_arg; 11165 char *end; 11166 unsigned long int_fld; 11167 char *str_fld[max_num]; 11168 int i; 11169 unsigned size; 11170 int ret = -1; 11171 11172 p = strchr(p0, '('); 11173 if (p == NULL) 11174 return -1; 11175 ++p; 11176 p0 = strchr(p, ')'); 11177 if (p0 == NULL) 11178 return -1; 11179 11180 size = p0 - p; 11181 if (size >= sizeof(s)) 11182 return -1; 11183 11184 snprintf(s, sizeof(s), "%.*s", size, p); 11185 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 11186 if (ret < 0 || ret > max_num) 11187 return -1; 11188 for (i = 0; i < ret; i++) { 11189 errno = 0; 11190 int_fld = strtoul(str_fld[i], &end, 0); 11191 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 11192 return -1; 11193 offsets[i] = (uint16_t)int_fld; 11194 } 11195 return ret; 11196 } 11197 11198 static void 11199 cmd_flow_director_flxpld_parsed(void *parsed_result, 11200 __attribute__((unused)) struct cmdline *cl, 11201 __attribute__((unused)) void *data) 11202 { 11203 struct cmd_flow_director_flexpayload_result *res = parsed_result; 11204 struct rte_eth_flex_payload_cfg flex_cfg; 11205 struct rte_port *port; 11206 int ret = 0; 11207 11208 port = &ports[res->port_id]; 11209 /** Check if the port is not started **/ 11210 if (port->port_status != RTE_PORT_STOPPED) { 11211 printf("Please stop port %d first\n", res->port_id); 11212 return; 11213 } 11214 11215 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 11216 11217 if (!strcmp(res->payload_layer, "raw")) 11218 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 11219 else if (!strcmp(res->payload_layer, "l2")) 11220 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 11221 else if (!strcmp(res->payload_layer, "l3")) 11222 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 11223 else if (!strcmp(res->payload_layer, "l4")) 11224 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 11225 11226 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 11227 RTE_ETH_FDIR_MAX_FLEXLEN); 11228 if (ret < 0) { 11229 printf("error: Cannot parse flex payload input.\n"); 11230 return; 11231 } 11232 11233 fdir_set_flex_payload(res->port_id, &flex_cfg); 11234 cmd_reconfig_device_queue(res->port_id, 1, 1); 11235 } 11236 11237 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 11238 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11239 flow_director_flexpayload, 11240 "flow_director_flex_payload"); 11241 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 11242 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11243 port_id, UINT16); 11244 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 11245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11246 payload_layer, "raw#l2#l3#l4"); 11247 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 11248 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11249 payload_cfg, NULL); 11250 11251 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 11252 .f = cmd_flow_director_flxpld_parsed, 11253 .data = NULL, 11254 .help_str = "flow_director_flexpayload ... : " 11255 "Set flow director's flex payload on NIC", 11256 .tokens = { 11257 (void *)&cmd_flow_director_flexpayload, 11258 (void *)&cmd_flow_director_flexpayload_port_id, 11259 (void *)&cmd_flow_director_flexpayload_payload_layer, 11260 (void *)&cmd_flow_director_flexpayload_payload_cfg, 11261 NULL, 11262 }, 11263 }; 11264 11265 /* Generic flow interface command. */ 11266 extern cmdline_parse_inst_t cmd_flow; 11267 11268 /* *** Classification Filters Control *** */ 11269 /* *** Get symmetric hash enable per port *** */ 11270 struct cmd_get_sym_hash_ena_per_port_result { 11271 cmdline_fixed_string_t get_sym_hash_ena_per_port; 11272 portid_t port_id; 11273 }; 11274 11275 static void 11276 cmd_get_sym_hash_per_port_parsed(void *parsed_result, 11277 __rte_unused struct cmdline *cl, 11278 __rte_unused void *data) 11279 { 11280 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result; 11281 struct rte_eth_hash_filter_info info; 11282 int ret; 11283 11284 if (rte_eth_dev_filter_supported(res->port_id, 11285 RTE_ETH_FILTER_HASH) < 0) { 11286 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11287 res->port_id); 11288 return; 11289 } 11290 11291 memset(&info, 0, sizeof(info)); 11292 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11293 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11294 RTE_ETH_FILTER_GET, &info); 11295 11296 if (ret < 0) { 11297 printf("Cannot get symmetric hash enable per port " 11298 "on port %u\n", res->port_id); 11299 return; 11300 } 11301 11302 printf("Symmetric hash is %s on port %u\n", info.info.enable ? 11303 "enabled" : "disabled", res->port_id); 11304 } 11305 11306 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all = 11307 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11308 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port"); 11309 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id = 11310 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11311 port_id, UINT16); 11312 11313 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = { 11314 .f = cmd_get_sym_hash_per_port_parsed, 11315 .data = NULL, 11316 .help_str = "get_sym_hash_ena_per_port <port_id>", 11317 .tokens = { 11318 (void *)&cmd_get_sym_hash_ena_per_port_all, 11319 (void *)&cmd_get_sym_hash_ena_per_port_port_id, 11320 NULL, 11321 }, 11322 }; 11323 11324 /* *** Set symmetric hash enable per port *** */ 11325 struct cmd_set_sym_hash_ena_per_port_result { 11326 cmdline_fixed_string_t set_sym_hash_ena_per_port; 11327 cmdline_fixed_string_t enable; 11328 portid_t port_id; 11329 }; 11330 11331 static void 11332 cmd_set_sym_hash_per_port_parsed(void *parsed_result, 11333 __rte_unused struct cmdline *cl, 11334 __rte_unused void *data) 11335 { 11336 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result; 11337 struct rte_eth_hash_filter_info info; 11338 int ret; 11339 11340 if (rte_eth_dev_filter_supported(res->port_id, 11341 RTE_ETH_FILTER_HASH) < 0) { 11342 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11343 res->port_id); 11344 return; 11345 } 11346 11347 memset(&info, 0, sizeof(info)); 11348 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11349 if (!strcmp(res->enable, "enable")) 11350 info.info.enable = 1; 11351 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11352 RTE_ETH_FILTER_SET, &info); 11353 if (ret < 0) { 11354 printf("Cannot set symmetric hash enable per port on " 11355 "port %u\n", res->port_id); 11356 return; 11357 } 11358 printf("Symmetric hash has been set to %s on port %u\n", 11359 res->enable, res->port_id); 11360 } 11361 11362 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all = 11363 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11364 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port"); 11365 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id = 11366 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11367 port_id, UINT16); 11368 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable = 11369 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11370 enable, "enable#disable"); 11371 11372 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = { 11373 .f = cmd_set_sym_hash_per_port_parsed, 11374 .data = NULL, 11375 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable", 11376 .tokens = { 11377 (void *)&cmd_set_sym_hash_ena_per_port_all, 11378 (void *)&cmd_set_sym_hash_ena_per_port_port_id, 11379 (void *)&cmd_set_sym_hash_ena_per_port_enable, 11380 NULL, 11381 }, 11382 }; 11383 11384 /* Get global config of hash function */ 11385 struct cmd_get_hash_global_config_result { 11386 cmdline_fixed_string_t get_hash_global_config; 11387 portid_t port_id; 11388 }; 11389 11390 static char * 11391 flowtype_to_str(uint16_t ftype) 11392 { 11393 uint16_t i; 11394 static struct { 11395 char str[16]; 11396 uint16_t ftype; 11397 } ftype_table[] = { 11398 {"ipv4", RTE_ETH_FLOW_IPV4}, 11399 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 11400 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 11401 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 11402 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 11403 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 11404 {"ipv6", RTE_ETH_FLOW_IPV6}, 11405 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 11406 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 11407 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 11408 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 11409 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 11410 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 11411 {"port", RTE_ETH_FLOW_PORT}, 11412 {"vxlan", RTE_ETH_FLOW_VXLAN}, 11413 {"geneve", RTE_ETH_FLOW_GENEVE}, 11414 {"nvgre", RTE_ETH_FLOW_NVGRE}, 11415 }; 11416 11417 for (i = 0; i < RTE_DIM(ftype_table); i++) { 11418 if (ftype_table[i].ftype == ftype) 11419 return ftype_table[i].str; 11420 } 11421 11422 return NULL; 11423 } 11424 11425 static void 11426 cmd_get_hash_global_config_parsed(void *parsed_result, 11427 __rte_unused struct cmdline *cl, 11428 __rte_unused void *data) 11429 { 11430 struct cmd_get_hash_global_config_result *res = parsed_result; 11431 struct rte_eth_hash_filter_info info; 11432 uint32_t idx, offset; 11433 uint16_t i; 11434 char *str; 11435 int ret; 11436 11437 if (rte_eth_dev_filter_supported(res->port_id, 11438 RTE_ETH_FILTER_HASH) < 0) { 11439 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 11440 res->port_id); 11441 return; 11442 } 11443 11444 memset(&info, 0, sizeof(info)); 11445 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 11446 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11447 RTE_ETH_FILTER_GET, &info); 11448 if (ret < 0) { 11449 printf("Cannot get hash global configurations by port %d\n", 11450 res->port_id); 11451 return; 11452 } 11453 11454 switch (info.info.global_conf.hash_func) { 11455 case RTE_ETH_HASH_FUNCTION_TOEPLITZ: 11456 printf("Hash function is Toeplitz\n"); 11457 break; 11458 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: 11459 printf("Hash function is Simple XOR\n"); 11460 break; 11461 default: 11462 printf("Unknown hash function\n"); 11463 break; 11464 } 11465 11466 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) { 11467 idx = i / UINT64_BIT; 11468 offset = i % UINT64_BIT; 11469 if (!(info.info.global_conf.valid_bit_mask[idx] & 11470 (1ULL << offset))) 11471 continue; 11472 str = flowtype_to_str(i); 11473 if (!str) 11474 continue; 11475 printf("Symmetric hash is %s globally for flow type %s " 11476 "by port %d\n", 11477 ((info.info.global_conf.sym_hash_enable_mask[idx] & 11478 (1ULL << offset)) ? "enabled" : "disabled"), str, 11479 res->port_id); 11480 } 11481 } 11482 11483 cmdline_parse_token_string_t cmd_get_hash_global_config_all = 11484 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result, 11485 get_hash_global_config, "get_hash_global_config"); 11486 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id = 11487 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result, 11488 port_id, UINT16); 11489 11490 cmdline_parse_inst_t cmd_get_hash_global_config = { 11491 .f = cmd_get_hash_global_config_parsed, 11492 .data = NULL, 11493 .help_str = "get_hash_global_config <port_id>", 11494 .tokens = { 11495 (void *)&cmd_get_hash_global_config_all, 11496 (void *)&cmd_get_hash_global_config_port_id, 11497 NULL, 11498 }, 11499 }; 11500 11501 /* Set global config of hash function */ 11502 struct cmd_set_hash_global_config_result { 11503 cmdline_fixed_string_t set_hash_global_config; 11504 portid_t port_id; 11505 cmdline_fixed_string_t hash_func; 11506 cmdline_fixed_string_t flow_type; 11507 cmdline_fixed_string_t enable; 11508 }; 11509 11510 static void 11511 cmd_set_hash_global_config_parsed(void *parsed_result, 11512 __rte_unused struct cmdline *cl, 11513 __rte_unused void *data) 11514 { 11515 struct cmd_set_hash_global_config_result *res = parsed_result; 11516 struct rte_eth_hash_filter_info info; 11517 uint32_t ftype, idx, offset; 11518 int ret; 11519 11520 if (rte_eth_dev_filter_supported(res->port_id, 11521 RTE_ETH_FILTER_HASH) < 0) { 11522 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 11523 res->port_id); 11524 return; 11525 } 11526 memset(&info, 0, sizeof(info)); 11527 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 11528 if (!strcmp(res->hash_func, "toeplitz")) 11529 info.info.global_conf.hash_func = 11530 RTE_ETH_HASH_FUNCTION_TOEPLITZ; 11531 else if (!strcmp(res->hash_func, "simple_xor")) 11532 info.info.global_conf.hash_func = 11533 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; 11534 else if (!strcmp(res->hash_func, "default")) 11535 info.info.global_conf.hash_func = 11536 RTE_ETH_HASH_FUNCTION_DEFAULT; 11537 11538 ftype = str2flowtype(res->flow_type); 11539 idx = ftype / UINT64_BIT; 11540 offset = ftype % UINT64_BIT; 11541 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset); 11542 if (!strcmp(res->enable, "enable")) 11543 info.info.global_conf.sym_hash_enable_mask[idx] |= 11544 (1ULL << offset); 11545 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11546 RTE_ETH_FILTER_SET, &info); 11547 if (ret < 0) 11548 printf("Cannot set global hash configurations by port %d\n", 11549 res->port_id); 11550 else 11551 printf("Global hash configurations have been set " 11552 "succcessfully by port %d\n", res->port_id); 11553 } 11554 11555 cmdline_parse_token_string_t cmd_set_hash_global_config_all = 11556 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11557 set_hash_global_config, "set_hash_global_config"); 11558 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id = 11559 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result, 11560 port_id, UINT16); 11561 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func = 11562 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11563 hash_func, "toeplitz#simple_xor#default"); 11564 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type = 11565 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11566 flow_type, 11567 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#" 11568 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 11569 cmdline_parse_token_string_t cmd_set_hash_global_config_enable = 11570 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11571 enable, "enable#disable"); 11572 11573 cmdline_parse_inst_t cmd_set_hash_global_config = { 11574 .f = cmd_set_hash_global_config_parsed, 11575 .data = NULL, 11576 .help_str = "set_hash_global_config <port_id> " 11577 "toeplitz|simple_xor|default " 11578 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 11579 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 11580 "l2_payload enable|disable", 11581 .tokens = { 11582 (void *)&cmd_set_hash_global_config_all, 11583 (void *)&cmd_set_hash_global_config_port_id, 11584 (void *)&cmd_set_hash_global_config_hash_func, 11585 (void *)&cmd_set_hash_global_config_flow_type, 11586 (void *)&cmd_set_hash_global_config_enable, 11587 NULL, 11588 }, 11589 }; 11590 11591 /* Set hash input set */ 11592 struct cmd_set_hash_input_set_result { 11593 cmdline_fixed_string_t set_hash_input_set; 11594 portid_t port_id; 11595 cmdline_fixed_string_t flow_type; 11596 cmdline_fixed_string_t inset_field; 11597 cmdline_fixed_string_t select; 11598 }; 11599 11600 static enum rte_eth_input_set_field 11601 str2inset(char *string) 11602 { 11603 uint16_t i; 11604 11605 static const struct { 11606 char str[32]; 11607 enum rte_eth_input_set_field inset; 11608 } inset_table[] = { 11609 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE}, 11610 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN}, 11611 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN}, 11612 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4}, 11613 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4}, 11614 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS}, 11615 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO}, 11616 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL}, 11617 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6}, 11618 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6}, 11619 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC}, 11620 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER}, 11621 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS}, 11622 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT}, 11623 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT}, 11624 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT}, 11625 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT}, 11626 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT}, 11627 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT}, 11628 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG}, 11629 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY}, 11630 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY}, 11631 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD}, 11632 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD}, 11633 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD}, 11634 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD}, 11635 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD}, 11636 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD}, 11637 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD}, 11638 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD}, 11639 {"none", RTE_ETH_INPUT_SET_NONE}, 11640 }; 11641 11642 for (i = 0; i < RTE_DIM(inset_table); i++) { 11643 if (!strcmp(string, inset_table[i].str)) 11644 return inset_table[i].inset; 11645 } 11646 11647 return RTE_ETH_INPUT_SET_UNKNOWN; 11648 } 11649 11650 static void 11651 cmd_set_hash_input_set_parsed(void *parsed_result, 11652 __rte_unused struct cmdline *cl, 11653 __rte_unused void *data) 11654 { 11655 struct cmd_set_hash_input_set_result *res = parsed_result; 11656 struct rte_eth_hash_filter_info info; 11657 11658 memset(&info, 0, sizeof(info)); 11659 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT; 11660 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 11661 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 11662 info.info.input_set_conf.inset_size = 1; 11663 if (!strcmp(res->select, "select")) 11664 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 11665 else if (!strcmp(res->select, "add")) 11666 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 11667 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11668 RTE_ETH_FILTER_SET, &info); 11669 } 11670 11671 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd = 11672 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 11673 set_hash_input_set, "set_hash_input_set"); 11674 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id = 11675 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result, 11676 port_id, UINT16); 11677 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type = 11678 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 11679 flow_type, NULL); 11680 cmdline_parse_token_string_t cmd_set_hash_input_set_field = 11681 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 11682 inset_field, 11683 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 11684 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#" 11685 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#" 11686 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#" 11687 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#" 11688 "fld-8th#none"); 11689 cmdline_parse_token_string_t cmd_set_hash_input_set_select = 11690 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 11691 select, "select#add"); 11692 11693 cmdline_parse_inst_t cmd_set_hash_input_set = { 11694 .f = cmd_set_hash_input_set_parsed, 11695 .data = NULL, 11696 .help_str = "set_hash_input_set <port_id> " 11697 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 11698 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> " 11699 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|" 11700 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|" 11701 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|" 11702 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|" 11703 "fld-7th|fld-8th|none select|add", 11704 .tokens = { 11705 (void *)&cmd_set_hash_input_set_cmd, 11706 (void *)&cmd_set_hash_input_set_port_id, 11707 (void *)&cmd_set_hash_input_set_flow_type, 11708 (void *)&cmd_set_hash_input_set_field, 11709 (void *)&cmd_set_hash_input_set_select, 11710 NULL, 11711 }, 11712 }; 11713 11714 /* Set flow director input set */ 11715 struct cmd_set_fdir_input_set_result { 11716 cmdline_fixed_string_t set_fdir_input_set; 11717 portid_t port_id; 11718 cmdline_fixed_string_t flow_type; 11719 cmdline_fixed_string_t inset_field; 11720 cmdline_fixed_string_t select; 11721 }; 11722 11723 static void 11724 cmd_set_fdir_input_set_parsed(void *parsed_result, 11725 __rte_unused struct cmdline *cl, 11726 __rte_unused void *data) 11727 { 11728 struct cmd_set_fdir_input_set_result *res = parsed_result; 11729 struct rte_eth_fdir_filter_info info; 11730 11731 memset(&info, 0, sizeof(info)); 11732 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT; 11733 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 11734 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 11735 info.info.input_set_conf.inset_size = 1; 11736 if (!strcmp(res->select, "select")) 11737 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 11738 else if (!strcmp(res->select, "add")) 11739 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 11740 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11741 RTE_ETH_FILTER_SET, &info); 11742 } 11743 11744 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd = 11745 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 11746 set_fdir_input_set, "set_fdir_input_set"); 11747 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id = 11748 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result, 11749 port_id, UINT16); 11750 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type = 11751 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 11752 flow_type, 11753 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#" 11754 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 11755 cmdline_parse_token_string_t cmd_set_fdir_input_set_field = 11756 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 11757 inset_field, 11758 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 11759 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#" 11760 "ipv6-hop-limits#udp-src-port#udp-dst-port#" 11761 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#" 11762 "sctp-veri-tag#none"); 11763 cmdline_parse_token_string_t cmd_set_fdir_input_set_select = 11764 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 11765 select, "select#add"); 11766 11767 cmdline_parse_inst_t cmd_set_fdir_input_set = { 11768 .f = cmd_set_fdir_input_set_parsed, 11769 .data = NULL, 11770 .help_str = "set_fdir_input_set <port_id> " 11771 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 11772 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload " 11773 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|" 11774 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|" 11775 "ipv6-hop-limits|udp-src-port|udp-dst-port|" 11776 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|" 11777 "sctp-veri-tag|none select|add", 11778 .tokens = { 11779 (void *)&cmd_set_fdir_input_set_cmd, 11780 (void *)&cmd_set_fdir_input_set_port_id, 11781 (void *)&cmd_set_fdir_input_set_flow_type, 11782 (void *)&cmd_set_fdir_input_set_field, 11783 (void *)&cmd_set_fdir_input_set_select, 11784 NULL, 11785 }, 11786 }; 11787 11788 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 11789 struct cmd_mcast_addr_result { 11790 cmdline_fixed_string_t mcast_addr_cmd; 11791 cmdline_fixed_string_t what; 11792 uint16_t port_num; 11793 struct ether_addr mc_addr; 11794 }; 11795 11796 static void cmd_mcast_addr_parsed(void *parsed_result, 11797 __attribute__((unused)) struct cmdline *cl, 11798 __attribute__((unused)) void *data) 11799 { 11800 struct cmd_mcast_addr_result *res = parsed_result; 11801 11802 if (!is_multicast_ether_addr(&res->mc_addr)) { 11803 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", 11804 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], 11805 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], 11806 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); 11807 return; 11808 } 11809 if (strcmp(res->what, "add") == 0) 11810 mcast_addr_add(res->port_num, &res->mc_addr); 11811 else 11812 mcast_addr_remove(res->port_num, &res->mc_addr); 11813 } 11814 11815 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 11816 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 11817 mcast_addr_cmd, "mcast_addr"); 11818 cmdline_parse_token_string_t cmd_mcast_addr_what = 11819 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 11820 "add#remove"); 11821 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 11822 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16); 11823 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 11824 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 11825 11826 cmdline_parse_inst_t cmd_mcast_addr = { 11827 .f = cmd_mcast_addr_parsed, 11828 .data = (void *)0, 11829 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 11830 "Add/Remove multicast MAC address on port_id", 11831 .tokens = { 11832 (void *)&cmd_mcast_addr_cmd, 11833 (void *)&cmd_mcast_addr_what, 11834 (void *)&cmd_mcast_addr_portnum, 11835 (void *)&cmd_mcast_addr_addr, 11836 NULL, 11837 }, 11838 }; 11839 11840 /* l2 tunnel config 11841 * only support E-tag now. 11842 */ 11843 11844 /* Ether type config */ 11845 struct cmd_config_l2_tunnel_eth_type_result { 11846 cmdline_fixed_string_t port; 11847 cmdline_fixed_string_t config; 11848 cmdline_fixed_string_t all; 11849 uint8_t id; 11850 cmdline_fixed_string_t l2_tunnel; 11851 cmdline_fixed_string_t l2_tunnel_type; 11852 cmdline_fixed_string_t eth_type; 11853 uint16_t eth_type_val; 11854 }; 11855 11856 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port = 11857 TOKEN_STRING_INITIALIZER 11858 (struct cmd_config_l2_tunnel_eth_type_result, 11859 port, "port"); 11860 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config = 11861 TOKEN_STRING_INITIALIZER 11862 (struct cmd_config_l2_tunnel_eth_type_result, 11863 config, "config"); 11864 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str = 11865 TOKEN_STRING_INITIALIZER 11866 (struct cmd_config_l2_tunnel_eth_type_result, 11867 all, "all"); 11868 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id = 11869 TOKEN_NUM_INITIALIZER 11870 (struct cmd_config_l2_tunnel_eth_type_result, 11871 id, UINT8); 11872 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel = 11873 TOKEN_STRING_INITIALIZER 11874 (struct cmd_config_l2_tunnel_eth_type_result, 11875 l2_tunnel, "l2-tunnel"); 11876 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type = 11877 TOKEN_STRING_INITIALIZER 11878 (struct cmd_config_l2_tunnel_eth_type_result, 11879 l2_tunnel_type, "E-tag"); 11880 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type = 11881 TOKEN_STRING_INITIALIZER 11882 (struct cmd_config_l2_tunnel_eth_type_result, 11883 eth_type, "ether-type"); 11884 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val = 11885 TOKEN_NUM_INITIALIZER 11886 (struct cmd_config_l2_tunnel_eth_type_result, 11887 eth_type_val, UINT16); 11888 11889 static enum rte_eth_tunnel_type 11890 str2fdir_l2_tunnel_type(char *string) 11891 { 11892 uint32_t i = 0; 11893 11894 static const struct { 11895 char str[32]; 11896 enum rte_eth_tunnel_type type; 11897 } l2_tunnel_type_str[] = { 11898 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG}, 11899 }; 11900 11901 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) { 11902 if (!strcmp(l2_tunnel_type_str[i].str, string)) 11903 return l2_tunnel_type_str[i].type; 11904 } 11905 return RTE_TUNNEL_TYPE_NONE; 11906 } 11907 11908 /* ether type config for all ports */ 11909 static void 11910 cmd_config_l2_tunnel_eth_type_all_parsed 11911 (void *parsed_result, 11912 __attribute__((unused)) struct cmdline *cl, 11913 __attribute__((unused)) void *data) 11914 { 11915 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result; 11916 struct rte_eth_l2_tunnel_conf entry; 11917 portid_t pid; 11918 11919 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 11920 entry.ether_type = res->eth_type_val; 11921 11922 RTE_ETH_FOREACH_DEV(pid) { 11923 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry); 11924 } 11925 } 11926 11927 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = { 11928 .f = cmd_config_l2_tunnel_eth_type_all_parsed, 11929 .data = NULL, 11930 .help_str = "port config all l2-tunnel E-tag ether-type <value>", 11931 .tokens = { 11932 (void *)&cmd_config_l2_tunnel_eth_type_port, 11933 (void *)&cmd_config_l2_tunnel_eth_type_config, 11934 (void *)&cmd_config_l2_tunnel_eth_type_all_str, 11935 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 11936 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 11937 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 11938 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 11939 NULL, 11940 }, 11941 }; 11942 11943 /* ether type config for a specific port */ 11944 static void 11945 cmd_config_l2_tunnel_eth_type_specific_parsed( 11946 void *parsed_result, 11947 __attribute__((unused)) struct cmdline *cl, 11948 __attribute__((unused)) void *data) 11949 { 11950 struct cmd_config_l2_tunnel_eth_type_result *res = 11951 parsed_result; 11952 struct rte_eth_l2_tunnel_conf entry; 11953 11954 if (port_id_is_invalid(res->id, ENABLED_WARN)) 11955 return; 11956 11957 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 11958 entry.ether_type = res->eth_type_val; 11959 11960 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry); 11961 } 11962 11963 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = { 11964 .f = cmd_config_l2_tunnel_eth_type_specific_parsed, 11965 .data = NULL, 11966 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>", 11967 .tokens = { 11968 (void *)&cmd_config_l2_tunnel_eth_type_port, 11969 (void *)&cmd_config_l2_tunnel_eth_type_config, 11970 (void *)&cmd_config_l2_tunnel_eth_type_id, 11971 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 11972 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 11973 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 11974 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 11975 NULL, 11976 }, 11977 }; 11978 11979 /* Enable/disable l2 tunnel */ 11980 struct cmd_config_l2_tunnel_en_dis_result { 11981 cmdline_fixed_string_t port; 11982 cmdline_fixed_string_t config; 11983 cmdline_fixed_string_t all; 11984 uint8_t id; 11985 cmdline_fixed_string_t l2_tunnel; 11986 cmdline_fixed_string_t l2_tunnel_type; 11987 cmdline_fixed_string_t en_dis; 11988 }; 11989 11990 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port = 11991 TOKEN_STRING_INITIALIZER 11992 (struct cmd_config_l2_tunnel_en_dis_result, 11993 port, "port"); 11994 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config = 11995 TOKEN_STRING_INITIALIZER 11996 (struct cmd_config_l2_tunnel_en_dis_result, 11997 config, "config"); 11998 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str = 11999 TOKEN_STRING_INITIALIZER 12000 (struct cmd_config_l2_tunnel_en_dis_result, 12001 all, "all"); 12002 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id = 12003 TOKEN_NUM_INITIALIZER 12004 (struct cmd_config_l2_tunnel_en_dis_result, 12005 id, UINT8); 12006 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel = 12007 TOKEN_STRING_INITIALIZER 12008 (struct cmd_config_l2_tunnel_en_dis_result, 12009 l2_tunnel, "l2-tunnel"); 12010 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type = 12011 TOKEN_STRING_INITIALIZER 12012 (struct cmd_config_l2_tunnel_en_dis_result, 12013 l2_tunnel_type, "E-tag"); 12014 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis = 12015 TOKEN_STRING_INITIALIZER 12016 (struct cmd_config_l2_tunnel_en_dis_result, 12017 en_dis, "enable#disable"); 12018 12019 /* enable/disable l2 tunnel for all ports */ 12020 static void 12021 cmd_config_l2_tunnel_en_dis_all_parsed( 12022 void *parsed_result, 12023 __attribute__((unused)) struct cmdline *cl, 12024 __attribute__((unused)) void *data) 12025 { 12026 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result; 12027 struct rte_eth_l2_tunnel_conf entry; 12028 portid_t pid; 12029 uint8_t en; 12030 12031 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12032 12033 if (!strcmp("enable", res->en_dis)) 12034 en = 1; 12035 else 12036 en = 0; 12037 12038 RTE_ETH_FOREACH_DEV(pid) { 12039 rte_eth_dev_l2_tunnel_offload_set(pid, 12040 &entry, 12041 ETH_L2_TUNNEL_ENABLE_MASK, 12042 en); 12043 } 12044 } 12045 12046 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = { 12047 .f = cmd_config_l2_tunnel_en_dis_all_parsed, 12048 .data = NULL, 12049 .help_str = "port config all l2-tunnel E-tag enable|disable", 12050 .tokens = { 12051 (void *)&cmd_config_l2_tunnel_en_dis_port, 12052 (void *)&cmd_config_l2_tunnel_en_dis_config, 12053 (void *)&cmd_config_l2_tunnel_en_dis_all_str, 12054 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12055 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12056 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12057 NULL, 12058 }, 12059 }; 12060 12061 /* enable/disable l2 tunnel for a port */ 12062 static void 12063 cmd_config_l2_tunnel_en_dis_specific_parsed( 12064 void *parsed_result, 12065 __attribute__((unused)) struct cmdline *cl, 12066 __attribute__((unused)) void *data) 12067 { 12068 struct cmd_config_l2_tunnel_en_dis_result *res = 12069 parsed_result; 12070 struct rte_eth_l2_tunnel_conf entry; 12071 12072 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12073 return; 12074 12075 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12076 12077 if (!strcmp("enable", res->en_dis)) 12078 rte_eth_dev_l2_tunnel_offload_set(res->id, 12079 &entry, 12080 ETH_L2_TUNNEL_ENABLE_MASK, 12081 1); 12082 else 12083 rte_eth_dev_l2_tunnel_offload_set(res->id, 12084 &entry, 12085 ETH_L2_TUNNEL_ENABLE_MASK, 12086 0); 12087 } 12088 12089 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = { 12090 .f = cmd_config_l2_tunnel_en_dis_specific_parsed, 12091 .data = NULL, 12092 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable", 12093 .tokens = { 12094 (void *)&cmd_config_l2_tunnel_en_dis_port, 12095 (void *)&cmd_config_l2_tunnel_en_dis_config, 12096 (void *)&cmd_config_l2_tunnel_en_dis_id, 12097 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12098 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12099 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12100 NULL, 12101 }, 12102 }; 12103 12104 /* E-tag configuration */ 12105 12106 /* Common result structure for all E-tag configuration */ 12107 struct cmd_config_e_tag_result { 12108 cmdline_fixed_string_t e_tag; 12109 cmdline_fixed_string_t set; 12110 cmdline_fixed_string_t insertion; 12111 cmdline_fixed_string_t stripping; 12112 cmdline_fixed_string_t forwarding; 12113 cmdline_fixed_string_t filter; 12114 cmdline_fixed_string_t add; 12115 cmdline_fixed_string_t del; 12116 cmdline_fixed_string_t on; 12117 cmdline_fixed_string_t off; 12118 cmdline_fixed_string_t on_off; 12119 cmdline_fixed_string_t port_tag_id; 12120 uint32_t port_tag_id_val; 12121 cmdline_fixed_string_t e_tag_id; 12122 uint16_t e_tag_id_val; 12123 cmdline_fixed_string_t dst_pool; 12124 uint8_t dst_pool_val; 12125 cmdline_fixed_string_t port; 12126 portid_t port_id; 12127 cmdline_fixed_string_t vf; 12128 uint8_t vf_id; 12129 }; 12130 12131 /* Common CLI fields for all E-tag configuration */ 12132 cmdline_parse_token_string_t cmd_config_e_tag_e_tag = 12133 TOKEN_STRING_INITIALIZER 12134 (struct cmd_config_e_tag_result, 12135 e_tag, "E-tag"); 12136 cmdline_parse_token_string_t cmd_config_e_tag_set = 12137 TOKEN_STRING_INITIALIZER 12138 (struct cmd_config_e_tag_result, 12139 set, "set"); 12140 cmdline_parse_token_string_t cmd_config_e_tag_insertion = 12141 TOKEN_STRING_INITIALIZER 12142 (struct cmd_config_e_tag_result, 12143 insertion, "insertion"); 12144 cmdline_parse_token_string_t cmd_config_e_tag_stripping = 12145 TOKEN_STRING_INITIALIZER 12146 (struct cmd_config_e_tag_result, 12147 stripping, "stripping"); 12148 cmdline_parse_token_string_t cmd_config_e_tag_forwarding = 12149 TOKEN_STRING_INITIALIZER 12150 (struct cmd_config_e_tag_result, 12151 forwarding, "forwarding"); 12152 cmdline_parse_token_string_t cmd_config_e_tag_filter = 12153 TOKEN_STRING_INITIALIZER 12154 (struct cmd_config_e_tag_result, 12155 filter, "filter"); 12156 cmdline_parse_token_string_t cmd_config_e_tag_add = 12157 TOKEN_STRING_INITIALIZER 12158 (struct cmd_config_e_tag_result, 12159 add, "add"); 12160 cmdline_parse_token_string_t cmd_config_e_tag_del = 12161 TOKEN_STRING_INITIALIZER 12162 (struct cmd_config_e_tag_result, 12163 del, "del"); 12164 cmdline_parse_token_string_t cmd_config_e_tag_on = 12165 TOKEN_STRING_INITIALIZER 12166 (struct cmd_config_e_tag_result, 12167 on, "on"); 12168 cmdline_parse_token_string_t cmd_config_e_tag_off = 12169 TOKEN_STRING_INITIALIZER 12170 (struct cmd_config_e_tag_result, 12171 off, "off"); 12172 cmdline_parse_token_string_t cmd_config_e_tag_on_off = 12173 TOKEN_STRING_INITIALIZER 12174 (struct cmd_config_e_tag_result, 12175 on_off, "on#off"); 12176 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id = 12177 TOKEN_STRING_INITIALIZER 12178 (struct cmd_config_e_tag_result, 12179 port_tag_id, "port-tag-id"); 12180 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val = 12181 TOKEN_NUM_INITIALIZER 12182 (struct cmd_config_e_tag_result, 12183 port_tag_id_val, UINT32); 12184 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id = 12185 TOKEN_STRING_INITIALIZER 12186 (struct cmd_config_e_tag_result, 12187 e_tag_id, "e-tag-id"); 12188 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val = 12189 TOKEN_NUM_INITIALIZER 12190 (struct cmd_config_e_tag_result, 12191 e_tag_id_val, UINT16); 12192 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool = 12193 TOKEN_STRING_INITIALIZER 12194 (struct cmd_config_e_tag_result, 12195 dst_pool, "dst-pool"); 12196 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val = 12197 TOKEN_NUM_INITIALIZER 12198 (struct cmd_config_e_tag_result, 12199 dst_pool_val, UINT8); 12200 cmdline_parse_token_string_t cmd_config_e_tag_port = 12201 TOKEN_STRING_INITIALIZER 12202 (struct cmd_config_e_tag_result, 12203 port, "port"); 12204 cmdline_parse_token_num_t cmd_config_e_tag_port_id = 12205 TOKEN_NUM_INITIALIZER 12206 (struct cmd_config_e_tag_result, 12207 port_id, UINT16); 12208 cmdline_parse_token_string_t cmd_config_e_tag_vf = 12209 TOKEN_STRING_INITIALIZER 12210 (struct cmd_config_e_tag_result, 12211 vf, "vf"); 12212 cmdline_parse_token_num_t cmd_config_e_tag_vf_id = 12213 TOKEN_NUM_INITIALIZER 12214 (struct cmd_config_e_tag_result, 12215 vf_id, UINT8); 12216 12217 /* E-tag insertion configuration */ 12218 static void 12219 cmd_config_e_tag_insertion_en_parsed( 12220 void *parsed_result, 12221 __attribute__((unused)) struct cmdline *cl, 12222 __attribute__((unused)) void *data) 12223 { 12224 struct cmd_config_e_tag_result *res = 12225 parsed_result; 12226 struct rte_eth_l2_tunnel_conf entry; 12227 12228 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12229 return; 12230 12231 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12232 entry.tunnel_id = res->port_tag_id_val; 12233 entry.vf_id = res->vf_id; 12234 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12235 &entry, 12236 ETH_L2_TUNNEL_INSERTION_MASK, 12237 1); 12238 } 12239 12240 static void 12241 cmd_config_e_tag_insertion_dis_parsed( 12242 void *parsed_result, 12243 __attribute__((unused)) struct cmdline *cl, 12244 __attribute__((unused)) void *data) 12245 { 12246 struct cmd_config_e_tag_result *res = 12247 parsed_result; 12248 struct rte_eth_l2_tunnel_conf entry; 12249 12250 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12251 return; 12252 12253 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12254 entry.vf_id = res->vf_id; 12255 12256 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12257 &entry, 12258 ETH_L2_TUNNEL_INSERTION_MASK, 12259 0); 12260 } 12261 12262 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = { 12263 .f = cmd_config_e_tag_insertion_en_parsed, 12264 .data = NULL, 12265 .help_str = "E-tag ... : E-tag insertion enable", 12266 .tokens = { 12267 (void *)&cmd_config_e_tag_e_tag, 12268 (void *)&cmd_config_e_tag_set, 12269 (void *)&cmd_config_e_tag_insertion, 12270 (void *)&cmd_config_e_tag_on, 12271 (void *)&cmd_config_e_tag_port_tag_id, 12272 (void *)&cmd_config_e_tag_port_tag_id_val, 12273 (void *)&cmd_config_e_tag_port, 12274 (void *)&cmd_config_e_tag_port_id, 12275 (void *)&cmd_config_e_tag_vf, 12276 (void *)&cmd_config_e_tag_vf_id, 12277 NULL, 12278 }, 12279 }; 12280 12281 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = { 12282 .f = cmd_config_e_tag_insertion_dis_parsed, 12283 .data = NULL, 12284 .help_str = "E-tag ... : E-tag insertion disable", 12285 .tokens = { 12286 (void *)&cmd_config_e_tag_e_tag, 12287 (void *)&cmd_config_e_tag_set, 12288 (void *)&cmd_config_e_tag_insertion, 12289 (void *)&cmd_config_e_tag_off, 12290 (void *)&cmd_config_e_tag_port, 12291 (void *)&cmd_config_e_tag_port_id, 12292 (void *)&cmd_config_e_tag_vf, 12293 (void *)&cmd_config_e_tag_vf_id, 12294 NULL, 12295 }, 12296 }; 12297 12298 /* E-tag stripping configuration */ 12299 static void 12300 cmd_config_e_tag_stripping_parsed( 12301 void *parsed_result, 12302 __attribute__((unused)) struct cmdline *cl, 12303 __attribute__((unused)) void *data) 12304 { 12305 struct cmd_config_e_tag_result *res = 12306 parsed_result; 12307 struct rte_eth_l2_tunnel_conf entry; 12308 12309 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12310 return; 12311 12312 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12313 12314 if (!strcmp(res->on_off, "on")) 12315 rte_eth_dev_l2_tunnel_offload_set 12316 (res->port_id, 12317 &entry, 12318 ETH_L2_TUNNEL_STRIPPING_MASK, 12319 1); 12320 else 12321 rte_eth_dev_l2_tunnel_offload_set 12322 (res->port_id, 12323 &entry, 12324 ETH_L2_TUNNEL_STRIPPING_MASK, 12325 0); 12326 } 12327 12328 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = { 12329 .f = cmd_config_e_tag_stripping_parsed, 12330 .data = NULL, 12331 .help_str = "E-tag ... : E-tag stripping enable/disable", 12332 .tokens = { 12333 (void *)&cmd_config_e_tag_e_tag, 12334 (void *)&cmd_config_e_tag_set, 12335 (void *)&cmd_config_e_tag_stripping, 12336 (void *)&cmd_config_e_tag_on_off, 12337 (void *)&cmd_config_e_tag_port, 12338 (void *)&cmd_config_e_tag_port_id, 12339 NULL, 12340 }, 12341 }; 12342 12343 /* E-tag forwarding configuration */ 12344 static void 12345 cmd_config_e_tag_forwarding_parsed( 12346 void *parsed_result, 12347 __attribute__((unused)) struct cmdline *cl, 12348 __attribute__((unused)) void *data) 12349 { 12350 struct cmd_config_e_tag_result *res = parsed_result; 12351 struct rte_eth_l2_tunnel_conf entry; 12352 12353 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12354 return; 12355 12356 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12357 12358 if (!strcmp(res->on_off, "on")) 12359 rte_eth_dev_l2_tunnel_offload_set 12360 (res->port_id, 12361 &entry, 12362 ETH_L2_TUNNEL_FORWARDING_MASK, 12363 1); 12364 else 12365 rte_eth_dev_l2_tunnel_offload_set 12366 (res->port_id, 12367 &entry, 12368 ETH_L2_TUNNEL_FORWARDING_MASK, 12369 0); 12370 } 12371 12372 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = { 12373 .f = cmd_config_e_tag_forwarding_parsed, 12374 .data = NULL, 12375 .help_str = "E-tag ... : E-tag forwarding enable/disable", 12376 .tokens = { 12377 (void *)&cmd_config_e_tag_e_tag, 12378 (void *)&cmd_config_e_tag_set, 12379 (void *)&cmd_config_e_tag_forwarding, 12380 (void *)&cmd_config_e_tag_on_off, 12381 (void *)&cmd_config_e_tag_port, 12382 (void *)&cmd_config_e_tag_port_id, 12383 NULL, 12384 }, 12385 }; 12386 12387 /* E-tag filter configuration */ 12388 static void 12389 cmd_config_e_tag_filter_add_parsed( 12390 void *parsed_result, 12391 __attribute__((unused)) struct cmdline *cl, 12392 __attribute__((unused)) void *data) 12393 { 12394 struct cmd_config_e_tag_result *res = parsed_result; 12395 struct rte_eth_l2_tunnel_conf entry; 12396 int ret = 0; 12397 12398 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12399 return; 12400 12401 if (res->e_tag_id_val > 0x3fff) { 12402 printf("e-tag-id must be equal or less than 0x3fff.\n"); 12403 return; 12404 } 12405 12406 ret = rte_eth_dev_filter_supported(res->port_id, 12407 RTE_ETH_FILTER_L2_TUNNEL); 12408 if (ret < 0) { 12409 printf("E-tag filter is not supported on port %u.\n", 12410 res->port_id); 12411 return; 12412 } 12413 12414 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12415 entry.tunnel_id = res->e_tag_id_val; 12416 entry.pool = res->dst_pool_val; 12417 12418 ret = rte_eth_dev_filter_ctrl(res->port_id, 12419 RTE_ETH_FILTER_L2_TUNNEL, 12420 RTE_ETH_FILTER_ADD, 12421 &entry); 12422 if (ret < 0) 12423 printf("E-tag filter programming error: (%s)\n", 12424 strerror(-ret)); 12425 } 12426 12427 cmdline_parse_inst_t cmd_config_e_tag_filter_add = { 12428 .f = cmd_config_e_tag_filter_add_parsed, 12429 .data = NULL, 12430 .help_str = "E-tag ... : E-tag filter add", 12431 .tokens = { 12432 (void *)&cmd_config_e_tag_e_tag, 12433 (void *)&cmd_config_e_tag_set, 12434 (void *)&cmd_config_e_tag_filter, 12435 (void *)&cmd_config_e_tag_add, 12436 (void *)&cmd_config_e_tag_e_tag_id, 12437 (void *)&cmd_config_e_tag_e_tag_id_val, 12438 (void *)&cmd_config_e_tag_dst_pool, 12439 (void *)&cmd_config_e_tag_dst_pool_val, 12440 (void *)&cmd_config_e_tag_port, 12441 (void *)&cmd_config_e_tag_port_id, 12442 NULL, 12443 }, 12444 }; 12445 12446 static void 12447 cmd_config_e_tag_filter_del_parsed( 12448 void *parsed_result, 12449 __attribute__((unused)) struct cmdline *cl, 12450 __attribute__((unused)) void *data) 12451 { 12452 struct cmd_config_e_tag_result *res = parsed_result; 12453 struct rte_eth_l2_tunnel_conf entry; 12454 int ret = 0; 12455 12456 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12457 return; 12458 12459 if (res->e_tag_id_val > 0x3fff) { 12460 printf("e-tag-id must be less than 0x3fff.\n"); 12461 return; 12462 } 12463 12464 ret = rte_eth_dev_filter_supported(res->port_id, 12465 RTE_ETH_FILTER_L2_TUNNEL); 12466 if (ret < 0) { 12467 printf("E-tag filter is not supported on port %u.\n", 12468 res->port_id); 12469 return; 12470 } 12471 12472 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12473 entry.tunnel_id = res->e_tag_id_val; 12474 12475 ret = rte_eth_dev_filter_ctrl(res->port_id, 12476 RTE_ETH_FILTER_L2_TUNNEL, 12477 RTE_ETH_FILTER_DELETE, 12478 &entry); 12479 if (ret < 0) 12480 printf("E-tag filter programming error: (%s)\n", 12481 strerror(-ret)); 12482 } 12483 12484 cmdline_parse_inst_t cmd_config_e_tag_filter_del = { 12485 .f = cmd_config_e_tag_filter_del_parsed, 12486 .data = NULL, 12487 .help_str = "E-tag ... : E-tag filter delete", 12488 .tokens = { 12489 (void *)&cmd_config_e_tag_e_tag, 12490 (void *)&cmd_config_e_tag_set, 12491 (void *)&cmd_config_e_tag_filter, 12492 (void *)&cmd_config_e_tag_del, 12493 (void *)&cmd_config_e_tag_e_tag_id, 12494 (void *)&cmd_config_e_tag_e_tag_id_val, 12495 (void *)&cmd_config_e_tag_port, 12496 (void *)&cmd_config_e_tag_port_id, 12497 NULL, 12498 }, 12499 }; 12500 12501 /* vf vlan anti spoof configuration */ 12502 12503 /* Common result structure for vf vlan anti spoof */ 12504 struct cmd_vf_vlan_anti_spoof_result { 12505 cmdline_fixed_string_t set; 12506 cmdline_fixed_string_t vf; 12507 cmdline_fixed_string_t vlan; 12508 cmdline_fixed_string_t antispoof; 12509 portid_t port_id; 12510 uint32_t vf_id; 12511 cmdline_fixed_string_t on_off; 12512 }; 12513 12514 /* Common CLI fields for vf vlan anti spoof enable disable */ 12515 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 12516 TOKEN_STRING_INITIALIZER 12517 (struct cmd_vf_vlan_anti_spoof_result, 12518 set, "set"); 12519 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 12520 TOKEN_STRING_INITIALIZER 12521 (struct cmd_vf_vlan_anti_spoof_result, 12522 vf, "vf"); 12523 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 12524 TOKEN_STRING_INITIALIZER 12525 (struct cmd_vf_vlan_anti_spoof_result, 12526 vlan, "vlan"); 12527 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 12528 TOKEN_STRING_INITIALIZER 12529 (struct cmd_vf_vlan_anti_spoof_result, 12530 antispoof, "antispoof"); 12531 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 12532 TOKEN_NUM_INITIALIZER 12533 (struct cmd_vf_vlan_anti_spoof_result, 12534 port_id, UINT16); 12535 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 12536 TOKEN_NUM_INITIALIZER 12537 (struct cmd_vf_vlan_anti_spoof_result, 12538 vf_id, UINT32); 12539 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 12540 TOKEN_STRING_INITIALIZER 12541 (struct cmd_vf_vlan_anti_spoof_result, 12542 on_off, "on#off"); 12543 12544 static void 12545 cmd_set_vf_vlan_anti_spoof_parsed( 12546 void *parsed_result, 12547 __attribute__((unused)) struct cmdline *cl, 12548 __attribute__((unused)) void *data) 12549 { 12550 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 12551 int ret = -ENOTSUP; 12552 12553 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12554 12555 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12556 return; 12557 12558 #ifdef RTE_LIBRTE_IXGBE_PMD 12559 if (ret == -ENOTSUP) 12560 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 12561 res->vf_id, is_on); 12562 #endif 12563 #ifdef RTE_LIBRTE_I40E_PMD 12564 if (ret == -ENOTSUP) 12565 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 12566 res->vf_id, is_on); 12567 #endif 12568 #ifdef RTE_LIBRTE_BNXT_PMD 12569 if (ret == -ENOTSUP) 12570 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 12571 res->vf_id, is_on); 12572 #endif 12573 12574 switch (ret) { 12575 case 0: 12576 break; 12577 case -EINVAL: 12578 printf("invalid vf_id %d\n", res->vf_id); 12579 break; 12580 case -ENODEV: 12581 printf("invalid port_id %d\n", res->port_id); 12582 break; 12583 case -ENOTSUP: 12584 printf("function not implemented\n"); 12585 break; 12586 default: 12587 printf("programming error: (%s)\n", strerror(-ret)); 12588 } 12589 } 12590 12591 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 12592 .f = cmd_set_vf_vlan_anti_spoof_parsed, 12593 .data = NULL, 12594 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 12595 .tokens = { 12596 (void *)&cmd_vf_vlan_anti_spoof_set, 12597 (void *)&cmd_vf_vlan_anti_spoof_vf, 12598 (void *)&cmd_vf_vlan_anti_spoof_vlan, 12599 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 12600 (void *)&cmd_vf_vlan_anti_spoof_port_id, 12601 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 12602 (void *)&cmd_vf_vlan_anti_spoof_on_off, 12603 NULL, 12604 }, 12605 }; 12606 12607 /* vf mac anti spoof configuration */ 12608 12609 /* Common result structure for vf mac anti spoof */ 12610 struct cmd_vf_mac_anti_spoof_result { 12611 cmdline_fixed_string_t set; 12612 cmdline_fixed_string_t vf; 12613 cmdline_fixed_string_t mac; 12614 cmdline_fixed_string_t antispoof; 12615 portid_t port_id; 12616 uint32_t vf_id; 12617 cmdline_fixed_string_t on_off; 12618 }; 12619 12620 /* Common CLI fields for vf mac anti spoof enable disable */ 12621 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 12622 TOKEN_STRING_INITIALIZER 12623 (struct cmd_vf_mac_anti_spoof_result, 12624 set, "set"); 12625 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 12626 TOKEN_STRING_INITIALIZER 12627 (struct cmd_vf_mac_anti_spoof_result, 12628 vf, "vf"); 12629 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 12630 TOKEN_STRING_INITIALIZER 12631 (struct cmd_vf_mac_anti_spoof_result, 12632 mac, "mac"); 12633 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 12634 TOKEN_STRING_INITIALIZER 12635 (struct cmd_vf_mac_anti_spoof_result, 12636 antispoof, "antispoof"); 12637 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 12638 TOKEN_NUM_INITIALIZER 12639 (struct cmd_vf_mac_anti_spoof_result, 12640 port_id, UINT16); 12641 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 12642 TOKEN_NUM_INITIALIZER 12643 (struct cmd_vf_mac_anti_spoof_result, 12644 vf_id, UINT32); 12645 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 12646 TOKEN_STRING_INITIALIZER 12647 (struct cmd_vf_mac_anti_spoof_result, 12648 on_off, "on#off"); 12649 12650 static void 12651 cmd_set_vf_mac_anti_spoof_parsed( 12652 void *parsed_result, 12653 __attribute__((unused)) struct cmdline *cl, 12654 __attribute__((unused)) void *data) 12655 { 12656 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 12657 int ret = -ENOTSUP; 12658 12659 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12660 12661 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12662 return; 12663 12664 #ifdef RTE_LIBRTE_IXGBE_PMD 12665 if (ret == -ENOTSUP) 12666 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 12667 res->vf_id, is_on); 12668 #endif 12669 #ifdef RTE_LIBRTE_I40E_PMD 12670 if (ret == -ENOTSUP) 12671 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 12672 res->vf_id, is_on); 12673 #endif 12674 #ifdef RTE_LIBRTE_BNXT_PMD 12675 if (ret == -ENOTSUP) 12676 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 12677 res->vf_id, is_on); 12678 #endif 12679 12680 switch (ret) { 12681 case 0: 12682 break; 12683 case -EINVAL: 12684 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 12685 break; 12686 case -ENODEV: 12687 printf("invalid port_id %d\n", res->port_id); 12688 break; 12689 case -ENOTSUP: 12690 printf("function not implemented\n"); 12691 break; 12692 default: 12693 printf("programming error: (%s)\n", strerror(-ret)); 12694 } 12695 } 12696 12697 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 12698 .f = cmd_set_vf_mac_anti_spoof_parsed, 12699 .data = NULL, 12700 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 12701 .tokens = { 12702 (void *)&cmd_vf_mac_anti_spoof_set, 12703 (void *)&cmd_vf_mac_anti_spoof_vf, 12704 (void *)&cmd_vf_mac_anti_spoof_mac, 12705 (void *)&cmd_vf_mac_anti_spoof_antispoof, 12706 (void *)&cmd_vf_mac_anti_spoof_port_id, 12707 (void *)&cmd_vf_mac_anti_spoof_vf_id, 12708 (void *)&cmd_vf_mac_anti_spoof_on_off, 12709 NULL, 12710 }, 12711 }; 12712 12713 /* vf vlan strip queue configuration */ 12714 12715 /* Common result structure for vf mac anti spoof */ 12716 struct cmd_vf_vlan_stripq_result { 12717 cmdline_fixed_string_t set; 12718 cmdline_fixed_string_t vf; 12719 cmdline_fixed_string_t vlan; 12720 cmdline_fixed_string_t stripq; 12721 portid_t port_id; 12722 uint16_t vf_id; 12723 cmdline_fixed_string_t on_off; 12724 }; 12725 12726 /* Common CLI fields for vf vlan strip enable disable */ 12727 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 12728 TOKEN_STRING_INITIALIZER 12729 (struct cmd_vf_vlan_stripq_result, 12730 set, "set"); 12731 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 12732 TOKEN_STRING_INITIALIZER 12733 (struct cmd_vf_vlan_stripq_result, 12734 vf, "vf"); 12735 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 12736 TOKEN_STRING_INITIALIZER 12737 (struct cmd_vf_vlan_stripq_result, 12738 vlan, "vlan"); 12739 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 12740 TOKEN_STRING_INITIALIZER 12741 (struct cmd_vf_vlan_stripq_result, 12742 stripq, "stripq"); 12743 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 12744 TOKEN_NUM_INITIALIZER 12745 (struct cmd_vf_vlan_stripq_result, 12746 port_id, UINT16); 12747 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 12748 TOKEN_NUM_INITIALIZER 12749 (struct cmd_vf_vlan_stripq_result, 12750 vf_id, UINT16); 12751 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 12752 TOKEN_STRING_INITIALIZER 12753 (struct cmd_vf_vlan_stripq_result, 12754 on_off, "on#off"); 12755 12756 static void 12757 cmd_set_vf_vlan_stripq_parsed( 12758 void *parsed_result, 12759 __attribute__((unused)) struct cmdline *cl, 12760 __attribute__((unused)) void *data) 12761 { 12762 struct cmd_vf_vlan_stripq_result *res = parsed_result; 12763 int ret = -ENOTSUP; 12764 12765 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12766 12767 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12768 return; 12769 12770 #ifdef RTE_LIBRTE_IXGBE_PMD 12771 if (ret == -ENOTSUP) 12772 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 12773 res->vf_id, is_on); 12774 #endif 12775 #ifdef RTE_LIBRTE_I40E_PMD 12776 if (ret == -ENOTSUP) 12777 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 12778 res->vf_id, is_on); 12779 #endif 12780 #ifdef RTE_LIBRTE_BNXT_PMD 12781 if (ret == -ENOTSUP) 12782 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 12783 res->vf_id, is_on); 12784 #endif 12785 12786 switch (ret) { 12787 case 0: 12788 break; 12789 case -EINVAL: 12790 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 12791 break; 12792 case -ENODEV: 12793 printf("invalid port_id %d\n", res->port_id); 12794 break; 12795 case -ENOTSUP: 12796 printf("function not implemented\n"); 12797 break; 12798 default: 12799 printf("programming error: (%s)\n", strerror(-ret)); 12800 } 12801 } 12802 12803 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 12804 .f = cmd_set_vf_vlan_stripq_parsed, 12805 .data = NULL, 12806 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 12807 .tokens = { 12808 (void *)&cmd_vf_vlan_stripq_set, 12809 (void *)&cmd_vf_vlan_stripq_vf, 12810 (void *)&cmd_vf_vlan_stripq_vlan, 12811 (void *)&cmd_vf_vlan_stripq_stripq, 12812 (void *)&cmd_vf_vlan_stripq_port_id, 12813 (void *)&cmd_vf_vlan_stripq_vf_id, 12814 (void *)&cmd_vf_vlan_stripq_on_off, 12815 NULL, 12816 }, 12817 }; 12818 12819 /* vf vlan insert configuration */ 12820 12821 /* Common result structure for vf vlan insert */ 12822 struct cmd_vf_vlan_insert_result { 12823 cmdline_fixed_string_t set; 12824 cmdline_fixed_string_t vf; 12825 cmdline_fixed_string_t vlan; 12826 cmdline_fixed_string_t insert; 12827 portid_t port_id; 12828 uint16_t vf_id; 12829 uint16_t vlan_id; 12830 }; 12831 12832 /* Common CLI fields for vf vlan insert enable disable */ 12833 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 12834 TOKEN_STRING_INITIALIZER 12835 (struct cmd_vf_vlan_insert_result, 12836 set, "set"); 12837 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 12838 TOKEN_STRING_INITIALIZER 12839 (struct cmd_vf_vlan_insert_result, 12840 vf, "vf"); 12841 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 12842 TOKEN_STRING_INITIALIZER 12843 (struct cmd_vf_vlan_insert_result, 12844 vlan, "vlan"); 12845 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 12846 TOKEN_STRING_INITIALIZER 12847 (struct cmd_vf_vlan_insert_result, 12848 insert, "insert"); 12849 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 12850 TOKEN_NUM_INITIALIZER 12851 (struct cmd_vf_vlan_insert_result, 12852 port_id, UINT16); 12853 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 12854 TOKEN_NUM_INITIALIZER 12855 (struct cmd_vf_vlan_insert_result, 12856 vf_id, UINT16); 12857 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 12858 TOKEN_NUM_INITIALIZER 12859 (struct cmd_vf_vlan_insert_result, 12860 vlan_id, UINT16); 12861 12862 static void 12863 cmd_set_vf_vlan_insert_parsed( 12864 void *parsed_result, 12865 __attribute__((unused)) struct cmdline *cl, 12866 __attribute__((unused)) void *data) 12867 { 12868 struct cmd_vf_vlan_insert_result *res = parsed_result; 12869 int ret = -ENOTSUP; 12870 12871 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12872 return; 12873 12874 #ifdef RTE_LIBRTE_IXGBE_PMD 12875 if (ret == -ENOTSUP) 12876 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 12877 res->vlan_id); 12878 #endif 12879 #ifdef RTE_LIBRTE_I40E_PMD 12880 if (ret == -ENOTSUP) 12881 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 12882 res->vlan_id); 12883 #endif 12884 #ifdef RTE_LIBRTE_BNXT_PMD 12885 if (ret == -ENOTSUP) 12886 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 12887 res->vlan_id); 12888 #endif 12889 12890 switch (ret) { 12891 case 0: 12892 break; 12893 case -EINVAL: 12894 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); 12895 break; 12896 case -ENODEV: 12897 printf("invalid port_id %d\n", res->port_id); 12898 break; 12899 case -ENOTSUP: 12900 printf("function not implemented\n"); 12901 break; 12902 default: 12903 printf("programming error: (%s)\n", strerror(-ret)); 12904 } 12905 } 12906 12907 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 12908 .f = cmd_set_vf_vlan_insert_parsed, 12909 .data = NULL, 12910 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 12911 .tokens = { 12912 (void *)&cmd_vf_vlan_insert_set, 12913 (void *)&cmd_vf_vlan_insert_vf, 12914 (void *)&cmd_vf_vlan_insert_vlan, 12915 (void *)&cmd_vf_vlan_insert_insert, 12916 (void *)&cmd_vf_vlan_insert_port_id, 12917 (void *)&cmd_vf_vlan_insert_vf_id, 12918 (void *)&cmd_vf_vlan_insert_vlan_id, 12919 NULL, 12920 }, 12921 }; 12922 12923 /* tx loopback configuration */ 12924 12925 /* Common result structure for tx loopback */ 12926 struct cmd_tx_loopback_result { 12927 cmdline_fixed_string_t set; 12928 cmdline_fixed_string_t tx; 12929 cmdline_fixed_string_t loopback; 12930 portid_t port_id; 12931 cmdline_fixed_string_t on_off; 12932 }; 12933 12934 /* Common CLI fields for tx loopback enable disable */ 12935 cmdline_parse_token_string_t cmd_tx_loopback_set = 12936 TOKEN_STRING_INITIALIZER 12937 (struct cmd_tx_loopback_result, 12938 set, "set"); 12939 cmdline_parse_token_string_t cmd_tx_loopback_tx = 12940 TOKEN_STRING_INITIALIZER 12941 (struct cmd_tx_loopback_result, 12942 tx, "tx"); 12943 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 12944 TOKEN_STRING_INITIALIZER 12945 (struct cmd_tx_loopback_result, 12946 loopback, "loopback"); 12947 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 12948 TOKEN_NUM_INITIALIZER 12949 (struct cmd_tx_loopback_result, 12950 port_id, UINT16); 12951 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 12952 TOKEN_STRING_INITIALIZER 12953 (struct cmd_tx_loopback_result, 12954 on_off, "on#off"); 12955 12956 static void 12957 cmd_set_tx_loopback_parsed( 12958 void *parsed_result, 12959 __attribute__((unused)) struct cmdline *cl, 12960 __attribute__((unused)) void *data) 12961 { 12962 struct cmd_tx_loopback_result *res = parsed_result; 12963 int ret = -ENOTSUP; 12964 12965 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12966 12967 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12968 return; 12969 12970 #ifdef RTE_LIBRTE_IXGBE_PMD 12971 if (ret == -ENOTSUP) 12972 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 12973 #endif 12974 #ifdef RTE_LIBRTE_I40E_PMD 12975 if (ret == -ENOTSUP) 12976 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 12977 #endif 12978 #ifdef RTE_LIBRTE_BNXT_PMD 12979 if (ret == -ENOTSUP) 12980 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 12981 #endif 12982 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 12983 if (ret == -ENOTSUP) 12984 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 12985 #endif 12986 12987 switch (ret) { 12988 case 0: 12989 break; 12990 case -EINVAL: 12991 printf("invalid is_on %d\n", is_on); 12992 break; 12993 case -ENODEV: 12994 printf("invalid port_id %d\n", res->port_id); 12995 break; 12996 case -ENOTSUP: 12997 printf("function not implemented\n"); 12998 break; 12999 default: 13000 printf("programming error: (%s)\n", strerror(-ret)); 13001 } 13002 } 13003 13004 cmdline_parse_inst_t cmd_set_tx_loopback = { 13005 .f = cmd_set_tx_loopback_parsed, 13006 .data = NULL, 13007 .help_str = "set tx loopback <port_id> on|off", 13008 .tokens = { 13009 (void *)&cmd_tx_loopback_set, 13010 (void *)&cmd_tx_loopback_tx, 13011 (void *)&cmd_tx_loopback_loopback, 13012 (void *)&cmd_tx_loopback_port_id, 13013 (void *)&cmd_tx_loopback_on_off, 13014 NULL, 13015 }, 13016 }; 13017 13018 /* all queues drop enable configuration */ 13019 13020 /* Common result structure for all queues drop enable */ 13021 struct cmd_all_queues_drop_en_result { 13022 cmdline_fixed_string_t set; 13023 cmdline_fixed_string_t all; 13024 cmdline_fixed_string_t queues; 13025 cmdline_fixed_string_t drop; 13026 portid_t port_id; 13027 cmdline_fixed_string_t on_off; 13028 }; 13029 13030 /* Common CLI fields for tx loopback enable disable */ 13031 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 13032 TOKEN_STRING_INITIALIZER 13033 (struct cmd_all_queues_drop_en_result, 13034 set, "set"); 13035 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 13036 TOKEN_STRING_INITIALIZER 13037 (struct cmd_all_queues_drop_en_result, 13038 all, "all"); 13039 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 13040 TOKEN_STRING_INITIALIZER 13041 (struct cmd_all_queues_drop_en_result, 13042 queues, "queues"); 13043 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 13044 TOKEN_STRING_INITIALIZER 13045 (struct cmd_all_queues_drop_en_result, 13046 drop, "drop"); 13047 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 13048 TOKEN_NUM_INITIALIZER 13049 (struct cmd_all_queues_drop_en_result, 13050 port_id, UINT16); 13051 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 13052 TOKEN_STRING_INITIALIZER 13053 (struct cmd_all_queues_drop_en_result, 13054 on_off, "on#off"); 13055 13056 static void 13057 cmd_set_all_queues_drop_en_parsed( 13058 void *parsed_result, 13059 __attribute__((unused)) struct cmdline *cl, 13060 __attribute__((unused)) void *data) 13061 { 13062 struct cmd_all_queues_drop_en_result *res = parsed_result; 13063 int ret = -ENOTSUP; 13064 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13065 13066 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13067 return; 13068 13069 #ifdef RTE_LIBRTE_IXGBE_PMD 13070 if (ret == -ENOTSUP) 13071 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 13072 #endif 13073 #ifdef RTE_LIBRTE_BNXT_PMD 13074 if (ret == -ENOTSUP) 13075 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 13076 #endif 13077 switch (ret) { 13078 case 0: 13079 break; 13080 case -EINVAL: 13081 printf("invalid is_on %d\n", is_on); 13082 break; 13083 case -ENODEV: 13084 printf("invalid port_id %d\n", res->port_id); 13085 break; 13086 case -ENOTSUP: 13087 printf("function not implemented\n"); 13088 break; 13089 default: 13090 printf("programming error: (%s)\n", strerror(-ret)); 13091 } 13092 } 13093 13094 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 13095 .f = cmd_set_all_queues_drop_en_parsed, 13096 .data = NULL, 13097 .help_str = "set all queues drop <port_id> on|off", 13098 .tokens = { 13099 (void *)&cmd_all_queues_drop_en_set, 13100 (void *)&cmd_all_queues_drop_en_all, 13101 (void *)&cmd_all_queues_drop_en_queues, 13102 (void *)&cmd_all_queues_drop_en_drop, 13103 (void *)&cmd_all_queues_drop_en_port_id, 13104 (void *)&cmd_all_queues_drop_en_on_off, 13105 NULL, 13106 }, 13107 }; 13108 13109 /* vf split drop enable configuration */ 13110 13111 /* Common result structure for vf split drop enable */ 13112 struct cmd_vf_split_drop_en_result { 13113 cmdline_fixed_string_t set; 13114 cmdline_fixed_string_t vf; 13115 cmdline_fixed_string_t split; 13116 cmdline_fixed_string_t drop; 13117 portid_t port_id; 13118 uint16_t vf_id; 13119 cmdline_fixed_string_t on_off; 13120 }; 13121 13122 /* Common CLI fields for vf split drop enable disable */ 13123 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 13124 TOKEN_STRING_INITIALIZER 13125 (struct cmd_vf_split_drop_en_result, 13126 set, "set"); 13127 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 13128 TOKEN_STRING_INITIALIZER 13129 (struct cmd_vf_split_drop_en_result, 13130 vf, "vf"); 13131 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 13132 TOKEN_STRING_INITIALIZER 13133 (struct cmd_vf_split_drop_en_result, 13134 split, "split"); 13135 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 13136 TOKEN_STRING_INITIALIZER 13137 (struct cmd_vf_split_drop_en_result, 13138 drop, "drop"); 13139 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 13140 TOKEN_NUM_INITIALIZER 13141 (struct cmd_vf_split_drop_en_result, 13142 port_id, UINT16); 13143 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 13144 TOKEN_NUM_INITIALIZER 13145 (struct cmd_vf_split_drop_en_result, 13146 vf_id, UINT16); 13147 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 13148 TOKEN_STRING_INITIALIZER 13149 (struct cmd_vf_split_drop_en_result, 13150 on_off, "on#off"); 13151 13152 static void 13153 cmd_set_vf_split_drop_en_parsed( 13154 void *parsed_result, 13155 __attribute__((unused)) struct cmdline *cl, 13156 __attribute__((unused)) void *data) 13157 { 13158 struct cmd_vf_split_drop_en_result *res = parsed_result; 13159 int ret = -ENOTSUP; 13160 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13161 13162 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13163 return; 13164 13165 #ifdef RTE_LIBRTE_IXGBE_PMD 13166 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 13167 is_on); 13168 #endif 13169 switch (ret) { 13170 case 0: 13171 break; 13172 case -EINVAL: 13173 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13174 break; 13175 case -ENODEV: 13176 printf("invalid port_id %d\n", res->port_id); 13177 break; 13178 case -ENOTSUP: 13179 printf("not supported on port %d\n", res->port_id); 13180 break; 13181 default: 13182 printf("programming error: (%s)\n", strerror(-ret)); 13183 } 13184 } 13185 13186 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 13187 .f = cmd_set_vf_split_drop_en_parsed, 13188 .data = NULL, 13189 .help_str = "set vf split drop <port_id> <vf_id> on|off", 13190 .tokens = { 13191 (void *)&cmd_vf_split_drop_en_set, 13192 (void *)&cmd_vf_split_drop_en_vf, 13193 (void *)&cmd_vf_split_drop_en_split, 13194 (void *)&cmd_vf_split_drop_en_drop, 13195 (void *)&cmd_vf_split_drop_en_port_id, 13196 (void *)&cmd_vf_split_drop_en_vf_id, 13197 (void *)&cmd_vf_split_drop_en_on_off, 13198 NULL, 13199 }, 13200 }; 13201 13202 /* vf mac address configuration */ 13203 13204 /* Common result structure for vf mac address */ 13205 struct cmd_set_vf_mac_addr_result { 13206 cmdline_fixed_string_t set; 13207 cmdline_fixed_string_t vf; 13208 cmdline_fixed_string_t mac; 13209 cmdline_fixed_string_t addr; 13210 portid_t port_id; 13211 uint16_t vf_id; 13212 struct ether_addr mac_addr; 13213 13214 }; 13215 13216 /* Common CLI fields for vf split drop enable disable */ 13217 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 13218 TOKEN_STRING_INITIALIZER 13219 (struct cmd_set_vf_mac_addr_result, 13220 set, "set"); 13221 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 13222 TOKEN_STRING_INITIALIZER 13223 (struct cmd_set_vf_mac_addr_result, 13224 vf, "vf"); 13225 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 13226 TOKEN_STRING_INITIALIZER 13227 (struct cmd_set_vf_mac_addr_result, 13228 mac, "mac"); 13229 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 13230 TOKEN_STRING_INITIALIZER 13231 (struct cmd_set_vf_mac_addr_result, 13232 addr, "addr"); 13233 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 13234 TOKEN_NUM_INITIALIZER 13235 (struct cmd_set_vf_mac_addr_result, 13236 port_id, UINT16); 13237 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 13238 TOKEN_NUM_INITIALIZER 13239 (struct cmd_set_vf_mac_addr_result, 13240 vf_id, UINT16); 13241 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 13242 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 13243 mac_addr); 13244 13245 static void 13246 cmd_set_vf_mac_addr_parsed( 13247 void *parsed_result, 13248 __attribute__((unused)) struct cmdline *cl, 13249 __attribute__((unused)) void *data) 13250 { 13251 struct cmd_set_vf_mac_addr_result *res = parsed_result; 13252 int ret = -ENOTSUP; 13253 13254 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13255 return; 13256 13257 #ifdef RTE_LIBRTE_IXGBE_PMD 13258 if (ret == -ENOTSUP) 13259 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 13260 &res->mac_addr); 13261 #endif 13262 #ifdef RTE_LIBRTE_I40E_PMD 13263 if (ret == -ENOTSUP) 13264 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 13265 &res->mac_addr); 13266 #endif 13267 #ifdef RTE_LIBRTE_BNXT_PMD 13268 if (ret == -ENOTSUP) 13269 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 13270 &res->mac_addr); 13271 #endif 13272 13273 switch (ret) { 13274 case 0: 13275 break; 13276 case -EINVAL: 13277 printf("invalid vf_id %d or mac_addr\n", res->vf_id); 13278 break; 13279 case -ENODEV: 13280 printf("invalid port_id %d\n", res->port_id); 13281 break; 13282 case -ENOTSUP: 13283 printf("function not implemented\n"); 13284 break; 13285 default: 13286 printf("programming error: (%s)\n", strerror(-ret)); 13287 } 13288 } 13289 13290 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 13291 .f = cmd_set_vf_mac_addr_parsed, 13292 .data = NULL, 13293 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 13294 .tokens = { 13295 (void *)&cmd_set_vf_mac_addr_set, 13296 (void *)&cmd_set_vf_mac_addr_vf, 13297 (void *)&cmd_set_vf_mac_addr_mac, 13298 (void *)&cmd_set_vf_mac_addr_addr, 13299 (void *)&cmd_set_vf_mac_addr_port_id, 13300 (void *)&cmd_set_vf_mac_addr_vf_id, 13301 (void *)&cmd_set_vf_mac_addr_mac_addr, 13302 NULL, 13303 }, 13304 }; 13305 13306 /* MACsec configuration */ 13307 13308 /* Common result structure for MACsec offload enable */ 13309 struct cmd_macsec_offload_on_result { 13310 cmdline_fixed_string_t set; 13311 cmdline_fixed_string_t macsec; 13312 cmdline_fixed_string_t offload; 13313 portid_t port_id; 13314 cmdline_fixed_string_t on; 13315 cmdline_fixed_string_t encrypt; 13316 cmdline_fixed_string_t en_on_off; 13317 cmdline_fixed_string_t replay_protect; 13318 cmdline_fixed_string_t rp_on_off; 13319 }; 13320 13321 /* Common CLI fields for MACsec offload disable */ 13322 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 13323 TOKEN_STRING_INITIALIZER 13324 (struct cmd_macsec_offload_on_result, 13325 set, "set"); 13326 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 13327 TOKEN_STRING_INITIALIZER 13328 (struct cmd_macsec_offload_on_result, 13329 macsec, "macsec"); 13330 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 13331 TOKEN_STRING_INITIALIZER 13332 (struct cmd_macsec_offload_on_result, 13333 offload, "offload"); 13334 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 13335 TOKEN_NUM_INITIALIZER 13336 (struct cmd_macsec_offload_on_result, 13337 port_id, UINT16); 13338 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 13339 TOKEN_STRING_INITIALIZER 13340 (struct cmd_macsec_offload_on_result, 13341 on, "on"); 13342 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 13343 TOKEN_STRING_INITIALIZER 13344 (struct cmd_macsec_offload_on_result, 13345 encrypt, "encrypt"); 13346 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 13347 TOKEN_STRING_INITIALIZER 13348 (struct cmd_macsec_offload_on_result, 13349 en_on_off, "on#off"); 13350 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 13351 TOKEN_STRING_INITIALIZER 13352 (struct cmd_macsec_offload_on_result, 13353 replay_protect, "replay-protect"); 13354 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 13355 TOKEN_STRING_INITIALIZER 13356 (struct cmd_macsec_offload_on_result, 13357 rp_on_off, "on#off"); 13358 13359 static void 13360 cmd_set_macsec_offload_on_parsed( 13361 void *parsed_result, 13362 __attribute__((unused)) struct cmdline *cl, 13363 __attribute__((unused)) void *data) 13364 { 13365 struct cmd_macsec_offload_on_result *res = parsed_result; 13366 int ret = -ENOTSUP; 13367 portid_t port_id = res->port_id; 13368 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 13369 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 13370 struct rte_eth_dev_info dev_info; 13371 13372 if (port_id_is_invalid(port_id, ENABLED_WARN)) 13373 return; 13374 if (!port_is_stopped(port_id)) { 13375 printf("Please stop port %d first\n", port_id); 13376 return; 13377 } 13378 13379 rte_eth_dev_info_get(port_id, &dev_info); 13380 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 13381 #ifdef RTE_LIBRTE_IXGBE_PMD 13382 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 13383 #endif 13384 } 13385 RTE_SET_USED(en); 13386 RTE_SET_USED(rp); 13387 13388 switch (ret) { 13389 case 0: 13390 ports[port_id].dev_conf.txmode.offloads |= 13391 DEV_TX_OFFLOAD_MACSEC_INSERT; 13392 cmd_reconfig_device_queue(port_id, 1, 1); 13393 break; 13394 case -ENODEV: 13395 printf("invalid port_id %d\n", port_id); 13396 break; 13397 case -ENOTSUP: 13398 printf("not supported on port %d\n", port_id); 13399 break; 13400 default: 13401 printf("programming error: (%s)\n", strerror(-ret)); 13402 } 13403 } 13404 13405 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 13406 .f = cmd_set_macsec_offload_on_parsed, 13407 .data = NULL, 13408 .help_str = "set macsec offload <port_id> on " 13409 "encrypt on|off replay-protect on|off", 13410 .tokens = { 13411 (void *)&cmd_macsec_offload_on_set, 13412 (void *)&cmd_macsec_offload_on_macsec, 13413 (void *)&cmd_macsec_offload_on_offload, 13414 (void *)&cmd_macsec_offload_on_port_id, 13415 (void *)&cmd_macsec_offload_on_on, 13416 (void *)&cmd_macsec_offload_on_encrypt, 13417 (void *)&cmd_macsec_offload_on_en_on_off, 13418 (void *)&cmd_macsec_offload_on_replay_protect, 13419 (void *)&cmd_macsec_offload_on_rp_on_off, 13420 NULL, 13421 }, 13422 }; 13423 13424 /* Common result structure for MACsec offload disable */ 13425 struct cmd_macsec_offload_off_result { 13426 cmdline_fixed_string_t set; 13427 cmdline_fixed_string_t macsec; 13428 cmdline_fixed_string_t offload; 13429 portid_t port_id; 13430 cmdline_fixed_string_t off; 13431 }; 13432 13433 /* Common CLI fields for MACsec offload disable */ 13434 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 13435 TOKEN_STRING_INITIALIZER 13436 (struct cmd_macsec_offload_off_result, 13437 set, "set"); 13438 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 13439 TOKEN_STRING_INITIALIZER 13440 (struct cmd_macsec_offload_off_result, 13441 macsec, "macsec"); 13442 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 13443 TOKEN_STRING_INITIALIZER 13444 (struct cmd_macsec_offload_off_result, 13445 offload, "offload"); 13446 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 13447 TOKEN_NUM_INITIALIZER 13448 (struct cmd_macsec_offload_off_result, 13449 port_id, UINT16); 13450 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 13451 TOKEN_STRING_INITIALIZER 13452 (struct cmd_macsec_offload_off_result, 13453 off, "off"); 13454 13455 static void 13456 cmd_set_macsec_offload_off_parsed( 13457 void *parsed_result, 13458 __attribute__((unused)) struct cmdline *cl, 13459 __attribute__((unused)) void *data) 13460 { 13461 struct cmd_macsec_offload_off_result *res = parsed_result; 13462 int ret = -ENOTSUP; 13463 struct rte_eth_dev_info dev_info; 13464 portid_t port_id = res->port_id; 13465 13466 if (port_id_is_invalid(port_id, ENABLED_WARN)) 13467 return; 13468 if (!port_is_stopped(port_id)) { 13469 printf("Please stop port %d first\n", port_id); 13470 return; 13471 } 13472 13473 rte_eth_dev_info_get(port_id, &dev_info); 13474 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 13475 #ifdef RTE_LIBRTE_IXGBE_PMD 13476 ret = rte_pmd_ixgbe_macsec_disable(port_id); 13477 #endif 13478 } 13479 switch (ret) { 13480 case 0: 13481 ports[port_id].dev_conf.txmode.offloads &= 13482 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 13483 cmd_reconfig_device_queue(port_id, 1, 1); 13484 break; 13485 case -ENODEV: 13486 printf("invalid port_id %d\n", port_id); 13487 break; 13488 case -ENOTSUP: 13489 printf("not supported on port %d\n", port_id); 13490 break; 13491 default: 13492 printf("programming error: (%s)\n", strerror(-ret)); 13493 } 13494 } 13495 13496 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 13497 .f = cmd_set_macsec_offload_off_parsed, 13498 .data = NULL, 13499 .help_str = "set macsec offload <port_id> off", 13500 .tokens = { 13501 (void *)&cmd_macsec_offload_off_set, 13502 (void *)&cmd_macsec_offload_off_macsec, 13503 (void *)&cmd_macsec_offload_off_offload, 13504 (void *)&cmd_macsec_offload_off_port_id, 13505 (void *)&cmd_macsec_offload_off_off, 13506 NULL, 13507 }, 13508 }; 13509 13510 /* Common result structure for MACsec secure connection configure */ 13511 struct cmd_macsec_sc_result { 13512 cmdline_fixed_string_t set; 13513 cmdline_fixed_string_t macsec; 13514 cmdline_fixed_string_t sc; 13515 cmdline_fixed_string_t tx_rx; 13516 portid_t port_id; 13517 struct ether_addr mac; 13518 uint16_t pi; 13519 }; 13520 13521 /* Common CLI fields for MACsec secure connection configure */ 13522 cmdline_parse_token_string_t cmd_macsec_sc_set = 13523 TOKEN_STRING_INITIALIZER 13524 (struct cmd_macsec_sc_result, 13525 set, "set"); 13526 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 13527 TOKEN_STRING_INITIALIZER 13528 (struct cmd_macsec_sc_result, 13529 macsec, "macsec"); 13530 cmdline_parse_token_string_t cmd_macsec_sc_sc = 13531 TOKEN_STRING_INITIALIZER 13532 (struct cmd_macsec_sc_result, 13533 sc, "sc"); 13534 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 13535 TOKEN_STRING_INITIALIZER 13536 (struct cmd_macsec_sc_result, 13537 tx_rx, "tx#rx"); 13538 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 13539 TOKEN_NUM_INITIALIZER 13540 (struct cmd_macsec_sc_result, 13541 port_id, UINT16); 13542 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 13543 TOKEN_ETHERADDR_INITIALIZER 13544 (struct cmd_macsec_sc_result, 13545 mac); 13546 cmdline_parse_token_num_t cmd_macsec_sc_pi = 13547 TOKEN_NUM_INITIALIZER 13548 (struct cmd_macsec_sc_result, 13549 pi, UINT16); 13550 13551 static void 13552 cmd_set_macsec_sc_parsed( 13553 void *parsed_result, 13554 __attribute__((unused)) struct cmdline *cl, 13555 __attribute__((unused)) void *data) 13556 { 13557 struct cmd_macsec_sc_result *res = parsed_result; 13558 int ret = -ENOTSUP; 13559 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 13560 13561 #ifdef RTE_LIBRTE_IXGBE_PMD 13562 ret = is_tx ? 13563 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 13564 res->mac.addr_bytes) : 13565 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 13566 res->mac.addr_bytes, res->pi); 13567 #endif 13568 RTE_SET_USED(is_tx); 13569 13570 switch (ret) { 13571 case 0: 13572 break; 13573 case -ENODEV: 13574 printf("invalid port_id %d\n", res->port_id); 13575 break; 13576 case -ENOTSUP: 13577 printf("not supported on port %d\n", res->port_id); 13578 break; 13579 default: 13580 printf("programming error: (%s)\n", strerror(-ret)); 13581 } 13582 } 13583 13584 cmdline_parse_inst_t cmd_set_macsec_sc = { 13585 .f = cmd_set_macsec_sc_parsed, 13586 .data = NULL, 13587 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 13588 .tokens = { 13589 (void *)&cmd_macsec_sc_set, 13590 (void *)&cmd_macsec_sc_macsec, 13591 (void *)&cmd_macsec_sc_sc, 13592 (void *)&cmd_macsec_sc_tx_rx, 13593 (void *)&cmd_macsec_sc_port_id, 13594 (void *)&cmd_macsec_sc_mac, 13595 (void *)&cmd_macsec_sc_pi, 13596 NULL, 13597 }, 13598 }; 13599 13600 /* Common result structure for MACsec secure connection configure */ 13601 struct cmd_macsec_sa_result { 13602 cmdline_fixed_string_t set; 13603 cmdline_fixed_string_t macsec; 13604 cmdline_fixed_string_t sa; 13605 cmdline_fixed_string_t tx_rx; 13606 portid_t port_id; 13607 uint8_t idx; 13608 uint8_t an; 13609 uint32_t pn; 13610 cmdline_fixed_string_t key; 13611 }; 13612 13613 /* Common CLI fields for MACsec secure connection configure */ 13614 cmdline_parse_token_string_t cmd_macsec_sa_set = 13615 TOKEN_STRING_INITIALIZER 13616 (struct cmd_macsec_sa_result, 13617 set, "set"); 13618 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 13619 TOKEN_STRING_INITIALIZER 13620 (struct cmd_macsec_sa_result, 13621 macsec, "macsec"); 13622 cmdline_parse_token_string_t cmd_macsec_sa_sa = 13623 TOKEN_STRING_INITIALIZER 13624 (struct cmd_macsec_sa_result, 13625 sa, "sa"); 13626 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 13627 TOKEN_STRING_INITIALIZER 13628 (struct cmd_macsec_sa_result, 13629 tx_rx, "tx#rx"); 13630 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 13631 TOKEN_NUM_INITIALIZER 13632 (struct cmd_macsec_sa_result, 13633 port_id, UINT16); 13634 cmdline_parse_token_num_t cmd_macsec_sa_idx = 13635 TOKEN_NUM_INITIALIZER 13636 (struct cmd_macsec_sa_result, 13637 idx, UINT8); 13638 cmdline_parse_token_num_t cmd_macsec_sa_an = 13639 TOKEN_NUM_INITIALIZER 13640 (struct cmd_macsec_sa_result, 13641 an, UINT8); 13642 cmdline_parse_token_num_t cmd_macsec_sa_pn = 13643 TOKEN_NUM_INITIALIZER 13644 (struct cmd_macsec_sa_result, 13645 pn, UINT32); 13646 cmdline_parse_token_string_t cmd_macsec_sa_key = 13647 TOKEN_STRING_INITIALIZER 13648 (struct cmd_macsec_sa_result, 13649 key, NULL); 13650 13651 static void 13652 cmd_set_macsec_sa_parsed( 13653 void *parsed_result, 13654 __attribute__((unused)) struct cmdline *cl, 13655 __attribute__((unused)) void *data) 13656 { 13657 struct cmd_macsec_sa_result *res = parsed_result; 13658 int ret = -ENOTSUP; 13659 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 13660 uint8_t key[16] = { 0 }; 13661 uint8_t xdgt0; 13662 uint8_t xdgt1; 13663 int key_len; 13664 int i; 13665 13666 key_len = strlen(res->key) / 2; 13667 if (key_len > 16) 13668 key_len = 16; 13669 13670 for (i = 0; i < key_len; i++) { 13671 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 13672 if (xdgt0 == 0xFF) 13673 return; 13674 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 13675 if (xdgt1 == 0xFF) 13676 return; 13677 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 13678 } 13679 13680 #ifdef RTE_LIBRTE_IXGBE_PMD 13681 ret = is_tx ? 13682 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 13683 res->idx, res->an, res->pn, key) : 13684 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 13685 res->idx, res->an, res->pn, key); 13686 #endif 13687 RTE_SET_USED(is_tx); 13688 RTE_SET_USED(key); 13689 13690 switch (ret) { 13691 case 0: 13692 break; 13693 case -EINVAL: 13694 printf("invalid idx %d or an %d\n", res->idx, res->an); 13695 break; 13696 case -ENODEV: 13697 printf("invalid port_id %d\n", res->port_id); 13698 break; 13699 case -ENOTSUP: 13700 printf("not supported on port %d\n", res->port_id); 13701 break; 13702 default: 13703 printf("programming error: (%s)\n", strerror(-ret)); 13704 } 13705 } 13706 13707 cmdline_parse_inst_t cmd_set_macsec_sa = { 13708 .f = cmd_set_macsec_sa_parsed, 13709 .data = NULL, 13710 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 13711 .tokens = { 13712 (void *)&cmd_macsec_sa_set, 13713 (void *)&cmd_macsec_sa_macsec, 13714 (void *)&cmd_macsec_sa_sa, 13715 (void *)&cmd_macsec_sa_tx_rx, 13716 (void *)&cmd_macsec_sa_port_id, 13717 (void *)&cmd_macsec_sa_idx, 13718 (void *)&cmd_macsec_sa_an, 13719 (void *)&cmd_macsec_sa_pn, 13720 (void *)&cmd_macsec_sa_key, 13721 NULL, 13722 }, 13723 }; 13724 13725 /* VF unicast promiscuous mode configuration */ 13726 13727 /* Common result structure for VF unicast promiscuous mode */ 13728 struct cmd_vf_promisc_result { 13729 cmdline_fixed_string_t set; 13730 cmdline_fixed_string_t vf; 13731 cmdline_fixed_string_t promisc; 13732 portid_t port_id; 13733 uint32_t vf_id; 13734 cmdline_fixed_string_t on_off; 13735 }; 13736 13737 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 13738 cmdline_parse_token_string_t cmd_vf_promisc_set = 13739 TOKEN_STRING_INITIALIZER 13740 (struct cmd_vf_promisc_result, 13741 set, "set"); 13742 cmdline_parse_token_string_t cmd_vf_promisc_vf = 13743 TOKEN_STRING_INITIALIZER 13744 (struct cmd_vf_promisc_result, 13745 vf, "vf"); 13746 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 13747 TOKEN_STRING_INITIALIZER 13748 (struct cmd_vf_promisc_result, 13749 promisc, "promisc"); 13750 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 13751 TOKEN_NUM_INITIALIZER 13752 (struct cmd_vf_promisc_result, 13753 port_id, UINT16); 13754 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 13755 TOKEN_NUM_INITIALIZER 13756 (struct cmd_vf_promisc_result, 13757 vf_id, UINT32); 13758 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 13759 TOKEN_STRING_INITIALIZER 13760 (struct cmd_vf_promisc_result, 13761 on_off, "on#off"); 13762 13763 static void 13764 cmd_set_vf_promisc_parsed( 13765 void *parsed_result, 13766 __attribute__((unused)) struct cmdline *cl, 13767 __attribute__((unused)) void *data) 13768 { 13769 struct cmd_vf_promisc_result *res = parsed_result; 13770 int ret = -ENOTSUP; 13771 13772 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13773 13774 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13775 return; 13776 13777 #ifdef RTE_LIBRTE_I40E_PMD 13778 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 13779 res->vf_id, is_on); 13780 #endif 13781 13782 switch (ret) { 13783 case 0: 13784 break; 13785 case -EINVAL: 13786 printf("invalid vf_id %d\n", res->vf_id); 13787 break; 13788 case -ENODEV: 13789 printf("invalid port_id %d\n", res->port_id); 13790 break; 13791 case -ENOTSUP: 13792 printf("function not implemented\n"); 13793 break; 13794 default: 13795 printf("programming error: (%s)\n", strerror(-ret)); 13796 } 13797 } 13798 13799 cmdline_parse_inst_t cmd_set_vf_promisc = { 13800 .f = cmd_set_vf_promisc_parsed, 13801 .data = NULL, 13802 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 13803 "Set unicast promiscuous mode for a VF from the PF", 13804 .tokens = { 13805 (void *)&cmd_vf_promisc_set, 13806 (void *)&cmd_vf_promisc_vf, 13807 (void *)&cmd_vf_promisc_promisc, 13808 (void *)&cmd_vf_promisc_port_id, 13809 (void *)&cmd_vf_promisc_vf_id, 13810 (void *)&cmd_vf_promisc_on_off, 13811 NULL, 13812 }, 13813 }; 13814 13815 /* VF multicast promiscuous mode configuration */ 13816 13817 /* Common result structure for VF multicast promiscuous mode */ 13818 struct cmd_vf_allmulti_result { 13819 cmdline_fixed_string_t set; 13820 cmdline_fixed_string_t vf; 13821 cmdline_fixed_string_t allmulti; 13822 portid_t port_id; 13823 uint32_t vf_id; 13824 cmdline_fixed_string_t on_off; 13825 }; 13826 13827 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 13828 cmdline_parse_token_string_t cmd_vf_allmulti_set = 13829 TOKEN_STRING_INITIALIZER 13830 (struct cmd_vf_allmulti_result, 13831 set, "set"); 13832 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 13833 TOKEN_STRING_INITIALIZER 13834 (struct cmd_vf_allmulti_result, 13835 vf, "vf"); 13836 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 13837 TOKEN_STRING_INITIALIZER 13838 (struct cmd_vf_allmulti_result, 13839 allmulti, "allmulti"); 13840 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 13841 TOKEN_NUM_INITIALIZER 13842 (struct cmd_vf_allmulti_result, 13843 port_id, UINT16); 13844 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 13845 TOKEN_NUM_INITIALIZER 13846 (struct cmd_vf_allmulti_result, 13847 vf_id, UINT32); 13848 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 13849 TOKEN_STRING_INITIALIZER 13850 (struct cmd_vf_allmulti_result, 13851 on_off, "on#off"); 13852 13853 static void 13854 cmd_set_vf_allmulti_parsed( 13855 void *parsed_result, 13856 __attribute__((unused)) struct cmdline *cl, 13857 __attribute__((unused)) void *data) 13858 { 13859 struct cmd_vf_allmulti_result *res = parsed_result; 13860 int ret = -ENOTSUP; 13861 13862 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13863 13864 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13865 return; 13866 13867 #ifdef RTE_LIBRTE_I40E_PMD 13868 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 13869 res->vf_id, is_on); 13870 #endif 13871 13872 switch (ret) { 13873 case 0: 13874 break; 13875 case -EINVAL: 13876 printf("invalid vf_id %d\n", res->vf_id); 13877 break; 13878 case -ENODEV: 13879 printf("invalid port_id %d\n", res->port_id); 13880 break; 13881 case -ENOTSUP: 13882 printf("function not implemented\n"); 13883 break; 13884 default: 13885 printf("programming error: (%s)\n", strerror(-ret)); 13886 } 13887 } 13888 13889 cmdline_parse_inst_t cmd_set_vf_allmulti = { 13890 .f = cmd_set_vf_allmulti_parsed, 13891 .data = NULL, 13892 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 13893 "Set multicast promiscuous mode for a VF from the PF", 13894 .tokens = { 13895 (void *)&cmd_vf_allmulti_set, 13896 (void *)&cmd_vf_allmulti_vf, 13897 (void *)&cmd_vf_allmulti_allmulti, 13898 (void *)&cmd_vf_allmulti_port_id, 13899 (void *)&cmd_vf_allmulti_vf_id, 13900 (void *)&cmd_vf_allmulti_on_off, 13901 NULL, 13902 }, 13903 }; 13904 13905 /* vf broadcast mode configuration */ 13906 13907 /* Common result structure for vf broadcast */ 13908 struct cmd_set_vf_broadcast_result { 13909 cmdline_fixed_string_t set; 13910 cmdline_fixed_string_t vf; 13911 cmdline_fixed_string_t broadcast; 13912 portid_t port_id; 13913 uint16_t vf_id; 13914 cmdline_fixed_string_t on_off; 13915 }; 13916 13917 /* Common CLI fields for vf broadcast enable disable */ 13918 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 13919 TOKEN_STRING_INITIALIZER 13920 (struct cmd_set_vf_broadcast_result, 13921 set, "set"); 13922 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 13923 TOKEN_STRING_INITIALIZER 13924 (struct cmd_set_vf_broadcast_result, 13925 vf, "vf"); 13926 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 13927 TOKEN_STRING_INITIALIZER 13928 (struct cmd_set_vf_broadcast_result, 13929 broadcast, "broadcast"); 13930 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 13931 TOKEN_NUM_INITIALIZER 13932 (struct cmd_set_vf_broadcast_result, 13933 port_id, UINT16); 13934 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 13935 TOKEN_NUM_INITIALIZER 13936 (struct cmd_set_vf_broadcast_result, 13937 vf_id, UINT16); 13938 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 13939 TOKEN_STRING_INITIALIZER 13940 (struct cmd_set_vf_broadcast_result, 13941 on_off, "on#off"); 13942 13943 static void 13944 cmd_set_vf_broadcast_parsed( 13945 void *parsed_result, 13946 __attribute__((unused)) struct cmdline *cl, 13947 __attribute__((unused)) void *data) 13948 { 13949 struct cmd_set_vf_broadcast_result *res = parsed_result; 13950 int ret = -ENOTSUP; 13951 13952 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13953 13954 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13955 return; 13956 13957 #ifdef RTE_LIBRTE_I40E_PMD 13958 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 13959 res->vf_id, is_on); 13960 #endif 13961 13962 switch (ret) { 13963 case 0: 13964 break; 13965 case -EINVAL: 13966 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13967 break; 13968 case -ENODEV: 13969 printf("invalid port_id %d\n", res->port_id); 13970 break; 13971 case -ENOTSUP: 13972 printf("function not implemented\n"); 13973 break; 13974 default: 13975 printf("programming error: (%s)\n", strerror(-ret)); 13976 } 13977 } 13978 13979 cmdline_parse_inst_t cmd_set_vf_broadcast = { 13980 .f = cmd_set_vf_broadcast_parsed, 13981 .data = NULL, 13982 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 13983 .tokens = { 13984 (void *)&cmd_set_vf_broadcast_set, 13985 (void *)&cmd_set_vf_broadcast_vf, 13986 (void *)&cmd_set_vf_broadcast_broadcast, 13987 (void *)&cmd_set_vf_broadcast_port_id, 13988 (void *)&cmd_set_vf_broadcast_vf_id, 13989 (void *)&cmd_set_vf_broadcast_on_off, 13990 NULL, 13991 }, 13992 }; 13993 13994 /* vf vlan tag configuration */ 13995 13996 /* Common result structure for vf vlan tag */ 13997 struct cmd_set_vf_vlan_tag_result { 13998 cmdline_fixed_string_t set; 13999 cmdline_fixed_string_t vf; 14000 cmdline_fixed_string_t vlan; 14001 cmdline_fixed_string_t tag; 14002 portid_t port_id; 14003 uint16_t vf_id; 14004 cmdline_fixed_string_t on_off; 14005 }; 14006 14007 /* Common CLI fields for vf vlan tag enable disable */ 14008 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 14009 TOKEN_STRING_INITIALIZER 14010 (struct cmd_set_vf_vlan_tag_result, 14011 set, "set"); 14012 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 14013 TOKEN_STRING_INITIALIZER 14014 (struct cmd_set_vf_vlan_tag_result, 14015 vf, "vf"); 14016 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 14017 TOKEN_STRING_INITIALIZER 14018 (struct cmd_set_vf_vlan_tag_result, 14019 vlan, "vlan"); 14020 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 14021 TOKEN_STRING_INITIALIZER 14022 (struct cmd_set_vf_vlan_tag_result, 14023 tag, "tag"); 14024 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 14025 TOKEN_NUM_INITIALIZER 14026 (struct cmd_set_vf_vlan_tag_result, 14027 port_id, UINT16); 14028 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 14029 TOKEN_NUM_INITIALIZER 14030 (struct cmd_set_vf_vlan_tag_result, 14031 vf_id, UINT16); 14032 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 14033 TOKEN_STRING_INITIALIZER 14034 (struct cmd_set_vf_vlan_tag_result, 14035 on_off, "on#off"); 14036 14037 static void 14038 cmd_set_vf_vlan_tag_parsed( 14039 void *parsed_result, 14040 __attribute__((unused)) struct cmdline *cl, 14041 __attribute__((unused)) void *data) 14042 { 14043 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 14044 int ret = -ENOTSUP; 14045 14046 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14047 14048 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14049 return; 14050 14051 #ifdef RTE_LIBRTE_I40E_PMD 14052 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 14053 res->vf_id, is_on); 14054 #endif 14055 14056 switch (ret) { 14057 case 0: 14058 break; 14059 case -EINVAL: 14060 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14061 break; 14062 case -ENODEV: 14063 printf("invalid port_id %d\n", res->port_id); 14064 break; 14065 case -ENOTSUP: 14066 printf("function not implemented\n"); 14067 break; 14068 default: 14069 printf("programming error: (%s)\n", strerror(-ret)); 14070 } 14071 } 14072 14073 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 14074 .f = cmd_set_vf_vlan_tag_parsed, 14075 .data = NULL, 14076 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 14077 .tokens = { 14078 (void *)&cmd_set_vf_vlan_tag_set, 14079 (void *)&cmd_set_vf_vlan_tag_vf, 14080 (void *)&cmd_set_vf_vlan_tag_vlan, 14081 (void *)&cmd_set_vf_vlan_tag_tag, 14082 (void *)&cmd_set_vf_vlan_tag_port_id, 14083 (void *)&cmd_set_vf_vlan_tag_vf_id, 14084 (void *)&cmd_set_vf_vlan_tag_on_off, 14085 NULL, 14086 }, 14087 }; 14088 14089 /* Common definition of VF and TC TX bandwidth configuration */ 14090 struct cmd_vf_tc_bw_result { 14091 cmdline_fixed_string_t set; 14092 cmdline_fixed_string_t vf; 14093 cmdline_fixed_string_t tc; 14094 cmdline_fixed_string_t tx; 14095 cmdline_fixed_string_t min_bw; 14096 cmdline_fixed_string_t max_bw; 14097 cmdline_fixed_string_t strict_link_prio; 14098 portid_t port_id; 14099 uint16_t vf_id; 14100 uint8_t tc_no; 14101 uint32_t bw; 14102 cmdline_fixed_string_t bw_list; 14103 uint8_t tc_map; 14104 }; 14105 14106 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 14107 TOKEN_STRING_INITIALIZER 14108 (struct cmd_vf_tc_bw_result, 14109 set, "set"); 14110 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 14111 TOKEN_STRING_INITIALIZER 14112 (struct cmd_vf_tc_bw_result, 14113 vf, "vf"); 14114 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 14115 TOKEN_STRING_INITIALIZER 14116 (struct cmd_vf_tc_bw_result, 14117 tc, "tc"); 14118 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 14119 TOKEN_STRING_INITIALIZER 14120 (struct cmd_vf_tc_bw_result, 14121 tx, "tx"); 14122 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 14123 TOKEN_STRING_INITIALIZER 14124 (struct cmd_vf_tc_bw_result, 14125 strict_link_prio, "strict-link-priority"); 14126 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 14127 TOKEN_STRING_INITIALIZER 14128 (struct cmd_vf_tc_bw_result, 14129 min_bw, "min-bandwidth"); 14130 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 14131 TOKEN_STRING_INITIALIZER 14132 (struct cmd_vf_tc_bw_result, 14133 max_bw, "max-bandwidth"); 14134 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 14135 TOKEN_NUM_INITIALIZER 14136 (struct cmd_vf_tc_bw_result, 14137 port_id, UINT16); 14138 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 14139 TOKEN_NUM_INITIALIZER 14140 (struct cmd_vf_tc_bw_result, 14141 vf_id, UINT16); 14142 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 14143 TOKEN_NUM_INITIALIZER 14144 (struct cmd_vf_tc_bw_result, 14145 tc_no, UINT8); 14146 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 14147 TOKEN_NUM_INITIALIZER 14148 (struct cmd_vf_tc_bw_result, 14149 bw, UINT32); 14150 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 14151 TOKEN_STRING_INITIALIZER 14152 (struct cmd_vf_tc_bw_result, 14153 bw_list, NULL); 14154 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 14155 TOKEN_NUM_INITIALIZER 14156 (struct cmd_vf_tc_bw_result, 14157 tc_map, UINT8); 14158 14159 /* VF max bandwidth setting */ 14160 static void 14161 cmd_vf_max_bw_parsed( 14162 void *parsed_result, 14163 __attribute__((unused)) struct cmdline *cl, 14164 __attribute__((unused)) void *data) 14165 { 14166 struct cmd_vf_tc_bw_result *res = parsed_result; 14167 int ret = -ENOTSUP; 14168 14169 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14170 return; 14171 14172 #ifdef RTE_LIBRTE_I40E_PMD 14173 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 14174 res->vf_id, res->bw); 14175 #endif 14176 14177 switch (ret) { 14178 case 0: 14179 break; 14180 case -EINVAL: 14181 printf("invalid vf_id %d or bandwidth %d\n", 14182 res->vf_id, res->bw); 14183 break; 14184 case -ENODEV: 14185 printf("invalid port_id %d\n", res->port_id); 14186 break; 14187 case -ENOTSUP: 14188 printf("function not implemented\n"); 14189 break; 14190 default: 14191 printf("programming error: (%s)\n", strerror(-ret)); 14192 } 14193 } 14194 14195 cmdline_parse_inst_t cmd_vf_max_bw = { 14196 .f = cmd_vf_max_bw_parsed, 14197 .data = NULL, 14198 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 14199 .tokens = { 14200 (void *)&cmd_vf_tc_bw_set, 14201 (void *)&cmd_vf_tc_bw_vf, 14202 (void *)&cmd_vf_tc_bw_tx, 14203 (void *)&cmd_vf_tc_bw_max_bw, 14204 (void *)&cmd_vf_tc_bw_port_id, 14205 (void *)&cmd_vf_tc_bw_vf_id, 14206 (void *)&cmd_vf_tc_bw_bw, 14207 NULL, 14208 }, 14209 }; 14210 14211 static int 14212 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 14213 uint8_t *tc_num, 14214 char *str) 14215 { 14216 uint32_t size; 14217 const char *p, *p0 = str; 14218 char s[256]; 14219 char *end; 14220 char *str_fld[16]; 14221 uint16_t i; 14222 int ret; 14223 14224 p = strchr(p0, '('); 14225 if (p == NULL) { 14226 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14227 return -1; 14228 } 14229 p++; 14230 p0 = strchr(p, ')'); 14231 if (p0 == NULL) { 14232 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14233 return -1; 14234 } 14235 size = p0 - p; 14236 if (size >= sizeof(s)) { 14237 printf("The string size exceeds the internal buffer size\n"); 14238 return -1; 14239 } 14240 snprintf(s, sizeof(s), "%.*s", size, p); 14241 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 14242 if (ret <= 0) { 14243 printf("Failed to get the bandwidth list. "); 14244 return -1; 14245 } 14246 *tc_num = ret; 14247 for (i = 0; i < ret; i++) 14248 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 14249 14250 return 0; 14251 } 14252 14253 /* TC min bandwidth setting */ 14254 static void 14255 cmd_vf_tc_min_bw_parsed( 14256 void *parsed_result, 14257 __attribute__((unused)) struct cmdline *cl, 14258 __attribute__((unused)) void *data) 14259 { 14260 struct cmd_vf_tc_bw_result *res = parsed_result; 14261 uint8_t tc_num; 14262 uint8_t bw[16]; 14263 int ret = -ENOTSUP; 14264 14265 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14266 return; 14267 14268 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14269 if (ret) 14270 return; 14271 14272 #ifdef RTE_LIBRTE_I40E_PMD 14273 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 14274 tc_num, bw); 14275 #endif 14276 14277 switch (ret) { 14278 case 0: 14279 break; 14280 case -EINVAL: 14281 printf("invalid vf_id %d or bandwidth\n", res->vf_id); 14282 break; 14283 case -ENODEV: 14284 printf("invalid port_id %d\n", res->port_id); 14285 break; 14286 case -ENOTSUP: 14287 printf("function not implemented\n"); 14288 break; 14289 default: 14290 printf("programming error: (%s)\n", strerror(-ret)); 14291 } 14292 } 14293 14294 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 14295 .f = cmd_vf_tc_min_bw_parsed, 14296 .data = NULL, 14297 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 14298 " <bw1, bw2, ...>", 14299 .tokens = { 14300 (void *)&cmd_vf_tc_bw_set, 14301 (void *)&cmd_vf_tc_bw_vf, 14302 (void *)&cmd_vf_tc_bw_tc, 14303 (void *)&cmd_vf_tc_bw_tx, 14304 (void *)&cmd_vf_tc_bw_min_bw, 14305 (void *)&cmd_vf_tc_bw_port_id, 14306 (void *)&cmd_vf_tc_bw_vf_id, 14307 (void *)&cmd_vf_tc_bw_bw_list, 14308 NULL, 14309 }, 14310 }; 14311 14312 static void 14313 cmd_tc_min_bw_parsed( 14314 void *parsed_result, 14315 __attribute__((unused)) struct cmdline *cl, 14316 __attribute__((unused)) void *data) 14317 { 14318 struct cmd_vf_tc_bw_result *res = parsed_result; 14319 struct rte_port *port; 14320 uint8_t tc_num; 14321 uint8_t bw[16]; 14322 int ret = -ENOTSUP; 14323 14324 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14325 return; 14326 14327 port = &ports[res->port_id]; 14328 /** Check if the port is not started **/ 14329 if (port->port_status != RTE_PORT_STOPPED) { 14330 printf("Please stop port %d first\n", res->port_id); 14331 return; 14332 } 14333 14334 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14335 if (ret) 14336 return; 14337 14338 #ifdef RTE_LIBRTE_IXGBE_PMD 14339 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 14340 #endif 14341 14342 switch (ret) { 14343 case 0: 14344 break; 14345 case -EINVAL: 14346 printf("invalid bandwidth\n"); 14347 break; 14348 case -ENODEV: 14349 printf("invalid port_id %d\n", res->port_id); 14350 break; 14351 case -ENOTSUP: 14352 printf("function not implemented\n"); 14353 break; 14354 default: 14355 printf("programming error: (%s)\n", strerror(-ret)); 14356 } 14357 } 14358 14359 cmdline_parse_inst_t cmd_tc_min_bw = { 14360 .f = cmd_tc_min_bw_parsed, 14361 .data = NULL, 14362 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 14363 .tokens = { 14364 (void *)&cmd_vf_tc_bw_set, 14365 (void *)&cmd_vf_tc_bw_tc, 14366 (void *)&cmd_vf_tc_bw_tx, 14367 (void *)&cmd_vf_tc_bw_min_bw, 14368 (void *)&cmd_vf_tc_bw_port_id, 14369 (void *)&cmd_vf_tc_bw_bw_list, 14370 NULL, 14371 }, 14372 }; 14373 14374 /* TC max bandwidth setting */ 14375 static void 14376 cmd_vf_tc_max_bw_parsed( 14377 void *parsed_result, 14378 __attribute__((unused)) struct cmdline *cl, 14379 __attribute__((unused)) void *data) 14380 { 14381 struct cmd_vf_tc_bw_result *res = parsed_result; 14382 int ret = -ENOTSUP; 14383 14384 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14385 return; 14386 14387 #ifdef RTE_LIBRTE_I40E_PMD 14388 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 14389 res->tc_no, res->bw); 14390 #endif 14391 14392 switch (ret) { 14393 case 0: 14394 break; 14395 case -EINVAL: 14396 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n", 14397 res->vf_id, res->tc_no, res->bw); 14398 break; 14399 case -ENODEV: 14400 printf("invalid port_id %d\n", res->port_id); 14401 break; 14402 case -ENOTSUP: 14403 printf("function not implemented\n"); 14404 break; 14405 default: 14406 printf("programming error: (%s)\n", strerror(-ret)); 14407 } 14408 } 14409 14410 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 14411 .f = cmd_vf_tc_max_bw_parsed, 14412 .data = NULL, 14413 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 14414 " <bandwidth>", 14415 .tokens = { 14416 (void *)&cmd_vf_tc_bw_set, 14417 (void *)&cmd_vf_tc_bw_vf, 14418 (void *)&cmd_vf_tc_bw_tc, 14419 (void *)&cmd_vf_tc_bw_tx, 14420 (void *)&cmd_vf_tc_bw_max_bw, 14421 (void *)&cmd_vf_tc_bw_port_id, 14422 (void *)&cmd_vf_tc_bw_vf_id, 14423 (void *)&cmd_vf_tc_bw_tc_no, 14424 (void *)&cmd_vf_tc_bw_bw, 14425 NULL, 14426 }, 14427 }; 14428 14429 14430 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 14431 14432 /* *** Set Port default Traffic Management Hierarchy *** */ 14433 struct cmd_set_port_tm_hierarchy_default_result { 14434 cmdline_fixed_string_t set; 14435 cmdline_fixed_string_t port; 14436 cmdline_fixed_string_t tm; 14437 cmdline_fixed_string_t hierarchy; 14438 cmdline_fixed_string_t def; 14439 portid_t port_id; 14440 }; 14441 14442 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set = 14443 TOKEN_STRING_INITIALIZER( 14444 struct cmd_set_port_tm_hierarchy_default_result, set, "set"); 14445 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port = 14446 TOKEN_STRING_INITIALIZER( 14447 struct cmd_set_port_tm_hierarchy_default_result, port, "port"); 14448 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm = 14449 TOKEN_STRING_INITIALIZER( 14450 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm"); 14451 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy = 14452 TOKEN_STRING_INITIALIZER( 14453 struct cmd_set_port_tm_hierarchy_default_result, 14454 hierarchy, "hierarchy"); 14455 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default = 14456 TOKEN_STRING_INITIALIZER( 14457 struct cmd_set_port_tm_hierarchy_default_result, 14458 def, "default"); 14459 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id = 14460 TOKEN_NUM_INITIALIZER( 14461 struct cmd_set_port_tm_hierarchy_default_result, 14462 port_id, UINT16); 14463 14464 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result, 14465 __attribute__((unused)) struct cmdline *cl, 14466 __attribute__((unused)) void *data) 14467 { 14468 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result; 14469 struct rte_port *p; 14470 portid_t port_id = res->port_id; 14471 14472 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14473 return; 14474 14475 p = &ports[port_id]; 14476 14477 /* Port tm flag */ 14478 if (p->softport.tm_flag == 0) { 14479 printf(" tm not enabled on port %u (error)\n", port_id); 14480 return; 14481 } 14482 14483 /* Forward mode: tm */ 14484 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) { 14485 printf(" tm mode not enabled(error)\n"); 14486 return; 14487 } 14488 14489 /* Set the default tm hierarchy */ 14490 p->softport.tm.default_hierarchy_enable = 1; 14491 } 14492 14493 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = { 14494 .f = cmd_set_port_tm_hierarchy_default_parsed, 14495 .data = NULL, 14496 .help_str = "set port tm hierarchy default <port_id>", 14497 .tokens = { 14498 (void *)&cmd_set_port_tm_hierarchy_default_set, 14499 (void *)&cmd_set_port_tm_hierarchy_default_port, 14500 (void *)&cmd_set_port_tm_hierarchy_default_tm, 14501 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy, 14502 (void *)&cmd_set_port_tm_hierarchy_default_default, 14503 (void *)&cmd_set_port_tm_hierarchy_default_port_id, 14504 NULL, 14505 }, 14506 }; 14507 #endif 14508 14509 /* Strict link priority scheduling mode setting */ 14510 static void 14511 cmd_strict_link_prio_parsed( 14512 void *parsed_result, 14513 __attribute__((unused)) struct cmdline *cl, 14514 __attribute__((unused)) void *data) 14515 { 14516 struct cmd_vf_tc_bw_result *res = parsed_result; 14517 int ret = -ENOTSUP; 14518 14519 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14520 return; 14521 14522 #ifdef RTE_LIBRTE_I40E_PMD 14523 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 14524 #endif 14525 14526 switch (ret) { 14527 case 0: 14528 break; 14529 case -EINVAL: 14530 printf("invalid tc_bitmap 0x%x\n", res->tc_map); 14531 break; 14532 case -ENODEV: 14533 printf("invalid port_id %d\n", res->port_id); 14534 break; 14535 case -ENOTSUP: 14536 printf("function not implemented\n"); 14537 break; 14538 default: 14539 printf("programming error: (%s)\n", strerror(-ret)); 14540 } 14541 } 14542 14543 cmdline_parse_inst_t cmd_strict_link_prio = { 14544 .f = cmd_strict_link_prio_parsed, 14545 .data = NULL, 14546 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 14547 .tokens = { 14548 (void *)&cmd_vf_tc_bw_set, 14549 (void *)&cmd_vf_tc_bw_tx, 14550 (void *)&cmd_vf_tc_bw_strict_link_prio, 14551 (void *)&cmd_vf_tc_bw_port_id, 14552 (void *)&cmd_vf_tc_bw_tc_map, 14553 NULL, 14554 }, 14555 }; 14556 14557 /* Load dynamic device personalization*/ 14558 struct cmd_ddp_add_result { 14559 cmdline_fixed_string_t ddp; 14560 cmdline_fixed_string_t add; 14561 portid_t port_id; 14562 char filepath[]; 14563 }; 14564 14565 cmdline_parse_token_string_t cmd_ddp_add_ddp = 14566 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 14567 cmdline_parse_token_string_t cmd_ddp_add_add = 14568 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 14569 cmdline_parse_token_num_t cmd_ddp_add_port_id = 14570 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16); 14571 cmdline_parse_token_string_t cmd_ddp_add_filepath = 14572 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 14573 14574 static void 14575 cmd_ddp_add_parsed( 14576 void *parsed_result, 14577 __attribute__((unused)) struct cmdline *cl, 14578 __attribute__((unused)) void *data) 14579 { 14580 struct cmd_ddp_add_result *res = parsed_result; 14581 uint8_t *buff; 14582 uint32_t size; 14583 char *filepath; 14584 char *file_fld[2]; 14585 int file_num; 14586 int ret = -ENOTSUP; 14587 14588 if (!all_ports_stopped()) { 14589 printf("Please stop all ports first\n"); 14590 return; 14591 } 14592 14593 filepath = strdup(res->filepath); 14594 if (filepath == NULL) { 14595 printf("Failed to allocate memory\n"); 14596 return; 14597 } 14598 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 14599 14600 buff = open_file(file_fld[0], &size); 14601 if (!buff) { 14602 free((void *)filepath); 14603 return; 14604 } 14605 14606 #ifdef RTE_LIBRTE_I40E_PMD 14607 if (ret == -ENOTSUP) 14608 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 14609 buff, size, 14610 RTE_PMD_I40E_PKG_OP_WR_ADD); 14611 #endif 14612 14613 if (ret == -EEXIST) 14614 printf("Profile has already existed.\n"); 14615 else if (ret < 0) 14616 printf("Failed to load profile.\n"); 14617 else if (file_num == 2) 14618 save_file(file_fld[1], buff, size); 14619 14620 close_file(buff); 14621 free((void *)filepath); 14622 } 14623 14624 cmdline_parse_inst_t cmd_ddp_add = { 14625 .f = cmd_ddp_add_parsed, 14626 .data = NULL, 14627 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 14628 .tokens = { 14629 (void *)&cmd_ddp_add_ddp, 14630 (void *)&cmd_ddp_add_add, 14631 (void *)&cmd_ddp_add_port_id, 14632 (void *)&cmd_ddp_add_filepath, 14633 NULL, 14634 }, 14635 }; 14636 14637 /* Delete dynamic device personalization*/ 14638 struct cmd_ddp_del_result { 14639 cmdline_fixed_string_t ddp; 14640 cmdline_fixed_string_t del; 14641 portid_t port_id; 14642 char filepath[]; 14643 }; 14644 14645 cmdline_parse_token_string_t cmd_ddp_del_ddp = 14646 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 14647 cmdline_parse_token_string_t cmd_ddp_del_del = 14648 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 14649 cmdline_parse_token_num_t cmd_ddp_del_port_id = 14650 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16); 14651 cmdline_parse_token_string_t cmd_ddp_del_filepath = 14652 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 14653 14654 static void 14655 cmd_ddp_del_parsed( 14656 void *parsed_result, 14657 __attribute__((unused)) struct cmdline *cl, 14658 __attribute__((unused)) void *data) 14659 { 14660 struct cmd_ddp_del_result *res = parsed_result; 14661 uint8_t *buff; 14662 uint32_t size; 14663 int ret = -ENOTSUP; 14664 14665 if (!all_ports_stopped()) { 14666 printf("Please stop all ports first\n"); 14667 return; 14668 } 14669 14670 buff = open_file(res->filepath, &size); 14671 if (!buff) 14672 return; 14673 14674 #ifdef RTE_LIBRTE_I40E_PMD 14675 if (ret == -ENOTSUP) 14676 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 14677 buff, size, 14678 RTE_PMD_I40E_PKG_OP_WR_DEL); 14679 #endif 14680 14681 if (ret == -EACCES) 14682 printf("Profile does not exist.\n"); 14683 else if (ret < 0) 14684 printf("Failed to delete profile.\n"); 14685 14686 close_file(buff); 14687 } 14688 14689 cmdline_parse_inst_t cmd_ddp_del = { 14690 .f = cmd_ddp_del_parsed, 14691 .data = NULL, 14692 .help_str = "ddp del <port_id> <backup_profile_path>", 14693 .tokens = { 14694 (void *)&cmd_ddp_del_ddp, 14695 (void *)&cmd_ddp_del_del, 14696 (void *)&cmd_ddp_del_port_id, 14697 (void *)&cmd_ddp_del_filepath, 14698 NULL, 14699 }, 14700 }; 14701 14702 /* Get dynamic device personalization profile info */ 14703 struct cmd_ddp_info_result { 14704 cmdline_fixed_string_t ddp; 14705 cmdline_fixed_string_t get; 14706 cmdline_fixed_string_t info; 14707 char filepath[]; 14708 }; 14709 14710 cmdline_parse_token_string_t cmd_ddp_info_ddp = 14711 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 14712 cmdline_parse_token_string_t cmd_ddp_info_get = 14713 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 14714 cmdline_parse_token_string_t cmd_ddp_info_info = 14715 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 14716 cmdline_parse_token_string_t cmd_ddp_info_filepath = 14717 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 14718 14719 static void 14720 cmd_ddp_info_parsed( 14721 void *parsed_result, 14722 __attribute__((unused)) struct cmdline *cl, 14723 __attribute__((unused)) void *data) 14724 { 14725 struct cmd_ddp_info_result *res = parsed_result; 14726 uint8_t *pkg; 14727 uint32_t pkg_size; 14728 int ret = -ENOTSUP; 14729 #ifdef RTE_LIBRTE_I40E_PMD 14730 uint32_t i, j, n; 14731 uint8_t *buff; 14732 uint32_t buff_size = 0; 14733 struct rte_pmd_i40e_profile_info info; 14734 uint32_t dev_num = 0; 14735 struct rte_pmd_i40e_ddp_device_id *devs; 14736 uint32_t proto_num = 0; 14737 struct rte_pmd_i40e_proto_info *proto = NULL; 14738 uint32_t pctype_num = 0; 14739 struct rte_pmd_i40e_ptype_info *pctype; 14740 uint32_t ptype_num = 0; 14741 struct rte_pmd_i40e_ptype_info *ptype; 14742 uint8_t proto_id; 14743 14744 #endif 14745 14746 pkg = open_file(res->filepath, &pkg_size); 14747 if (!pkg) 14748 return; 14749 14750 #ifdef RTE_LIBRTE_I40E_PMD 14751 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14752 (uint8_t *)&info, sizeof(info), 14753 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 14754 if (!ret) { 14755 printf("Global Track id: 0x%x\n", info.track_id); 14756 printf("Global Version: %d.%d.%d.%d\n", 14757 info.version.major, 14758 info.version.minor, 14759 info.version.update, 14760 info.version.draft); 14761 printf("Global Package name: %s\n\n", info.name); 14762 } 14763 14764 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14765 (uint8_t *)&info, sizeof(info), 14766 RTE_PMD_I40E_PKG_INFO_HEADER); 14767 if (!ret) { 14768 printf("i40e Profile Track id: 0x%x\n", info.track_id); 14769 printf("i40e Profile Version: %d.%d.%d.%d\n", 14770 info.version.major, 14771 info.version.minor, 14772 info.version.update, 14773 info.version.draft); 14774 printf("i40e Profile name: %s\n\n", info.name); 14775 } 14776 14777 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14778 (uint8_t *)&buff_size, sizeof(buff_size), 14779 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 14780 if (!ret && buff_size) { 14781 buff = (uint8_t *)malloc(buff_size); 14782 if (buff) { 14783 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14784 buff, buff_size, 14785 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 14786 if (!ret) 14787 printf("Package Notes:\n%s\n\n", buff); 14788 free(buff); 14789 } 14790 } 14791 14792 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14793 (uint8_t *)&dev_num, sizeof(dev_num), 14794 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 14795 if (!ret && dev_num) { 14796 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 14797 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 14798 if (devs) { 14799 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14800 (uint8_t *)devs, buff_size, 14801 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 14802 if (!ret) { 14803 printf("List of supported devices:\n"); 14804 for (i = 0; i < dev_num; i++) { 14805 printf(" %04X:%04X %04X:%04X\n", 14806 devs[i].vendor_dev_id >> 16, 14807 devs[i].vendor_dev_id & 0xFFFF, 14808 devs[i].sub_vendor_dev_id >> 16, 14809 devs[i].sub_vendor_dev_id & 0xFFFF); 14810 } 14811 printf("\n"); 14812 } 14813 free(devs); 14814 } 14815 } 14816 14817 /* get information about protocols and packet types */ 14818 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14819 (uint8_t *)&proto_num, sizeof(proto_num), 14820 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 14821 if (ret || !proto_num) 14822 goto no_print_return; 14823 14824 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 14825 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 14826 if (!proto) 14827 goto no_print_return; 14828 14829 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 14830 buff_size, 14831 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 14832 if (!ret) { 14833 printf("List of used protocols:\n"); 14834 for (i = 0; i < proto_num; i++) 14835 printf(" %2u: %s\n", proto[i].proto_id, 14836 proto[i].name); 14837 printf("\n"); 14838 } 14839 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14840 (uint8_t *)&pctype_num, sizeof(pctype_num), 14841 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 14842 if (ret || !pctype_num) 14843 goto no_print_pctypes; 14844 14845 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 14846 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 14847 if (!pctype) 14848 goto no_print_pctypes; 14849 14850 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 14851 buff_size, 14852 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 14853 if (ret) { 14854 free(pctype); 14855 goto no_print_pctypes; 14856 } 14857 14858 printf("List of defined packet classification types:\n"); 14859 for (i = 0; i < pctype_num; i++) { 14860 printf(" %2u:", pctype[i].ptype_id); 14861 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 14862 proto_id = pctype[i].protocols[j]; 14863 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 14864 for (n = 0; n < proto_num; n++) { 14865 if (proto[n].proto_id == proto_id) { 14866 printf(" %s", proto[n].name); 14867 break; 14868 } 14869 } 14870 } 14871 } 14872 printf("\n"); 14873 } 14874 printf("\n"); 14875 free(pctype); 14876 14877 no_print_pctypes: 14878 14879 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 14880 sizeof(ptype_num), 14881 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 14882 if (ret || !ptype_num) 14883 goto no_print_return; 14884 14885 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 14886 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 14887 if (!ptype) 14888 goto no_print_return; 14889 14890 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 14891 buff_size, 14892 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 14893 if (ret) { 14894 free(ptype); 14895 goto no_print_return; 14896 } 14897 printf("List of defined packet types:\n"); 14898 for (i = 0; i < ptype_num; i++) { 14899 printf(" %2u:", ptype[i].ptype_id); 14900 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 14901 proto_id = ptype[i].protocols[j]; 14902 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 14903 for (n = 0; n < proto_num; n++) { 14904 if (proto[n].proto_id == proto_id) { 14905 printf(" %s", proto[n].name); 14906 break; 14907 } 14908 } 14909 } 14910 } 14911 printf("\n"); 14912 } 14913 free(ptype); 14914 printf("\n"); 14915 14916 ret = 0; 14917 no_print_return: 14918 if (proto) 14919 free(proto); 14920 #endif 14921 if (ret == -ENOTSUP) 14922 printf("Function not supported in PMD driver\n"); 14923 close_file(pkg); 14924 } 14925 14926 cmdline_parse_inst_t cmd_ddp_get_info = { 14927 .f = cmd_ddp_info_parsed, 14928 .data = NULL, 14929 .help_str = "ddp get info <profile_path>", 14930 .tokens = { 14931 (void *)&cmd_ddp_info_ddp, 14932 (void *)&cmd_ddp_info_get, 14933 (void *)&cmd_ddp_info_info, 14934 (void *)&cmd_ddp_info_filepath, 14935 NULL, 14936 }, 14937 }; 14938 14939 /* Get dynamic device personalization profile info list*/ 14940 #define PROFILE_INFO_SIZE 48 14941 #define MAX_PROFILE_NUM 16 14942 14943 struct cmd_ddp_get_list_result { 14944 cmdline_fixed_string_t ddp; 14945 cmdline_fixed_string_t get; 14946 cmdline_fixed_string_t list; 14947 portid_t port_id; 14948 }; 14949 14950 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 14951 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 14952 cmdline_parse_token_string_t cmd_ddp_get_list_get = 14953 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 14954 cmdline_parse_token_string_t cmd_ddp_get_list_list = 14955 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 14956 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 14957 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16); 14958 14959 static void 14960 cmd_ddp_get_list_parsed( 14961 __attribute__((unused)) void *parsed_result, 14962 __attribute__((unused)) struct cmdline *cl, 14963 __attribute__((unused)) void *data) 14964 { 14965 #ifdef RTE_LIBRTE_I40E_PMD 14966 struct cmd_ddp_get_list_result *res = parsed_result; 14967 struct rte_pmd_i40e_profile_list *p_list; 14968 struct rte_pmd_i40e_profile_info *p_info; 14969 uint32_t p_num; 14970 uint32_t size; 14971 uint32_t i; 14972 #endif 14973 int ret = -ENOTSUP; 14974 14975 #ifdef RTE_LIBRTE_I40E_PMD 14976 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 14977 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 14978 if (!p_list) 14979 printf("%s: Failed to malloc buffer\n", __func__); 14980 14981 if (ret == -ENOTSUP) 14982 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 14983 (uint8_t *)p_list, size); 14984 14985 if (!ret) { 14986 p_num = p_list->p_count; 14987 printf("Profile number is: %d\n\n", p_num); 14988 14989 for (i = 0; i < p_num; i++) { 14990 p_info = &p_list->p_info[i]; 14991 printf("Profile %d:\n", i); 14992 printf("Track id: 0x%x\n", p_info->track_id); 14993 printf("Version: %d.%d.%d.%d\n", 14994 p_info->version.major, 14995 p_info->version.minor, 14996 p_info->version.update, 14997 p_info->version.draft); 14998 printf("Profile name: %s\n\n", p_info->name); 14999 } 15000 } 15001 15002 free(p_list); 15003 #endif 15004 15005 if (ret < 0) 15006 printf("Failed to get ddp list\n"); 15007 } 15008 15009 cmdline_parse_inst_t cmd_ddp_get_list = { 15010 .f = cmd_ddp_get_list_parsed, 15011 .data = NULL, 15012 .help_str = "ddp get list <port_id>", 15013 .tokens = { 15014 (void *)&cmd_ddp_get_list_ddp, 15015 (void *)&cmd_ddp_get_list_get, 15016 (void *)&cmd_ddp_get_list_list, 15017 (void *)&cmd_ddp_get_list_port_id, 15018 NULL, 15019 }, 15020 }; 15021 15022 /* Configure input set */ 15023 struct cmd_cfg_input_set_result { 15024 cmdline_fixed_string_t port; 15025 cmdline_fixed_string_t cfg; 15026 portid_t port_id; 15027 cmdline_fixed_string_t pctype; 15028 uint8_t pctype_id; 15029 cmdline_fixed_string_t inset_type; 15030 cmdline_fixed_string_t opt; 15031 cmdline_fixed_string_t field; 15032 uint8_t field_idx; 15033 }; 15034 15035 static void 15036 cmd_cfg_input_set_parsed( 15037 __attribute__((unused)) void *parsed_result, 15038 __attribute__((unused)) struct cmdline *cl, 15039 __attribute__((unused)) void *data) 15040 { 15041 #ifdef RTE_LIBRTE_I40E_PMD 15042 struct cmd_cfg_input_set_result *res = parsed_result; 15043 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 15044 struct rte_pmd_i40e_inset inset; 15045 #endif 15046 int ret = -ENOTSUP; 15047 15048 if (!all_ports_stopped()) { 15049 printf("Please stop all ports first\n"); 15050 return; 15051 } 15052 15053 #ifdef RTE_LIBRTE_I40E_PMD 15054 if (!strcmp(res->inset_type, "hash_inset")) 15055 inset_type = INSET_HASH; 15056 else if (!strcmp(res->inset_type, "fdir_inset")) 15057 inset_type = INSET_FDIR; 15058 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 15059 inset_type = INSET_FDIR_FLX; 15060 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 15061 &inset, inset_type); 15062 if (ret) { 15063 printf("Failed to get input set.\n"); 15064 return; 15065 } 15066 15067 if (!strcmp(res->opt, "get")) { 15068 ret = rte_pmd_i40e_inset_field_get(inset.inset, 15069 res->field_idx); 15070 if (ret) 15071 printf("Field index %d is enabled.\n", res->field_idx); 15072 else 15073 printf("Field index %d is disabled.\n", res->field_idx); 15074 return; 15075 } else if (!strcmp(res->opt, "set")) 15076 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 15077 res->field_idx); 15078 else if (!strcmp(res->opt, "clear")) 15079 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 15080 res->field_idx); 15081 if (ret) { 15082 printf("Failed to configure input set field.\n"); 15083 return; 15084 } 15085 15086 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 15087 &inset, inset_type); 15088 if (ret) { 15089 printf("Failed to set input set.\n"); 15090 return; 15091 } 15092 #endif 15093 15094 if (ret == -ENOTSUP) 15095 printf("Function not supported\n"); 15096 } 15097 15098 cmdline_parse_token_string_t cmd_cfg_input_set_port = 15099 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15100 port, "port"); 15101 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 15102 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15103 cfg, "config"); 15104 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 15105 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 15106 port_id, UINT16); 15107 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 15108 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15109 pctype, "pctype"); 15110 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 15111 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 15112 pctype_id, UINT8); 15113 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 15114 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15115 inset_type, 15116 "hash_inset#fdir_inset#fdir_flx_inset"); 15117 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 15118 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15119 opt, "get#set#clear"); 15120 cmdline_parse_token_string_t cmd_cfg_input_set_field = 15121 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15122 field, "field"); 15123 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 15124 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 15125 field_idx, UINT8); 15126 15127 cmdline_parse_inst_t cmd_cfg_input_set = { 15128 .f = cmd_cfg_input_set_parsed, 15129 .data = NULL, 15130 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 15131 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 15132 .tokens = { 15133 (void *)&cmd_cfg_input_set_port, 15134 (void *)&cmd_cfg_input_set_cfg, 15135 (void *)&cmd_cfg_input_set_port_id, 15136 (void *)&cmd_cfg_input_set_pctype, 15137 (void *)&cmd_cfg_input_set_pctype_id, 15138 (void *)&cmd_cfg_input_set_inset_type, 15139 (void *)&cmd_cfg_input_set_opt, 15140 (void *)&cmd_cfg_input_set_field, 15141 (void *)&cmd_cfg_input_set_field_idx, 15142 NULL, 15143 }, 15144 }; 15145 15146 /* Clear input set */ 15147 struct cmd_clear_input_set_result { 15148 cmdline_fixed_string_t port; 15149 cmdline_fixed_string_t cfg; 15150 portid_t port_id; 15151 cmdline_fixed_string_t pctype; 15152 uint8_t pctype_id; 15153 cmdline_fixed_string_t inset_type; 15154 cmdline_fixed_string_t clear; 15155 cmdline_fixed_string_t all; 15156 }; 15157 15158 static void 15159 cmd_clear_input_set_parsed( 15160 __attribute__((unused)) void *parsed_result, 15161 __attribute__((unused)) struct cmdline *cl, 15162 __attribute__((unused)) void *data) 15163 { 15164 #ifdef RTE_LIBRTE_I40E_PMD 15165 struct cmd_clear_input_set_result *res = parsed_result; 15166 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 15167 struct rte_pmd_i40e_inset inset; 15168 #endif 15169 int ret = -ENOTSUP; 15170 15171 if (!all_ports_stopped()) { 15172 printf("Please stop all ports first\n"); 15173 return; 15174 } 15175 15176 #ifdef RTE_LIBRTE_I40E_PMD 15177 if (!strcmp(res->inset_type, "hash_inset")) 15178 inset_type = INSET_HASH; 15179 else if (!strcmp(res->inset_type, "fdir_inset")) 15180 inset_type = INSET_FDIR; 15181 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 15182 inset_type = INSET_FDIR_FLX; 15183 15184 memset(&inset, 0, sizeof(inset)); 15185 15186 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 15187 &inset, inset_type); 15188 if (ret) { 15189 printf("Failed to clear input set.\n"); 15190 return; 15191 } 15192 15193 #endif 15194 15195 if (ret == -ENOTSUP) 15196 printf("Function not supported\n"); 15197 } 15198 15199 cmdline_parse_token_string_t cmd_clear_input_set_port = 15200 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15201 port, "port"); 15202 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 15203 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15204 cfg, "config"); 15205 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 15206 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 15207 port_id, UINT16); 15208 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 15209 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15210 pctype, "pctype"); 15211 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 15212 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 15213 pctype_id, UINT8); 15214 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 15215 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15216 inset_type, 15217 "hash_inset#fdir_inset#fdir_flx_inset"); 15218 cmdline_parse_token_string_t cmd_clear_input_set_clear = 15219 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15220 clear, "clear"); 15221 cmdline_parse_token_string_t cmd_clear_input_set_all = 15222 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15223 all, "all"); 15224 15225 cmdline_parse_inst_t cmd_clear_input_set = { 15226 .f = cmd_clear_input_set_parsed, 15227 .data = NULL, 15228 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 15229 "fdir_inset|fdir_flx_inset clear all", 15230 .tokens = { 15231 (void *)&cmd_clear_input_set_port, 15232 (void *)&cmd_clear_input_set_cfg, 15233 (void *)&cmd_clear_input_set_port_id, 15234 (void *)&cmd_clear_input_set_pctype, 15235 (void *)&cmd_clear_input_set_pctype_id, 15236 (void *)&cmd_clear_input_set_inset_type, 15237 (void *)&cmd_clear_input_set_clear, 15238 (void *)&cmd_clear_input_set_all, 15239 NULL, 15240 }, 15241 }; 15242 15243 /* show vf stats */ 15244 15245 /* Common result structure for show vf stats */ 15246 struct cmd_show_vf_stats_result { 15247 cmdline_fixed_string_t show; 15248 cmdline_fixed_string_t vf; 15249 cmdline_fixed_string_t stats; 15250 portid_t port_id; 15251 uint16_t vf_id; 15252 }; 15253 15254 /* Common CLI fields show vf stats*/ 15255 cmdline_parse_token_string_t cmd_show_vf_stats_show = 15256 TOKEN_STRING_INITIALIZER 15257 (struct cmd_show_vf_stats_result, 15258 show, "show"); 15259 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 15260 TOKEN_STRING_INITIALIZER 15261 (struct cmd_show_vf_stats_result, 15262 vf, "vf"); 15263 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 15264 TOKEN_STRING_INITIALIZER 15265 (struct cmd_show_vf_stats_result, 15266 stats, "stats"); 15267 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 15268 TOKEN_NUM_INITIALIZER 15269 (struct cmd_show_vf_stats_result, 15270 port_id, UINT16); 15271 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 15272 TOKEN_NUM_INITIALIZER 15273 (struct cmd_show_vf_stats_result, 15274 vf_id, UINT16); 15275 15276 static void 15277 cmd_show_vf_stats_parsed( 15278 void *parsed_result, 15279 __attribute__((unused)) struct cmdline *cl, 15280 __attribute__((unused)) void *data) 15281 { 15282 struct cmd_show_vf_stats_result *res = parsed_result; 15283 struct rte_eth_stats stats; 15284 int ret = -ENOTSUP; 15285 static const char *nic_stats_border = "########################"; 15286 15287 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15288 return; 15289 15290 memset(&stats, 0, sizeof(stats)); 15291 15292 #ifdef RTE_LIBRTE_I40E_PMD 15293 if (ret == -ENOTSUP) 15294 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 15295 res->vf_id, 15296 &stats); 15297 #endif 15298 #ifdef RTE_LIBRTE_BNXT_PMD 15299 if (ret == -ENOTSUP) 15300 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 15301 res->vf_id, 15302 &stats); 15303 #endif 15304 15305 switch (ret) { 15306 case 0: 15307 break; 15308 case -EINVAL: 15309 printf("invalid vf_id %d\n", res->vf_id); 15310 break; 15311 case -ENODEV: 15312 printf("invalid port_id %d\n", res->port_id); 15313 break; 15314 case -ENOTSUP: 15315 printf("function not implemented\n"); 15316 break; 15317 default: 15318 printf("programming error: (%s)\n", strerror(-ret)); 15319 } 15320 15321 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 15322 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 15323 15324 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 15325 "%-"PRIu64"\n", 15326 stats.ipackets, stats.imissed, stats.ibytes); 15327 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 15328 printf(" RX-nombuf: %-10"PRIu64"\n", 15329 stats.rx_nombuf); 15330 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 15331 "%-"PRIu64"\n", 15332 stats.opackets, stats.oerrors, stats.obytes); 15333 15334 printf(" %s############################%s\n", 15335 nic_stats_border, nic_stats_border); 15336 } 15337 15338 cmdline_parse_inst_t cmd_show_vf_stats = { 15339 .f = cmd_show_vf_stats_parsed, 15340 .data = NULL, 15341 .help_str = "show vf stats <port_id> <vf_id>", 15342 .tokens = { 15343 (void *)&cmd_show_vf_stats_show, 15344 (void *)&cmd_show_vf_stats_vf, 15345 (void *)&cmd_show_vf_stats_stats, 15346 (void *)&cmd_show_vf_stats_port_id, 15347 (void *)&cmd_show_vf_stats_vf_id, 15348 NULL, 15349 }, 15350 }; 15351 15352 /* clear vf stats */ 15353 15354 /* Common result structure for clear vf stats */ 15355 struct cmd_clear_vf_stats_result { 15356 cmdline_fixed_string_t clear; 15357 cmdline_fixed_string_t vf; 15358 cmdline_fixed_string_t stats; 15359 portid_t port_id; 15360 uint16_t vf_id; 15361 }; 15362 15363 /* Common CLI fields clear vf stats*/ 15364 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 15365 TOKEN_STRING_INITIALIZER 15366 (struct cmd_clear_vf_stats_result, 15367 clear, "clear"); 15368 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 15369 TOKEN_STRING_INITIALIZER 15370 (struct cmd_clear_vf_stats_result, 15371 vf, "vf"); 15372 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 15373 TOKEN_STRING_INITIALIZER 15374 (struct cmd_clear_vf_stats_result, 15375 stats, "stats"); 15376 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 15377 TOKEN_NUM_INITIALIZER 15378 (struct cmd_clear_vf_stats_result, 15379 port_id, UINT16); 15380 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 15381 TOKEN_NUM_INITIALIZER 15382 (struct cmd_clear_vf_stats_result, 15383 vf_id, UINT16); 15384 15385 static void 15386 cmd_clear_vf_stats_parsed( 15387 void *parsed_result, 15388 __attribute__((unused)) struct cmdline *cl, 15389 __attribute__((unused)) void *data) 15390 { 15391 struct cmd_clear_vf_stats_result *res = parsed_result; 15392 int ret = -ENOTSUP; 15393 15394 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15395 return; 15396 15397 #ifdef RTE_LIBRTE_I40E_PMD 15398 if (ret == -ENOTSUP) 15399 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 15400 res->vf_id); 15401 #endif 15402 #ifdef RTE_LIBRTE_BNXT_PMD 15403 if (ret == -ENOTSUP) 15404 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 15405 res->vf_id); 15406 #endif 15407 15408 switch (ret) { 15409 case 0: 15410 break; 15411 case -EINVAL: 15412 printf("invalid vf_id %d\n", res->vf_id); 15413 break; 15414 case -ENODEV: 15415 printf("invalid port_id %d\n", res->port_id); 15416 break; 15417 case -ENOTSUP: 15418 printf("function not implemented\n"); 15419 break; 15420 default: 15421 printf("programming error: (%s)\n", strerror(-ret)); 15422 } 15423 } 15424 15425 cmdline_parse_inst_t cmd_clear_vf_stats = { 15426 .f = cmd_clear_vf_stats_parsed, 15427 .data = NULL, 15428 .help_str = "clear vf stats <port_id> <vf_id>", 15429 .tokens = { 15430 (void *)&cmd_clear_vf_stats_clear, 15431 (void *)&cmd_clear_vf_stats_vf, 15432 (void *)&cmd_clear_vf_stats_stats, 15433 (void *)&cmd_clear_vf_stats_port_id, 15434 (void *)&cmd_clear_vf_stats_vf_id, 15435 NULL, 15436 }, 15437 }; 15438 15439 /* port config pctype mapping reset */ 15440 15441 /* Common result structure for port config pctype mapping reset */ 15442 struct cmd_pctype_mapping_reset_result { 15443 cmdline_fixed_string_t port; 15444 cmdline_fixed_string_t config; 15445 portid_t port_id; 15446 cmdline_fixed_string_t pctype; 15447 cmdline_fixed_string_t mapping; 15448 cmdline_fixed_string_t reset; 15449 }; 15450 15451 /* Common CLI fields for port config pctype mapping reset*/ 15452 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 15453 TOKEN_STRING_INITIALIZER 15454 (struct cmd_pctype_mapping_reset_result, 15455 port, "port"); 15456 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 15457 TOKEN_STRING_INITIALIZER 15458 (struct cmd_pctype_mapping_reset_result, 15459 config, "config"); 15460 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 15461 TOKEN_NUM_INITIALIZER 15462 (struct cmd_pctype_mapping_reset_result, 15463 port_id, UINT16); 15464 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 15465 TOKEN_STRING_INITIALIZER 15466 (struct cmd_pctype_mapping_reset_result, 15467 pctype, "pctype"); 15468 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 15469 TOKEN_STRING_INITIALIZER 15470 (struct cmd_pctype_mapping_reset_result, 15471 mapping, "mapping"); 15472 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 15473 TOKEN_STRING_INITIALIZER 15474 (struct cmd_pctype_mapping_reset_result, 15475 reset, "reset"); 15476 15477 static void 15478 cmd_pctype_mapping_reset_parsed( 15479 void *parsed_result, 15480 __attribute__((unused)) struct cmdline *cl, 15481 __attribute__((unused)) void *data) 15482 { 15483 struct cmd_pctype_mapping_reset_result *res = parsed_result; 15484 int ret = -ENOTSUP; 15485 15486 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15487 return; 15488 15489 #ifdef RTE_LIBRTE_I40E_PMD 15490 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 15491 #endif 15492 15493 switch (ret) { 15494 case 0: 15495 break; 15496 case -ENODEV: 15497 printf("invalid port_id %d\n", res->port_id); 15498 break; 15499 case -ENOTSUP: 15500 printf("function not implemented\n"); 15501 break; 15502 default: 15503 printf("programming error: (%s)\n", strerror(-ret)); 15504 } 15505 } 15506 15507 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 15508 .f = cmd_pctype_mapping_reset_parsed, 15509 .data = NULL, 15510 .help_str = "port config <port_id> pctype mapping reset", 15511 .tokens = { 15512 (void *)&cmd_pctype_mapping_reset_port, 15513 (void *)&cmd_pctype_mapping_reset_config, 15514 (void *)&cmd_pctype_mapping_reset_port_id, 15515 (void *)&cmd_pctype_mapping_reset_pctype, 15516 (void *)&cmd_pctype_mapping_reset_mapping, 15517 (void *)&cmd_pctype_mapping_reset_reset, 15518 NULL, 15519 }, 15520 }; 15521 15522 /* show port pctype mapping */ 15523 15524 /* Common result structure for show port pctype mapping */ 15525 struct cmd_pctype_mapping_get_result { 15526 cmdline_fixed_string_t show; 15527 cmdline_fixed_string_t port; 15528 portid_t port_id; 15529 cmdline_fixed_string_t pctype; 15530 cmdline_fixed_string_t mapping; 15531 }; 15532 15533 /* Common CLI fields for pctype mapping get */ 15534 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 15535 TOKEN_STRING_INITIALIZER 15536 (struct cmd_pctype_mapping_get_result, 15537 show, "show"); 15538 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 15539 TOKEN_STRING_INITIALIZER 15540 (struct cmd_pctype_mapping_get_result, 15541 port, "port"); 15542 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 15543 TOKEN_NUM_INITIALIZER 15544 (struct cmd_pctype_mapping_get_result, 15545 port_id, UINT16); 15546 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 15547 TOKEN_STRING_INITIALIZER 15548 (struct cmd_pctype_mapping_get_result, 15549 pctype, "pctype"); 15550 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 15551 TOKEN_STRING_INITIALIZER 15552 (struct cmd_pctype_mapping_get_result, 15553 mapping, "mapping"); 15554 15555 static void 15556 cmd_pctype_mapping_get_parsed( 15557 void *parsed_result, 15558 __attribute__((unused)) struct cmdline *cl, 15559 __attribute__((unused)) void *data) 15560 { 15561 struct cmd_pctype_mapping_get_result *res = parsed_result; 15562 int ret = -ENOTSUP; 15563 #ifdef RTE_LIBRTE_I40E_PMD 15564 struct rte_pmd_i40e_flow_type_mapping 15565 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 15566 int i, j, first_pctype; 15567 #endif 15568 15569 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15570 return; 15571 15572 #ifdef RTE_LIBRTE_I40E_PMD 15573 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 15574 #endif 15575 15576 switch (ret) { 15577 case 0: 15578 break; 15579 case -ENODEV: 15580 printf("invalid port_id %d\n", res->port_id); 15581 return; 15582 case -ENOTSUP: 15583 printf("function not implemented\n"); 15584 return; 15585 default: 15586 printf("programming error: (%s)\n", strerror(-ret)); 15587 return; 15588 } 15589 15590 #ifdef RTE_LIBRTE_I40E_PMD 15591 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 15592 if (mapping[i].pctype != 0ULL) { 15593 first_pctype = 1; 15594 15595 printf("pctype: "); 15596 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 15597 if (mapping[i].pctype & (1ULL << j)) { 15598 printf(first_pctype ? 15599 "%02d" : ",%02d", j); 15600 first_pctype = 0; 15601 } 15602 } 15603 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 15604 } 15605 } 15606 #endif 15607 } 15608 15609 cmdline_parse_inst_t cmd_pctype_mapping_get = { 15610 .f = cmd_pctype_mapping_get_parsed, 15611 .data = NULL, 15612 .help_str = "show port <port_id> pctype mapping", 15613 .tokens = { 15614 (void *)&cmd_pctype_mapping_get_show, 15615 (void *)&cmd_pctype_mapping_get_port, 15616 (void *)&cmd_pctype_mapping_get_port_id, 15617 (void *)&cmd_pctype_mapping_get_pctype, 15618 (void *)&cmd_pctype_mapping_get_mapping, 15619 NULL, 15620 }, 15621 }; 15622 15623 /* port config pctype mapping update */ 15624 15625 /* Common result structure for port config pctype mapping update */ 15626 struct cmd_pctype_mapping_update_result { 15627 cmdline_fixed_string_t port; 15628 cmdline_fixed_string_t config; 15629 portid_t port_id; 15630 cmdline_fixed_string_t pctype; 15631 cmdline_fixed_string_t mapping; 15632 cmdline_fixed_string_t update; 15633 cmdline_fixed_string_t pctype_list; 15634 uint16_t flow_type; 15635 }; 15636 15637 /* Common CLI fields for pctype mapping update*/ 15638 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 15639 TOKEN_STRING_INITIALIZER 15640 (struct cmd_pctype_mapping_update_result, 15641 port, "port"); 15642 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 15643 TOKEN_STRING_INITIALIZER 15644 (struct cmd_pctype_mapping_update_result, 15645 config, "config"); 15646 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 15647 TOKEN_NUM_INITIALIZER 15648 (struct cmd_pctype_mapping_update_result, 15649 port_id, UINT16); 15650 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 15651 TOKEN_STRING_INITIALIZER 15652 (struct cmd_pctype_mapping_update_result, 15653 pctype, "pctype"); 15654 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 15655 TOKEN_STRING_INITIALIZER 15656 (struct cmd_pctype_mapping_update_result, 15657 mapping, "mapping"); 15658 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 15659 TOKEN_STRING_INITIALIZER 15660 (struct cmd_pctype_mapping_update_result, 15661 update, "update"); 15662 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 15663 TOKEN_STRING_INITIALIZER 15664 (struct cmd_pctype_mapping_update_result, 15665 pctype_list, NULL); 15666 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 15667 TOKEN_NUM_INITIALIZER 15668 (struct cmd_pctype_mapping_update_result, 15669 flow_type, UINT16); 15670 15671 static void 15672 cmd_pctype_mapping_update_parsed( 15673 void *parsed_result, 15674 __attribute__((unused)) struct cmdline *cl, 15675 __attribute__((unused)) void *data) 15676 { 15677 struct cmd_pctype_mapping_update_result *res = parsed_result; 15678 int ret = -ENOTSUP; 15679 #ifdef RTE_LIBRTE_I40E_PMD 15680 struct rte_pmd_i40e_flow_type_mapping mapping; 15681 unsigned int i; 15682 unsigned int nb_item; 15683 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 15684 #endif 15685 15686 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15687 return; 15688 15689 #ifdef RTE_LIBRTE_I40E_PMD 15690 nb_item = parse_item_list(res->pctype_list, "pctypes", 15691 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 15692 mapping.flow_type = res->flow_type; 15693 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 15694 mapping.pctype |= (1ULL << pctype_list[i]); 15695 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 15696 &mapping, 15697 1, 15698 0); 15699 #endif 15700 15701 switch (ret) { 15702 case 0: 15703 break; 15704 case -EINVAL: 15705 printf("invalid pctype or flow type\n"); 15706 break; 15707 case -ENODEV: 15708 printf("invalid port_id %d\n", res->port_id); 15709 break; 15710 case -ENOTSUP: 15711 printf("function not implemented\n"); 15712 break; 15713 default: 15714 printf("programming error: (%s)\n", strerror(-ret)); 15715 } 15716 } 15717 15718 cmdline_parse_inst_t cmd_pctype_mapping_update = { 15719 .f = cmd_pctype_mapping_update_parsed, 15720 .data = NULL, 15721 .help_str = "port config <port_id> pctype mapping update" 15722 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 15723 .tokens = { 15724 (void *)&cmd_pctype_mapping_update_port, 15725 (void *)&cmd_pctype_mapping_update_config, 15726 (void *)&cmd_pctype_mapping_update_port_id, 15727 (void *)&cmd_pctype_mapping_update_pctype, 15728 (void *)&cmd_pctype_mapping_update_mapping, 15729 (void *)&cmd_pctype_mapping_update_update, 15730 (void *)&cmd_pctype_mapping_update_pc_type, 15731 (void *)&cmd_pctype_mapping_update_flow_type, 15732 NULL, 15733 }, 15734 }; 15735 15736 /* ptype mapping get */ 15737 15738 /* Common result structure for ptype mapping get */ 15739 struct cmd_ptype_mapping_get_result { 15740 cmdline_fixed_string_t ptype; 15741 cmdline_fixed_string_t mapping; 15742 cmdline_fixed_string_t get; 15743 portid_t port_id; 15744 uint8_t valid_only; 15745 }; 15746 15747 /* Common CLI fields for ptype mapping get */ 15748 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 15749 TOKEN_STRING_INITIALIZER 15750 (struct cmd_ptype_mapping_get_result, 15751 ptype, "ptype"); 15752 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 15753 TOKEN_STRING_INITIALIZER 15754 (struct cmd_ptype_mapping_get_result, 15755 mapping, "mapping"); 15756 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 15757 TOKEN_STRING_INITIALIZER 15758 (struct cmd_ptype_mapping_get_result, 15759 get, "get"); 15760 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 15761 TOKEN_NUM_INITIALIZER 15762 (struct cmd_ptype_mapping_get_result, 15763 port_id, UINT16); 15764 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 15765 TOKEN_NUM_INITIALIZER 15766 (struct cmd_ptype_mapping_get_result, 15767 valid_only, UINT8); 15768 15769 static void 15770 cmd_ptype_mapping_get_parsed( 15771 void *parsed_result, 15772 __attribute__((unused)) struct cmdline *cl, 15773 __attribute__((unused)) void *data) 15774 { 15775 struct cmd_ptype_mapping_get_result *res = parsed_result; 15776 int ret = -ENOTSUP; 15777 #ifdef RTE_LIBRTE_I40E_PMD 15778 int max_ptype_num = 256; 15779 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 15780 uint16_t count; 15781 int i; 15782 #endif 15783 15784 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15785 return; 15786 15787 #ifdef RTE_LIBRTE_I40E_PMD 15788 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 15789 mapping, 15790 max_ptype_num, 15791 &count, 15792 res->valid_only); 15793 #endif 15794 15795 switch (ret) { 15796 case 0: 15797 break; 15798 case -ENODEV: 15799 printf("invalid port_id %d\n", res->port_id); 15800 break; 15801 case -ENOTSUP: 15802 printf("function not implemented\n"); 15803 break; 15804 default: 15805 printf("programming error: (%s)\n", strerror(-ret)); 15806 } 15807 15808 #ifdef RTE_LIBRTE_I40E_PMD 15809 if (!ret) { 15810 for (i = 0; i < count; i++) 15811 printf("%3d\t0x%08x\n", 15812 mapping[i].hw_ptype, mapping[i].sw_ptype); 15813 } 15814 #endif 15815 } 15816 15817 cmdline_parse_inst_t cmd_ptype_mapping_get = { 15818 .f = cmd_ptype_mapping_get_parsed, 15819 .data = NULL, 15820 .help_str = "ptype mapping get <port_id> <valid_only>", 15821 .tokens = { 15822 (void *)&cmd_ptype_mapping_get_ptype, 15823 (void *)&cmd_ptype_mapping_get_mapping, 15824 (void *)&cmd_ptype_mapping_get_get, 15825 (void *)&cmd_ptype_mapping_get_port_id, 15826 (void *)&cmd_ptype_mapping_get_valid_only, 15827 NULL, 15828 }, 15829 }; 15830 15831 /* ptype mapping replace */ 15832 15833 /* Common result structure for ptype mapping replace */ 15834 struct cmd_ptype_mapping_replace_result { 15835 cmdline_fixed_string_t ptype; 15836 cmdline_fixed_string_t mapping; 15837 cmdline_fixed_string_t replace; 15838 portid_t port_id; 15839 uint32_t target; 15840 uint8_t mask; 15841 uint32_t pkt_type; 15842 }; 15843 15844 /* Common CLI fields for ptype mapping replace */ 15845 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 15846 TOKEN_STRING_INITIALIZER 15847 (struct cmd_ptype_mapping_replace_result, 15848 ptype, "ptype"); 15849 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 15850 TOKEN_STRING_INITIALIZER 15851 (struct cmd_ptype_mapping_replace_result, 15852 mapping, "mapping"); 15853 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 15854 TOKEN_STRING_INITIALIZER 15855 (struct cmd_ptype_mapping_replace_result, 15856 replace, "replace"); 15857 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 15858 TOKEN_NUM_INITIALIZER 15859 (struct cmd_ptype_mapping_replace_result, 15860 port_id, UINT16); 15861 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 15862 TOKEN_NUM_INITIALIZER 15863 (struct cmd_ptype_mapping_replace_result, 15864 target, UINT32); 15865 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 15866 TOKEN_NUM_INITIALIZER 15867 (struct cmd_ptype_mapping_replace_result, 15868 mask, UINT8); 15869 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 15870 TOKEN_NUM_INITIALIZER 15871 (struct cmd_ptype_mapping_replace_result, 15872 pkt_type, UINT32); 15873 15874 static void 15875 cmd_ptype_mapping_replace_parsed( 15876 void *parsed_result, 15877 __attribute__((unused)) struct cmdline *cl, 15878 __attribute__((unused)) void *data) 15879 { 15880 struct cmd_ptype_mapping_replace_result *res = parsed_result; 15881 int ret = -ENOTSUP; 15882 15883 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15884 return; 15885 15886 #ifdef RTE_LIBRTE_I40E_PMD 15887 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 15888 res->target, 15889 res->mask, 15890 res->pkt_type); 15891 #endif 15892 15893 switch (ret) { 15894 case 0: 15895 break; 15896 case -EINVAL: 15897 printf("invalid ptype 0x%8x or 0x%8x\n", 15898 res->target, res->pkt_type); 15899 break; 15900 case -ENODEV: 15901 printf("invalid port_id %d\n", res->port_id); 15902 break; 15903 case -ENOTSUP: 15904 printf("function not implemented\n"); 15905 break; 15906 default: 15907 printf("programming error: (%s)\n", strerror(-ret)); 15908 } 15909 } 15910 15911 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 15912 .f = cmd_ptype_mapping_replace_parsed, 15913 .data = NULL, 15914 .help_str = 15915 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 15916 .tokens = { 15917 (void *)&cmd_ptype_mapping_replace_ptype, 15918 (void *)&cmd_ptype_mapping_replace_mapping, 15919 (void *)&cmd_ptype_mapping_replace_replace, 15920 (void *)&cmd_ptype_mapping_replace_port_id, 15921 (void *)&cmd_ptype_mapping_replace_target, 15922 (void *)&cmd_ptype_mapping_replace_mask, 15923 (void *)&cmd_ptype_mapping_replace_pkt_type, 15924 NULL, 15925 }, 15926 }; 15927 15928 /* ptype mapping reset */ 15929 15930 /* Common result structure for ptype mapping reset */ 15931 struct cmd_ptype_mapping_reset_result { 15932 cmdline_fixed_string_t ptype; 15933 cmdline_fixed_string_t mapping; 15934 cmdline_fixed_string_t reset; 15935 portid_t port_id; 15936 }; 15937 15938 /* Common CLI fields for ptype mapping reset*/ 15939 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 15940 TOKEN_STRING_INITIALIZER 15941 (struct cmd_ptype_mapping_reset_result, 15942 ptype, "ptype"); 15943 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 15944 TOKEN_STRING_INITIALIZER 15945 (struct cmd_ptype_mapping_reset_result, 15946 mapping, "mapping"); 15947 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 15948 TOKEN_STRING_INITIALIZER 15949 (struct cmd_ptype_mapping_reset_result, 15950 reset, "reset"); 15951 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 15952 TOKEN_NUM_INITIALIZER 15953 (struct cmd_ptype_mapping_reset_result, 15954 port_id, UINT16); 15955 15956 static void 15957 cmd_ptype_mapping_reset_parsed( 15958 void *parsed_result, 15959 __attribute__((unused)) struct cmdline *cl, 15960 __attribute__((unused)) void *data) 15961 { 15962 struct cmd_ptype_mapping_reset_result *res = parsed_result; 15963 int ret = -ENOTSUP; 15964 15965 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15966 return; 15967 15968 #ifdef RTE_LIBRTE_I40E_PMD 15969 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 15970 #endif 15971 15972 switch (ret) { 15973 case 0: 15974 break; 15975 case -ENODEV: 15976 printf("invalid port_id %d\n", res->port_id); 15977 break; 15978 case -ENOTSUP: 15979 printf("function not implemented\n"); 15980 break; 15981 default: 15982 printf("programming error: (%s)\n", strerror(-ret)); 15983 } 15984 } 15985 15986 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 15987 .f = cmd_ptype_mapping_reset_parsed, 15988 .data = NULL, 15989 .help_str = "ptype mapping reset <port_id>", 15990 .tokens = { 15991 (void *)&cmd_ptype_mapping_reset_ptype, 15992 (void *)&cmd_ptype_mapping_reset_mapping, 15993 (void *)&cmd_ptype_mapping_reset_reset, 15994 (void *)&cmd_ptype_mapping_reset_port_id, 15995 NULL, 15996 }, 15997 }; 15998 15999 /* ptype mapping update */ 16000 16001 /* Common result structure for ptype mapping update */ 16002 struct cmd_ptype_mapping_update_result { 16003 cmdline_fixed_string_t ptype; 16004 cmdline_fixed_string_t mapping; 16005 cmdline_fixed_string_t reset; 16006 portid_t port_id; 16007 uint8_t hw_ptype; 16008 uint32_t sw_ptype; 16009 }; 16010 16011 /* Common CLI fields for ptype mapping update*/ 16012 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 16013 TOKEN_STRING_INITIALIZER 16014 (struct cmd_ptype_mapping_update_result, 16015 ptype, "ptype"); 16016 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 16017 TOKEN_STRING_INITIALIZER 16018 (struct cmd_ptype_mapping_update_result, 16019 mapping, "mapping"); 16020 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 16021 TOKEN_STRING_INITIALIZER 16022 (struct cmd_ptype_mapping_update_result, 16023 reset, "update"); 16024 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 16025 TOKEN_NUM_INITIALIZER 16026 (struct cmd_ptype_mapping_update_result, 16027 port_id, UINT16); 16028 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 16029 TOKEN_NUM_INITIALIZER 16030 (struct cmd_ptype_mapping_update_result, 16031 hw_ptype, UINT8); 16032 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 16033 TOKEN_NUM_INITIALIZER 16034 (struct cmd_ptype_mapping_update_result, 16035 sw_ptype, UINT32); 16036 16037 static void 16038 cmd_ptype_mapping_update_parsed( 16039 void *parsed_result, 16040 __attribute__((unused)) struct cmdline *cl, 16041 __attribute__((unused)) void *data) 16042 { 16043 struct cmd_ptype_mapping_update_result *res = parsed_result; 16044 int ret = -ENOTSUP; 16045 #ifdef RTE_LIBRTE_I40E_PMD 16046 struct rte_pmd_i40e_ptype_mapping mapping; 16047 #endif 16048 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16049 return; 16050 16051 #ifdef RTE_LIBRTE_I40E_PMD 16052 mapping.hw_ptype = res->hw_ptype; 16053 mapping.sw_ptype = res->sw_ptype; 16054 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 16055 &mapping, 16056 1, 16057 0); 16058 #endif 16059 16060 switch (ret) { 16061 case 0: 16062 break; 16063 case -EINVAL: 16064 printf("invalid ptype 0x%8x\n", res->sw_ptype); 16065 break; 16066 case -ENODEV: 16067 printf("invalid port_id %d\n", res->port_id); 16068 break; 16069 case -ENOTSUP: 16070 printf("function not implemented\n"); 16071 break; 16072 default: 16073 printf("programming error: (%s)\n", strerror(-ret)); 16074 } 16075 } 16076 16077 cmdline_parse_inst_t cmd_ptype_mapping_update = { 16078 .f = cmd_ptype_mapping_update_parsed, 16079 .data = NULL, 16080 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 16081 .tokens = { 16082 (void *)&cmd_ptype_mapping_update_ptype, 16083 (void *)&cmd_ptype_mapping_update_mapping, 16084 (void *)&cmd_ptype_mapping_update_update, 16085 (void *)&cmd_ptype_mapping_update_port_id, 16086 (void *)&cmd_ptype_mapping_update_hw_ptype, 16087 (void *)&cmd_ptype_mapping_update_sw_ptype, 16088 NULL, 16089 }, 16090 }; 16091 16092 /* Common result structure for file commands */ 16093 struct cmd_cmdfile_result { 16094 cmdline_fixed_string_t load; 16095 cmdline_fixed_string_t filename; 16096 }; 16097 16098 /* Common CLI fields for file commands */ 16099 cmdline_parse_token_string_t cmd_load_cmdfile = 16100 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 16101 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 16102 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 16103 16104 static void 16105 cmd_load_from_file_parsed( 16106 void *parsed_result, 16107 __attribute__((unused)) struct cmdline *cl, 16108 __attribute__((unused)) void *data) 16109 { 16110 struct cmd_cmdfile_result *res = parsed_result; 16111 16112 cmdline_read_from_file(res->filename); 16113 } 16114 16115 cmdline_parse_inst_t cmd_load_from_file = { 16116 .f = cmd_load_from_file_parsed, 16117 .data = NULL, 16118 .help_str = "load <filename>", 16119 .tokens = { 16120 (void *)&cmd_load_cmdfile, 16121 (void *)&cmd_load_cmdfile_filename, 16122 NULL, 16123 }, 16124 }; 16125 16126 /* ******************************************************************************** */ 16127 16128 /* list of instructions */ 16129 cmdline_parse_ctx_t main_ctx[] = { 16130 (cmdline_parse_inst_t *)&cmd_help_brief, 16131 (cmdline_parse_inst_t *)&cmd_help_long, 16132 (cmdline_parse_inst_t *)&cmd_quit, 16133 (cmdline_parse_inst_t *)&cmd_load_from_file, 16134 (cmdline_parse_inst_t *)&cmd_showport, 16135 (cmdline_parse_inst_t *)&cmd_showqueue, 16136 (cmdline_parse_inst_t *)&cmd_showportall, 16137 (cmdline_parse_inst_t *)&cmd_showcfg, 16138 (cmdline_parse_inst_t *)&cmd_start, 16139 (cmdline_parse_inst_t *)&cmd_start_tx_first, 16140 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 16141 (cmdline_parse_inst_t *)&cmd_set_link_up, 16142 (cmdline_parse_inst_t *)&cmd_set_link_down, 16143 (cmdline_parse_inst_t *)&cmd_reset, 16144 (cmdline_parse_inst_t *)&cmd_set_numbers, 16145 (cmdline_parse_inst_t *)&cmd_set_log, 16146 (cmdline_parse_inst_t *)&cmd_set_txpkts, 16147 (cmdline_parse_inst_t *)&cmd_set_txsplit, 16148 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 16149 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 16150 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 16151 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 16152 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 16153 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 16154 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 16155 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 16156 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 16157 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 16158 (cmdline_parse_inst_t *)&cmd_set_link_check, 16159 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 16160 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 16161 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 16162 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 16163 #ifdef RTE_LIBRTE_PMD_BOND 16164 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 16165 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 16166 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 16167 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 16168 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 16169 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 16170 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 16171 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 16172 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 16173 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 16174 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 16175 #endif 16176 (cmdline_parse_inst_t *)&cmd_vlan_offload, 16177 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 16178 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 16179 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 16180 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 16181 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 16182 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 16183 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 16184 (cmdline_parse_inst_t *)&cmd_csum_set, 16185 (cmdline_parse_inst_t *)&cmd_csum_show, 16186 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 16187 (cmdline_parse_inst_t *)&cmd_tso_set, 16188 (cmdline_parse_inst_t *)&cmd_tso_show, 16189 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 16190 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 16191 (cmdline_parse_inst_t *)&cmd_gro_enable, 16192 (cmdline_parse_inst_t *)&cmd_gro_flush, 16193 (cmdline_parse_inst_t *)&cmd_gro_show, 16194 (cmdline_parse_inst_t *)&cmd_gso_enable, 16195 (cmdline_parse_inst_t *)&cmd_gso_size, 16196 (cmdline_parse_inst_t *)&cmd_gso_show, 16197 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 16198 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 16199 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 16200 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 16201 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 16202 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 16203 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 16204 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 16205 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 16206 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 16207 (cmdline_parse_inst_t *)&cmd_config_dcb, 16208 (cmdline_parse_inst_t *)&cmd_read_reg, 16209 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 16210 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 16211 (cmdline_parse_inst_t *)&cmd_write_reg, 16212 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 16213 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 16214 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 16215 (cmdline_parse_inst_t *)&cmd_stop, 16216 (cmdline_parse_inst_t *)&cmd_mac_addr, 16217 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 16218 (cmdline_parse_inst_t *)&cmd_set_qmap, 16219 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 16220 (cmdline_parse_inst_t *)&cmd_operate_port, 16221 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 16222 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 16223 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 16224 (cmdline_parse_inst_t *)&cmd_config_speed_all, 16225 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 16226 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 16227 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 16228 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 16229 (cmdline_parse_inst_t *)&cmd_config_mtu, 16230 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 16231 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 16232 (cmdline_parse_inst_t *)&cmd_config_rss, 16233 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 16234 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 16235 (cmdline_parse_inst_t *)&cmd_showport_reta, 16236 (cmdline_parse_inst_t *)&cmd_config_burst, 16237 (cmdline_parse_inst_t *)&cmd_config_thresh, 16238 (cmdline_parse_inst_t *)&cmd_config_threshold, 16239 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 16240 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 16241 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 16242 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter, 16243 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 16244 (cmdline_parse_inst_t *)&cmd_tunnel_filter, 16245 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 16246 (cmdline_parse_inst_t *)&cmd_global_config, 16247 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 16248 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 16249 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 16250 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 16251 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 16252 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 16253 (cmdline_parse_inst_t *)&cmd_dump, 16254 (cmdline_parse_inst_t *)&cmd_dump_one, 16255 (cmdline_parse_inst_t *)&cmd_ethertype_filter, 16256 (cmdline_parse_inst_t *)&cmd_syn_filter, 16257 (cmdline_parse_inst_t *)&cmd_2tuple_filter, 16258 (cmdline_parse_inst_t *)&cmd_5tuple_filter, 16259 (cmdline_parse_inst_t *)&cmd_flex_filter, 16260 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director, 16261 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director, 16262 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, 16263 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director, 16264 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director, 16265 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director, 16266 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 16267 (cmdline_parse_inst_t *)&cmd_flush_flow_director, 16268 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 16269 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 16270 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 16271 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, 16272 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 16273 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port, 16274 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port, 16275 (cmdline_parse_inst_t *)&cmd_get_hash_global_config, 16276 (cmdline_parse_inst_t *)&cmd_set_hash_global_config, 16277 (cmdline_parse_inst_t *)&cmd_set_hash_input_set, 16278 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set, 16279 (cmdline_parse_inst_t *)&cmd_flow, 16280 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 16281 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 16282 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 16283 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 16284 (cmdline_parse_inst_t *)&cmd_create_port_meter, 16285 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 16286 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 16287 (cmdline_parse_inst_t *)&cmd_del_port_meter, 16288 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 16289 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 16290 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, 16291 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 16292 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 16293 (cmdline_parse_inst_t *)&cmd_mcast_addr, 16294 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all, 16295 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific, 16296 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all, 16297 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific, 16298 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en, 16299 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis, 16300 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis, 16301 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis, 16302 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add, 16303 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del, 16304 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 16305 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 16306 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 16307 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 16308 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 16309 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 16310 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 16311 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 16312 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 16313 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 16314 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 16315 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 16316 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 16317 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 16318 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 16319 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 16320 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 16321 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 16322 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 16323 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 16324 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 16325 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 16326 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 16327 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 16328 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 16329 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 16330 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default, 16331 #endif 16332 (cmdline_parse_inst_t *)&cmd_ddp_add, 16333 (cmdline_parse_inst_t *)&cmd_ddp_del, 16334 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 16335 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 16336 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 16337 (cmdline_parse_inst_t *)&cmd_clear_input_set, 16338 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 16339 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 16340 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 16341 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 16342 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 16343 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 16344 16345 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 16346 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 16347 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 16348 (cmdline_parse_inst_t *)&cmd_queue_region, 16349 (cmdline_parse_inst_t *)&cmd_region_flowtype, 16350 (cmdline_parse_inst_t *)&cmd_user_priority_region, 16351 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 16352 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 16353 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 16354 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 16355 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 16356 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 16357 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 16358 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 16359 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 16360 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 16361 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 16362 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 16363 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 16364 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 16365 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 16366 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 16367 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 16368 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 16369 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 16370 NULL, 16371 }; 16372 16373 /* read cmdline commands from file */ 16374 void 16375 cmdline_read_from_file(const char *filename) 16376 { 16377 struct cmdline *cl; 16378 16379 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 16380 if (cl == NULL) { 16381 printf("Failed to create file based cmdline context: %s\n", 16382 filename); 16383 return; 16384 } 16385 16386 cmdline_interact(cl); 16387 cmdline_quit(cl); 16388 16389 cmdline_free(cl); 16390 16391 printf("Read CLI commands from %s\n", filename); 16392 } 16393 16394 /* prompt function, called from main on MASTER lcore */ 16395 void 16396 prompt(void) 16397 { 16398 /* initialize non-constant commands */ 16399 cmd_set_fwd_mode_init(); 16400 cmd_set_fwd_retry_mode_init(); 16401 16402 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 16403 if (testpmd_cl == NULL) 16404 return; 16405 cmdline_interact(testpmd_cl); 16406 cmdline_stdin_exit(testpmd_cl); 16407 } 16408 16409 void 16410 prompt_exit(void) 16411 { 16412 if (testpmd_cl != NULL) 16413 cmdline_quit(testpmd_cl); 16414 } 16415 16416 static void 16417 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 16418 { 16419 if (id == (portid_t)RTE_PORT_ALL) { 16420 portid_t pid; 16421 16422 RTE_ETH_FOREACH_DEV(pid) { 16423 /* check if need_reconfig has been set to 1 */ 16424 if (ports[pid].need_reconfig == 0) 16425 ports[pid].need_reconfig = dev; 16426 /* check if need_reconfig_queues has been set to 1 */ 16427 if (ports[pid].need_reconfig_queues == 0) 16428 ports[pid].need_reconfig_queues = queue; 16429 } 16430 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 16431 /* check if need_reconfig has been set to 1 */ 16432 if (ports[id].need_reconfig == 0) 16433 ports[id].need_reconfig = dev; 16434 /* check if need_reconfig_queues has been set to 1 */ 16435 if (ports[id].need_reconfig_queues == 0) 16436 ports[id].need_reconfig_queues = queue; 16437 } 16438 } 16439