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 <unistd.h> 12 #include <inttypes.h> 13 #include <sys/queue.h> 14 15 #include <rte_common.h> 16 #include <rte_byteorder.h> 17 #include <rte_log.h> 18 #include <rte_debug.h> 19 #include <rte_cycles.h> 20 #include <rte_memory.h> 21 #include <rte_memzone.h> 22 #include <rte_malloc.h> 23 #include <rte_launch.h> 24 #include <rte_eal.h> 25 #include <rte_per_lcore.h> 26 #include <rte_lcore.h> 27 #include <rte_atomic.h> 28 #include <rte_branch_prediction.h> 29 #include <rte_ring.h> 30 #include <rte_mempool.h> 31 #include <rte_interrupts.h> 32 #include <rte_pci.h> 33 #include <rte_ether.h> 34 #include <rte_ethdev.h> 35 #include <rte_string_fns.h> 36 #include <rte_devargs.h> 37 #include <rte_flow.h> 38 #include <rte_gro.h> 39 #include <rte_mbuf_dyn.h> 40 41 #include <cmdline_rdline.h> 42 #include <cmdline_parse.h> 43 #include <cmdline_parse_num.h> 44 #include <cmdline_parse_string.h> 45 #include <cmdline_parse_ipaddr.h> 46 #include <cmdline_parse_etheraddr.h> 47 #include <cmdline_socket.h> 48 #include <cmdline.h> 49 #ifdef RTE_NET_BOND 50 #include <rte_eth_bond.h> 51 #include <rte_eth_bond_8023ad.h> 52 #endif 53 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA 54 #include <rte_pmd_dpaa.h> 55 #endif 56 #ifdef RTE_NET_IXGBE 57 #include <rte_pmd_ixgbe.h> 58 #endif 59 #ifdef RTE_NET_I40E 60 #include <rte_pmd_i40e.h> 61 #endif 62 #ifdef RTE_NET_BNXT 63 #include <rte_pmd_bnxt.h> 64 #endif 65 #include "testpmd.h" 66 #include "cmdline_mtr.h" 67 #include "cmdline_tm.h" 68 #include "bpf_cmd.h" 69 70 static struct cmdline *testpmd_cl; 71 72 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); 73 74 /* *** Help command with introduction. *** */ 75 struct cmd_help_brief_result { 76 cmdline_fixed_string_t help; 77 }; 78 79 static void cmd_help_brief_parsed(__rte_unused void *parsed_result, 80 struct cmdline *cl, 81 __rte_unused void *data) 82 { 83 cmdline_printf( 84 cl, 85 "\n" 86 "Help is available for the following sections:\n\n" 87 " help control : Start and stop forwarding.\n" 88 " help display : Displaying port, stats and config " 89 "information.\n" 90 " help config : Configuration information.\n" 91 " help ports : Configuring ports.\n" 92 " help registers : Reading and setting port registers.\n" 93 " help filters : Filters configuration help.\n" 94 " help traffic_management : Traffic Management commands.\n" 95 " help devices : Device related cmds.\n" 96 " help all : All of the above sections.\n\n" 97 ); 98 99 } 100 101 cmdline_parse_token_string_t cmd_help_brief_help = 102 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help"); 103 104 cmdline_parse_inst_t cmd_help_brief = { 105 .f = cmd_help_brief_parsed, 106 .data = NULL, 107 .help_str = "help: Show help", 108 .tokens = { 109 (void *)&cmd_help_brief_help, 110 NULL, 111 }, 112 }; 113 114 /* *** Help command with help sections. *** */ 115 struct cmd_help_long_result { 116 cmdline_fixed_string_t help; 117 cmdline_fixed_string_t section; 118 }; 119 120 static void cmd_help_long_parsed(void *parsed_result, 121 struct cmdline *cl, 122 __rte_unused void *data) 123 { 124 int show_all = 0; 125 struct cmd_help_long_result *res = parsed_result; 126 127 if (!strcmp(res->section, "all")) 128 show_all = 1; 129 130 if (show_all || !strcmp(res->section, "control")) { 131 132 cmdline_printf( 133 cl, 134 "\n" 135 "Control forwarding:\n" 136 "-------------------\n\n" 137 138 "start\n" 139 " Start packet forwarding with current configuration.\n\n" 140 141 "start tx_first\n" 142 " Start packet forwarding with current config" 143 " after sending one burst of packets.\n\n" 144 145 "stop\n" 146 " Stop packet forwarding, and display accumulated" 147 " statistics.\n\n" 148 149 "quit\n" 150 " Quit to prompt.\n\n" 151 ); 152 } 153 154 if (show_all || !strcmp(res->section, "display")) { 155 156 cmdline_printf( 157 cl, 158 "\n" 159 "Display:\n" 160 "--------\n\n" 161 162 "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n" 163 " Display information for port_id, or all.\n\n" 164 165 "show port info (port_id) representor\n" 166 " Show supported representors for a specific port\n\n" 167 168 "show port port_id (module_eeprom|eeprom)\n" 169 " Display the module EEPROM or EEPROM information for port_id.\n\n" 170 171 "show port X rss reta (size) (mask0,mask1,...)\n" 172 " Display the rss redirection table entry indicated" 173 " by masks on port X. size is used to indicate the" 174 " hardware supported reta size\n\n" 175 176 "show port (port_id) rss-hash [key]\n" 177 " Display the RSS hash functions and RSS hash key of port\n\n" 178 179 "clear port (info|stats|xstats|fdir) (port_id|all)\n" 180 " Clear information for port_id, or all.\n\n" 181 182 "show (rxq|txq) info (port_id) (queue_id)\n" 183 " Display information for configured RX/TX queue.\n\n" 184 185 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n" 186 " Display the given configuration.\n\n" 187 188 "read rxd (port_id) (queue_id) (rxd_id)\n" 189 " Display an RX descriptor of a port RX queue.\n\n" 190 191 "read txd (port_id) (queue_id) (txd_id)\n" 192 " Display a TX descriptor of a port TX queue.\n\n" 193 194 "ddp get list (port_id)\n" 195 " Get ddp profile info list\n\n" 196 197 "ddp get info (profile_path)\n" 198 " Get ddp profile information.\n\n" 199 200 "show vf stats (port_id) (vf_id)\n" 201 " Display a VF's statistics.\n\n" 202 203 "clear vf stats (port_id) (vf_id)\n" 204 " Reset a VF's statistics.\n\n" 205 206 "show port (port_id) pctype mapping\n" 207 " Get flow ptype to pctype mapping on a port\n\n" 208 209 "show port meter stats (port_id) (meter_id) (clear)\n" 210 " Get meter stats on a port\n\n" 211 212 "show fwd stats all\n" 213 " Display statistics for all fwd engines.\n\n" 214 215 "clear fwd stats all\n" 216 " Clear statistics for all fwd engines.\n\n" 217 218 "show port (port_id) rx_offload capabilities\n" 219 " List all per queue and per port Rx offloading" 220 " capabilities of a port\n\n" 221 222 "show port (port_id) rx_offload configuration\n" 223 " List port level and all queue level" 224 " Rx offloading configuration\n\n" 225 226 "show port (port_id) tx_offload capabilities\n" 227 " List all per queue and per port" 228 " Tx offloading capabilities of a port\n\n" 229 230 "show port (port_id) tx_offload configuration\n" 231 " List port level and all queue level" 232 " Tx offloading configuration\n\n" 233 234 "show port (port_id) tx_metadata\n" 235 " Show Tx metadata value set" 236 " for a specific port\n\n" 237 238 "show port (port_id) ptypes\n" 239 " Show port supported ptypes" 240 " for a specific port\n\n" 241 242 "show device info (<identifier>|all)" 243 " Show general information about devices probed.\n\n" 244 245 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status" 246 " Show status of rx|tx descriptor.\n\n" 247 248 "show port (port_id) rxq (queue_id) desc used count\n" 249 " Show current number of filled receive" 250 " packet descriptors.\n\n" 251 252 "show port (port_id) macs|mcast_macs" 253 " Display list of mac addresses added to port.\n\n" 254 255 "show port (port_id) fec capabilities" 256 " Show fec capabilities of a port.\n\n" 257 258 "show port (port_id) fec_mode" 259 " Show fec mode of a port.\n\n" 260 261 "show port (port_id) flow_ctrl" 262 " Show flow control info of a port.\n\n" 263 ); 264 } 265 266 if (show_all || !strcmp(res->section, "config")) { 267 cmdline_printf( 268 cl, 269 "\n" 270 "Configuration:\n" 271 "--------------\n" 272 "Configuration changes only become active when" 273 " forwarding is started/restarted.\n\n" 274 275 "set default\n" 276 " Reset forwarding to the default configuration.\n\n" 277 278 "set verbose (level)\n" 279 " Set the debug verbosity level X.\n\n" 280 281 "set log global|(type) (level)\n" 282 " Set the log level.\n\n" 283 284 "set nbport (num)\n" 285 " Set number of ports.\n\n" 286 287 "set nbcore (num)\n" 288 " Set number of cores.\n\n" 289 290 "set coremask (mask)\n" 291 " Set the forwarding cores hexadecimal mask.\n\n" 292 293 "set portmask (mask)\n" 294 " Set the forwarding ports hexadecimal mask.\n\n" 295 296 "set burst (num)\n" 297 " Set number of packets per burst.\n\n" 298 299 "set burst tx delay (microseconds) retry (num)\n" 300 " Set the transmit delay time and number of retries," 301 " effective when retry is enabled.\n\n" 302 303 "set rxoffs (x[,y]*)\n" 304 " Set the offset of each packet segment on" 305 " receiving if split feature is engaged." 306 " Affects only the queues configured with split" 307 " offloads.\n\n" 308 309 "set rxpkts (x[,y]*)\n" 310 " Set the length of each segment to scatter" 311 " packets on receiving if split feature is engaged." 312 " Affects only the queues configured with split" 313 " offloads.\n\n" 314 315 "set txpkts (x[,y]*)\n" 316 " Set the length of each segment of TXONLY" 317 " and optionally CSUM packets.\n\n" 318 319 "set txsplit (off|on|rand)\n" 320 " Set the split policy for the TX packets." 321 " Right now only applicable for CSUM and TXONLY" 322 " modes\n\n" 323 324 "set txtimes (x, y)\n" 325 " Set the scheduling on timestamps" 326 " timings for the TXONLY mode\n\n" 327 328 "set corelist (x[,y]*)\n" 329 " Set the list of forwarding cores.\n\n" 330 331 "set portlist (x[,y]*)\n" 332 " Set the list of forwarding ports.\n\n" 333 334 "set port setup on (iterator|event)\n" 335 " Select how attached port is retrieved for setup.\n\n" 336 337 "set tx loopback (port_id) (on|off)\n" 338 " Enable or disable tx loopback.\n\n" 339 340 "set all queues drop (port_id) (on|off)\n" 341 " Set drop enable bit for all queues.\n\n" 342 343 "set vf split drop (port_id) (vf_id) (on|off)\n" 344 " Set split drop enable bit for a VF from the PF.\n\n" 345 346 "set vf mac antispoof (port_id) (vf_id) (on|off).\n" 347 " Set MAC antispoof for a VF from the PF.\n\n" 348 349 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" 350 " Enable MACsec offload.\n\n" 351 352 "set macsec offload (port_id) off\n" 353 " Disable MACsec offload.\n\n" 354 355 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" 356 " Configure MACsec secure connection (SC).\n\n" 357 358 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" 359 " Configure MACsec secure association (SA).\n\n" 360 361 "set vf broadcast (port_id) (vf_id) (on|off)\n" 362 " Set VF broadcast for a VF from the PF.\n\n" 363 364 "vlan set stripq (on|off) (port_id,queue_id)\n" 365 " Set the VLAN strip for a queue on a port.\n\n" 366 367 "set vf vlan stripq (port_id) (vf_id) (on|off)\n" 368 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" 369 370 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" 371 " Set VLAN insert for a VF from the PF.\n\n" 372 373 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" 374 " Set VLAN antispoof for a VF from the PF.\n\n" 375 376 "set vf vlan tag (port_id) (vf_id) (on|off)\n" 377 " Set VLAN tag for a VF from the PF.\n\n" 378 379 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n" 380 " Set a VF's max bandwidth(Mbps).\n\n" 381 382 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n" 383 " Set all TCs' min bandwidth(%%) on a VF.\n\n" 384 385 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n" 386 " Set a TC's max bandwidth(Mbps) on a VF.\n\n" 387 388 "set tx strict-link-priority (port_id) (tc_bitmap)\n" 389 " Set some TCs' strict link priority mode on a physical port.\n\n" 390 391 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" 392 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n" 393 394 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n" 395 " Set the VLAN strip or filter or qinq strip or extend\n\n" 396 397 "vlan set (inner|outer) tpid (value) (port_id)\n" 398 " Set the VLAN TPID for Packet Filtering on" 399 " a port\n\n" 400 401 "rx_vlan add (vlan_id|all) (port_id)\n" 402 " Add a vlan_id, or all identifiers, to the set" 403 " of VLAN identifiers filtered by port_id.\n\n" 404 405 "rx_vlan rm (vlan_id|all) (port_id)\n" 406 " Remove a vlan_id, or all identifiers, from the set" 407 " of VLAN identifiers filtered by port_id.\n\n" 408 409 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n" 410 " Add a vlan_id, to the set of VLAN identifiers" 411 "filtered for VF(s) from port_id.\n\n" 412 413 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n" 414 " Remove a vlan_id, to the set of VLAN identifiers" 415 "filtered for VF(s) from port_id.\n\n" 416 417 "rx_vxlan_port add (udp_port) (port_id)\n" 418 " Add an UDP port for VXLAN packet filter on a port\n\n" 419 420 "rx_vxlan_port rm (udp_port) (port_id)\n" 421 " Remove an UDP port for VXLAN packet filter on a port\n\n" 422 423 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" 424 " Set hardware insertion of VLAN IDs (single or double VLAN " 425 "depends on the number of VLAN IDs) in packets sent on a port.\n\n" 426 427 "tx_vlan set pvid port_id vlan_id (on|off)\n" 428 " Set port based TX VLAN insertion.\n\n" 429 430 "tx_vlan reset (port_id)\n" 431 " Disable hardware insertion of a VLAN header in" 432 " packets sent on a port.\n\n" 433 434 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n" 435 " Select hardware or software calculation of the" 436 " checksum when transmitting a packet using the" 437 " csum forward engine.\n" 438 " ip|udp|tcp|sctp always concern the inner layer.\n" 439 " outer-ip concerns the outer IP layer in" 440 " outer-udp concerns the outer UDP layer in" 441 " case the packet is recognized as a tunnel packet by" 442 " the forward engine (vxlan, gre and ipip are supported)\n" 443 " Please check the NIC datasheet for HW limits.\n\n" 444 445 "csum parse-tunnel (on|off) (tx_port_id)\n" 446 " If disabled, treat tunnel packets as non-tunneled" 447 " packets (treat inner headers as payload). The port\n" 448 " argument is the port used for TX in csum forward" 449 " engine.\n\n" 450 451 "csum show (port_id)\n" 452 " Display tx checksum offload configuration\n\n" 453 454 "tso set (segsize) (portid)\n" 455 " Enable TCP Segmentation Offload in csum forward" 456 " engine.\n" 457 " Please check the NIC datasheet for HW limits.\n\n" 458 459 "tso show (portid)" 460 " Display the status of TCP Segmentation Offload.\n\n" 461 462 "set port (port_id) gro on|off\n" 463 " Enable or disable Generic Receive Offload in" 464 " csum forwarding engine.\n\n" 465 466 "show port (port_id) gro\n" 467 " Display GRO configuration.\n\n" 468 469 "set gro flush (cycles)\n" 470 " Set the cycle to flush GROed packets from" 471 " reassembly tables.\n\n" 472 473 "set port (port_id) gso (on|off)" 474 " Enable or disable Generic Segmentation Offload in" 475 " csum forwarding engine.\n\n" 476 477 "set gso segsz (length)\n" 478 " Set max packet length for output GSO segments," 479 " including packet header and payload.\n\n" 480 481 "show port (port_id) gso\n" 482 " Show GSO configuration.\n\n" 483 484 "set fwd (%s)\n" 485 " Set packet forwarding mode.\n\n" 486 487 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" 488 " Add a MAC address on port_id.\n\n" 489 490 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n" 491 " Remove a MAC address from port_id.\n\n" 492 493 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n" 494 " Set the default MAC address for port_id.\n\n" 495 496 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n" 497 " Add a MAC address for a VF on the port.\n\n" 498 499 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n" 500 " Set the MAC address for a VF from the PF.\n\n" 501 502 "set eth-peer (port_id) (peer_addr)\n" 503 " set the peer address for certain port.\n\n" 504 505 "set port (port_id) uta (mac_address|all) (on|off)\n" 506 " Add/Remove a or all unicast hash filter(s)" 507 "from port X.\n\n" 508 509 "set promisc (port_id|all) (on|off)\n" 510 " Set the promiscuous mode on port_id, or all.\n\n" 511 512 "set allmulti (port_id|all) (on|off)\n" 513 " Set the allmulti mode on port_id, or all.\n\n" 514 515 "set vf promisc (port_id) (vf_id) (on|off)\n" 516 " Set unicast promiscuous mode for a VF from the PF.\n\n" 517 518 "set vf allmulti (port_id) (vf_id) (on|off)\n" 519 " Set multicast promiscuous mode for a VF from the PF.\n\n" 520 521 "set flow_ctrl rx (on|off) tx (on|off) (high_water)" 522 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" 523 " (on|off) autoneg (on|off) (port_id)\n" 524 "set flow_ctrl rx (on|off) (portid)\n" 525 "set flow_ctrl tx (on|off) (portid)\n" 526 "set flow_ctrl high_water (high_water) (portid)\n" 527 "set flow_ctrl low_water (low_water) (portid)\n" 528 "set flow_ctrl pause_time (pause_time) (portid)\n" 529 "set flow_ctrl send_xon (send_xon) (portid)\n" 530 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n" 531 "set flow_ctrl autoneg (on|off) (port_id)\n" 532 " Set the link flow control parameter on a port.\n\n" 533 534 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)" 535 " (low_water) (pause_time) (priority) (port_id)\n" 536 " Set the priority flow control parameter on a" 537 " port.\n\n" 538 539 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n" 540 " Set statistics mapping (qmapping 0..15) for RX/TX" 541 " queue on port.\n" 542 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2" 543 " on port 0 to mapping 5.\n\n" 544 545 "set xstats-hide-zero on|off\n" 546 " Set the option to hide the zero values" 547 " for xstats display.\n" 548 549 "set record-core-cycles on|off\n" 550 " Set the option to enable measurement of CPU cycles.\n" 551 552 "set record-burst-stats on|off\n" 553 " Set the option to enable display of RX and TX bursts.\n" 554 555 "set port (port_id) vf (vf_id) rx|tx on|off\n" 556 " Enable/Disable a VF receive/tranmit from a port\n\n" 557 558 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" 559 "|MPE) (on|off)\n" 560 " AUPE:accepts untagged VLAN;" 561 "ROPE:accept unicast hash\n\n" 562 " BAM:accepts broadcast packets;" 563 "MPE:accepts all multicast packets\n\n" 564 " Enable/Disable a VF receive mode of a port\n\n" 565 566 "set port (port_id) queue (queue_id) rate (rate_num)\n" 567 " Set rate limit for a queue of a port\n\n" 568 569 "set port (port_id) vf (vf_id) rate (rate_num) " 570 "queue_mask (queue_mask_value)\n" 571 " Set rate limit for queues in VF of a port\n\n" 572 573 "set flush_rx (on|off)\n" 574 " Flush (default) or don't flush RX streams before" 575 " forwarding. Mainly used with PCAP drivers.\n\n" 576 577 "set bypass mode (normal|bypass|isolate) (port_id)\n" 578 " Set the bypass mode for the lowest port on bypass enabled" 579 " NIC.\n\n" 580 581 "set bypass event (timeout|os_on|os_off|power_on|power_off) " 582 "mode (normal|bypass|isolate) (port_id)\n" 583 " Set the event required to initiate specified bypass mode for" 584 " the lowest port on a bypass enabled NIC where:\n" 585 " timeout = enable bypass after watchdog timeout.\n" 586 " os_on = enable bypass when OS/board is powered on.\n" 587 " os_off = enable bypass when OS/board is powered off.\n" 588 " power_on = enable bypass when power supply is turned on.\n" 589 " power_off = enable bypass when power supply is turned off." 590 "\n\n" 591 592 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" 593 " Set the bypass watchdog timeout to 'n' seconds" 594 " where 0 = instant.\n\n" 595 596 "show bypass config (port_id)\n" 597 " Show the bypass configuration for a bypass enabled NIC" 598 " using the lowest port on the NIC.\n\n" 599 600 #ifdef RTE_NET_BOND 601 "create bonded device (mode) (socket)\n" 602 " Create a new bonded device with specific bonding mode and socket.\n\n" 603 604 "add bonding slave (slave_id) (port_id)\n" 605 " Add a slave device to a bonded device.\n\n" 606 607 "remove bonding slave (slave_id) (port_id)\n" 608 " Remove a slave device from a bonded device.\n\n" 609 610 "set bonding mode (value) (port_id)\n" 611 " Set the bonding mode on a bonded device.\n\n" 612 613 "set bonding primary (slave_id) (port_id)\n" 614 " Set the primary slave for a bonded device.\n\n" 615 616 "show bonding config (port_id)\n" 617 " Show the bonding config for port_id.\n\n" 618 619 "show bonding lacp info (port_id)\n" 620 " Show the bonding lacp information for port_id.\n\n" 621 622 "set bonding mac_addr (port_id) (address)\n" 623 " Set the MAC address of a bonded device.\n\n" 624 625 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)" 626 " Set Aggregation mode for IEEE802.3AD (mode 4)" 627 628 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n" 629 " Set the transmit balance policy for bonded device running in balance mode.\n\n" 630 631 "set bonding mon_period (port_id) (value)\n" 632 " Set the bonding link status monitoring polling period in ms.\n\n" 633 634 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n" 635 " Enable/disable dedicated queues for LACP control traffic.\n\n" 636 637 #endif 638 "set link-up port (port_id)\n" 639 " Set link up for a port.\n\n" 640 641 "set link-down port (port_id)\n" 642 " Set link down for a port.\n\n" 643 644 "ddp add (port_id) (profile_path[,backup_profile_path])\n" 645 " Load a profile package on a port\n\n" 646 647 "ddp del (port_id) (backup_profile_path)\n" 648 " Delete a profile package from a port\n\n" 649 650 "ptype mapping get (port_id) (valid_only)\n" 651 " Get ptype mapping on a port\n\n" 652 653 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n" 654 " Replace target with the pkt_type in ptype mapping\n\n" 655 656 "ptype mapping reset (port_id)\n" 657 " Reset ptype mapping on a port\n\n" 658 659 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" 660 " Update a ptype mapping item on a port\n\n" 661 662 "set port (port_id) ptype_mask (ptype_mask)\n" 663 " set packet types classification for a specific port\n\n" 664 665 "set port (port_id) queue-region region_id (value) " 666 "queue_start_index (value) queue_num (value)\n" 667 " Set a queue region on a port\n\n" 668 669 "set port (port_id) queue-region region_id (value) " 670 "flowtype (value)\n" 671 " Set a flowtype region index on a port\n\n" 672 673 "set port (port_id) queue-region UP (value) region_id (value)\n" 674 " Set the mapping of User Priority to " 675 "queue region on a port\n\n" 676 677 "set port (port_id) queue-region flush (on|off)\n" 678 " flush all queue region related configuration\n\n" 679 680 "show port meter cap (port_id)\n" 681 " Show port meter capability information\n\n" 682 683 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n" 684 " meter profile add - srtcm rfc 2697\n\n" 685 686 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n" 687 " meter profile add - trtcm rfc 2698\n\n" 688 689 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n" 690 " meter profile add - trtcm rfc 4115\n\n" 691 692 "del port meter profile (port_id) (profile_id)\n" 693 " meter profile delete\n\n" 694 695 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n" 696 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 697 "(dscp_tbl_entry63)]\n" 698 " meter create\n\n" 699 700 "enable port meter (port_id) (mtr_id)\n" 701 " meter enable\n\n" 702 703 "disable port meter (port_id) (mtr_id)\n" 704 " meter disable\n\n" 705 706 "del port meter (port_id) (mtr_id)\n" 707 " meter delete\n\n" 708 709 "add port meter policy (port_id) (policy_id) g_actions (actions)\n" 710 "y_actions (actions) r_actions (actions)\n" 711 " meter policy add\n\n" 712 713 "del port meter policy (port_id) (policy_id)\n" 714 " meter policy delete\n\n" 715 716 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 717 " meter update meter profile\n\n" 718 719 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 720 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 721 " update meter dscp table entries\n\n" 722 723 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 724 "(action0) [(action1) (action2)]\n" 725 " meter update policer action\n\n" 726 727 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 728 " meter update stats\n\n" 729 730 "show port (port_id) queue-region\n" 731 " show all queue region related configuration info\n\n" 732 733 "set port (port_id) fec_mode auto|off|rs|baser\n" 734 " set fec mode for a specific port\n\n" 735 736 , list_pkt_forwarding_modes() 737 ); 738 } 739 740 if (show_all || !strcmp(res->section, "ports")) { 741 742 cmdline_printf( 743 cl, 744 "\n" 745 "Port Operations:\n" 746 "----------------\n\n" 747 748 "port start (port_id|all)\n" 749 " Start all ports or port_id.\n\n" 750 751 "port stop (port_id|all)\n" 752 " Stop all ports or port_id.\n\n" 753 754 "port close (port_id|all)\n" 755 " Close all ports or port_id.\n\n" 756 757 "port reset (port_id|all)\n" 758 " Reset all ports or port_id.\n\n" 759 760 "port attach (ident)\n" 761 " Attach physical or virtual dev by pci address or virtual device name\n\n" 762 763 "port detach (port_id)\n" 764 " Detach physical or virtual dev by port_id\n\n" 765 766 "port config (port_id|all)" 767 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)" 768 " duplex (half|full|auto)\n" 769 " Set speed and duplex for all ports or port_id\n\n" 770 771 "port config (port_id|all) loopback (mode)\n" 772 " Set loopback mode for all ports or port_id\n\n" 773 774 "port config all (rxq|txq|rxd|txd) (value)\n" 775 " Set number for rxq/txq/rxd/txd.\n\n" 776 777 "port config all max-pkt-len (value)\n" 778 " Set the max packet length.\n\n" 779 780 "port config all max-lro-pkt-size (value)\n" 781 " Set the max LRO aggregated packet size.\n\n" 782 783 "port config all drop-en (on|off)\n" 784 " Enable or disable packet drop on all RX queues of all ports when no " 785 "receive buffers available.\n\n" 786 787 "port config all rss (all|default|ip|tcp|udp|sctp|" 788 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|" 789 "level-outer|level-inner|<flowtype_id>)\n" 790 " Set the RSS mode.\n\n" 791 792 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 793 " Set the RSS redirection table.\n\n" 794 795 "port config (port_id) dcb vt (on|off) (traffic_class)" 796 " pfc (on|off)\n" 797 " Set the DCB mode.\n\n" 798 799 "port config all burst (value)\n" 800 " Set the number of packets per burst.\n\n" 801 802 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 803 " (value)\n" 804 " Set the ring prefetch/host/writeback threshold" 805 " for tx/rx queue.\n\n" 806 807 "port config all (txfreet|txrst|rxfreet) (value)\n" 808 " Set free threshold for rx/tx, or set" 809 " tx rs bit threshold.\n\n" 810 "port config mtu X value\n" 811 " Set the MTU of port X to a given value\n\n" 812 813 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n" 814 " Set a rx/tx queue's ring size configuration, the new" 815 " value will take effect after command that (re-)start the port" 816 " or command that setup the specific queue\n\n" 817 818 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 819 " Start/stop a rx/tx queue of port X. Only take effect" 820 " when port X is started\n\n" 821 822 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n" 823 " Switch on/off a deferred start of port X rx/tx queue. Only" 824 " take effect when port X is stopped.\n\n" 825 826 "port (port_id) (rxq|txq) (queue_id) setup\n" 827 " Setup a rx/tx queue of port X.\n\n" 828 829 "port config (port_id) pctype mapping reset\n" 830 " Reset flow type to pctype mapping on a port\n\n" 831 832 "port config (port_id) pctype mapping update" 833 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 834 " Update a flow type to pctype mapping item on a port\n\n" 835 836 "port config (port_id) pctype (pctype_id) hash_inset|" 837 "fdir_inset|fdir_flx_inset get|set|clear field\n" 838 " (field_idx)\n" 839 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n" 840 841 "port config (port_id) pctype (pctype_id) hash_inset|" 842 "fdir_inset|fdir_flx_inset clear all" 843 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n" 844 845 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n" 846 " Add/remove UDP tunnel port for tunneling offload\n\n" 847 848 "port config <port_id> rx_offload vlan_strip|" 849 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 850 "outer_ipv4_cksum|macsec_strip|header_split|" 851 "vlan_filter|vlan_extend|jumbo_frame|scatter|" 852 "buffer_split|timestamp|security|keep_crc on|off\n" 853 " Enable or disable a per port Rx offloading" 854 " on all Rx queues of a port\n\n" 855 856 "port (port_id) rxq (queue_id) rx_offload vlan_strip|" 857 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 858 "outer_ipv4_cksum|macsec_strip|header_split|" 859 "vlan_filter|vlan_extend|jumbo_frame|scatter|" 860 "buffer_split|timestamp|security|keep_crc on|off\n" 861 " Enable or disable a per queue Rx offloading" 862 " only on a specific Rx queue\n\n" 863 864 "port config (port_id) tx_offload vlan_insert|" 865 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 866 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 867 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|" 868 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|" 869 "security on|off\n" 870 " Enable or disable a per port Tx offloading" 871 " on all Tx queues of a port\n\n" 872 873 "port (port_id) txq (queue_id) tx_offload vlan_insert|" 874 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 875 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 876 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert" 877 "|mt_lockfree|multi_segs|mbuf_fast_free|security" 878 " on|off\n" 879 " Enable or disable a per queue Tx offloading" 880 " only on a specific Tx queue\n\n" 881 882 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n" 883 " Load an eBPF program as a callback" 884 " for particular RX/TX queue\n\n" 885 886 "bpf-unload rx|tx (port) (queue)\n" 887 " Unload previously loaded eBPF program" 888 " for particular RX/TX queue\n\n" 889 890 "port config (port_id) tx_metadata (value)\n" 891 " Set Tx metadata value per port. Testpmd will add this value" 892 " to any Tx packet sent from this port\n\n" 893 894 "port config (port_id) dynf (name) set|clear\n" 895 " Register a dynf and Set/clear this flag on Tx. " 896 "Testpmd will set this value to any Tx packet " 897 "sent from this port\n\n" 898 899 "port cleanup (port_id) txq (queue_id) (free_cnt)\n" 900 " Cleanup txq mbufs for a specific Tx queue\n\n" 901 ); 902 } 903 904 if (show_all || !strcmp(res->section, "registers")) { 905 906 cmdline_printf( 907 cl, 908 "\n" 909 "Registers:\n" 910 "----------\n\n" 911 912 "read reg (port_id) (address)\n" 913 " Display value of a port register.\n\n" 914 915 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 916 " Display a port register bit field.\n\n" 917 918 "read regbit (port_id) (address) (bit_x)\n" 919 " Display a single port register bit.\n\n" 920 921 "write reg (port_id) (address) (value)\n" 922 " Set value of a port register.\n\n" 923 924 "write regfield (port_id) (address) (bit_x) (bit_y)" 925 " (value)\n" 926 " Set bit field of a port register.\n\n" 927 928 "write regbit (port_id) (address) (bit_x) (value)\n" 929 " Set single bit value of a port register.\n\n" 930 ); 931 } 932 if (show_all || !strcmp(res->section, "filters")) { 933 934 cmdline_printf( 935 cl, 936 "\n" 937 "filters:\n" 938 "--------\n\n" 939 940 #ifdef RTE_NET_I40E 941 "flow_director_filter (port_id) mode raw (add|del|update)" 942 " flow (flow_id) (drop|fwd) queue (queue_id)" 943 " fd_id (fd_id_value) packet (packet file name)\n" 944 " Add/Del a raw type flow director filter.\n\n" 945 #endif 946 947 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 948 " src_mask (ipv4_src) (ipv6_src) (src_port)" 949 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 950 " Set flow director IP mask.\n\n" 951 952 "flow_director_mask (port_id) mode MAC-VLAN" 953 " vlan (vlan_value)\n" 954 " Set flow director MAC-VLAN mask.\n\n" 955 956 "flow_director_mask (port_id) mode Tunnel" 957 " vlan (vlan_value) mac (mac_value)" 958 " tunnel-type (tunnel_type_value)" 959 " tunnel-id (tunnel_id_value)\n" 960 " Set flow director Tunnel mask.\n\n" 961 962 "flow_director_flex_payload (port_id)" 963 " (raw|l2|l3|l4) (config)\n" 964 " Configure flex payload selection.\n\n" 965 966 "flow validate {port_id}" 967 " [group {group_id}] [priority {level}]" 968 " [ingress] [egress]" 969 " pattern {item} [/ {item} [...]] / end" 970 " actions {action} [/ {action} [...]] / end\n" 971 " Check whether a flow rule can be created.\n\n" 972 973 "flow create {port_id}" 974 " [group {group_id}] [priority {level}]" 975 " [ingress] [egress]" 976 " pattern {item} [/ {item} [...]] / end" 977 " actions {action} [/ {action} [...]] / end\n" 978 " Create a flow rule.\n\n" 979 980 "flow destroy {port_id} rule {rule_id} [...]\n" 981 " Destroy specific flow rules.\n\n" 982 983 "flow flush {port_id}\n" 984 " Destroy all flow rules.\n\n" 985 986 "flow query {port_id} {rule_id} {action}\n" 987 " Query an existing flow rule.\n\n" 988 989 "flow list {port_id} [group {group_id}] [...]\n" 990 " List existing flow rules sorted by priority," 991 " filtered by group identifiers.\n\n" 992 993 "flow isolate {port_id} {boolean}\n" 994 " Restrict ingress traffic to the defined" 995 " flow rules\n\n" 996 997 "flow aged {port_id} [destroy]\n" 998 " List and destroy aged flows" 999 " flow rules\n\n" 1000 1001 "flow indirect_action {port_id} create" 1002 " [action_id {indirect_action_id}]" 1003 " [ingress] [egress]" 1004 " action {action} / end\n" 1005 " Create indirect action.\n\n" 1006 1007 "flow indirect_action {port_id} update" 1008 " {indirect_action_id} action {action} / end\n" 1009 " Update indirect action.\n\n" 1010 1011 "flow indirect_action {port_id} destroy" 1012 " action_id {indirect_action_id} [...]\n" 1013 " Destroy specific indirect actions.\n\n" 1014 1015 "flow indirect_action {port_id} query" 1016 " {indirect_action_id}\n" 1017 " Query an existing indirect action.\n\n" 1018 1019 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" 1020 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" 1021 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n" 1022 " Configure the VXLAN encapsulation for flows.\n\n" 1023 1024 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)" 1025 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)" 1026 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)" 1027 " eth-dst (eth-dst)\n" 1028 " Configure the VXLAN encapsulation for flows.\n\n" 1029 1030 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src" 1031 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)" 1032 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)" 1033 " eth-dst (eth-dst)\n" 1034 " Configure the VXLAN encapsulation for flows.\n\n" 1035 1036 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src" 1037 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst" 1038 " (eth-dst)\n" 1039 " Configure the NVGRE encapsulation for flows.\n\n" 1040 1041 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)" 1042 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)" 1043 " eth-src (eth-src) eth-dst (eth-dst)\n" 1044 " Configure the NVGRE encapsulation for flows.\n\n" 1045 1046 "set raw_encap {flow items}\n" 1047 " Configure the encapsulation with raw data.\n\n" 1048 1049 "set raw_decap {flow items}\n" 1050 " Configure the decapsulation with raw data.\n\n" 1051 1052 ); 1053 } 1054 1055 if (show_all || !strcmp(res->section, "traffic_management")) { 1056 cmdline_printf( 1057 cl, 1058 "\n" 1059 "Traffic Management:\n" 1060 "--------------\n" 1061 "show port tm cap (port_id)\n" 1062 " Display the port TM capability.\n\n" 1063 1064 "show port tm level cap (port_id) (level_id)\n" 1065 " Display the port TM hierarchical level capability.\n\n" 1066 1067 "show port tm node cap (port_id) (node_id)\n" 1068 " Display the port TM node capability.\n\n" 1069 1070 "show port tm node type (port_id) (node_id)\n" 1071 " Display the port TM node type.\n\n" 1072 1073 "show port tm node stats (port_id) (node_id) (clear)\n" 1074 " Display the port TM node stats.\n\n" 1075 1076 "add port tm node shaper profile (port_id) (shaper_profile_id)" 1077 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)" 1078 " (packet_length_adjust) (packet_mode)\n" 1079 " Add port tm node private shaper profile.\n\n" 1080 1081 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 1082 " Delete port tm node private shaper profile.\n\n" 1083 1084 "add port tm node shared shaper (port_id) (shared_shaper_id)" 1085 " (shaper_profile_id)\n" 1086 " Add/update port tm node shared shaper.\n\n" 1087 1088 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 1089 " Delete port tm node shared shaper.\n\n" 1090 1091 "set port tm node shaper profile (port_id) (node_id)" 1092 " (shaper_profile_id)\n" 1093 " Set port tm node shaper profile.\n\n" 1094 1095 "add port tm node wred profile (port_id) (wred_profile_id)" 1096 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 1097 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 1098 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 1099 " Add port tm node wred profile.\n\n" 1100 1101 "del port tm node wred profile (port_id) (wred_profile_id)\n" 1102 " Delete port tm node wred profile.\n\n" 1103 1104 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 1105 " (priority) (weight) (level_id) (shaper_profile_id)" 1106 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1107 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1108 " Add port tm nonleaf node.\n\n" 1109 1110 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)" 1111 " (priority) (weight) (level_id) (shaper_profile_id)" 1112 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1113 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1114 " Add port tm nonleaf node with pkt mode enabled.\n\n" 1115 1116 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 1117 " (priority) (weight) (level_id) (shaper_profile_id)" 1118 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 1119 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1120 " Add port tm leaf node.\n\n" 1121 1122 "del port tm node (port_id) (node_id)\n" 1123 " Delete port tm node.\n\n" 1124 1125 "set port tm node parent (port_id) (node_id) (parent_node_id)" 1126 " (priority) (weight)\n" 1127 " Set port tm node parent.\n\n" 1128 1129 "suspend port tm node (port_id) (node_id)" 1130 " Suspend tm node.\n\n" 1131 1132 "resume port tm node (port_id) (node_id)" 1133 " Resume tm node.\n\n" 1134 1135 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 1136 " Commit tm hierarchy.\n\n" 1137 1138 "set port tm mark ip_ecn (port) (green) (yellow)" 1139 " (red)\n" 1140 " Enables/Disables the traffic management marking" 1141 " for IP ECN (Explicit Congestion Notification)" 1142 " packets on a given port\n\n" 1143 1144 "set port tm mark ip_dscp (port) (green) (yellow)" 1145 " (red)\n" 1146 " Enables/Disables the traffic management marking" 1147 " on the port for IP dscp packets\n\n" 1148 1149 "set port tm mark vlan_dei (port) (green) (yellow)" 1150 " (red)\n" 1151 " Enables/Disables the traffic management marking" 1152 " on the port for VLAN packets with DEI enabled\n\n" 1153 ); 1154 } 1155 1156 if (show_all || !strcmp(res->section, "devices")) { 1157 cmdline_printf( 1158 cl, 1159 "\n" 1160 "Device Operations:\n" 1161 "--------------\n" 1162 "device detach (identifier)\n" 1163 " Detach device by identifier.\n\n" 1164 ); 1165 } 1166 1167 } 1168 1169 cmdline_parse_token_string_t cmd_help_long_help = 1170 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1171 1172 cmdline_parse_token_string_t cmd_help_long_section = 1173 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1174 "all#control#display#config#" 1175 "ports#registers#filters#traffic_management#devices"); 1176 1177 cmdline_parse_inst_t cmd_help_long = { 1178 .f = cmd_help_long_parsed, 1179 .data = NULL, 1180 .help_str = "help all|control|display|config|ports|register|" 1181 "filters|traffic_management|devices: " 1182 "Show help", 1183 .tokens = { 1184 (void *)&cmd_help_long_help, 1185 (void *)&cmd_help_long_section, 1186 NULL, 1187 }, 1188 }; 1189 1190 1191 /* *** start/stop/close all ports *** */ 1192 struct cmd_operate_port_result { 1193 cmdline_fixed_string_t keyword; 1194 cmdline_fixed_string_t name; 1195 cmdline_fixed_string_t value; 1196 }; 1197 1198 static void cmd_operate_port_parsed(void *parsed_result, 1199 __rte_unused struct cmdline *cl, 1200 __rte_unused void *data) 1201 { 1202 struct cmd_operate_port_result *res = parsed_result; 1203 1204 if (!strcmp(res->name, "start")) 1205 start_port(RTE_PORT_ALL); 1206 else if (!strcmp(res->name, "stop")) 1207 stop_port(RTE_PORT_ALL); 1208 else if (!strcmp(res->name, "close")) 1209 close_port(RTE_PORT_ALL); 1210 else if (!strcmp(res->name, "reset")) 1211 reset_port(RTE_PORT_ALL); 1212 else 1213 fprintf(stderr, "Unknown parameter\n"); 1214 } 1215 1216 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1217 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1218 "port"); 1219 cmdline_parse_token_string_t cmd_operate_port_all_port = 1220 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1221 "start#stop#close#reset"); 1222 cmdline_parse_token_string_t cmd_operate_port_all_all = 1223 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1224 1225 cmdline_parse_inst_t cmd_operate_port = { 1226 .f = cmd_operate_port_parsed, 1227 .data = NULL, 1228 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports", 1229 .tokens = { 1230 (void *)&cmd_operate_port_all_cmd, 1231 (void *)&cmd_operate_port_all_port, 1232 (void *)&cmd_operate_port_all_all, 1233 NULL, 1234 }, 1235 }; 1236 1237 /* *** start/stop/close specific port *** */ 1238 struct cmd_operate_specific_port_result { 1239 cmdline_fixed_string_t keyword; 1240 cmdline_fixed_string_t name; 1241 uint8_t value; 1242 }; 1243 1244 static void cmd_operate_specific_port_parsed(void *parsed_result, 1245 __rte_unused struct cmdline *cl, 1246 __rte_unused void *data) 1247 { 1248 struct cmd_operate_specific_port_result *res = parsed_result; 1249 1250 if (!strcmp(res->name, "start")) 1251 start_port(res->value); 1252 else if (!strcmp(res->name, "stop")) 1253 stop_port(res->value); 1254 else if (!strcmp(res->name, "close")) 1255 close_port(res->value); 1256 else if (!strcmp(res->name, "reset")) 1257 reset_port(res->value); 1258 else 1259 fprintf(stderr, "Unknown parameter\n"); 1260 } 1261 1262 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1263 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1264 keyword, "port"); 1265 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1266 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1267 name, "start#stop#close#reset"); 1268 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1269 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1270 value, RTE_UINT8); 1271 1272 cmdline_parse_inst_t cmd_operate_specific_port = { 1273 .f = cmd_operate_specific_port_parsed, 1274 .data = NULL, 1275 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id", 1276 .tokens = { 1277 (void *)&cmd_operate_specific_port_cmd, 1278 (void *)&cmd_operate_specific_port_port, 1279 (void *)&cmd_operate_specific_port_id, 1280 NULL, 1281 }, 1282 }; 1283 1284 /* *** enable port setup (after attach) via iterator or event *** */ 1285 struct cmd_set_port_setup_on_result { 1286 cmdline_fixed_string_t set; 1287 cmdline_fixed_string_t port; 1288 cmdline_fixed_string_t setup; 1289 cmdline_fixed_string_t on; 1290 cmdline_fixed_string_t mode; 1291 }; 1292 1293 static void cmd_set_port_setup_on_parsed(void *parsed_result, 1294 __rte_unused struct cmdline *cl, 1295 __rte_unused void *data) 1296 { 1297 struct cmd_set_port_setup_on_result *res = parsed_result; 1298 1299 if (strcmp(res->mode, "event") == 0) 1300 setup_on_probe_event = true; 1301 else if (strcmp(res->mode, "iterator") == 0) 1302 setup_on_probe_event = false; 1303 else 1304 fprintf(stderr, "Unknown mode\n"); 1305 } 1306 1307 cmdline_parse_token_string_t cmd_set_port_setup_on_set = 1308 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1309 set, "set"); 1310 cmdline_parse_token_string_t cmd_set_port_setup_on_port = 1311 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1312 port, "port"); 1313 cmdline_parse_token_string_t cmd_set_port_setup_on_setup = 1314 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1315 setup, "setup"); 1316 cmdline_parse_token_string_t cmd_set_port_setup_on_on = 1317 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1318 on, "on"); 1319 cmdline_parse_token_string_t cmd_set_port_setup_on_mode = 1320 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1321 mode, "iterator#event"); 1322 1323 cmdline_parse_inst_t cmd_set_port_setup_on = { 1324 .f = cmd_set_port_setup_on_parsed, 1325 .data = NULL, 1326 .help_str = "set port setup on iterator|event", 1327 .tokens = { 1328 (void *)&cmd_set_port_setup_on_set, 1329 (void *)&cmd_set_port_setup_on_port, 1330 (void *)&cmd_set_port_setup_on_setup, 1331 (void *)&cmd_set_port_setup_on_on, 1332 (void *)&cmd_set_port_setup_on_mode, 1333 NULL, 1334 }, 1335 }; 1336 1337 /* *** attach a specified port *** */ 1338 struct cmd_operate_attach_port_result { 1339 cmdline_fixed_string_t port; 1340 cmdline_fixed_string_t keyword; 1341 cmdline_multi_string_t identifier; 1342 }; 1343 1344 static void cmd_operate_attach_port_parsed(void *parsed_result, 1345 __rte_unused struct cmdline *cl, 1346 __rte_unused void *data) 1347 { 1348 struct cmd_operate_attach_port_result *res = parsed_result; 1349 1350 if (!strcmp(res->keyword, "attach")) 1351 attach_port(res->identifier); 1352 else 1353 fprintf(stderr, "Unknown parameter\n"); 1354 } 1355 1356 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1357 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1358 port, "port"); 1359 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1360 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1361 keyword, "attach"); 1362 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1363 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1364 identifier, TOKEN_STRING_MULTI); 1365 1366 cmdline_parse_inst_t cmd_operate_attach_port = { 1367 .f = cmd_operate_attach_port_parsed, 1368 .data = NULL, 1369 .help_str = "port attach <identifier>: " 1370 "(identifier: pci address or virtual dev name)", 1371 .tokens = { 1372 (void *)&cmd_operate_attach_port_port, 1373 (void *)&cmd_operate_attach_port_keyword, 1374 (void *)&cmd_operate_attach_port_identifier, 1375 NULL, 1376 }, 1377 }; 1378 1379 /* *** detach a specified port *** */ 1380 struct cmd_operate_detach_port_result { 1381 cmdline_fixed_string_t port; 1382 cmdline_fixed_string_t keyword; 1383 portid_t port_id; 1384 }; 1385 1386 static void cmd_operate_detach_port_parsed(void *parsed_result, 1387 __rte_unused struct cmdline *cl, 1388 __rte_unused void *data) 1389 { 1390 struct cmd_operate_detach_port_result *res = parsed_result; 1391 1392 if (!strcmp(res->keyword, "detach")) { 1393 RTE_ETH_VALID_PORTID_OR_RET(res->port_id); 1394 detach_port_device(res->port_id); 1395 } else { 1396 fprintf(stderr, "Unknown parameter\n"); 1397 } 1398 } 1399 1400 cmdline_parse_token_string_t cmd_operate_detach_port_port = 1401 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1402 port, "port"); 1403 cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1404 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1405 keyword, "detach"); 1406 cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1407 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1408 port_id, RTE_UINT16); 1409 1410 cmdline_parse_inst_t cmd_operate_detach_port = { 1411 .f = cmd_operate_detach_port_parsed, 1412 .data = NULL, 1413 .help_str = "port detach <port_id>", 1414 .tokens = { 1415 (void *)&cmd_operate_detach_port_port, 1416 (void *)&cmd_operate_detach_port_keyword, 1417 (void *)&cmd_operate_detach_port_port_id, 1418 NULL, 1419 }, 1420 }; 1421 1422 /* *** detach device by identifier *** */ 1423 struct cmd_operate_detach_device_result { 1424 cmdline_fixed_string_t device; 1425 cmdline_fixed_string_t keyword; 1426 cmdline_fixed_string_t identifier; 1427 }; 1428 1429 static void cmd_operate_detach_device_parsed(void *parsed_result, 1430 __rte_unused struct cmdline *cl, 1431 __rte_unused void *data) 1432 { 1433 struct cmd_operate_detach_device_result *res = parsed_result; 1434 1435 if (!strcmp(res->keyword, "detach")) 1436 detach_devargs(res->identifier); 1437 else 1438 fprintf(stderr, "Unknown parameter\n"); 1439 } 1440 1441 cmdline_parse_token_string_t cmd_operate_detach_device_device = 1442 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1443 device, "device"); 1444 cmdline_parse_token_string_t cmd_operate_detach_device_keyword = 1445 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1446 keyword, "detach"); 1447 cmdline_parse_token_string_t cmd_operate_detach_device_identifier = 1448 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1449 identifier, NULL); 1450 1451 cmdline_parse_inst_t cmd_operate_detach_device = { 1452 .f = cmd_operate_detach_device_parsed, 1453 .data = NULL, 1454 .help_str = "device detach <identifier>:" 1455 "(identifier: pci address or virtual dev name)", 1456 .tokens = { 1457 (void *)&cmd_operate_detach_device_device, 1458 (void *)&cmd_operate_detach_device_keyword, 1459 (void *)&cmd_operate_detach_device_identifier, 1460 NULL, 1461 }, 1462 }; 1463 /* *** configure speed for all ports *** */ 1464 struct cmd_config_speed_all { 1465 cmdline_fixed_string_t port; 1466 cmdline_fixed_string_t keyword; 1467 cmdline_fixed_string_t all; 1468 cmdline_fixed_string_t item1; 1469 cmdline_fixed_string_t item2; 1470 cmdline_fixed_string_t value1; 1471 cmdline_fixed_string_t value2; 1472 }; 1473 1474 static int 1475 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1476 { 1477 1478 int duplex; 1479 1480 if (!strcmp(duplexstr, "half")) { 1481 duplex = ETH_LINK_HALF_DUPLEX; 1482 } else if (!strcmp(duplexstr, "full")) { 1483 duplex = ETH_LINK_FULL_DUPLEX; 1484 } else if (!strcmp(duplexstr, "auto")) { 1485 duplex = ETH_LINK_FULL_DUPLEX; 1486 } else { 1487 fprintf(stderr, "Unknown duplex parameter\n"); 1488 return -1; 1489 } 1490 1491 if (!strcmp(speedstr, "10")) { 1492 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1493 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M; 1494 } else if (!strcmp(speedstr, "100")) { 1495 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1496 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M; 1497 } else { 1498 if (duplex != ETH_LINK_FULL_DUPLEX) { 1499 fprintf(stderr, "Invalid speed/duplex parameters\n"); 1500 return -1; 1501 } 1502 if (!strcmp(speedstr, "1000")) { 1503 *speed = ETH_LINK_SPEED_1G; 1504 } else if (!strcmp(speedstr, "10000")) { 1505 *speed = ETH_LINK_SPEED_10G; 1506 } else if (!strcmp(speedstr, "25000")) { 1507 *speed = ETH_LINK_SPEED_25G; 1508 } else if (!strcmp(speedstr, "40000")) { 1509 *speed = ETH_LINK_SPEED_40G; 1510 } else if (!strcmp(speedstr, "50000")) { 1511 *speed = ETH_LINK_SPEED_50G; 1512 } else if (!strcmp(speedstr, "100000")) { 1513 *speed = ETH_LINK_SPEED_100G; 1514 } else if (!strcmp(speedstr, "200000")) { 1515 *speed = ETH_LINK_SPEED_200G; 1516 } else if (!strcmp(speedstr, "auto")) { 1517 *speed = ETH_LINK_SPEED_AUTONEG; 1518 } else { 1519 fprintf(stderr, "Unknown speed parameter\n"); 1520 return -1; 1521 } 1522 } 1523 1524 if (*speed != ETH_LINK_SPEED_AUTONEG) 1525 *speed |= ETH_LINK_SPEED_FIXED; 1526 1527 return 0; 1528 } 1529 1530 static void 1531 cmd_config_speed_all_parsed(void *parsed_result, 1532 __rte_unused struct cmdline *cl, 1533 __rte_unused void *data) 1534 { 1535 struct cmd_config_speed_all *res = parsed_result; 1536 uint32_t link_speed; 1537 portid_t pid; 1538 1539 if (!all_ports_stopped()) { 1540 fprintf(stderr, "Please stop all ports first\n"); 1541 return; 1542 } 1543 1544 if (parse_and_check_speed_duplex(res->value1, res->value2, 1545 &link_speed) < 0) 1546 return; 1547 1548 RTE_ETH_FOREACH_DEV(pid) { 1549 ports[pid].dev_conf.link_speeds = link_speed; 1550 } 1551 1552 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1553 } 1554 1555 cmdline_parse_token_string_t cmd_config_speed_all_port = 1556 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1557 cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1558 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1559 "config"); 1560 cmdline_parse_token_string_t cmd_config_speed_all_all = 1561 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1562 cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1563 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1564 cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1565 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1566 "10#100#1000#10000#25000#40000#50000#100000#200000#auto"); 1567 cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1568 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1569 cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1570 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1571 "half#full#auto"); 1572 1573 cmdline_parse_inst_t cmd_config_speed_all = { 1574 .f = cmd_config_speed_all_parsed, 1575 .data = NULL, 1576 .help_str = "port config all speed " 1577 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex " 1578 "half|full|auto", 1579 .tokens = { 1580 (void *)&cmd_config_speed_all_port, 1581 (void *)&cmd_config_speed_all_keyword, 1582 (void *)&cmd_config_speed_all_all, 1583 (void *)&cmd_config_speed_all_item1, 1584 (void *)&cmd_config_speed_all_value1, 1585 (void *)&cmd_config_speed_all_item2, 1586 (void *)&cmd_config_speed_all_value2, 1587 NULL, 1588 }, 1589 }; 1590 1591 /* *** configure speed for specific port *** */ 1592 struct cmd_config_speed_specific { 1593 cmdline_fixed_string_t port; 1594 cmdline_fixed_string_t keyword; 1595 portid_t id; 1596 cmdline_fixed_string_t item1; 1597 cmdline_fixed_string_t item2; 1598 cmdline_fixed_string_t value1; 1599 cmdline_fixed_string_t value2; 1600 }; 1601 1602 static void 1603 cmd_config_speed_specific_parsed(void *parsed_result, 1604 __rte_unused struct cmdline *cl, 1605 __rte_unused void *data) 1606 { 1607 struct cmd_config_speed_specific *res = parsed_result; 1608 uint32_t link_speed; 1609 1610 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1611 return; 1612 1613 if (!port_is_stopped(res->id)) { 1614 fprintf(stderr, "Please stop port %d first\n", res->id); 1615 return; 1616 } 1617 1618 if (parse_and_check_speed_duplex(res->value1, res->value2, 1619 &link_speed) < 0) 1620 return; 1621 1622 ports[res->id].dev_conf.link_speeds = link_speed; 1623 1624 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1625 } 1626 1627 1628 cmdline_parse_token_string_t cmd_config_speed_specific_port = 1629 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1630 "port"); 1631 cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1632 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1633 "config"); 1634 cmdline_parse_token_num_t cmd_config_speed_specific_id = 1635 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16); 1636 cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1637 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1638 "speed"); 1639 cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1640 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1641 "10#100#1000#10000#25000#40000#50000#100000#200000#auto"); 1642 cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1643 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1644 "duplex"); 1645 cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1646 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1647 "half#full#auto"); 1648 1649 cmdline_parse_inst_t cmd_config_speed_specific = { 1650 .f = cmd_config_speed_specific_parsed, 1651 .data = NULL, 1652 .help_str = "port config <port_id> speed " 1653 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex " 1654 "half|full|auto", 1655 .tokens = { 1656 (void *)&cmd_config_speed_specific_port, 1657 (void *)&cmd_config_speed_specific_keyword, 1658 (void *)&cmd_config_speed_specific_id, 1659 (void *)&cmd_config_speed_specific_item1, 1660 (void *)&cmd_config_speed_specific_value1, 1661 (void *)&cmd_config_speed_specific_item2, 1662 (void *)&cmd_config_speed_specific_value2, 1663 NULL, 1664 }, 1665 }; 1666 1667 /* *** configure loopback for all ports *** */ 1668 struct cmd_config_loopback_all { 1669 cmdline_fixed_string_t port; 1670 cmdline_fixed_string_t keyword; 1671 cmdline_fixed_string_t all; 1672 cmdline_fixed_string_t item; 1673 uint32_t mode; 1674 }; 1675 1676 static void 1677 cmd_config_loopback_all_parsed(void *parsed_result, 1678 __rte_unused struct cmdline *cl, 1679 __rte_unused void *data) 1680 { 1681 struct cmd_config_loopback_all *res = parsed_result; 1682 portid_t pid; 1683 1684 if (!all_ports_stopped()) { 1685 fprintf(stderr, "Please stop all ports first\n"); 1686 return; 1687 } 1688 1689 RTE_ETH_FOREACH_DEV(pid) { 1690 ports[pid].dev_conf.lpbk_mode = res->mode; 1691 } 1692 1693 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1694 } 1695 1696 cmdline_parse_token_string_t cmd_config_loopback_all_port = 1697 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port"); 1698 cmdline_parse_token_string_t cmd_config_loopback_all_keyword = 1699 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword, 1700 "config"); 1701 cmdline_parse_token_string_t cmd_config_loopback_all_all = 1702 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all"); 1703 cmdline_parse_token_string_t cmd_config_loopback_all_item = 1704 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item, 1705 "loopback"); 1706 cmdline_parse_token_num_t cmd_config_loopback_all_mode = 1707 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32); 1708 1709 cmdline_parse_inst_t cmd_config_loopback_all = { 1710 .f = cmd_config_loopback_all_parsed, 1711 .data = NULL, 1712 .help_str = "port config all loopback <mode>", 1713 .tokens = { 1714 (void *)&cmd_config_loopback_all_port, 1715 (void *)&cmd_config_loopback_all_keyword, 1716 (void *)&cmd_config_loopback_all_all, 1717 (void *)&cmd_config_loopback_all_item, 1718 (void *)&cmd_config_loopback_all_mode, 1719 NULL, 1720 }, 1721 }; 1722 1723 /* *** configure loopback for specific port *** */ 1724 struct cmd_config_loopback_specific { 1725 cmdline_fixed_string_t port; 1726 cmdline_fixed_string_t keyword; 1727 uint16_t port_id; 1728 cmdline_fixed_string_t item; 1729 uint32_t mode; 1730 }; 1731 1732 static void 1733 cmd_config_loopback_specific_parsed(void *parsed_result, 1734 __rte_unused struct cmdline *cl, 1735 __rte_unused void *data) 1736 { 1737 struct cmd_config_loopback_specific *res = parsed_result; 1738 1739 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 1740 return; 1741 1742 if (!port_is_stopped(res->port_id)) { 1743 fprintf(stderr, "Please stop port %u first\n", res->port_id); 1744 return; 1745 } 1746 1747 ports[res->port_id].dev_conf.lpbk_mode = res->mode; 1748 1749 cmd_reconfig_device_queue(res->port_id, 1, 1); 1750 } 1751 1752 1753 cmdline_parse_token_string_t cmd_config_loopback_specific_port = 1754 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port, 1755 "port"); 1756 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword = 1757 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword, 1758 "config"); 1759 cmdline_parse_token_num_t cmd_config_loopback_specific_id = 1760 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id, 1761 RTE_UINT16); 1762 cmdline_parse_token_string_t cmd_config_loopback_specific_item = 1763 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item, 1764 "loopback"); 1765 cmdline_parse_token_num_t cmd_config_loopback_specific_mode = 1766 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode, 1767 RTE_UINT32); 1768 1769 cmdline_parse_inst_t cmd_config_loopback_specific = { 1770 .f = cmd_config_loopback_specific_parsed, 1771 .data = NULL, 1772 .help_str = "port config <port_id> loopback <mode>", 1773 .tokens = { 1774 (void *)&cmd_config_loopback_specific_port, 1775 (void *)&cmd_config_loopback_specific_keyword, 1776 (void *)&cmd_config_loopback_specific_id, 1777 (void *)&cmd_config_loopback_specific_item, 1778 (void *)&cmd_config_loopback_specific_mode, 1779 NULL, 1780 }, 1781 }; 1782 1783 /* *** configure txq/rxq, txd/rxd *** */ 1784 struct cmd_config_rx_tx { 1785 cmdline_fixed_string_t port; 1786 cmdline_fixed_string_t keyword; 1787 cmdline_fixed_string_t all; 1788 cmdline_fixed_string_t name; 1789 uint16_t value; 1790 }; 1791 1792 static void 1793 cmd_config_rx_tx_parsed(void *parsed_result, 1794 __rte_unused struct cmdline *cl, 1795 __rte_unused void *data) 1796 { 1797 struct cmd_config_rx_tx *res = parsed_result; 1798 1799 if (!all_ports_stopped()) { 1800 fprintf(stderr, "Please stop all ports first\n"); 1801 return; 1802 } 1803 if (!strcmp(res->name, "rxq")) { 1804 if (!res->value && !nb_txq) { 1805 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n"); 1806 return; 1807 } 1808 if (check_nb_rxq(res->value) != 0) 1809 return; 1810 nb_rxq = res->value; 1811 } 1812 else if (!strcmp(res->name, "txq")) { 1813 if (!res->value && !nb_rxq) { 1814 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n"); 1815 return; 1816 } 1817 if (check_nb_txq(res->value) != 0) 1818 return; 1819 nb_txq = res->value; 1820 } 1821 else if (!strcmp(res->name, "rxd")) { 1822 if (check_nb_rxd(res->value) != 0) 1823 return; 1824 nb_rxd = res->value; 1825 } else if (!strcmp(res->name, "txd")) { 1826 if (check_nb_txd(res->value) != 0) 1827 return; 1828 1829 nb_txd = res->value; 1830 } else { 1831 fprintf(stderr, "Unknown parameter\n"); 1832 return; 1833 } 1834 1835 fwd_config_setup(); 1836 1837 init_port_config(); 1838 1839 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1840 } 1841 1842 cmdline_parse_token_string_t cmd_config_rx_tx_port = 1843 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1844 cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1845 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1846 cmdline_parse_token_string_t cmd_config_rx_tx_all = 1847 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1848 cmdline_parse_token_string_t cmd_config_rx_tx_name = 1849 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1850 "rxq#txq#rxd#txd"); 1851 cmdline_parse_token_num_t cmd_config_rx_tx_value = 1852 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16); 1853 1854 cmdline_parse_inst_t cmd_config_rx_tx = { 1855 .f = cmd_config_rx_tx_parsed, 1856 .data = NULL, 1857 .help_str = "port config all rxq|txq|rxd|txd <value>", 1858 .tokens = { 1859 (void *)&cmd_config_rx_tx_port, 1860 (void *)&cmd_config_rx_tx_keyword, 1861 (void *)&cmd_config_rx_tx_all, 1862 (void *)&cmd_config_rx_tx_name, 1863 (void *)&cmd_config_rx_tx_value, 1864 NULL, 1865 }, 1866 }; 1867 1868 /* *** config max packet length *** */ 1869 struct cmd_config_max_pkt_len_result { 1870 cmdline_fixed_string_t port; 1871 cmdline_fixed_string_t keyword; 1872 cmdline_fixed_string_t all; 1873 cmdline_fixed_string_t name; 1874 uint32_t value; 1875 }; 1876 1877 static void 1878 cmd_config_max_pkt_len_parsed(void *parsed_result, 1879 __rte_unused struct cmdline *cl, 1880 __rte_unused void *data) 1881 { 1882 struct cmd_config_max_pkt_len_result *res = parsed_result; 1883 uint32_t max_rx_pkt_len_backup = 0; 1884 portid_t pid; 1885 int ret; 1886 1887 if (!all_ports_stopped()) { 1888 fprintf(stderr, "Please stop all ports first\n"); 1889 return; 1890 } 1891 1892 RTE_ETH_FOREACH_DEV(pid) { 1893 struct rte_port *port = &ports[pid]; 1894 1895 if (!strcmp(res->name, "max-pkt-len")) { 1896 if (res->value < RTE_ETHER_MIN_LEN) { 1897 fprintf(stderr, 1898 "max-pkt-len can not be less than %d\n", 1899 RTE_ETHER_MIN_LEN); 1900 return; 1901 } 1902 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len) 1903 return; 1904 1905 ret = eth_dev_info_get_print_err(pid, &port->dev_info); 1906 if (ret != 0) { 1907 fprintf(stderr, 1908 "rte_eth_dev_info_get() failed for port %u\n", 1909 pid); 1910 return; 1911 } 1912 1913 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len; 1914 1915 port->dev_conf.rxmode.max_rx_pkt_len = res->value; 1916 if (update_jumbo_frame_offload(pid) != 0) 1917 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup; 1918 } else { 1919 fprintf(stderr, "Unknown parameter\n"); 1920 return; 1921 } 1922 } 1923 1924 init_port_config(); 1925 1926 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1927 } 1928 1929 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 1930 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 1931 "port"); 1932 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 1933 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 1934 "config"); 1935 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 1936 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 1937 "all"); 1938 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 1939 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 1940 "max-pkt-len"); 1941 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 1942 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 1943 RTE_UINT32); 1944 1945 cmdline_parse_inst_t cmd_config_max_pkt_len = { 1946 .f = cmd_config_max_pkt_len_parsed, 1947 .data = NULL, 1948 .help_str = "port config all max-pkt-len <value>", 1949 .tokens = { 1950 (void *)&cmd_config_max_pkt_len_port, 1951 (void *)&cmd_config_max_pkt_len_keyword, 1952 (void *)&cmd_config_max_pkt_len_all, 1953 (void *)&cmd_config_max_pkt_len_name, 1954 (void *)&cmd_config_max_pkt_len_value, 1955 NULL, 1956 }, 1957 }; 1958 1959 /* *** config max LRO aggregated packet size *** */ 1960 struct cmd_config_max_lro_pkt_size_result { 1961 cmdline_fixed_string_t port; 1962 cmdline_fixed_string_t keyword; 1963 cmdline_fixed_string_t all; 1964 cmdline_fixed_string_t name; 1965 uint32_t value; 1966 }; 1967 1968 static void 1969 cmd_config_max_lro_pkt_size_parsed(void *parsed_result, 1970 __rte_unused struct cmdline *cl, 1971 __rte_unused void *data) 1972 { 1973 struct cmd_config_max_lro_pkt_size_result *res = parsed_result; 1974 portid_t pid; 1975 1976 if (!all_ports_stopped()) { 1977 fprintf(stderr, "Please stop all ports first\n"); 1978 return; 1979 } 1980 1981 RTE_ETH_FOREACH_DEV(pid) { 1982 struct rte_port *port = &ports[pid]; 1983 1984 if (!strcmp(res->name, "max-lro-pkt-size")) { 1985 if (res->value == 1986 port->dev_conf.rxmode.max_lro_pkt_size) 1987 return; 1988 1989 port->dev_conf.rxmode.max_lro_pkt_size = res->value; 1990 } else { 1991 fprintf(stderr, "Unknown parameter\n"); 1992 return; 1993 } 1994 } 1995 1996 init_port_config(); 1997 1998 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1999 } 2000 2001 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port = 2002 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2003 port, "port"); 2004 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword = 2005 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2006 keyword, "config"); 2007 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all = 2008 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2009 all, "all"); 2010 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name = 2011 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2012 name, "max-lro-pkt-size"); 2013 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value = 2014 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2015 value, RTE_UINT32); 2016 2017 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = { 2018 .f = cmd_config_max_lro_pkt_size_parsed, 2019 .data = NULL, 2020 .help_str = "port config all max-lro-pkt-size <value>", 2021 .tokens = { 2022 (void *)&cmd_config_max_lro_pkt_size_port, 2023 (void *)&cmd_config_max_lro_pkt_size_keyword, 2024 (void *)&cmd_config_max_lro_pkt_size_all, 2025 (void *)&cmd_config_max_lro_pkt_size_name, 2026 (void *)&cmd_config_max_lro_pkt_size_value, 2027 NULL, 2028 }, 2029 }; 2030 2031 /* *** configure port MTU *** */ 2032 struct cmd_config_mtu_result { 2033 cmdline_fixed_string_t port; 2034 cmdline_fixed_string_t keyword; 2035 cmdline_fixed_string_t mtu; 2036 portid_t port_id; 2037 uint16_t value; 2038 }; 2039 2040 static void 2041 cmd_config_mtu_parsed(void *parsed_result, 2042 __rte_unused struct cmdline *cl, 2043 __rte_unused void *data) 2044 { 2045 struct cmd_config_mtu_result *res = parsed_result; 2046 2047 if (res->value < RTE_ETHER_MIN_LEN) { 2048 fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN); 2049 return; 2050 } 2051 port_mtu_set(res->port_id, res->value); 2052 } 2053 2054 cmdline_parse_token_string_t cmd_config_mtu_port = 2055 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 2056 "port"); 2057 cmdline_parse_token_string_t cmd_config_mtu_keyword = 2058 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2059 "config"); 2060 cmdline_parse_token_string_t cmd_config_mtu_mtu = 2061 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2062 "mtu"); 2063 cmdline_parse_token_num_t cmd_config_mtu_port_id = 2064 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, 2065 RTE_UINT16); 2066 cmdline_parse_token_num_t cmd_config_mtu_value = 2067 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, 2068 RTE_UINT16); 2069 2070 cmdline_parse_inst_t cmd_config_mtu = { 2071 .f = cmd_config_mtu_parsed, 2072 .data = NULL, 2073 .help_str = "port config mtu <port_id> <value>", 2074 .tokens = { 2075 (void *)&cmd_config_mtu_port, 2076 (void *)&cmd_config_mtu_keyword, 2077 (void *)&cmd_config_mtu_mtu, 2078 (void *)&cmd_config_mtu_port_id, 2079 (void *)&cmd_config_mtu_value, 2080 NULL, 2081 }, 2082 }; 2083 2084 /* *** configure rx mode *** */ 2085 struct cmd_config_rx_mode_flag { 2086 cmdline_fixed_string_t port; 2087 cmdline_fixed_string_t keyword; 2088 cmdline_fixed_string_t all; 2089 cmdline_fixed_string_t name; 2090 cmdline_fixed_string_t value; 2091 }; 2092 2093 static void 2094 cmd_config_rx_mode_flag_parsed(void *parsed_result, 2095 __rte_unused struct cmdline *cl, 2096 __rte_unused void *data) 2097 { 2098 struct cmd_config_rx_mode_flag *res = parsed_result; 2099 2100 if (!all_ports_stopped()) { 2101 fprintf(stderr, "Please stop all ports first\n"); 2102 return; 2103 } 2104 2105 if (!strcmp(res->name, "drop-en")) { 2106 if (!strcmp(res->value, "on")) 2107 rx_drop_en = 1; 2108 else if (!strcmp(res->value, "off")) 2109 rx_drop_en = 0; 2110 else { 2111 fprintf(stderr, "Unknown parameter\n"); 2112 return; 2113 } 2114 } else { 2115 fprintf(stderr, "Unknown parameter\n"); 2116 return; 2117 } 2118 2119 init_port_config(); 2120 2121 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2122 } 2123 2124 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 2125 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 2126 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 2127 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 2128 "config"); 2129 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 2130 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 2131 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 2132 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 2133 "drop-en"); 2134 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 2135 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 2136 "on#off"); 2137 2138 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 2139 .f = cmd_config_rx_mode_flag_parsed, 2140 .data = NULL, 2141 .help_str = "port config all drop-en on|off", 2142 .tokens = { 2143 (void *)&cmd_config_rx_mode_flag_port, 2144 (void *)&cmd_config_rx_mode_flag_keyword, 2145 (void *)&cmd_config_rx_mode_flag_all, 2146 (void *)&cmd_config_rx_mode_flag_name, 2147 (void *)&cmd_config_rx_mode_flag_value, 2148 NULL, 2149 }, 2150 }; 2151 2152 /* *** configure rss *** */ 2153 struct cmd_config_rss { 2154 cmdline_fixed_string_t port; 2155 cmdline_fixed_string_t keyword; 2156 cmdline_fixed_string_t all; 2157 cmdline_fixed_string_t name; 2158 cmdline_fixed_string_t value; 2159 }; 2160 2161 static void 2162 cmd_config_rss_parsed(void *parsed_result, 2163 __rte_unused struct cmdline *cl, 2164 __rte_unused void *data) 2165 { 2166 struct cmd_config_rss *res = parsed_result; 2167 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2168 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2169 int use_default = 0; 2170 int all_updated = 1; 2171 int diag; 2172 uint16_t i; 2173 int ret; 2174 2175 if (!strcmp(res->value, "all")) 2176 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP | 2177 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP | 2178 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP | 2179 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU | 2180 ETH_RSS_ECPRI; 2181 else if (!strcmp(res->value, "eth")) 2182 rss_conf.rss_hf = ETH_RSS_ETH; 2183 else if (!strcmp(res->value, "vlan")) 2184 rss_conf.rss_hf = ETH_RSS_VLAN; 2185 else if (!strcmp(res->value, "ip")) 2186 rss_conf.rss_hf = ETH_RSS_IP; 2187 else if (!strcmp(res->value, "udp")) 2188 rss_conf.rss_hf = ETH_RSS_UDP; 2189 else if (!strcmp(res->value, "tcp")) 2190 rss_conf.rss_hf = ETH_RSS_TCP; 2191 else if (!strcmp(res->value, "sctp")) 2192 rss_conf.rss_hf = ETH_RSS_SCTP; 2193 else if (!strcmp(res->value, "ether")) 2194 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 2195 else if (!strcmp(res->value, "port")) 2196 rss_conf.rss_hf = ETH_RSS_PORT; 2197 else if (!strcmp(res->value, "vxlan")) 2198 rss_conf.rss_hf = ETH_RSS_VXLAN; 2199 else if (!strcmp(res->value, "geneve")) 2200 rss_conf.rss_hf = ETH_RSS_GENEVE; 2201 else if (!strcmp(res->value, "nvgre")) 2202 rss_conf.rss_hf = ETH_RSS_NVGRE; 2203 else if (!strcmp(res->value, "l3-pre32")) 2204 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32; 2205 else if (!strcmp(res->value, "l3-pre40")) 2206 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40; 2207 else if (!strcmp(res->value, "l3-pre48")) 2208 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48; 2209 else if (!strcmp(res->value, "l3-pre56")) 2210 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56; 2211 else if (!strcmp(res->value, "l3-pre64")) 2212 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64; 2213 else if (!strcmp(res->value, "l3-pre96")) 2214 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96; 2215 else if (!strcmp(res->value, "l3-src-only")) 2216 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY; 2217 else if (!strcmp(res->value, "l3-dst-only")) 2218 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY; 2219 else if (!strcmp(res->value, "l4-src-only")) 2220 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY; 2221 else if (!strcmp(res->value, "l4-dst-only")) 2222 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY; 2223 else if (!strcmp(res->value, "l2-src-only")) 2224 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY; 2225 else if (!strcmp(res->value, "l2-dst-only")) 2226 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY; 2227 else if (!strcmp(res->value, "l2tpv3")) 2228 rss_conf.rss_hf = ETH_RSS_L2TPV3; 2229 else if (!strcmp(res->value, "esp")) 2230 rss_conf.rss_hf = ETH_RSS_ESP; 2231 else if (!strcmp(res->value, "ah")) 2232 rss_conf.rss_hf = ETH_RSS_AH; 2233 else if (!strcmp(res->value, "pfcp")) 2234 rss_conf.rss_hf = ETH_RSS_PFCP; 2235 else if (!strcmp(res->value, "pppoe")) 2236 rss_conf.rss_hf = ETH_RSS_PPPOE; 2237 else if (!strcmp(res->value, "gtpu")) 2238 rss_conf.rss_hf = ETH_RSS_GTPU; 2239 else if (!strcmp(res->value, "ecpri")) 2240 rss_conf.rss_hf = ETH_RSS_ECPRI; 2241 else if (!strcmp(res->value, "mpls")) 2242 rss_conf.rss_hf = ETH_RSS_MPLS; 2243 else if (!strcmp(res->value, "ipv4-chksum")) 2244 rss_conf.rss_hf = ETH_RSS_IPV4_CHKSUM; 2245 else if (!strcmp(res->value, "none")) 2246 rss_conf.rss_hf = 0; 2247 else if (!strcmp(res->value, "level-default")) { 2248 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2249 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT); 2250 } else if (!strcmp(res->value, "level-outer")) { 2251 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2252 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST); 2253 } else if (!strcmp(res->value, "level-inner")) { 2254 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2255 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST); 2256 } else if (!strcmp(res->value, "default")) 2257 use_default = 1; 2258 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 2259 atoi(res->value) < 64) 2260 rss_conf.rss_hf = 1ULL << atoi(res->value); 2261 else { 2262 fprintf(stderr, "Unknown parameter\n"); 2263 return; 2264 } 2265 rss_conf.rss_key = NULL; 2266 /* Update global configuration for RSS types. */ 2267 RTE_ETH_FOREACH_DEV(i) { 2268 struct rte_eth_rss_conf local_rss_conf; 2269 2270 ret = eth_dev_info_get_print_err(i, &dev_info); 2271 if (ret != 0) 2272 return; 2273 2274 if (use_default) 2275 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2276 2277 local_rss_conf = rss_conf; 2278 local_rss_conf.rss_hf = rss_conf.rss_hf & 2279 dev_info.flow_type_rss_offloads; 2280 if (local_rss_conf.rss_hf != rss_conf.rss_hf) { 2281 printf("Port %u modified RSS hash function based on hardware support," 2282 "requested:%#"PRIx64" configured:%#"PRIx64"\n", 2283 i, rss_conf.rss_hf, local_rss_conf.rss_hf); 2284 } 2285 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf); 2286 if (diag < 0) { 2287 all_updated = 0; 2288 fprintf(stderr, 2289 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n", 2290 i, -diag, strerror(-diag)); 2291 } 2292 } 2293 if (all_updated && !use_default) { 2294 rss_hf = rss_conf.rss_hf; 2295 printf("rss_hf %#"PRIx64"\n", rss_hf); 2296 } 2297 } 2298 2299 cmdline_parse_token_string_t cmd_config_rss_port = 2300 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2301 cmdline_parse_token_string_t cmd_config_rss_keyword = 2302 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2303 cmdline_parse_token_string_t cmd_config_rss_all = 2304 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2305 cmdline_parse_token_string_t cmd_config_rss_name = 2306 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2307 cmdline_parse_token_string_t cmd_config_rss_value = 2308 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2309 2310 cmdline_parse_inst_t cmd_config_rss = { 2311 .f = cmd_config_rss_parsed, 2312 .data = NULL, 2313 .help_str = "port config all rss " 2314 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|" 2315 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|" 2316 "level-outer|level-inner|ipv4-chksum|<flowtype_id>", 2317 .tokens = { 2318 (void *)&cmd_config_rss_port, 2319 (void *)&cmd_config_rss_keyword, 2320 (void *)&cmd_config_rss_all, 2321 (void *)&cmd_config_rss_name, 2322 (void *)&cmd_config_rss_value, 2323 NULL, 2324 }, 2325 }; 2326 2327 /* *** configure rss hash key *** */ 2328 struct cmd_config_rss_hash_key { 2329 cmdline_fixed_string_t port; 2330 cmdline_fixed_string_t config; 2331 portid_t port_id; 2332 cmdline_fixed_string_t rss_hash_key; 2333 cmdline_fixed_string_t rss_type; 2334 cmdline_fixed_string_t key; 2335 }; 2336 2337 static uint8_t 2338 hexa_digit_to_value(char hexa_digit) 2339 { 2340 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2341 return (uint8_t) (hexa_digit - '0'); 2342 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2343 return (uint8_t) ((hexa_digit - 'a') + 10); 2344 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2345 return (uint8_t) ((hexa_digit - 'A') + 10); 2346 /* Invalid hexa digit */ 2347 return 0xFF; 2348 } 2349 2350 static uint8_t 2351 parse_and_check_key_hexa_digit(char *key, int idx) 2352 { 2353 uint8_t hexa_v; 2354 2355 hexa_v = hexa_digit_to_value(key[idx]); 2356 if (hexa_v == 0xFF) 2357 fprintf(stderr, 2358 "invalid key: character %c at position %d is not a valid hexa digit\n", 2359 key[idx], idx); 2360 return hexa_v; 2361 } 2362 2363 static void 2364 cmd_config_rss_hash_key_parsed(void *parsed_result, 2365 __rte_unused struct cmdline *cl, 2366 __rte_unused void *data) 2367 { 2368 struct cmd_config_rss_hash_key *res = parsed_result; 2369 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2370 uint8_t xdgt0; 2371 uint8_t xdgt1; 2372 int i; 2373 struct rte_eth_dev_info dev_info; 2374 uint8_t hash_key_size; 2375 uint32_t key_len; 2376 int ret; 2377 2378 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2379 if (ret != 0) 2380 return; 2381 2382 if (dev_info.hash_key_size > 0 && 2383 dev_info.hash_key_size <= sizeof(hash_key)) 2384 hash_key_size = dev_info.hash_key_size; 2385 else { 2386 fprintf(stderr, 2387 "dev_info did not provide a valid hash key size\n"); 2388 return; 2389 } 2390 /* Check the length of the RSS hash key */ 2391 key_len = strlen(res->key); 2392 if (key_len != (hash_key_size * 2)) { 2393 fprintf(stderr, 2394 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n", 2395 (int)key_len, hash_key_size * 2); 2396 return; 2397 } 2398 /* Translate RSS hash key into binary representation */ 2399 for (i = 0; i < hash_key_size; i++) { 2400 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2401 if (xdgt0 == 0xFF) 2402 return; 2403 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2404 if (xdgt1 == 0xFF) 2405 return; 2406 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2407 } 2408 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2409 hash_key_size); 2410 } 2411 2412 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2413 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2414 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2415 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2416 "config"); 2417 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2418 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, 2419 RTE_UINT16); 2420 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2421 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2422 rss_hash_key, "rss-hash-key"); 2423 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2424 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2425 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2426 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2427 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2428 "ipv6-tcp-ex#ipv6-udp-ex#" 2429 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#" 2430 "l2-src-only#l2-dst-only#s-vlan#c-vlan#" 2431 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls"); 2432 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2433 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2434 2435 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2436 .f = cmd_config_rss_hash_key_parsed, 2437 .data = NULL, 2438 .help_str = "port config <port_id> rss-hash-key " 2439 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2440 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2441 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|" 2442 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|" 2443 "l2-src-only|l2-dst-only|s-vlan|c-vlan|" 2444 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls " 2445 "<string of hex digits (variable length, NIC dependent)>", 2446 .tokens = { 2447 (void *)&cmd_config_rss_hash_key_port, 2448 (void *)&cmd_config_rss_hash_key_config, 2449 (void *)&cmd_config_rss_hash_key_port_id, 2450 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2451 (void *)&cmd_config_rss_hash_key_rss_type, 2452 (void *)&cmd_config_rss_hash_key_value, 2453 NULL, 2454 }, 2455 }; 2456 2457 /* *** cleanup txq mbufs *** */ 2458 struct cmd_cleanup_txq_mbufs_result { 2459 cmdline_fixed_string_t port; 2460 cmdline_fixed_string_t keyword; 2461 cmdline_fixed_string_t name; 2462 uint16_t port_id; 2463 uint16_t queue_id; 2464 uint32_t free_cnt; 2465 }; 2466 2467 static void 2468 cmd_cleanup_txq_mbufs_parsed(void *parsed_result, 2469 __rte_unused struct cmdline *cl, 2470 __rte_unused void *data) 2471 { 2472 struct cmd_cleanup_txq_mbufs_result *res = parsed_result; 2473 uint16_t port_id = res->port_id; 2474 uint16_t queue_id = res->queue_id; 2475 uint32_t free_cnt = res->free_cnt; 2476 struct rte_eth_txq_info qinfo; 2477 int ret; 2478 2479 if (test_done == 0) { 2480 fprintf(stderr, "Please stop forwarding first\n"); 2481 return; 2482 } 2483 2484 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) { 2485 fprintf(stderr, "Failed to get port %u Tx queue %u info\n", 2486 port_id, queue_id); 2487 return; 2488 } 2489 2490 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) { 2491 fprintf(stderr, "Tx queue %u not started\n", queue_id); 2492 return; 2493 } 2494 2495 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt); 2496 if (ret < 0) { 2497 fprintf(stderr, 2498 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n", 2499 port_id, queue_id, strerror(-ret), ret); 2500 return; 2501 } 2502 2503 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n", 2504 port_id, queue_id, ret); 2505 } 2506 2507 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port = 2508 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port, 2509 "port"); 2510 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup = 2511 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword, 2512 "cleanup"); 2513 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id = 2514 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id, 2515 RTE_UINT16); 2516 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq = 2517 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name, 2518 "txq"); 2519 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id = 2520 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id, 2521 RTE_UINT16); 2522 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt = 2523 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt, 2524 RTE_UINT32); 2525 2526 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = { 2527 .f = cmd_cleanup_txq_mbufs_parsed, 2528 .data = NULL, 2529 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>", 2530 .tokens = { 2531 (void *)&cmd_cleanup_txq_mbufs_port, 2532 (void *)&cmd_cleanup_txq_mbufs_cleanup, 2533 (void *)&cmd_cleanup_txq_mbufs_port_id, 2534 (void *)&cmd_cleanup_txq_mbufs_txq, 2535 (void *)&cmd_cleanup_txq_mbufs_queue_id, 2536 (void *)&cmd_cleanup_txq_mbufs_free_cnt, 2537 NULL, 2538 }, 2539 }; 2540 2541 /* *** configure port rxq/txq ring size *** */ 2542 struct cmd_config_rxtx_ring_size { 2543 cmdline_fixed_string_t port; 2544 cmdline_fixed_string_t config; 2545 portid_t portid; 2546 cmdline_fixed_string_t rxtxq; 2547 uint16_t qid; 2548 cmdline_fixed_string_t rsize; 2549 uint16_t size; 2550 }; 2551 2552 static void 2553 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2554 __rte_unused struct cmdline *cl, 2555 __rte_unused void *data) 2556 { 2557 struct cmd_config_rxtx_ring_size *res = parsed_result; 2558 struct rte_port *port; 2559 uint8_t isrx; 2560 2561 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2562 return; 2563 2564 if (res->portid == (portid_t)RTE_PORT_ALL) { 2565 fprintf(stderr, "Invalid port id\n"); 2566 return; 2567 } 2568 2569 port = &ports[res->portid]; 2570 2571 if (!strcmp(res->rxtxq, "rxq")) 2572 isrx = 1; 2573 else if (!strcmp(res->rxtxq, "txq")) 2574 isrx = 0; 2575 else { 2576 fprintf(stderr, "Unknown parameter\n"); 2577 return; 2578 } 2579 2580 if (isrx && rx_queue_id_is_invalid(res->qid)) 2581 return; 2582 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2583 return; 2584 2585 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2586 fprintf(stderr, 2587 "Invalid rx ring_size, must > rx_free_thresh: %d\n", 2588 rx_free_thresh); 2589 return; 2590 } 2591 2592 if (isrx) 2593 port->nb_rx_desc[res->qid] = res->size; 2594 else 2595 port->nb_tx_desc[res->qid] = res->size; 2596 2597 cmd_reconfig_device_queue(res->portid, 0, 1); 2598 } 2599 2600 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2601 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2602 port, "port"); 2603 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2604 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2605 config, "config"); 2606 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2607 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2608 portid, RTE_UINT16); 2609 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2610 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2611 rxtxq, "rxq#txq"); 2612 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2613 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2614 qid, RTE_UINT16); 2615 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2616 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2617 rsize, "ring_size"); 2618 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2619 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2620 size, RTE_UINT16); 2621 2622 cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2623 .f = cmd_config_rxtx_ring_size_parsed, 2624 .data = NULL, 2625 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2626 .tokens = { 2627 (void *)&cmd_config_rxtx_ring_size_port, 2628 (void *)&cmd_config_rxtx_ring_size_config, 2629 (void *)&cmd_config_rxtx_ring_size_portid, 2630 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2631 (void *)&cmd_config_rxtx_ring_size_qid, 2632 (void *)&cmd_config_rxtx_ring_size_rsize, 2633 (void *)&cmd_config_rxtx_ring_size_size, 2634 NULL, 2635 }, 2636 }; 2637 2638 /* *** configure port rxq/txq start/stop *** */ 2639 struct cmd_config_rxtx_queue { 2640 cmdline_fixed_string_t port; 2641 portid_t portid; 2642 cmdline_fixed_string_t rxtxq; 2643 uint16_t qid; 2644 cmdline_fixed_string_t opname; 2645 }; 2646 2647 static void 2648 cmd_config_rxtx_queue_parsed(void *parsed_result, 2649 __rte_unused struct cmdline *cl, 2650 __rte_unused void *data) 2651 { 2652 struct cmd_config_rxtx_queue *res = parsed_result; 2653 uint8_t isrx; 2654 uint8_t isstart; 2655 int ret = 0; 2656 2657 if (test_done == 0) { 2658 fprintf(stderr, "Please stop forwarding first\n"); 2659 return; 2660 } 2661 2662 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2663 return; 2664 2665 if (port_is_started(res->portid) != 1) { 2666 fprintf(stderr, "Please start port %u first\n", res->portid); 2667 return; 2668 } 2669 2670 if (!strcmp(res->rxtxq, "rxq")) 2671 isrx = 1; 2672 else if (!strcmp(res->rxtxq, "txq")) 2673 isrx = 0; 2674 else { 2675 fprintf(stderr, "Unknown parameter\n"); 2676 return; 2677 } 2678 2679 if (isrx && rx_queue_id_is_invalid(res->qid)) 2680 return; 2681 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2682 return; 2683 2684 if (!strcmp(res->opname, "start")) 2685 isstart = 1; 2686 else if (!strcmp(res->opname, "stop")) 2687 isstart = 0; 2688 else { 2689 fprintf(stderr, "Unknown parameter\n"); 2690 return; 2691 } 2692 2693 if (isstart && isrx) 2694 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2695 else if (!isstart && isrx) 2696 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2697 else if (isstart && !isrx) 2698 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2699 else 2700 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2701 2702 if (ret == -ENOTSUP) 2703 fprintf(stderr, "Function not supported in PMD driver\n"); 2704 } 2705 2706 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2707 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2708 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2709 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16); 2710 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2711 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2712 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2713 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16); 2714 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2715 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2716 "start#stop"); 2717 2718 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2719 .f = cmd_config_rxtx_queue_parsed, 2720 .data = NULL, 2721 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2722 .tokens = { 2723 (void *)&cmd_config_rxtx_queue_port, 2724 (void *)&cmd_config_rxtx_queue_portid, 2725 (void *)&cmd_config_rxtx_queue_rxtxq, 2726 (void *)&cmd_config_rxtx_queue_qid, 2727 (void *)&cmd_config_rxtx_queue_opname, 2728 NULL, 2729 }, 2730 }; 2731 2732 /* *** configure port rxq/txq deferred start on/off *** */ 2733 struct cmd_config_deferred_start_rxtx_queue { 2734 cmdline_fixed_string_t port; 2735 portid_t port_id; 2736 cmdline_fixed_string_t rxtxq; 2737 uint16_t qid; 2738 cmdline_fixed_string_t opname; 2739 cmdline_fixed_string_t state; 2740 }; 2741 2742 static void 2743 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, 2744 __rte_unused struct cmdline *cl, 2745 __rte_unused void *data) 2746 { 2747 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; 2748 struct rte_port *port; 2749 uint8_t isrx; 2750 uint8_t ison; 2751 uint8_t needreconfig = 0; 2752 2753 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 2754 return; 2755 2756 if (port_is_started(res->port_id) != 0) { 2757 fprintf(stderr, "Please stop port %u first\n", res->port_id); 2758 return; 2759 } 2760 2761 port = &ports[res->port_id]; 2762 2763 isrx = !strcmp(res->rxtxq, "rxq"); 2764 2765 if (isrx && rx_queue_id_is_invalid(res->qid)) 2766 return; 2767 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2768 return; 2769 2770 ison = !strcmp(res->state, "on"); 2771 2772 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) { 2773 port->rx_conf[res->qid].rx_deferred_start = ison; 2774 needreconfig = 1; 2775 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) { 2776 port->tx_conf[res->qid].tx_deferred_start = ison; 2777 needreconfig = 1; 2778 } 2779 2780 if (needreconfig) 2781 cmd_reconfig_device_queue(res->port_id, 0, 1); 2782 } 2783 2784 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = 2785 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2786 port, "port"); 2787 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = 2788 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2789 port_id, RTE_UINT16); 2790 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = 2791 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2792 rxtxq, "rxq#txq"); 2793 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = 2794 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2795 qid, RTE_UINT16); 2796 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = 2797 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2798 opname, "deferred_start"); 2799 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = 2800 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2801 state, "on#off"); 2802 2803 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { 2804 .f = cmd_config_deferred_start_rxtx_queue_parsed, 2805 .data = NULL, 2806 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", 2807 .tokens = { 2808 (void *)&cmd_config_deferred_start_rxtx_queue_port, 2809 (void *)&cmd_config_deferred_start_rxtx_queue_port_id, 2810 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, 2811 (void *)&cmd_config_deferred_start_rxtx_queue_qid, 2812 (void *)&cmd_config_deferred_start_rxtx_queue_opname, 2813 (void *)&cmd_config_deferred_start_rxtx_queue_state, 2814 NULL, 2815 }, 2816 }; 2817 2818 /* *** configure port rxq/txq setup *** */ 2819 struct cmd_setup_rxtx_queue { 2820 cmdline_fixed_string_t port; 2821 portid_t portid; 2822 cmdline_fixed_string_t rxtxq; 2823 uint16_t qid; 2824 cmdline_fixed_string_t setup; 2825 }; 2826 2827 /* Common CLI fields for queue setup */ 2828 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2829 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2830 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2831 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16); 2832 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2833 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2834 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2835 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16); 2836 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2837 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2838 2839 static void 2840 cmd_setup_rxtx_queue_parsed( 2841 void *parsed_result, 2842 __rte_unused struct cmdline *cl, 2843 __rte_unused void *data) 2844 { 2845 struct cmd_setup_rxtx_queue *res = parsed_result; 2846 struct rte_port *port; 2847 struct rte_mempool *mp; 2848 unsigned int socket_id; 2849 uint8_t isrx = 0; 2850 int ret; 2851 2852 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2853 return; 2854 2855 if (res->portid == (portid_t)RTE_PORT_ALL) { 2856 fprintf(stderr, "Invalid port id\n"); 2857 return; 2858 } 2859 2860 if (!strcmp(res->rxtxq, "rxq")) 2861 isrx = 1; 2862 else if (!strcmp(res->rxtxq, "txq")) 2863 isrx = 0; 2864 else { 2865 fprintf(stderr, "Unknown parameter\n"); 2866 return; 2867 } 2868 2869 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2870 fprintf(stderr, "Invalid rx queue\n"); 2871 return; 2872 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2873 fprintf(stderr, "Invalid tx queue\n"); 2874 return; 2875 } 2876 2877 port = &ports[res->portid]; 2878 if (isrx) { 2879 socket_id = rxring_numa[res->portid]; 2880 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2881 socket_id = port->socket_id; 2882 2883 mp = mbuf_pool_find(socket_id, 0); 2884 if (mp == NULL) { 2885 fprintf(stderr, 2886 "Failed to setup RX queue: No mempool allocation on the socket %d\n", 2887 rxring_numa[res->portid]); 2888 return; 2889 } 2890 ret = rx_queue_setup(res->portid, 2891 res->qid, 2892 port->nb_rx_desc[res->qid], 2893 socket_id, 2894 &port->rx_conf[res->qid], 2895 mp); 2896 if (ret) 2897 fprintf(stderr, "Failed to setup RX queue\n"); 2898 } else { 2899 socket_id = txring_numa[res->portid]; 2900 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2901 socket_id = port->socket_id; 2902 2903 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) { 2904 fprintf(stderr, 2905 "Failed to setup TX queue: not enough descriptors\n"); 2906 return; 2907 } 2908 ret = rte_eth_tx_queue_setup(res->portid, 2909 res->qid, 2910 port->nb_tx_desc[res->qid], 2911 socket_id, 2912 &port->tx_conf[res->qid]); 2913 if (ret) 2914 fprintf(stderr, "Failed to setup TX queue\n"); 2915 } 2916 } 2917 2918 cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2919 .f = cmd_setup_rxtx_queue_parsed, 2920 .data = NULL, 2921 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2922 .tokens = { 2923 (void *)&cmd_setup_rxtx_queue_port, 2924 (void *)&cmd_setup_rxtx_queue_portid, 2925 (void *)&cmd_setup_rxtx_queue_rxtxq, 2926 (void *)&cmd_setup_rxtx_queue_qid, 2927 (void *)&cmd_setup_rxtx_queue_setup, 2928 NULL, 2929 }, 2930 }; 2931 2932 2933 /* *** Configure RSS RETA *** */ 2934 struct cmd_config_rss_reta { 2935 cmdline_fixed_string_t port; 2936 cmdline_fixed_string_t keyword; 2937 portid_t port_id; 2938 cmdline_fixed_string_t name; 2939 cmdline_fixed_string_t list_name; 2940 cmdline_fixed_string_t list_of_items; 2941 }; 2942 2943 static int 2944 parse_reta_config(const char *str, 2945 struct rte_eth_rss_reta_entry64 *reta_conf, 2946 uint16_t nb_entries) 2947 { 2948 int i; 2949 unsigned size; 2950 uint16_t hash_index, idx, shift; 2951 uint16_t nb_queue; 2952 char s[256]; 2953 const char *p, *p0 = str; 2954 char *end; 2955 enum fieldnames { 2956 FLD_HASH_INDEX = 0, 2957 FLD_QUEUE, 2958 _NUM_FLD 2959 }; 2960 unsigned long int_fld[_NUM_FLD]; 2961 char *str_fld[_NUM_FLD]; 2962 2963 while ((p = strchr(p0,'(')) != NULL) { 2964 ++p; 2965 if((p0 = strchr(p,')')) == NULL) 2966 return -1; 2967 2968 size = p0 - p; 2969 if(size >= sizeof(s)) 2970 return -1; 2971 2972 snprintf(s, sizeof(s), "%.*s", size, p); 2973 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2974 return -1; 2975 for (i = 0; i < _NUM_FLD; i++) { 2976 errno = 0; 2977 int_fld[i] = strtoul(str_fld[i], &end, 0); 2978 if (errno != 0 || end == str_fld[i] || 2979 int_fld[i] > 65535) 2980 return -1; 2981 } 2982 2983 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2984 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2985 2986 if (hash_index >= nb_entries) { 2987 fprintf(stderr, "Invalid RETA hash index=%d\n", 2988 hash_index); 2989 return -1; 2990 } 2991 2992 idx = hash_index / RTE_RETA_GROUP_SIZE; 2993 shift = hash_index % RTE_RETA_GROUP_SIZE; 2994 reta_conf[idx].mask |= (1ULL << shift); 2995 reta_conf[idx].reta[shift] = nb_queue; 2996 } 2997 2998 return 0; 2999 } 3000 3001 static void 3002 cmd_set_rss_reta_parsed(void *parsed_result, 3003 __rte_unused struct cmdline *cl, 3004 __rte_unused void *data) 3005 { 3006 int ret; 3007 struct rte_eth_dev_info dev_info; 3008 struct rte_eth_rss_reta_entry64 reta_conf[8]; 3009 struct cmd_config_rss_reta *res = parsed_result; 3010 3011 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 3012 if (ret != 0) 3013 return; 3014 3015 if (dev_info.reta_size == 0) { 3016 fprintf(stderr, 3017 "Redirection table size is 0 which is invalid for RSS\n"); 3018 return; 3019 } else 3020 printf("The reta size of port %d is %u\n", 3021 res->port_id, dev_info.reta_size); 3022 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 3023 fprintf(stderr, 3024 "Currently do not support more than %u entries of redirection table\n", 3025 ETH_RSS_RETA_SIZE_512); 3026 return; 3027 } 3028 3029 memset(reta_conf, 0, sizeof(reta_conf)); 3030 if (!strcmp(res->list_name, "reta")) { 3031 if (parse_reta_config(res->list_of_items, reta_conf, 3032 dev_info.reta_size)) { 3033 fprintf(stderr, 3034 "Invalid RSS Redirection Table config entered\n"); 3035 return; 3036 } 3037 ret = rte_eth_dev_rss_reta_update(res->port_id, 3038 reta_conf, dev_info.reta_size); 3039 if (ret != 0) 3040 fprintf(stderr, 3041 "Bad redirection table parameter, return code = %d\n", 3042 ret); 3043 } 3044 } 3045 3046 cmdline_parse_token_string_t cmd_config_rss_reta_port = 3047 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 3048 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 3049 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 3050 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 3051 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16); 3052 cmdline_parse_token_string_t cmd_config_rss_reta_name = 3053 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 3054 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 3055 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 3056 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 3057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 3058 NULL); 3059 cmdline_parse_inst_t cmd_config_rss_reta = { 3060 .f = cmd_set_rss_reta_parsed, 3061 .data = NULL, 3062 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 3063 .tokens = { 3064 (void *)&cmd_config_rss_reta_port, 3065 (void *)&cmd_config_rss_reta_keyword, 3066 (void *)&cmd_config_rss_reta_port_id, 3067 (void *)&cmd_config_rss_reta_name, 3068 (void *)&cmd_config_rss_reta_list_name, 3069 (void *)&cmd_config_rss_reta_list_of_items, 3070 NULL, 3071 }, 3072 }; 3073 3074 /* *** SHOW PORT RETA INFO *** */ 3075 struct cmd_showport_reta { 3076 cmdline_fixed_string_t show; 3077 cmdline_fixed_string_t port; 3078 portid_t port_id; 3079 cmdline_fixed_string_t rss; 3080 cmdline_fixed_string_t reta; 3081 uint16_t size; 3082 cmdline_fixed_string_t list_of_items; 3083 }; 3084 3085 static int 3086 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 3087 uint16_t nb_entries, 3088 char *str) 3089 { 3090 uint32_t size; 3091 const char *p, *p0 = str; 3092 char s[256]; 3093 char *end; 3094 char *str_fld[8]; 3095 uint16_t i; 3096 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 3097 RTE_RETA_GROUP_SIZE; 3098 int ret; 3099 3100 p = strchr(p0, '('); 3101 if (p == NULL) 3102 return -1; 3103 p++; 3104 p0 = strchr(p, ')'); 3105 if (p0 == NULL) 3106 return -1; 3107 size = p0 - p; 3108 if (size >= sizeof(s)) { 3109 fprintf(stderr, 3110 "The string size exceeds the internal buffer size\n"); 3111 return -1; 3112 } 3113 snprintf(s, sizeof(s), "%.*s", size, p); 3114 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 3115 if (ret <= 0 || ret != num) { 3116 fprintf(stderr, 3117 "The bits of masks do not match the number of reta entries: %u\n", 3118 num); 3119 return -1; 3120 } 3121 for (i = 0; i < ret; i++) 3122 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 3123 3124 return 0; 3125 } 3126 3127 static void 3128 cmd_showport_reta_parsed(void *parsed_result, 3129 __rte_unused struct cmdline *cl, 3130 __rte_unused void *data) 3131 { 3132 struct cmd_showport_reta *res = parsed_result; 3133 struct rte_eth_rss_reta_entry64 reta_conf[8]; 3134 struct rte_eth_dev_info dev_info; 3135 uint16_t max_reta_size; 3136 int ret; 3137 3138 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 3139 if (ret != 0) 3140 return; 3141 3142 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 3143 if (res->size == 0 || res->size > max_reta_size) { 3144 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n", 3145 res->size, max_reta_size); 3146 return; 3147 } 3148 3149 memset(reta_conf, 0, sizeof(reta_conf)); 3150 if (showport_parse_reta_config(reta_conf, res->size, 3151 res->list_of_items) < 0) { 3152 fprintf(stderr, "Invalid string: %s for reta masks\n", 3153 res->list_of_items); 3154 return; 3155 } 3156 port_rss_reta_info(res->port_id, reta_conf, res->size); 3157 } 3158 3159 cmdline_parse_token_string_t cmd_showport_reta_show = 3160 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 3161 cmdline_parse_token_string_t cmd_showport_reta_port = 3162 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 3163 cmdline_parse_token_num_t cmd_showport_reta_port_id = 3164 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16); 3165 cmdline_parse_token_string_t cmd_showport_reta_rss = 3166 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 3167 cmdline_parse_token_string_t cmd_showport_reta_reta = 3168 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 3169 cmdline_parse_token_num_t cmd_showport_reta_size = 3170 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16); 3171 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 3172 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 3173 list_of_items, NULL); 3174 3175 cmdline_parse_inst_t cmd_showport_reta = { 3176 .f = cmd_showport_reta_parsed, 3177 .data = NULL, 3178 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 3179 .tokens = { 3180 (void *)&cmd_showport_reta_show, 3181 (void *)&cmd_showport_reta_port, 3182 (void *)&cmd_showport_reta_port_id, 3183 (void *)&cmd_showport_reta_rss, 3184 (void *)&cmd_showport_reta_reta, 3185 (void *)&cmd_showport_reta_size, 3186 (void *)&cmd_showport_reta_list_of_items, 3187 NULL, 3188 }, 3189 }; 3190 3191 /* *** Show RSS hash configuration *** */ 3192 struct cmd_showport_rss_hash { 3193 cmdline_fixed_string_t show; 3194 cmdline_fixed_string_t port; 3195 portid_t port_id; 3196 cmdline_fixed_string_t rss_hash; 3197 cmdline_fixed_string_t rss_type; 3198 cmdline_fixed_string_t key; /* optional argument */ 3199 }; 3200 3201 static void cmd_showport_rss_hash_parsed(void *parsed_result, 3202 __rte_unused struct cmdline *cl, 3203 void *show_rss_key) 3204 { 3205 struct cmd_showport_rss_hash *res = parsed_result; 3206 3207 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); 3208 } 3209 3210 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 3211 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 3212 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 3213 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 3214 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 3215 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, 3216 RTE_UINT16); 3217 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 3218 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 3219 "rss-hash"); 3220 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 3221 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 3222 3223 cmdline_parse_inst_t cmd_showport_rss_hash = { 3224 .f = cmd_showport_rss_hash_parsed, 3225 .data = NULL, 3226 .help_str = "show port <port_id> rss-hash", 3227 .tokens = { 3228 (void *)&cmd_showport_rss_hash_show, 3229 (void *)&cmd_showport_rss_hash_port, 3230 (void *)&cmd_showport_rss_hash_port_id, 3231 (void *)&cmd_showport_rss_hash_rss_hash, 3232 NULL, 3233 }, 3234 }; 3235 3236 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 3237 .f = cmd_showport_rss_hash_parsed, 3238 .data = (void *)1, 3239 .help_str = "show port <port_id> rss-hash key", 3240 .tokens = { 3241 (void *)&cmd_showport_rss_hash_show, 3242 (void *)&cmd_showport_rss_hash_port, 3243 (void *)&cmd_showport_rss_hash_port_id, 3244 (void *)&cmd_showport_rss_hash_rss_hash, 3245 (void *)&cmd_showport_rss_hash_rss_key, 3246 NULL, 3247 }, 3248 }; 3249 3250 /* *** Configure DCB *** */ 3251 struct cmd_config_dcb { 3252 cmdline_fixed_string_t port; 3253 cmdline_fixed_string_t config; 3254 portid_t port_id; 3255 cmdline_fixed_string_t dcb; 3256 cmdline_fixed_string_t vt; 3257 cmdline_fixed_string_t vt_en; 3258 uint8_t num_tcs; 3259 cmdline_fixed_string_t pfc; 3260 cmdline_fixed_string_t pfc_en; 3261 }; 3262 3263 static void 3264 cmd_config_dcb_parsed(void *parsed_result, 3265 __rte_unused struct cmdline *cl, 3266 __rte_unused void *data) 3267 { 3268 struct cmd_config_dcb *res = parsed_result; 3269 struct rte_eth_dcb_info dcb_info; 3270 portid_t port_id = res->port_id; 3271 struct rte_port *port; 3272 uint8_t pfc_en; 3273 int ret; 3274 3275 port = &ports[port_id]; 3276 /** Check if the port is not started **/ 3277 if (port->port_status != RTE_PORT_STOPPED) { 3278 fprintf(stderr, "Please stop port %d first\n", port_id); 3279 return; 3280 } 3281 3282 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 3283 fprintf(stderr, 3284 "The invalid number of traffic class, only 4 or 8 allowed.\n"); 3285 return; 3286 } 3287 3288 if (nb_fwd_lcores < res->num_tcs) { 3289 fprintf(stderr, 3290 "nb_cores shouldn't be less than number of TCs.\n"); 3291 return; 3292 } 3293 3294 /* Check whether the port supports the report of DCB info. */ 3295 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info); 3296 if (ret == -ENOTSUP) { 3297 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n"); 3298 return; 3299 } 3300 3301 if (!strncmp(res->pfc_en, "on", 2)) 3302 pfc_en = 1; 3303 else 3304 pfc_en = 0; 3305 3306 /* DCB in VT mode */ 3307 if (!strncmp(res->vt_en, "on", 2)) 3308 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 3309 (enum rte_eth_nb_tcs)res->num_tcs, 3310 pfc_en); 3311 else 3312 ret = init_port_dcb_config(port_id, DCB_ENABLED, 3313 (enum rte_eth_nb_tcs)res->num_tcs, 3314 pfc_en); 3315 if (ret != 0) { 3316 fprintf(stderr, "Cannot initialize network ports.\n"); 3317 return; 3318 } 3319 3320 fwd_config_setup(); 3321 3322 cmd_reconfig_device_queue(port_id, 1, 1); 3323 } 3324 3325 cmdline_parse_token_string_t cmd_config_dcb_port = 3326 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 3327 cmdline_parse_token_string_t cmd_config_dcb_config = 3328 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 3329 cmdline_parse_token_num_t cmd_config_dcb_port_id = 3330 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16); 3331 cmdline_parse_token_string_t cmd_config_dcb_dcb = 3332 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 3333 cmdline_parse_token_string_t cmd_config_dcb_vt = 3334 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 3335 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 3336 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 3337 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 3338 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8); 3339 cmdline_parse_token_string_t cmd_config_dcb_pfc= 3340 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 3341 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 3342 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 3343 3344 cmdline_parse_inst_t cmd_config_dcb = { 3345 .f = cmd_config_dcb_parsed, 3346 .data = NULL, 3347 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 3348 .tokens = { 3349 (void *)&cmd_config_dcb_port, 3350 (void *)&cmd_config_dcb_config, 3351 (void *)&cmd_config_dcb_port_id, 3352 (void *)&cmd_config_dcb_dcb, 3353 (void *)&cmd_config_dcb_vt, 3354 (void *)&cmd_config_dcb_vt_en, 3355 (void *)&cmd_config_dcb_num_tcs, 3356 (void *)&cmd_config_dcb_pfc, 3357 (void *)&cmd_config_dcb_pfc_en, 3358 NULL, 3359 }, 3360 }; 3361 3362 /* *** configure number of packets per burst *** */ 3363 struct cmd_config_burst { 3364 cmdline_fixed_string_t port; 3365 cmdline_fixed_string_t keyword; 3366 cmdline_fixed_string_t all; 3367 cmdline_fixed_string_t name; 3368 uint16_t value; 3369 }; 3370 3371 static void 3372 cmd_config_burst_parsed(void *parsed_result, 3373 __rte_unused struct cmdline *cl, 3374 __rte_unused void *data) 3375 { 3376 struct cmd_config_burst *res = parsed_result; 3377 struct rte_eth_dev_info dev_info; 3378 uint16_t rec_nb_pkts; 3379 int ret; 3380 3381 if (!all_ports_stopped()) { 3382 fprintf(stderr, "Please stop all ports first\n"); 3383 return; 3384 } 3385 3386 if (!strcmp(res->name, "burst")) { 3387 if (res->value == 0) { 3388 /* If user gives a value of zero, query the PMD for 3389 * its recommended Rx burst size. Testpmd uses a single 3390 * size for all ports, so assume all ports are the same 3391 * NIC model and use the values from Port 0. 3392 */ 3393 ret = eth_dev_info_get_print_err(0, &dev_info); 3394 if (ret != 0) 3395 return; 3396 3397 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 3398 3399 if (rec_nb_pkts == 0) { 3400 printf("PMD does not recommend a burst size.\n" 3401 "User provided value must be between" 3402 " 1 and %d\n", MAX_PKT_BURST); 3403 return; 3404 } else if (rec_nb_pkts > MAX_PKT_BURST) { 3405 printf("PMD recommended burst size of %d" 3406 " exceeds maximum value of %d\n", 3407 rec_nb_pkts, MAX_PKT_BURST); 3408 return; 3409 } 3410 printf("Using PMD-provided burst value of %d\n", 3411 rec_nb_pkts); 3412 nb_pkt_per_burst = rec_nb_pkts; 3413 } else if (res->value > MAX_PKT_BURST) { 3414 fprintf(stderr, "burst must be >= 1 && <= %d\n", 3415 MAX_PKT_BURST); 3416 return; 3417 } else 3418 nb_pkt_per_burst = res->value; 3419 } else { 3420 fprintf(stderr, "Unknown parameter\n"); 3421 return; 3422 } 3423 3424 init_port_config(); 3425 3426 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3427 } 3428 3429 cmdline_parse_token_string_t cmd_config_burst_port = 3430 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3431 cmdline_parse_token_string_t cmd_config_burst_keyword = 3432 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3433 cmdline_parse_token_string_t cmd_config_burst_all = 3434 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3435 cmdline_parse_token_string_t cmd_config_burst_name = 3436 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3437 cmdline_parse_token_num_t cmd_config_burst_value = 3438 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16); 3439 3440 cmdline_parse_inst_t cmd_config_burst = { 3441 .f = cmd_config_burst_parsed, 3442 .data = NULL, 3443 .help_str = "port config all burst <value>", 3444 .tokens = { 3445 (void *)&cmd_config_burst_port, 3446 (void *)&cmd_config_burst_keyword, 3447 (void *)&cmd_config_burst_all, 3448 (void *)&cmd_config_burst_name, 3449 (void *)&cmd_config_burst_value, 3450 NULL, 3451 }, 3452 }; 3453 3454 /* *** configure rx/tx queues *** */ 3455 struct cmd_config_thresh { 3456 cmdline_fixed_string_t port; 3457 cmdline_fixed_string_t keyword; 3458 cmdline_fixed_string_t all; 3459 cmdline_fixed_string_t name; 3460 uint8_t value; 3461 }; 3462 3463 static void 3464 cmd_config_thresh_parsed(void *parsed_result, 3465 __rte_unused struct cmdline *cl, 3466 __rte_unused void *data) 3467 { 3468 struct cmd_config_thresh *res = parsed_result; 3469 3470 if (!all_ports_stopped()) { 3471 fprintf(stderr, "Please stop all ports first\n"); 3472 return; 3473 } 3474 3475 if (!strcmp(res->name, "txpt")) 3476 tx_pthresh = res->value; 3477 else if(!strcmp(res->name, "txht")) 3478 tx_hthresh = res->value; 3479 else if(!strcmp(res->name, "txwt")) 3480 tx_wthresh = res->value; 3481 else if(!strcmp(res->name, "rxpt")) 3482 rx_pthresh = res->value; 3483 else if(!strcmp(res->name, "rxht")) 3484 rx_hthresh = res->value; 3485 else if(!strcmp(res->name, "rxwt")) 3486 rx_wthresh = res->value; 3487 else { 3488 fprintf(stderr, "Unknown parameter\n"); 3489 return; 3490 } 3491 3492 init_port_config(); 3493 3494 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3495 } 3496 3497 cmdline_parse_token_string_t cmd_config_thresh_port = 3498 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3499 cmdline_parse_token_string_t cmd_config_thresh_keyword = 3500 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3501 cmdline_parse_token_string_t cmd_config_thresh_all = 3502 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3503 cmdline_parse_token_string_t cmd_config_thresh_name = 3504 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3505 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3506 cmdline_parse_token_num_t cmd_config_thresh_value = 3507 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8); 3508 3509 cmdline_parse_inst_t cmd_config_thresh = { 3510 .f = cmd_config_thresh_parsed, 3511 .data = NULL, 3512 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3513 .tokens = { 3514 (void *)&cmd_config_thresh_port, 3515 (void *)&cmd_config_thresh_keyword, 3516 (void *)&cmd_config_thresh_all, 3517 (void *)&cmd_config_thresh_name, 3518 (void *)&cmd_config_thresh_value, 3519 NULL, 3520 }, 3521 }; 3522 3523 /* *** configure free/rs threshold *** */ 3524 struct cmd_config_threshold { 3525 cmdline_fixed_string_t port; 3526 cmdline_fixed_string_t keyword; 3527 cmdline_fixed_string_t all; 3528 cmdline_fixed_string_t name; 3529 uint16_t value; 3530 }; 3531 3532 static void 3533 cmd_config_threshold_parsed(void *parsed_result, 3534 __rte_unused struct cmdline *cl, 3535 __rte_unused void *data) 3536 { 3537 struct cmd_config_threshold *res = parsed_result; 3538 3539 if (!all_ports_stopped()) { 3540 fprintf(stderr, "Please stop all ports first\n"); 3541 return; 3542 } 3543 3544 if (!strcmp(res->name, "txfreet")) 3545 tx_free_thresh = res->value; 3546 else if (!strcmp(res->name, "txrst")) 3547 tx_rs_thresh = res->value; 3548 else if (!strcmp(res->name, "rxfreet")) 3549 rx_free_thresh = res->value; 3550 else { 3551 fprintf(stderr, "Unknown parameter\n"); 3552 return; 3553 } 3554 3555 init_port_config(); 3556 3557 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3558 } 3559 3560 cmdline_parse_token_string_t cmd_config_threshold_port = 3561 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3562 cmdline_parse_token_string_t cmd_config_threshold_keyword = 3563 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3564 "config"); 3565 cmdline_parse_token_string_t cmd_config_threshold_all = 3566 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3567 cmdline_parse_token_string_t cmd_config_threshold_name = 3568 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3569 "txfreet#txrst#rxfreet"); 3570 cmdline_parse_token_num_t cmd_config_threshold_value = 3571 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16); 3572 3573 cmdline_parse_inst_t cmd_config_threshold = { 3574 .f = cmd_config_threshold_parsed, 3575 .data = NULL, 3576 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3577 .tokens = { 3578 (void *)&cmd_config_threshold_port, 3579 (void *)&cmd_config_threshold_keyword, 3580 (void *)&cmd_config_threshold_all, 3581 (void *)&cmd_config_threshold_name, 3582 (void *)&cmd_config_threshold_value, 3583 NULL, 3584 }, 3585 }; 3586 3587 /* *** stop *** */ 3588 struct cmd_stop_result { 3589 cmdline_fixed_string_t stop; 3590 }; 3591 3592 static void cmd_stop_parsed(__rte_unused void *parsed_result, 3593 __rte_unused struct cmdline *cl, 3594 __rte_unused void *data) 3595 { 3596 stop_packet_forwarding(); 3597 } 3598 3599 cmdline_parse_token_string_t cmd_stop_stop = 3600 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3601 3602 cmdline_parse_inst_t cmd_stop = { 3603 .f = cmd_stop_parsed, 3604 .data = NULL, 3605 .help_str = "stop: Stop packet forwarding", 3606 .tokens = { 3607 (void *)&cmd_stop_stop, 3608 NULL, 3609 }, 3610 }; 3611 3612 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3613 3614 unsigned int 3615 parse_item_list(const char *str, const char *item_name, unsigned int max_items, 3616 unsigned int *parsed_items, int check_unique_values) 3617 { 3618 unsigned int nb_item; 3619 unsigned int value; 3620 unsigned int i; 3621 unsigned int j; 3622 int value_ok; 3623 char c; 3624 3625 /* 3626 * First parse all items in the list and store their value. 3627 */ 3628 value = 0; 3629 nb_item = 0; 3630 value_ok = 0; 3631 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3632 c = str[i]; 3633 if ((c >= '0') && (c <= '9')) { 3634 value = (unsigned int) (value * 10 + (c - '0')); 3635 value_ok = 1; 3636 continue; 3637 } 3638 if (c != ',') { 3639 fprintf(stderr, "character %c is not a decimal digit\n", c); 3640 return 0; 3641 } 3642 if (! value_ok) { 3643 fprintf(stderr, "No valid value before comma\n"); 3644 return 0; 3645 } 3646 if (nb_item < max_items) { 3647 parsed_items[nb_item] = value; 3648 value_ok = 0; 3649 value = 0; 3650 } 3651 nb_item++; 3652 } 3653 if (nb_item >= max_items) { 3654 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n", 3655 item_name, nb_item + 1, max_items); 3656 return 0; 3657 } 3658 parsed_items[nb_item++] = value; 3659 if (! check_unique_values) 3660 return nb_item; 3661 3662 /* 3663 * Then, check that all values in the list are differents. 3664 * No optimization here... 3665 */ 3666 for (i = 0; i < nb_item; i++) { 3667 for (j = i + 1; j < nb_item; j++) { 3668 if (parsed_items[j] == parsed_items[i]) { 3669 fprintf(stderr, 3670 "duplicated %s %u at index %u and %u\n", 3671 item_name, parsed_items[i], i, j); 3672 return 0; 3673 } 3674 } 3675 } 3676 return nb_item; 3677 } 3678 3679 struct cmd_set_list_result { 3680 cmdline_fixed_string_t cmd_keyword; 3681 cmdline_fixed_string_t list_name; 3682 cmdline_fixed_string_t list_of_items; 3683 }; 3684 3685 static void cmd_set_list_parsed(void *parsed_result, 3686 __rte_unused struct cmdline *cl, 3687 __rte_unused void *data) 3688 { 3689 struct cmd_set_list_result *res; 3690 union { 3691 unsigned int lcorelist[RTE_MAX_LCORE]; 3692 unsigned int portlist[RTE_MAX_ETHPORTS]; 3693 } parsed_items; 3694 unsigned int nb_item; 3695 3696 if (test_done == 0) { 3697 fprintf(stderr, "Please stop forwarding first\n"); 3698 return; 3699 } 3700 3701 res = parsed_result; 3702 if (!strcmp(res->list_name, "corelist")) { 3703 nb_item = parse_item_list(res->list_of_items, "core", 3704 RTE_MAX_LCORE, 3705 parsed_items.lcorelist, 1); 3706 if (nb_item > 0) { 3707 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3708 fwd_config_setup(); 3709 } 3710 return; 3711 } 3712 if (!strcmp(res->list_name, "portlist")) { 3713 nb_item = parse_item_list(res->list_of_items, "port", 3714 RTE_MAX_ETHPORTS, 3715 parsed_items.portlist, 1); 3716 if (nb_item > 0) { 3717 set_fwd_ports_list(parsed_items.portlist, nb_item); 3718 fwd_config_setup(); 3719 } 3720 } 3721 } 3722 3723 cmdline_parse_token_string_t cmd_set_list_keyword = 3724 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3725 "set"); 3726 cmdline_parse_token_string_t cmd_set_list_name = 3727 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3728 "corelist#portlist"); 3729 cmdline_parse_token_string_t cmd_set_list_of_items = 3730 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3731 NULL); 3732 3733 cmdline_parse_inst_t cmd_set_fwd_list = { 3734 .f = cmd_set_list_parsed, 3735 .data = NULL, 3736 .help_str = "set corelist|portlist <list0[,list1]*>", 3737 .tokens = { 3738 (void *)&cmd_set_list_keyword, 3739 (void *)&cmd_set_list_name, 3740 (void *)&cmd_set_list_of_items, 3741 NULL, 3742 }, 3743 }; 3744 3745 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3746 3747 struct cmd_setmask_result { 3748 cmdline_fixed_string_t set; 3749 cmdline_fixed_string_t mask; 3750 uint64_t hexavalue; 3751 }; 3752 3753 static void cmd_set_mask_parsed(void *parsed_result, 3754 __rte_unused struct cmdline *cl, 3755 __rte_unused void *data) 3756 { 3757 struct cmd_setmask_result *res = parsed_result; 3758 3759 if (test_done == 0) { 3760 fprintf(stderr, "Please stop forwarding first\n"); 3761 return; 3762 } 3763 if (!strcmp(res->mask, "coremask")) { 3764 set_fwd_lcores_mask(res->hexavalue); 3765 fwd_config_setup(); 3766 } else if (!strcmp(res->mask, "portmask")) { 3767 set_fwd_ports_mask(res->hexavalue); 3768 fwd_config_setup(); 3769 } 3770 } 3771 3772 cmdline_parse_token_string_t cmd_setmask_set = 3773 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3774 cmdline_parse_token_string_t cmd_setmask_mask = 3775 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3776 "coremask#portmask"); 3777 cmdline_parse_token_num_t cmd_setmask_value = 3778 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64); 3779 3780 cmdline_parse_inst_t cmd_set_fwd_mask = { 3781 .f = cmd_set_mask_parsed, 3782 .data = NULL, 3783 .help_str = "set coremask|portmask <hexadecimal value>", 3784 .tokens = { 3785 (void *)&cmd_setmask_set, 3786 (void *)&cmd_setmask_mask, 3787 (void *)&cmd_setmask_value, 3788 NULL, 3789 }, 3790 }; 3791 3792 /* 3793 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3794 */ 3795 struct cmd_set_result { 3796 cmdline_fixed_string_t set; 3797 cmdline_fixed_string_t what; 3798 uint16_t value; 3799 }; 3800 3801 static void cmd_set_parsed(void *parsed_result, 3802 __rte_unused struct cmdline *cl, 3803 __rte_unused void *data) 3804 { 3805 struct cmd_set_result *res = parsed_result; 3806 if (!strcmp(res->what, "nbport")) { 3807 set_fwd_ports_number(res->value); 3808 fwd_config_setup(); 3809 } else if (!strcmp(res->what, "nbcore")) { 3810 set_fwd_lcores_number(res->value); 3811 fwd_config_setup(); 3812 } else if (!strcmp(res->what, "burst")) 3813 set_nb_pkt_per_burst(res->value); 3814 else if (!strcmp(res->what, "verbose")) 3815 set_verbose_level(res->value); 3816 } 3817 3818 cmdline_parse_token_string_t cmd_set_set = 3819 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3820 cmdline_parse_token_string_t cmd_set_what = 3821 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3822 "nbport#nbcore#burst#verbose"); 3823 cmdline_parse_token_num_t cmd_set_value = 3824 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16); 3825 3826 cmdline_parse_inst_t cmd_set_numbers = { 3827 .f = cmd_set_parsed, 3828 .data = NULL, 3829 .help_str = "set nbport|nbcore|burst|verbose <value>", 3830 .tokens = { 3831 (void *)&cmd_set_set, 3832 (void *)&cmd_set_what, 3833 (void *)&cmd_set_value, 3834 NULL, 3835 }, 3836 }; 3837 3838 /* *** SET LOG LEVEL CONFIGURATION *** */ 3839 3840 struct cmd_set_log_result { 3841 cmdline_fixed_string_t set; 3842 cmdline_fixed_string_t log; 3843 cmdline_fixed_string_t type; 3844 uint32_t level; 3845 }; 3846 3847 static void 3848 cmd_set_log_parsed(void *parsed_result, 3849 __rte_unused struct cmdline *cl, 3850 __rte_unused void *data) 3851 { 3852 struct cmd_set_log_result *res; 3853 int ret; 3854 3855 res = parsed_result; 3856 if (!strcmp(res->type, "global")) 3857 rte_log_set_global_level(res->level); 3858 else { 3859 ret = rte_log_set_level_regexp(res->type, res->level); 3860 if (ret < 0) 3861 fprintf(stderr, "Unable to set log level\n"); 3862 } 3863 } 3864 3865 cmdline_parse_token_string_t cmd_set_log_set = 3866 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3867 cmdline_parse_token_string_t cmd_set_log_log = 3868 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3869 cmdline_parse_token_string_t cmd_set_log_type = 3870 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3871 cmdline_parse_token_num_t cmd_set_log_level = 3872 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32); 3873 3874 cmdline_parse_inst_t cmd_set_log = { 3875 .f = cmd_set_log_parsed, 3876 .data = NULL, 3877 .help_str = "set log global|<type> <level>", 3878 .tokens = { 3879 (void *)&cmd_set_log_set, 3880 (void *)&cmd_set_log_log, 3881 (void *)&cmd_set_log_type, 3882 (void *)&cmd_set_log_level, 3883 NULL, 3884 }, 3885 }; 3886 3887 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */ 3888 3889 struct cmd_set_rxoffs_result { 3890 cmdline_fixed_string_t cmd_keyword; 3891 cmdline_fixed_string_t rxoffs; 3892 cmdline_fixed_string_t seg_offsets; 3893 }; 3894 3895 static void 3896 cmd_set_rxoffs_parsed(void *parsed_result, 3897 __rte_unused struct cmdline *cl, 3898 __rte_unused void *data) 3899 { 3900 struct cmd_set_rxoffs_result *res; 3901 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT]; 3902 unsigned int nb_segs; 3903 3904 res = parsed_result; 3905 nb_segs = parse_item_list(res->seg_offsets, "segment offsets", 3906 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0); 3907 if (nb_segs > 0) 3908 set_rx_pkt_offsets(seg_offsets, nb_segs); 3909 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1); 3910 } 3911 3912 cmdline_parse_token_string_t cmd_set_rxoffs_keyword = 3913 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3914 cmd_keyword, "set"); 3915 cmdline_parse_token_string_t cmd_set_rxoffs_name = 3916 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3917 rxoffs, "rxoffs"); 3918 cmdline_parse_token_string_t cmd_set_rxoffs_offsets = 3919 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3920 seg_offsets, NULL); 3921 3922 cmdline_parse_inst_t cmd_set_rxoffs = { 3923 .f = cmd_set_rxoffs_parsed, 3924 .data = NULL, 3925 .help_str = "set rxoffs <len0[,len1]*>", 3926 .tokens = { 3927 (void *)&cmd_set_rxoffs_keyword, 3928 (void *)&cmd_set_rxoffs_name, 3929 (void *)&cmd_set_rxoffs_offsets, 3930 NULL, 3931 }, 3932 }; 3933 3934 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */ 3935 3936 struct cmd_set_rxpkts_result { 3937 cmdline_fixed_string_t cmd_keyword; 3938 cmdline_fixed_string_t rxpkts; 3939 cmdline_fixed_string_t seg_lengths; 3940 }; 3941 3942 static void 3943 cmd_set_rxpkts_parsed(void *parsed_result, 3944 __rte_unused struct cmdline *cl, 3945 __rte_unused void *data) 3946 { 3947 struct cmd_set_rxpkts_result *res; 3948 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT]; 3949 unsigned int nb_segs; 3950 3951 res = parsed_result; 3952 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3953 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0); 3954 if (nb_segs > 0) 3955 set_rx_pkt_segments(seg_lengths, nb_segs); 3956 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1); 3957 } 3958 3959 cmdline_parse_token_string_t cmd_set_rxpkts_keyword = 3960 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3961 cmd_keyword, "set"); 3962 cmdline_parse_token_string_t cmd_set_rxpkts_name = 3963 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3964 rxpkts, "rxpkts"); 3965 cmdline_parse_token_string_t cmd_set_rxpkts_lengths = 3966 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3967 seg_lengths, NULL); 3968 3969 cmdline_parse_inst_t cmd_set_rxpkts = { 3970 .f = cmd_set_rxpkts_parsed, 3971 .data = NULL, 3972 .help_str = "set rxpkts <len0[,len1]*>", 3973 .tokens = { 3974 (void *)&cmd_set_rxpkts_keyword, 3975 (void *)&cmd_set_rxpkts_name, 3976 (void *)&cmd_set_rxpkts_lengths, 3977 NULL, 3978 }, 3979 }; 3980 3981 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3982 3983 struct cmd_set_txpkts_result { 3984 cmdline_fixed_string_t cmd_keyword; 3985 cmdline_fixed_string_t txpkts; 3986 cmdline_fixed_string_t seg_lengths; 3987 }; 3988 3989 static void 3990 cmd_set_txpkts_parsed(void *parsed_result, 3991 __rte_unused struct cmdline *cl, 3992 __rte_unused void *data) 3993 { 3994 struct cmd_set_txpkts_result *res; 3995 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3996 unsigned int nb_segs; 3997 3998 res = parsed_result; 3999 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 4000 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 4001 if (nb_segs > 0) 4002 set_tx_pkt_segments(seg_lengths, nb_segs); 4003 } 4004 4005 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 4006 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 4007 cmd_keyword, "set"); 4008 cmdline_parse_token_string_t cmd_set_txpkts_name = 4009 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 4010 txpkts, "txpkts"); 4011 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 4012 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 4013 seg_lengths, NULL); 4014 4015 cmdline_parse_inst_t cmd_set_txpkts = { 4016 .f = cmd_set_txpkts_parsed, 4017 .data = NULL, 4018 .help_str = "set txpkts <len0[,len1]*>", 4019 .tokens = { 4020 (void *)&cmd_set_txpkts_keyword, 4021 (void *)&cmd_set_txpkts_name, 4022 (void *)&cmd_set_txpkts_lengths, 4023 NULL, 4024 }, 4025 }; 4026 4027 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 4028 4029 struct cmd_set_txsplit_result { 4030 cmdline_fixed_string_t cmd_keyword; 4031 cmdline_fixed_string_t txsplit; 4032 cmdline_fixed_string_t mode; 4033 }; 4034 4035 static void 4036 cmd_set_txsplit_parsed(void *parsed_result, 4037 __rte_unused struct cmdline *cl, 4038 __rte_unused void *data) 4039 { 4040 struct cmd_set_txsplit_result *res; 4041 4042 res = parsed_result; 4043 set_tx_pkt_split(res->mode); 4044 } 4045 4046 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 4047 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 4048 cmd_keyword, "set"); 4049 cmdline_parse_token_string_t cmd_set_txsplit_name = 4050 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 4051 txsplit, "txsplit"); 4052 cmdline_parse_token_string_t cmd_set_txsplit_mode = 4053 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 4054 mode, NULL); 4055 4056 cmdline_parse_inst_t cmd_set_txsplit = { 4057 .f = cmd_set_txsplit_parsed, 4058 .data = NULL, 4059 .help_str = "set txsplit on|off|rand", 4060 .tokens = { 4061 (void *)&cmd_set_txsplit_keyword, 4062 (void *)&cmd_set_txsplit_name, 4063 (void *)&cmd_set_txsplit_mode, 4064 NULL, 4065 }, 4066 }; 4067 4068 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */ 4069 4070 struct cmd_set_txtimes_result { 4071 cmdline_fixed_string_t cmd_keyword; 4072 cmdline_fixed_string_t txtimes; 4073 cmdline_fixed_string_t tx_times; 4074 }; 4075 4076 static void 4077 cmd_set_txtimes_parsed(void *parsed_result, 4078 __rte_unused struct cmdline *cl, 4079 __rte_unused void *data) 4080 { 4081 struct cmd_set_txtimes_result *res; 4082 unsigned int tx_times[2] = {0, 0}; 4083 unsigned int n_times; 4084 4085 res = parsed_result; 4086 n_times = parse_item_list(res->tx_times, "tx times", 4087 2, tx_times, 0); 4088 if (n_times == 2) 4089 set_tx_pkt_times(tx_times); 4090 } 4091 4092 cmdline_parse_token_string_t cmd_set_txtimes_keyword = 4093 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 4094 cmd_keyword, "set"); 4095 cmdline_parse_token_string_t cmd_set_txtimes_name = 4096 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 4097 txtimes, "txtimes"); 4098 cmdline_parse_token_string_t cmd_set_txtimes_value = 4099 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 4100 tx_times, NULL); 4101 4102 cmdline_parse_inst_t cmd_set_txtimes = { 4103 .f = cmd_set_txtimes_parsed, 4104 .data = NULL, 4105 .help_str = "set txtimes <inter_burst>,<intra_burst>", 4106 .tokens = { 4107 (void *)&cmd_set_txtimes_keyword, 4108 (void *)&cmd_set_txtimes_name, 4109 (void *)&cmd_set_txtimes_value, 4110 NULL, 4111 }, 4112 }; 4113 4114 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 4115 struct cmd_rx_vlan_filter_all_result { 4116 cmdline_fixed_string_t rx_vlan; 4117 cmdline_fixed_string_t what; 4118 cmdline_fixed_string_t all; 4119 portid_t port_id; 4120 }; 4121 4122 static void 4123 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 4124 __rte_unused struct cmdline *cl, 4125 __rte_unused void *data) 4126 { 4127 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 4128 4129 if (!strcmp(res->what, "add")) 4130 rx_vlan_all_filter_set(res->port_id, 1); 4131 else 4132 rx_vlan_all_filter_set(res->port_id, 0); 4133 } 4134 4135 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 4136 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4137 rx_vlan, "rx_vlan"); 4138 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 4139 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4140 what, "add#rm"); 4141 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 4142 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4143 all, "all"); 4144 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 4145 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4146 port_id, RTE_UINT16); 4147 4148 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 4149 .f = cmd_rx_vlan_filter_all_parsed, 4150 .data = NULL, 4151 .help_str = "rx_vlan add|rm all <port_id>: " 4152 "Add/Remove all identifiers to/from the set of VLAN " 4153 "identifiers filtered by a port", 4154 .tokens = { 4155 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 4156 (void *)&cmd_rx_vlan_filter_all_what, 4157 (void *)&cmd_rx_vlan_filter_all_all, 4158 (void *)&cmd_rx_vlan_filter_all_portid, 4159 NULL, 4160 }, 4161 }; 4162 4163 /* *** VLAN OFFLOAD SET ON A PORT *** */ 4164 struct cmd_vlan_offload_result { 4165 cmdline_fixed_string_t vlan; 4166 cmdline_fixed_string_t set; 4167 cmdline_fixed_string_t vlan_type; 4168 cmdline_fixed_string_t what; 4169 cmdline_fixed_string_t on; 4170 cmdline_fixed_string_t port_id; 4171 }; 4172 4173 static void 4174 cmd_vlan_offload_parsed(void *parsed_result, 4175 __rte_unused struct cmdline *cl, 4176 __rte_unused void *data) 4177 { 4178 int on; 4179 struct cmd_vlan_offload_result *res = parsed_result; 4180 char *str; 4181 int i, len = 0; 4182 portid_t port_id = 0; 4183 unsigned int tmp; 4184 4185 str = res->port_id; 4186 len = strnlen(str, STR_TOKEN_SIZE); 4187 i = 0; 4188 /* Get port_id first */ 4189 while(i < len){ 4190 if(str[i] == ',') 4191 break; 4192 4193 i++; 4194 } 4195 str[i]='\0'; 4196 tmp = strtoul(str, NULL, 0); 4197 /* If port_id greater that what portid_t can represent, return */ 4198 if(tmp >= RTE_MAX_ETHPORTS) 4199 return; 4200 port_id = (portid_t)tmp; 4201 4202 if (!strcmp(res->on, "on")) 4203 on = 1; 4204 else 4205 on = 0; 4206 4207 if (!strcmp(res->what, "strip")) 4208 rx_vlan_strip_set(port_id, on); 4209 else if(!strcmp(res->what, "stripq")){ 4210 uint16_t queue_id = 0; 4211 4212 /* No queue_id, return */ 4213 if(i + 1 >= len) { 4214 fprintf(stderr, "must specify (port,queue_id)\n"); 4215 return; 4216 } 4217 tmp = strtoul(str + i + 1, NULL, 0); 4218 /* If queue_id greater that what 16-bits can represent, return */ 4219 if(tmp > 0xffff) 4220 return; 4221 4222 queue_id = (uint16_t)tmp; 4223 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 4224 } 4225 else if (!strcmp(res->what, "filter")) 4226 rx_vlan_filter_set(port_id, on); 4227 else if (!strcmp(res->what, "qinq_strip")) 4228 rx_vlan_qinq_strip_set(port_id, on); 4229 else 4230 vlan_extend_set(port_id, on); 4231 4232 return; 4233 } 4234 4235 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 4236 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4237 vlan, "vlan"); 4238 cmdline_parse_token_string_t cmd_vlan_offload_set = 4239 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4240 set, "set"); 4241 cmdline_parse_token_string_t cmd_vlan_offload_what = 4242 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4243 what, "strip#filter#qinq_strip#extend#stripq"); 4244 cmdline_parse_token_string_t cmd_vlan_offload_on = 4245 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4246 on, "on#off"); 4247 cmdline_parse_token_string_t cmd_vlan_offload_portid = 4248 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4249 port_id, NULL); 4250 4251 cmdline_parse_inst_t cmd_vlan_offload = { 4252 .f = cmd_vlan_offload_parsed, 4253 .data = NULL, 4254 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off " 4255 "<port_id[,queue_id]>: " 4256 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides", 4257 .tokens = { 4258 (void *)&cmd_vlan_offload_vlan, 4259 (void *)&cmd_vlan_offload_set, 4260 (void *)&cmd_vlan_offload_what, 4261 (void *)&cmd_vlan_offload_on, 4262 (void *)&cmd_vlan_offload_portid, 4263 NULL, 4264 }, 4265 }; 4266 4267 /* *** VLAN TPID SET ON A PORT *** */ 4268 struct cmd_vlan_tpid_result { 4269 cmdline_fixed_string_t vlan; 4270 cmdline_fixed_string_t set; 4271 cmdline_fixed_string_t vlan_type; 4272 cmdline_fixed_string_t what; 4273 uint16_t tp_id; 4274 portid_t port_id; 4275 }; 4276 4277 static void 4278 cmd_vlan_tpid_parsed(void *parsed_result, 4279 __rte_unused struct cmdline *cl, 4280 __rte_unused void *data) 4281 { 4282 struct cmd_vlan_tpid_result *res = parsed_result; 4283 enum rte_vlan_type vlan_type; 4284 4285 if (!strcmp(res->vlan_type, "inner")) 4286 vlan_type = ETH_VLAN_TYPE_INNER; 4287 else if (!strcmp(res->vlan_type, "outer")) 4288 vlan_type = ETH_VLAN_TYPE_OUTER; 4289 else { 4290 fprintf(stderr, "Unknown vlan type\n"); 4291 return; 4292 } 4293 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 4294 } 4295 4296 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 4297 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4298 vlan, "vlan"); 4299 cmdline_parse_token_string_t cmd_vlan_tpid_set = 4300 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4301 set, "set"); 4302 cmdline_parse_token_string_t cmd_vlan_type = 4303 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4304 vlan_type, "inner#outer"); 4305 cmdline_parse_token_string_t cmd_vlan_tpid_what = 4306 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4307 what, "tpid"); 4308 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 4309 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4310 tp_id, RTE_UINT16); 4311 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 4312 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4313 port_id, RTE_UINT16); 4314 4315 cmdline_parse_inst_t cmd_vlan_tpid = { 4316 .f = cmd_vlan_tpid_parsed, 4317 .data = NULL, 4318 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 4319 "Set the VLAN Ether type", 4320 .tokens = { 4321 (void *)&cmd_vlan_tpid_vlan, 4322 (void *)&cmd_vlan_tpid_set, 4323 (void *)&cmd_vlan_type, 4324 (void *)&cmd_vlan_tpid_what, 4325 (void *)&cmd_vlan_tpid_tpid, 4326 (void *)&cmd_vlan_tpid_portid, 4327 NULL, 4328 }, 4329 }; 4330 4331 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 4332 struct cmd_rx_vlan_filter_result { 4333 cmdline_fixed_string_t rx_vlan; 4334 cmdline_fixed_string_t what; 4335 uint16_t vlan_id; 4336 portid_t port_id; 4337 }; 4338 4339 static void 4340 cmd_rx_vlan_filter_parsed(void *parsed_result, 4341 __rte_unused struct cmdline *cl, 4342 __rte_unused void *data) 4343 { 4344 struct cmd_rx_vlan_filter_result *res = parsed_result; 4345 4346 if (!strcmp(res->what, "add")) 4347 rx_vft_set(res->port_id, res->vlan_id, 1); 4348 else 4349 rx_vft_set(res->port_id, res->vlan_id, 0); 4350 } 4351 4352 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 4353 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4354 rx_vlan, "rx_vlan"); 4355 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 4356 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4357 what, "add#rm"); 4358 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 4359 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4360 vlan_id, RTE_UINT16); 4361 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 4362 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4363 port_id, RTE_UINT16); 4364 4365 cmdline_parse_inst_t cmd_rx_vlan_filter = { 4366 .f = cmd_rx_vlan_filter_parsed, 4367 .data = NULL, 4368 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 4369 "Add/Remove a VLAN identifier to/from the set of VLAN " 4370 "identifiers filtered by a port", 4371 .tokens = { 4372 (void *)&cmd_rx_vlan_filter_rx_vlan, 4373 (void *)&cmd_rx_vlan_filter_what, 4374 (void *)&cmd_rx_vlan_filter_vlanid, 4375 (void *)&cmd_rx_vlan_filter_portid, 4376 NULL, 4377 }, 4378 }; 4379 4380 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4381 struct cmd_tx_vlan_set_result { 4382 cmdline_fixed_string_t tx_vlan; 4383 cmdline_fixed_string_t set; 4384 portid_t port_id; 4385 uint16_t vlan_id; 4386 }; 4387 4388 static void 4389 cmd_tx_vlan_set_parsed(void *parsed_result, 4390 __rte_unused struct cmdline *cl, 4391 __rte_unused void *data) 4392 { 4393 struct cmd_tx_vlan_set_result *res = parsed_result; 4394 4395 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4396 return; 4397 4398 if (!port_is_stopped(res->port_id)) { 4399 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4400 return; 4401 } 4402 4403 tx_vlan_set(res->port_id, res->vlan_id); 4404 4405 cmd_reconfig_device_queue(res->port_id, 1, 1); 4406 } 4407 4408 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 4409 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4410 tx_vlan, "tx_vlan"); 4411 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 4412 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4413 set, "set"); 4414 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 4415 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4416 port_id, RTE_UINT16); 4417 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 4418 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4419 vlan_id, RTE_UINT16); 4420 4421 cmdline_parse_inst_t cmd_tx_vlan_set = { 4422 .f = cmd_tx_vlan_set_parsed, 4423 .data = NULL, 4424 .help_str = "tx_vlan set <port_id> <vlan_id>: " 4425 "Enable hardware insertion of a single VLAN header " 4426 "with a given TAG Identifier in packets sent on a port", 4427 .tokens = { 4428 (void *)&cmd_tx_vlan_set_tx_vlan, 4429 (void *)&cmd_tx_vlan_set_set, 4430 (void *)&cmd_tx_vlan_set_portid, 4431 (void *)&cmd_tx_vlan_set_vlanid, 4432 NULL, 4433 }, 4434 }; 4435 4436 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 4437 struct cmd_tx_vlan_set_qinq_result { 4438 cmdline_fixed_string_t tx_vlan; 4439 cmdline_fixed_string_t set; 4440 portid_t port_id; 4441 uint16_t vlan_id; 4442 uint16_t vlan_id_outer; 4443 }; 4444 4445 static void 4446 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 4447 __rte_unused struct cmdline *cl, 4448 __rte_unused void *data) 4449 { 4450 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 4451 4452 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4453 return; 4454 4455 if (!port_is_stopped(res->port_id)) { 4456 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4457 return; 4458 } 4459 4460 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 4461 4462 cmd_reconfig_device_queue(res->port_id, 1, 1); 4463 } 4464 4465 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 4466 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4467 tx_vlan, "tx_vlan"); 4468 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 4469 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4470 set, "set"); 4471 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 4472 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4473 port_id, RTE_UINT16); 4474 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 4475 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4476 vlan_id, RTE_UINT16); 4477 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 4478 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4479 vlan_id_outer, RTE_UINT16); 4480 4481 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 4482 .f = cmd_tx_vlan_set_qinq_parsed, 4483 .data = NULL, 4484 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 4485 "Enable hardware insertion of double VLAN header " 4486 "with given TAG Identifiers in packets sent on a port", 4487 .tokens = { 4488 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 4489 (void *)&cmd_tx_vlan_set_qinq_set, 4490 (void *)&cmd_tx_vlan_set_qinq_portid, 4491 (void *)&cmd_tx_vlan_set_qinq_vlanid, 4492 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 4493 NULL, 4494 }, 4495 }; 4496 4497 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 4498 struct cmd_tx_vlan_set_pvid_result { 4499 cmdline_fixed_string_t tx_vlan; 4500 cmdline_fixed_string_t set; 4501 cmdline_fixed_string_t pvid; 4502 portid_t port_id; 4503 uint16_t vlan_id; 4504 cmdline_fixed_string_t mode; 4505 }; 4506 4507 static void 4508 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 4509 __rte_unused struct cmdline *cl, 4510 __rte_unused void *data) 4511 { 4512 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 4513 4514 if (strcmp(res->mode, "on") == 0) 4515 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 4516 else 4517 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 4518 } 4519 4520 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 4521 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4522 tx_vlan, "tx_vlan"); 4523 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 4524 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4525 set, "set"); 4526 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 4527 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4528 pvid, "pvid"); 4529 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 4530 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4531 port_id, RTE_UINT16); 4532 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 4533 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4534 vlan_id, RTE_UINT16); 4535 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 4536 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4537 mode, "on#off"); 4538 4539 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 4540 .f = cmd_tx_vlan_set_pvid_parsed, 4541 .data = NULL, 4542 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 4543 .tokens = { 4544 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 4545 (void *)&cmd_tx_vlan_set_pvid_set, 4546 (void *)&cmd_tx_vlan_set_pvid_pvid, 4547 (void *)&cmd_tx_vlan_set_pvid_port_id, 4548 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 4549 (void *)&cmd_tx_vlan_set_pvid_mode, 4550 NULL, 4551 }, 4552 }; 4553 4554 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4555 struct cmd_tx_vlan_reset_result { 4556 cmdline_fixed_string_t tx_vlan; 4557 cmdline_fixed_string_t reset; 4558 portid_t port_id; 4559 }; 4560 4561 static void 4562 cmd_tx_vlan_reset_parsed(void *parsed_result, 4563 __rte_unused struct cmdline *cl, 4564 __rte_unused void *data) 4565 { 4566 struct cmd_tx_vlan_reset_result *res = parsed_result; 4567 4568 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4569 return; 4570 4571 if (!port_is_stopped(res->port_id)) { 4572 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4573 return; 4574 } 4575 4576 tx_vlan_reset(res->port_id); 4577 4578 cmd_reconfig_device_queue(res->port_id, 1, 1); 4579 } 4580 4581 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4582 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4583 tx_vlan, "tx_vlan"); 4584 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4585 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4586 reset, "reset"); 4587 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4588 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4589 port_id, RTE_UINT16); 4590 4591 cmdline_parse_inst_t cmd_tx_vlan_reset = { 4592 .f = cmd_tx_vlan_reset_parsed, 4593 .data = NULL, 4594 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4595 "VLAN header in packets sent on a port", 4596 .tokens = { 4597 (void *)&cmd_tx_vlan_reset_tx_vlan, 4598 (void *)&cmd_tx_vlan_reset_reset, 4599 (void *)&cmd_tx_vlan_reset_portid, 4600 NULL, 4601 }, 4602 }; 4603 4604 4605 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4606 struct cmd_csum_result { 4607 cmdline_fixed_string_t csum; 4608 cmdline_fixed_string_t mode; 4609 cmdline_fixed_string_t proto; 4610 cmdline_fixed_string_t hwsw; 4611 portid_t port_id; 4612 }; 4613 4614 static void 4615 csum_show(int port_id) 4616 { 4617 struct rte_eth_dev_info dev_info; 4618 uint64_t tx_offloads; 4619 int ret; 4620 4621 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4622 printf("Parse tunnel is %s\n", 4623 (ports[port_id].parse_tunnel) ? "on" : "off"); 4624 printf("IP checksum offload is %s\n", 4625 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4626 printf("UDP checksum offload is %s\n", 4627 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4628 printf("TCP checksum offload is %s\n", 4629 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4630 printf("SCTP checksum offload is %s\n", 4631 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4632 printf("Outer-Ip checksum offload is %s\n", 4633 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4634 printf("Outer-Udp checksum offload is %s\n", 4635 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); 4636 4637 /* display warnings if configuration is not supported by the NIC */ 4638 ret = eth_dev_info_get_print_err(port_id, &dev_info); 4639 if (ret != 0) 4640 return; 4641 4642 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 4643 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4644 fprintf(stderr, 4645 "Warning: hardware IP checksum enabled but not supported by port %d\n", 4646 port_id); 4647 } 4648 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 4649 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 4650 fprintf(stderr, 4651 "Warning: hardware UDP checksum enabled but not supported by port %d\n", 4652 port_id); 4653 } 4654 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 4655 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 4656 fprintf(stderr, 4657 "Warning: hardware TCP checksum enabled but not supported by port %d\n", 4658 port_id); 4659 } 4660 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 4661 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4662 fprintf(stderr, 4663 "Warning: hardware SCTP checksum enabled but not supported by port %d\n", 4664 port_id); 4665 } 4666 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4667 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4668 fprintf(stderr, 4669 "Warning: hardware outer IP checksum enabled but not supported by port %d\n", 4670 port_id); 4671 } 4672 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) && 4673 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) 4674 == 0) { 4675 fprintf(stderr, 4676 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n", 4677 port_id); 4678 } 4679 } 4680 4681 static void 4682 cmd_config_queue_tx_offloads(struct rte_port *port) 4683 { 4684 int k; 4685 4686 /* Apply queue tx offloads configuration */ 4687 for (k = 0; k < port->dev_info.max_tx_queues; k++) 4688 port->tx_conf[k].offloads = 4689 port->dev_conf.txmode.offloads; 4690 } 4691 4692 static void 4693 cmd_csum_parsed(void *parsed_result, 4694 __rte_unused struct cmdline *cl, 4695 __rte_unused void *data) 4696 { 4697 struct cmd_csum_result *res = parsed_result; 4698 int hw = 0; 4699 uint64_t csum_offloads = 0; 4700 struct rte_eth_dev_info dev_info; 4701 int ret; 4702 4703 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4704 fprintf(stderr, "invalid port %d\n", res->port_id); 4705 return; 4706 } 4707 if (!port_is_stopped(res->port_id)) { 4708 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4709 return; 4710 } 4711 4712 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4713 if (ret != 0) 4714 return; 4715 4716 if (!strcmp(res->mode, "set")) { 4717 4718 if (!strcmp(res->hwsw, "hw")) 4719 hw = 1; 4720 4721 if (!strcmp(res->proto, "ip")) { 4722 if (hw == 0 || (dev_info.tx_offload_capa & 4723 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 4724 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 4725 } else { 4726 fprintf(stderr, 4727 "IP checksum offload is not supported by port %u\n", 4728 res->port_id); 4729 } 4730 } else if (!strcmp(res->proto, "udp")) { 4731 if (hw == 0 || (dev_info.tx_offload_capa & 4732 DEV_TX_OFFLOAD_UDP_CKSUM)) { 4733 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 4734 } else { 4735 fprintf(stderr, 4736 "UDP checksum offload is not supported by port %u\n", 4737 res->port_id); 4738 } 4739 } else if (!strcmp(res->proto, "tcp")) { 4740 if (hw == 0 || (dev_info.tx_offload_capa & 4741 DEV_TX_OFFLOAD_TCP_CKSUM)) { 4742 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 4743 } else { 4744 fprintf(stderr, 4745 "TCP checksum offload is not supported by port %u\n", 4746 res->port_id); 4747 } 4748 } else if (!strcmp(res->proto, "sctp")) { 4749 if (hw == 0 || (dev_info.tx_offload_capa & 4750 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 4751 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 4752 } else { 4753 fprintf(stderr, 4754 "SCTP checksum offload is not supported by port %u\n", 4755 res->port_id); 4756 } 4757 } else if (!strcmp(res->proto, "outer-ip")) { 4758 if (hw == 0 || (dev_info.tx_offload_capa & 4759 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4760 csum_offloads |= 4761 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4762 } else { 4763 fprintf(stderr, 4764 "Outer IP checksum offload is not supported by port %u\n", 4765 res->port_id); 4766 } 4767 } else if (!strcmp(res->proto, "outer-udp")) { 4768 if (hw == 0 || (dev_info.tx_offload_capa & 4769 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) { 4770 csum_offloads |= 4771 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; 4772 } else { 4773 fprintf(stderr, 4774 "Outer UDP checksum offload is not supported by port %u\n", 4775 res->port_id); 4776 } 4777 } 4778 4779 if (hw) { 4780 ports[res->port_id].dev_conf.txmode.offloads |= 4781 csum_offloads; 4782 } else { 4783 ports[res->port_id].dev_conf.txmode.offloads &= 4784 (~csum_offloads); 4785 } 4786 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4787 } 4788 csum_show(res->port_id); 4789 4790 cmd_reconfig_device_queue(res->port_id, 1, 1); 4791 } 4792 4793 cmdline_parse_token_string_t cmd_csum_csum = 4794 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4795 csum, "csum"); 4796 cmdline_parse_token_string_t cmd_csum_mode = 4797 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4798 mode, "set"); 4799 cmdline_parse_token_string_t cmd_csum_proto = 4800 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4801 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); 4802 cmdline_parse_token_string_t cmd_csum_hwsw = 4803 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4804 hwsw, "hw#sw"); 4805 cmdline_parse_token_num_t cmd_csum_portid = 4806 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4807 port_id, RTE_UINT16); 4808 4809 cmdline_parse_inst_t cmd_csum_set = { 4810 .f = cmd_csum_parsed, 4811 .data = NULL, 4812 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: " 4813 "Enable/Disable hardware calculation of L3/L4 checksum when " 4814 "using csum forward engine", 4815 .tokens = { 4816 (void *)&cmd_csum_csum, 4817 (void *)&cmd_csum_mode, 4818 (void *)&cmd_csum_proto, 4819 (void *)&cmd_csum_hwsw, 4820 (void *)&cmd_csum_portid, 4821 NULL, 4822 }, 4823 }; 4824 4825 cmdline_parse_token_string_t cmd_csum_mode_show = 4826 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4827 mode, "show"); 4828 4829 cmdline_parse_inst_t cmd_csum_show = { 4830 .f = cmd_csum_parsed, 4831 .data = NULL, 4832 .help_str = "csum show <port_id>: Show checksum offload configuration", 4833 .tokens = { 4834 (void *)&cmd_csum_csum, 4835 (void *)&cmd_csum_mode_show, 4836 (void *)&cmd_csum_portid, 4837 NULL, 4838 }, 4839 }; 4840 4841 /* Enable/disable tunnel parsing */ 4842 struct cmd_csum_tunnel_result { 4843 cmdline_fixed_string_t csum; 4844 cmdline_fixed_string_t parse; 4845 cmdline_fixed_string_t onoff; 4846 portid_t port_id; 4847 }; 4848 4849 static void 4850 cmd_csum_tunnel_parsed(void *parsed_result, 4851 __rte_unused struct cmdline *cl, 4852 __rte_unused void *data) 4853 { 4854 struct cmd_csum_tunnel_result *res = parsed_result; 4855 4856 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4857 return; 4858 4859 if (!strcmp(res->onoff, "on")) 4860 ports[res->port_id].parse_tunnel = 1; 4861 else 4862 ports[res->port_id].parse_tunnel = 0; 4863 4864 csum_show(res->port_id); 4865 } 4866 4867 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4868 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4869 csum, "csum"); 4870 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4871 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4872 parse, "parse-tunnel"); 4873 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4874 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4875 onoff, "on#off"); 4876 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4877 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4878 port_id, RTE_UINT16); 4879 4880 cmdline_parse_inst_t cmd_csum_tunnel = { 4881 .f = cmd_csum_tunnel_parsed, 4882 .data = NULL, 4883 .help_str = "csum parse-tunnel on|off <port_id>: " 4884 "Enable/Disable parsing of tunnels for csum engine", 4885 .tokens = { 4886 (void *)&cmd_csum_tunnel_csum, 4887 (void *)&cmd_csum_tunnel_parse, 4888 (void *)&cmd_csum_tunnel_onoff, 4889 (void *)&cmd_csum_tunnel_portid, 4890 NULL, 4891 }, 4892 }; 4893 4894 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4895 struct cmd_tso_set_result { 4896 cmdline_fixed_string_t tso; 4897 cmdline_fixed_string_t mode; 4898 uint16_t tso_segsz; 4899 portid_t port_id; 4900 }; 4901 4902 static void 4903 cmd_tso_set_parsed(void *parsed_result, 4904 __rte_unused struct cmdline *cl, 4905 __rte_unused void *data) 4906 { 4907 struct cmd_tso_set_result *res = parsed_result; 4908 struct rte_eth_dev_info dev_info; 4909 int ret; 4910 4911 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4912 return; 4913 if (!port_is_stopped(res->port_id)) { 4914 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4915 return; 4916 } 4917 4918 if (!strcmp(res->mode, "set")) 4919 ports[res->port_id].tso_segsz = res->tso_segsz; 4920 4921 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4922 if (ret != 0) 4923 return; 4924 4925 if ((ports[res->port_id].tso_segsz != 0) && 4926 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4927 fprintf(stderr, "Error: TSO is not supported by port %d\n", 4928 res->port_id); 4929 return; 4930 } 4931 4932 if (ports[res->port_id].tso_segsz == 0) { 4933 ports[res->port_id].dev_conf.txmode.offloads &= 4934 ~DEV_TX_OFFLOAD_TCP_TSO; 4935 printf("TSO for non-tunneled packets is disabled\n"); 4936 } else { 4937 ports[res->port_id].dev_conf.txmode.offloads |= 4938 DEV_TX_OFFLOAD_TCP_TSO; 4939 printf("TSO segment size for non-tunneled packets is %d\n", 4940 ports[res->port_id].tso_segsz); 4941 } 4942 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4943 4944 /* display warnings if configuration is not supported by the NIC */ 4945 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4946 if (ret != 0) 4947 return; 4948 4949 if ((ports[res->port_id].tso_segsz != 0) && 4950 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4951 fprintf(stderr, 4952 "Warning: TSO enabled but not supported by port %d\n", 4953 res->port_id); 4954 } 4955 4956 cmd_reconfig_device_queue(res->port_id, 1, 1); 4957 } 4958 4959 cmdline_parse_token_string_t cmd_tso_set_tso = 4960 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4961 tso, "tso"); 4962 cmdline_parse_token_string_t cmd_tso_set_mode = 4963 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4964 mode, "set"); 4965 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4966 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4967 tso_segsz, RTE_UINT16); 4968 cmdline_parse_token_num_t cmd_tso_set_portid = 4969 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4970 port_id, RTE_UINT16); 4971 4972 cmdline_parse_inst_t cmd_tso_set = { 4973 .f = cmd_tso_set_parsed, 4974 .data = NULL, 4975 .help_str = "tso set <tso_segsz> <port_id>: " 4976 "Set TSO segment size of non-tunneled packets for csum engine " 4977 "(0 to disable)", 4978 .tokens = { 4979 (void *)&cmd_tso_set_tso, 4980 (void *)&cmd_tso_set_mode, 4981 (void *)&cmd_tso_set_tso_segsz, 4982 (void *)&cmd_tso_set_portid, 4983 NULL, 4984 }, 4985 }; 4986 4987 cmdline_parse_token_string_t cmd_tso_show_mode = 4988 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4989 mode, "show"); 4990 4991 4992 cmdline_parse_inst_t cmd_tso_show = { 4993 .f = cmd_tso_set_parsed, 4994 .data = NULL, 4995 .help_str = "tso show <port_id>: " 4996 "Show TSO segment size of non-tunneled packets for csum engine", 4997 .tokens = { 4998 (void *)&cmd_tso_set_tso, 4999 (void *)&cmd_tso_show_mode, 5000 (void *)&cmd_tso_set_portid, 5001 NULL, 5002 }, 5003 }; 5004 5005 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 5006 struct cmd_tunnel_tso_set_result { 5007 cmdline_fixed_string_t tso; 5008 cmdline_fixed_string_t mode; 5009 uint16_t tso_segsz; 5010 portid_t port_id; 5011 }; 5012 5013 static struct rte_eth_dev_info 5014 check_tunnel_tso_nic_support(portid_t port_id) 5015 { 5016 struct rte_eth_dev_info dev_info; 5017 5018 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0) 5019 return dev_info; 5020 5021 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 5022 fprintf(stderr, 5023 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n", 5024 port_id); 5025 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 5026 fprintf(stderr, 5027 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n", 5028 port_id); 5029 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 5030 fprintf(stderr, 5031 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n", 5032 port_id); 5033 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 5034 fprintf(stderr, 5035 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n", 5036 port_id); 5037 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO)) 5038 fprintf(stderr, 5039 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n", 5040 port_id); 5041 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO)) 5042 fprintf(stderr, 5043 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n", 5044 port_id); 5045 return dev_info; 5046 } 5047 5048 static void 5049 cmd_tunnel_tso_set_parsed(void *parsed_result, 5050 __rte_unused struct cmdline *cl, 5051 __rte_unused void *data) 5052 { 5053 struct cmd_tunnel_tso_set_result *res = parsed_result; 5054 struct rte_eth_dev_info dev_info; 5055 5056 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 5057 return; 5058 if (!port_is_stopped(res->port_id)) { 5059 fprintf(stderr, "Please stop port %d first\n", res->port_id); 5060 return; 5061 } 5062 5063 if (!strcmp(res->mode, "set")) 5064 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 5065 5066 dev_info = check_tunnel_tso_nic_support(res->port_id); 5067 if (ports[res->port_id].tunnel_tso_segsz == 0) { 5068 ports[res->port_id].dev_conf.txmode.offloads &= 5069 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 5070 DEV_TX_OFFLOAD_GRE_TNL_TSO | 5071 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 5072 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 5073 DEV_TX_OFFLOAD_IP_TNL_TSO | 5074 DEV_TX_OFFLOAD_UDP_TNL_TSO); 5075 printf("TSO for tunneled packets is disabled\n"); 5076 } else { 5077 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 5078 DEV_TX_OFFLOAD_GRE_TNL_TSO | 5079 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 5080 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 5081 DEV_TX_OFFLOAD_IP_TNL_TSO | 5082 DEV_TX_OFFLOAD_UDP_TNL_TSO); 5083 5084 ports[res->port_id].dev_conf.txmode.offloads |= 5085 (tso_offloads & dev_info.tx_offload_capa); 5086 printf("TSO segment size for tunneled packets is %d\n", 5087 ports[res->port_id].tunnel_tso_segsz); 5088 5089 /* Below conditions are needed to make it work: 5090 * (1) tunnel TSO is supported by the NIC; 5091 * (2) "csum parse_tunnel" must be set so that tunneled pkts 5092 * are recognized; 5093 * (3) for tunneled pkts with outer L3 of IPv4, 5094 * "csum set outer-ip" must be set to hw, because after tso, 5095 * total_len of outer IP header is changed, and the checksum 5096 * of outer IP header calculated by sw should be wrong; that 5097 * is not necessary for IPv6 tunneled pkts because there's no 5098 * checksum in IP header anymore. 5099 */ 5100 5101 if (!ports[res->port_id].parse_tunnel) 5102 fprintf(stderr, 5103 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n"); 5104 if (!(ports[res->port_id].dev_conf.txmode.offloads & 5105 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 5106 fprintf(stderr, 5107 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n"); 5108 } 5109 5110 cmd_config_queue_tx_offloads(&ports[res->port_id]); 5111 cmd_reconfig_device_queue(res->port_id, 1, 1); 5112 } 5113 5114 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 5115 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5116 tso, "tunnel_tso"); 5117 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 5118 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5119 mode, "set"); 5120 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 5121 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 5122 tso_segsz, RTE_UINT16); 5123 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 5124 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 5125 port_id, RTE_UINT16); 5126 5127 cmdline_parse_inst_t cmd_tunnel_tso_set = { 5128 .f = cmd_tunnel_tso_set_parsed, 5129 .data = NULL, 5130 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 5131 "Set TSO segment size of tunneled packets for csum engine " 5132 "(0 to disable)", 5133 .tokens = { 5134 (void *)&cmd_tunnel_tso_set_tso, 5135 (void *)&cmd_tunnel_tso_set_mode, 5136 (void *)&cmd_tunnel_tso_set_tso_segsz, 5137 (void *)&cmd_tunnel_tso_set_portid, 5138 NULL, 5139 }, 5140 }; 5141 5142 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 5143 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5144 mode, "show"); 5145 5146 5147 cmdline_parse_inst_t cmd_tunnel_tso_show = { 5148 .f = cmd_tunnel_tso_set_parsed, 5149 .data = NULL, 5150 .help_str = "tunnel_tso show <port_id> " 5151 "Show TSO segment size of tunneled packets for csum engine", 5152 .tokens = { 5153 (void *)&cmd_tunnel_tso_set_tso, 5154 (void *)&cmd_tunnel_tso_show_mode, 5155 (void *)&cmd_tunnel_tso_set_portid, 5156 NULL, 5157 }, 5158 }; 5159 5160 /* *** SET GRO FOR A PORT *** */ 5161 struct cmd_gro_enable_result { 5162 cmdline_fixed_string_t cmd_set; 5163 cmdline_fixed_string_t cmd_port; 5164 cmdline_fixed_string_t cmd_keyword; 5165 cmdline_fixed_string_t cmd_onoff; 5166 portid_t cmd_pid; 5167 }; 5168 5169 static void 5170 cmd_gro_enable_parsed(void *parsed_result, 5171 __rte_unused struct cmdline *cl, 5172 __rte_unused void *data) 5173 { 5174 struct cmd_gro_enable_result *res; 5175 5176 res = parsed_result; 5177 if (!strcmp(res->cmd_keyword, "gro")) 5178 setup_gro(res->cmd_onoff, res->cmd_pid); 5179 } 5180 5181 cmdline_parse_token_string_t cmd_gro_enable_set = 5182 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5183 cmd_set, "set"); 5184 cmdline_parse_token_string_t cmd_gro_enable_port = 5185 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5186 cmd_keyword, "port"); 5187 cmdline_parse_token_num_t cmd_gro_enable_pid = 5188 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 5189 cmd_pid, RTE_UINT16); 5190 cmdline_parse_token_string_t cmd_gro_enable_keyword = 5191 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5192 cmd_keyword, "gro"); 5193 cmdline_parse_token_string_t cmd_gro_enable_onoff = 5194 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5195 cmd_onoff, "on#off"); 5196 5197 cmdline_parse_inst_t cmd_gro_enable = { 5198 .f = cmd_gro_enable_parsed, 5199 .data = NULL, 5200 .help_str = "set port <port_id> gro on|off", 5201 .tokens = { 5202 (void *)&cmd_gro_enable_set, 5203 (void *)&cmd_gro_enable_port, 5204 (void *)&cmd_gro_enable_pid, 5205 (void *)&cmd_gro_enable_keyword, 5206 (void *)&cmd_gro_enable_onoff, 5207 NULL, 5208 }, 5209 }; 5210 5211 /* *** DISPLAY GRO CONFIGURATION *** */ 5212 struct cmd_gro_show_result { 5213 cmdline_fixed_string_t cmd_show; 5214 cmdline_fixed_string_t cmd_port; 5215 cmdline_fixed_string_t cmd_keyword; 5216 portid_t cmd_pid; 5217 }; 5218 5219 static void 5220 cmd_gro_show_parsed(void *parsed_result, 5221 __rte_unused struct cmdline *cl, 5222 __rte_unused void *data) 5223 { 5224 struct cmd_gro_show_result *res; 5225 5226 res = parsed_result; 5227 if (!strcmp(res->cmd_keyword, "gro")) 5228 show_gro(res->cmd_pid); 5229 } 5230 5231 cmdline_parse_token_string_t cmd_gro_show_show = 5232 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5233 cmd_show, "show"); 5234 cmdline_parse_token_string_t cmd_gro_show_port = 5235 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5236 cmd_port, "port"); 5237 cmdline_parse_token_num_t cmd_gro_show_pid = 5238 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 5239 cmd_pid, RTE_UINT16); 5240 cmdline_parse_token_string_t cmd_gro_show_keyword = 5241 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5242 cmd_keyword, "gro"); 5243 5244 cmdline_parse_inst_t cmd_gro_show = { 5245 .f = cmd_gro_show_parsed, 5246 .data = NULL, 5247 .help_str = "show port <port_id> gro", 5248 .tokens = { 5249 (void *)&cmd_gro_show_show, 5250 (void *)&cmd_gro_show_port, 5251 (void *)&cmd_gro_show_pid, 5252 (void *)&cmd_gro_show_keyword, 5253 NULL, 5254 }, 5255 }; 5256 5257 /* *** SET FLUSH CYCLES FOR GRO *** */ 5258 struct cmd_gro_flush_result { 5259 cmdline_fixed_string_t cmd_set; 5260 cmdline_fixed_string_t cmd_keyword; 5261 cmdline_fixed_string_t cmd_flush; 5262 uint8_t cmd_cycles; 5263 }; 5264 5265 static void 5266 cmd_gro_flush_parsed(void *parsed_result, 5267 __rte_unused struct cmdline *cl, 5268 __rte_unused void *data) 5269 { 5270 struct cmd_gro_flush_result *res; 5271 5272 res = parsed_result; 5273 if ((!strcmp(res->cmd_keyword, "gro")) && 5274 (!strcmp(res->cmd_flush, "flush"))) 5275 setup_gro_flush_cycles(res->cmd_cycles); 5276 } 5277 5278 cmdline_parse_token_string_t cmd_gro_flush_set = 5279 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5280 cmd_set, "set"); 5281 cmdline_parse_token_string_t cmd_gro_flush_keyword = 5282 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5283 cmd_keyword, "gro"); 5284 cmdline_parse_token_string_t cmd_gro_flush_flush = 5285 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5286 cmd_flush, "flush"); 5287 cmdline_parse_token_num_t cmd_gro_flush_cycles = 5288 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 5289 cmd_cycles, RTE_UINT8); 5290 5291 cmdline_parse_inst_t cmd_gro_flush = { 5292 .f = cmd_gro_flush_parsed, 5293 .data = NULL, 5294 .help_str = "set gro flush <cycles>", 5295 .tokens = { 5296 (void *)&cmd_gro_flush_set, 5297 (void *)&cmd_gro_flush_keyword, 5298 (void *)&cmd_gro_flush_flush, 5299 (void *)&cmd_gro_flush_cycles, 5300 NULL, 5301 }, 5302 }; 5303 5304 /* *** ENABLE/DISABLE GSO *** */ 5305 struct cmd_gso_enable_result { 5306 cmdline_fixed_string_t cmd_set; 5307 cmdline_fixed_string_t cmd_port; 5308 cmdline_fixed_string_t cmd_keyword; 5309 cmdline_fixed_string_t cmd_mode; 5310 portid_t cmd_pid; 5311 }; 5312 5313 static void 5314 cmd_gso_enable_parsed(void *parsed_result, 5315 __rte_unused struct cmdline *cl, 5316 __rte_unused void *data) 5317 { 5318 struct cmd_gso_enable_result *res; 5319 5320 res = parsed_result; 5321 if (!strcmp(res->cmd_keyword, "gso")) 5322 setup_gso(res->cmd_mode, res->cmd_pid); 5323 } 5324 5325 cmdline_parse_token_string_t cmd_gso_enable_set = 5326 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5327 cmd_set, "set"); 5328 cmdline_parse_token_string_t cmd_gso_enable_port = 5329 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5330 cmd_port, "port"); 5331 cmdline_parse_token_string_t cmd_gso_enable_keyword = 5332 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5333 cmd_keyword, "gso"); 5334 cmdline_parse_token_string_t cmd_gso_enable_mode = 5335 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5336 cmd_mode, "on#off"); 5337 cmdline_parse_token_num_t cmd_gso_enable_pid = 5338 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 5339 cmd_pid, RTE_UINT16); 5340 5341 cmdline_parse_inst_t cmd_gso_enable = { 5342 .f = cmd_gso_enable_parsed, 5343 .data = NULL, 5344 .help_str = "set port <port_id> gso on|off", 5345 .tokens = { 5346 (void *)&cmd_gso_enable_set, 5347 (void *)&cmd_gso_enable_port, 5348 (void *)&cmd_gso_enable_pid, 5349 (void *)&cmd_gso_enable_keyword, 5350 (void *)&cmd_gso_enable_mode, 5351 NULL, 5352 }, 5353 }; 5354 5355 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 5356 struct cmd_gso_size_result { 5357 cmdline_fixed_string_t cmd_set; 5358 cmdline_fixed_string_t cmd_keyword; 5359 cmdline_fixed_string_t cmd_segsz; 5360 uint16_t cmd_size; 5361 }; 5362 5363 static void 5364 cmd_gso_size_parsed(void *parsed_result, 5365 __rte_unused struct cmdline *cl, 5366 __rte_unused void *data) 5367 { 5368 struct cmd_gso_size_result *res = parsed_result; 5369 5370 if (test_done == 0) { 5371 fprintf(stderr, 5372 "Before setting GSO segsz, please first stop forwarding\n"); 5373 return; 5374 } 5375 5376 if (!strcmp(res->cmd_keyword, "gso") && 5377 !strcmp(res->cmd_segsz, "segsz")) { 5378 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 5379 fprintf(stderr, 5380 "gso_size should be larger than %zu. Please input a legal value\n", 5381 RTE_GSO_SEG_SIZE_MIN); 5382 else 5383 gso_max_segment_size = res->cmd_size; 5384 } 5385 } 5386 5387 cmdline_parse_token_string_t cmd_gso_size_set = 5388 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5389 cmd_set, "set"); 5390 cmdline_parse_token_string_t cmd_gso_size_keyword = 5391 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5392 cmd_keyword, "gso"); 5393 cmdline_parse_token_string_t cmd_gso_size_segsz = 5394 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5395 cmd_segsz, "segsz"); 5396 cmdline_parse_token_num_t cmd_gso_size_size = 5397 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 5398 cmd_size, RTE_UINT16); 5399 5400 cmdline_parse_inst_t cmd_gso_size = { 5401 .f = cmd_gso_size_parsed, 5402 .data = NULL, 5403 .help_str = "set gso segsz <length>", 5404 .tokens = { 5405 (void *)&cmd_gso_size_set, 5406 (void *)&cmd_gso_size_keyword, 5407 (void *)&cmd_gso_size_segsz, 5408 (void *)&cmd_gso_size_size, 5409 NULL, 5410 }, 5411 }; 5412 5413 /* *** SHOW GSO CONFIGURATION *** */ 5414 struct cmd_gso_show_result { 5415 cmdline_fixed_string_t cmd_show; 5416 cmdline_fixed_string_t cmd_port; 5417 cmdline_fixed_string_t cmd_keyword; 5418 portid_t cmd_pid; 5419 }; 5420 5421 static void 5422 cmd_gso_show_parsed(void *parsed_result, 5423 __rte_unused struct cmdline *cl, 5424 __rte_unused void *data) 5425 { 5426 struct cmd_gso_show_result *res = parsed_result; 5427 5428 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 5429 fprintf(stderr, "invalid port id %u\n", res->cmd_pid); 5430 return; 5431 } 5432 if (!strcmp(res->cmd_keyword, "gso")) { 5433 if (gso_ports[res->cmd_pid].enable) { 5434 printf("Max GSO'd packet size: %uB\n" 5435 "Supported GSO types: TCP/IPv4, " 5436 "UDP/IPv4, VxLAN with inner " 5437 "TCP/IPv4 packet, GRE with inner " 5438 "TCP/IPv4 packet\n", 5439 gso_max_segment_size); 5440 } else 5441 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 5442 } 5443 } 5444 5445 cmdline_parse_token_string_t cmd_gso_show_show = 5446 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5447 cmd_show, "show"); 5448 cmdline_parse_token_string_t cmd_gso_show_port = 5449 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5450 cmd_port, "port"); 5451 cmdline_parse_token_string_t cmd_gso_show_keyword = 5452 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5453 cmd_keyword, "gso"); 5454 cmdline_parse_token_num_t cmd_gso_show_pid = 5455 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 5456 cmd_pid, RTE_UINT16); 5457 5458 cmdline_parse_inst_t cmd_gso_show = { 5459 .f = cmd_gso_show_parsed, 5460 .data = NULL, 5461 .help_str = "show port <port_id> gso", 5462 .tokens = { 5463 (void *)&cmd_gso_show_show, 5464 (void *)&cmd_gso_show_port, 5465 (void *)&cmd_gso_show_pid, 5466 (void *)&cmd_gso_show_keyword, 5467 NULL, 5468 }, 5469 }; 5470 5471 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 5472 struct cmd_set_flush_rx { 5473 cmdline_fixed_string_t set; 5474 cmdline_fixed_string_t flush_rx; 5475 cmdline_fixed_string_t mode; 5476 }; 5477 5478 static void 5479 cmd_set_flush_rx_parsed(void *parsed_result, 5480 __rte_unused struct cmdline *cl, 5481 __rte_unused void *data) 5482 { 5483 struct cmd_set_flush_rx *res = parsed_result; 5484 5485 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) { 5486 printf("multi-process doesn't support to flush Rx queues.\n"); 5487 return; 5488 } 5489 5490 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5491 } 5492 5493 cmdline_parse_token_string_t cmd_setflushrx_set = 5494 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5495 set, "set"); 5496 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 5497 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5498 flush_rx, "flush_rx"); 5499 cmdline_parse_token_string_t cmd_setflushrx_mode = 5500 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5501 mode, "on#off"); 5502 5503 5504 cmdline_parse_inst_t cmd_set_flush_rx = { 5505 .f = cmd_set_flush_rx_parsed, 5506 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 5507 .data = NULL, 5508 .tokens = { 5509 (void *)&cmd_setflushrx_set, 5510 (void *)&cmd_setflushrx_flush_rx, 5511 (void *)&cmd_setflushrx_mode, 5512 NULL, 5513 }, 5514 }; 5515 5516 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 5517 struct cmd_set_link_check { 5518 cmdline_fixed_string_t set; 5519 cmdline_fixed_string_t link_check; 5520 cmdline_fixed_string_t mode; 5521 }; 5522 5523 static void 5524 cmd_set_link_check_parsed(void *parsed_result, 5525 __rte_unused struct cmdline *cl, 5526 __rte_unused void *data) 5527 { 5528 struct cmd_set_link_check *res = parsed_result; 5529 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5530 } 5531 5532 cmdline_parse_token_string_t cmd_setlinkcheck_set = 5533 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5534 set, "set"); 5535 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 5536 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5537 link_check, "link_check"); 5538 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 5539 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5540 mode, "on#off"); 5541 5542 5543 cmdline_parse_inst_t cmd_set_link_check = { 5544 .f = cmd_set_link_check_parsed, 5545 .help_str = "set link_check on|off: Enable/Disable link status check " 5546 "when starting/stopping a port", 5547 .data = NULL, 5548 .tokens = { 5549 (void *)&cmd_setlinkcheck_set, 5550 (void *)&cmd_setlinkcheck_link_check, 5551 (void *)&cmd_setlinkcheck_mode, 5552 NULL, 5553 }, 5554 }; 5555 5556 /* *** SET NIC BYPASS MODE *** */ 5557 struct cmd_set_bypass_mode_result { 5558 cmdline_fixed_string_t set; 5559 cmdline_fixed_string_t bypass; 5560 cmdline_fixed_string_t mode; 5561 cmdline_fixed_string_t value; 5562 portid_t port_id; 5563 }; 5564 5565 static void 5566 cmd_set_bypass_mode_parsed(void *parsed_result, 5567 __rte_unused struct cmdline *cl, 5568 __rte_unused void *data) 5569 { 5570 struct cmd_set_bypass_mode_result *res = parsed_result; 5571 portid_t port_id = res->port_id; 5572 int32_t rc = -EINVAL; 5573 5574 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5575 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5576 5577 if (!strcmp(res->value, "bypass")) 5578 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5579 else if (!strcmp(res->value, "isolate")) 5580 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5581 else 5582 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5583 5584 /* Set the bypass mode for the relevant port. */ 5585 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 5586 #endif 5587 if (rc != 0) 5588 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n", 5589 port_id); 5590 } 5591 5592 cmdline_parse_token_string_t cmd_setbypass_mode_set = 5593 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5594 set, "set"); 5595 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 5596 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5597 bypass, "bypass"); 5598 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 5599 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5600 mode, "mode"); 5601 cmdline_parse_token_string_t cmd_setbypass_mode_value = 5602 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5603 value, "normal#bypass#isolate"); 5604 cmdline_parse_token_num_t cmd_setbypass_mode_port = 5605 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 5606 port_id, RTE_UINT16); 5607 5608 cmdline_parse_inst_t cmd_set_bypass_mode = { 5609 .f = cmd_set_bypass_mode_parsed, 5610 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 5611 "Set the NIC bypass mode for port_id", 5612 .data = NULL, 5613 .tokens = { 5614 (void *)&cmd_setbypass_mode_set, 5615 (void *)&cmd_setbypass_mode_bypass, 5616 (void *)&cmd_setbypass_mode_mode, 5617 (void *)&cmd_setbypass_mode_value, 5618 (void *)&cmd_setbypass_mode_port, 5619 NULL, 5620 }, 5621 }; 5622 5623 /* *** SET NIC BYPASS EVENT *** */ 5624 struct cmd_set_bypass_event_result { 5625 cmdline_fixed_string_t set; 5626 cmdline_fixed_string_t bypass; 5627 cmdline_fixed_string_t event; 5628 cmdline_fixed_string_t event_value; 5629 cmdline_fixed_string_t mode; 5630 cmdline_fixed_string_t mode_value; 5631 portid_t port_id; 5632 }; 5633 5634 static void 5635 cmd_set_bypass_event_parsed(void *parsed_result, 5636 __rte_unused struct cmdline *cl, 5637 __rte_unused void *data) 5638 { 5639 int32_t rc = -EINVAL; 5640 struct cmd_set_bypass_event_result *res = parsed_result; 5641 portid_t port_id = res->port_id; 5642 5643 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5644 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5645 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5646 5647 if (!strcmp(res->event_value, "timeout")) 5648 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 5649 else if (!strcmp(res->event_value, "os_on")) 5650 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 5651 else if (!strcmp(res->event_value, "os_off")) 5652 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 5653 else if (!strcmp(res->event_value, "power_on")) 5654 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 5655 else if (!strcmp(res->event_value, "power_off")) 5656 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 5657 else 5658 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5659 5660 if (!strcmp(res->mode_value, "bypass")) 5661 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5662 else if (!strcmp(res->mode_value, "isolate")) 5663 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5664 else 5665 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5666 5667 /* Set the watchdog timeout. */ 5668 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 5669 5670 rc = -EINVAL; 5671 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 5672 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 5673 bypass_timeout); 5674 } 5675 if (rc != 0) { 5676 fprintf(stderr, 5677 "Failed to set timeout value %u for port %d, errto code: %d.\n", 5678 bypass_timeout, port_id, rc); 5679 } 5680 } 5681 5682 /* Set the bypass event to transition to bypass mode. */ 5683 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 5684 bypass_mode); 5685 #endif 5686 5687 if (rc != 0) 5688 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n", 5689 port_id); 5690 } 5691 5692 cmdline_parse_token_string_t cmd_setbypass_event_set = 5693 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5694 set, "set"); 5695 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 5696 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5697 bypass, "bypass"); 5698 cmdline_parse_token_string_t cmd_setbypass_event_event = 5699 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5700 event, "event"); 5701 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 5702 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5703 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 5704 cmdline_parse_token_string_t cmd_setbypass_event_mode = 5705 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5706 mode, "mode"); 5707 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 5708 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5709 mode_value, "normal#bypass#isolate"); 5710 cmdline_parse_token_num_t cmd_setbypass_event_port = 5711 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 5712 port_id, RTE_UINT16); 5713 5714 cmdline_parse_inst_t cmd_set_bypass_event = { 5715 .f = cmd_set_bypass_event_parsed, 5716 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 5717 "power_off mode normal|bypass|isolate <port_id>: " 5718 "Set the NIC bypass event mode for port_id", 5719 .data = NULL, 5720 .tokens = { 5721 (void *)&cmd_setbypass_event_set, 5722 (void *)&cmd_setbypass_event_bypass, 5723 (void *)&cmd_setbypass_event_event, 5724 (void *)&cmd_setbypass_event_event_value, 5725 (void *)&cmd_setbypass_event_mode, 5726 (void *)&cmd_setbypass_event_mode_value, 5727 (void *)&cmd_setbypass_event_port, 5728 NULL, 5729 }, 5730 }; 5731 5732 5733 /* *** SET NIC BYPASS TIMEOUT *** */ 5734 struct cmd_set_bypass_timeout_result { 5735 cmdline_fixed_string_t set; 5736 cmdline_fixed_string_t bypass; 5737 cmdline_fixed_string_t timeout; 5738 cmdline_fixed_string_t value; 5739 }; 5740 5741 static void 5742 cmd_set_bypass_timeout_parsed(void *parsed_result, 5743 __rte_unused struct cmdline *cl, 5744 __rte_unused void *data) 5745 { 5746 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 5747 5748 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5749 if (!strcmp(res->value, "1.5")) 5750 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 5751 else if (!strcmp(res->value, "2")) 5752 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 5753 else if (!strcmp(res->value, "3")) 5754 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 5755 else if (!strcmp(res->value, "4")) 5756 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 5757 else if (!strcmp(res->value, "8")) 5758 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 5759 else if (!strcmp(res->value, "16")) 5760 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 5761 else if (!strcmp(res->value, "32")) 5762 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 5763 else 5764 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5765 #endif 5766 } 5767 5768 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 5769 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5770 set, "set"); 5771 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 5772 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5773 bypass, "bypass"); 5774 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 5775 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5776 timeout, "timeout"); 5777 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 5778 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5779 value, "0#1.5#2#3#4#8#16#32"); 5780 5781 cmdline_parse_inst_t cmd_set_bypass_timeout = { 5782 .f = cmd_set_bypass_timeout_parsed, 5783 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 5784 "Set the NIC bypass watchdog timeout in seconds", 5785 .data = NULL, 5786 .tokens = { 5787 (void *)&cmd_setbypass_timeout_set, 5788 (void *)&cmd_setbypass_timeout_bypass, 5789 (void *)&cmd_setbypass_timeout_timeout, 5790 (void *)&cmd_setbypass_timeout_value, 5791 NULL, 5792 }, 5793 }; 5794 5795 /* *** SHOW NIC BYPASS MODE *** */ 5796 struct cmd_show_bypass_config_result { 5797 cmdline_fixed_string_t show; 5798 cmdline_fixed_string_t bypass; 5799 cmdline_fixed_string_t config; 5800 portid_t port_id; 5801 }; 5802 5803 static void 5804 cmd_show_bypass_config_parsed(void *parsed_result, 5805 __rte_unused struct cmdline *cl, 5806 __rte_unused void *data) 5807 { 5808 struct cmd_show_bypass_config_result *res = parsed_result; 5809 portid_t port_id = res->port_id; 5810 int rc = -EINVAL; 5811 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5812 uint32_t event_mode; 5813 uint32_t bypass_mode; 5814 uint32_t timeout = bypass_timeout; 5815 unsigned int i; 5816 5817 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 5818 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 5819 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 5820 {"UNKNOWN", "normal", "bypass", "isolate"}; 5821 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 5822 "NONE", 5823 "OS/board on", 5824 "power supply on", 5825 "OS/board off", 5826 "power supply off", 5827 "timeout"}; 5828 5829 /* Display the bypass mode.*/ 5830 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 5831 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n", 5832 port_id); 5833 return; 5834 } 5835 else { 5836 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 5837 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5838 5839 printf("\tbypass mode = %s\n", modes[bypass_mode]); 5840 } 5841 5842 /* Display the bypass timeout.*/ 5843 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 5844 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5845 5846 printf("\tbypass timeout = %s\n", timeouts[timeout]); 5847 5848 /* Display the bypass events and associated modes. */ 5849 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) { 5850 5851 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 5852 fprintf(stderr, 5853 "\tFailed to get bypass mode for event = %s\n", 5854 events[i]); 5855 } else { 5856 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 5857 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5858 5859 printf("\tbypass event: %-16s = %s\n", events[i], 5860 modes[event_mode]); 5861 } 5862 } 5863 #endif 5864 if (rc != 0) 5865 fprintf(stderr, 5866 "\tFailed to get bypass configuration for port = %d\n", 5867 port_id); 5868 } 5869 5870 cmdline_parse_token_string_t cmd_showbypass_config_show = 5871 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5872 show, "show"); 5873 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 5874 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5875 bypass, "bypass"); 5876 cmdline_parse_token_string_t cmd_showbypass_config_config = 5877 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5878 config, "config"); 5879 cmdline_parse_token_num_t cmd_showbypass_config_port = 5880 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 5881 port_id, RTE_UINT16); 5882 5883 cmdline_parse_inst_t cmd_show_bypass_config = { 5884 .f = cmd_show_bypass_config_parsed, 5885 .help_str = "show bypass config <port_id>: " 5886 "Show the NIC bypass config for port_id", 5887 .data = NULL, 5888 .tokens = { 5889 (void *)&cmd_showbypass_config_show, 5890 (void *)&cmd_showbypass_config_bypass, 5891 (void *)&cmd_showbypass_config_config, 5892 (void *)&cmd_showbypass_config_port, 5893 NULL, 5894 }, 5895 }; 5896 5897 #ifdef RTE_NET_BOND 5898 /* *** SET BONDING MODE *** */ 5899 struct cmd_set_bonding_mode_result { 5900 cmdline_fixed_string_t set; 5901 cmdline_fixed_string_t bonding; 5902 cmdline_fixed_string_t mode; 5903 uint8_t value; 5904 portid_t port_id; 5905 }; 5906 5907 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5908 __rte_unused struct cmdline *cl, 5909 __rte_unused void *data) 5910 { 5911 struct cmd_set_bonding_mode_result *res = parsed_result; 5912 portid_t port_id = res->port_id; 5913 5914 /* Set the bonding mode for the relevant port. */ 5915 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5916 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n", 5917 port_id); 5918 } 5919 5920 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5921 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5922 set, "set"); 5923 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5924 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5925 bonding, "bonding"); 5926 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5927 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5928 mode, "mode"); 5929 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5930 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5931 value, RTE_UINT8); 5932 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5933 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5934 port_id, RTE_UINT16); 5935 5936 cmdline_parse_inst_t cmd_set_bonding_mode = { 5937 .f = cmd_set_bonding_mode_parsed, 5938 .help_str = "set bonding mode <mode_value> <port_id>: " 5939 "Set the bonding mode for port_id", 5940 .data = NULL, 5941 .tokens = { 5942 (void *) &cmd_setbonding_mode_set, 5943 (void *) &cmd_setbonding_mode_bonding, 5944 (void *) &cmd_setbonding_mode_mode, 5945 (void *) &cmd_setbonding_mode_value, 5946 (void *) &cmd_setbonding_mode_port, 5947 NULL 5948 } 5949 }; 5950 5951 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5952 struct cmd_set_bonding_lacp_dedicated_queues_result { 5953 cmdline_fixed_string_t set; 5954 cmdline_fixed_string_t bonding; 5955 cmdline_fixed_string_t lacp; 5956 cmdline_fixed_string_t dedicated_queues; 5957 portid_t port_id; 5958 cmdline_fixed_string_t mode; 5959 }; 5960 5961 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5962 __rte_unused struct cmdline *cl, 5963 __rte_unused void *data) 5964 { 5965 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5966 portid_t port_id = res->port_id; 5967 struct rte_port *port; 5968 5969 port = &ports[port_id]; 5970 5971 /** Check if the port is not started **/ 5972 if (port->port_status != RTE_PORT_STOPPED) { 5973 fprintf(stderr, "Please stop port %d first\n", port_id); 5974 return; 5975 } 5976 5977 if (!strcmp(res->mode, "enable")) { 5978 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5979 printf("Dedicate queues for LACP control packets" 5980 " enabled\n"); 5981 else 5982 printf("Enabling dedicate queues for LACP control " 5983 "packets on port %d failed\n", port_id); 5984 } else if (!strcmp(res->mode, "disable")) { 5985 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5986 printf("Dedicated queues for LACP control packets " 5987 "disabled\n"); 5988 else 5989 printf("Disabling dedicated queues for LACP control " 5990 "traffic on port %d failed\n", port_id); 5991 } 5992 } 5993 5994 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 5995 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5996 set, "set"); 5997 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 5998 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5999 bonding, "bonding"); 6000 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 6001 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 6002 lacp, "lacp"); 6003 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 6004 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 6005 dedicated_queues, "dedicated_queues"); 6006 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 6007 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 6008 port_id, RTE_UINT16); 6009 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 6010 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 6011 mode, "enable#disable"); 6012 6013 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 6014 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 6015 .help_str = "set bonding lacp dedicated_queues <port_id> " 6016 "enable|disable: " 6017 "Enable/disable dedicated queues for LACP control traffic for port_id", 6018 .data = NULL, 6019 .tokens = { 6020 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 6021 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 6022 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 6023 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 6024 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 6025 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 6026 NULL 6027 } 6028 }; 6029 6030 /* *** SET BALANCE XMIT POLICY *** */ 6031 struct cmd_set_bonding_balance_xmit_policy_result { 6032 cmdline_fixed_string_t set; 6033 cmdline_fixed_string_t bonding; 6034 cmdline_fixed_string_t balance_xmit_policy; 6035 portid_t port_id; 6036 cmdline_fixed_string_t policy; 6037 }; 6038 6039 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 6040 __rte_unused struct cmdline *cl, 6041 __rte_unused void *data) 6042 { 6043 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 6044 portid_t port_id = res->port_id; 6045 uint8_t policy; 6046 6047 if (!strcmp(res->policy, "l2")) { 6048 policy = BALANCE_XMIT_POLICY_LAYER2; 6049 } else if (!strcmp(res->policy, "l23")) { 6050 policy = BALANCE_XMIT_POLICY_LAYER23; 6051 } else if (!strcmp(res->policy, "l34")) { 6052 policy = BALANCE_XMIT_POLICY_LAYER34; 6053 } else { 6054 fprintf(stderr, "\t Invalid xmit policy selection"); 6055 return; 6056 } 6057 6058 /* Set the bonding mode for the relevant port. */ 6059 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 6060 fprintf(stderr, 6061 "\t Failed to set bonding balance xmit policy for port = %d.\n", 6062 port_id); 6063 } 6064 } 6065 6066 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 6067 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6068 set, "set"); 6069 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 6070 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6071 bonding, "bonding"); 6072 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 6073 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6074 balance_xmit_policy, "balance_xmit_policy"); 6075 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 6076 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6077 port_id, RTE_UINT16); 6078 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 6079 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6080 policy, "l2#l23#l34"); 6081 6082 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 6083 .f = cmd_set_bonding_balance_xmit_policy_parsed, 6084 .help_str = "set bonding balance_xmit_policy <port_id> " 6085 "l2|l23|l34: " 6086 "Set the bonding balance_xmit_policy for port_id", 6087 .data = NULL, 6088 .tokens = { 6089 (void *)&cmd_setbonding_balance_xmit_policy_set, 6090 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 6091 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 6092 (void *)&cmd_setbonding_balance_xmit_policy_port, 6093 (void *)&cmd_setbonding_balance_xmit_policy_policy, 6094 NULL 6095 } 6096 }; 6097 6098 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */ 6099 struct cmd_show_bonding_lacp_info_result { 6100 cmdline_fixed_string_t show; 6101 cmdline_fixed_string_t bonding; 6102 cmdline_fixed_string_t lacp; 6103 cmdline_fixed_string_t info; 6104 portid_t port_id; 6105 }; 6106 6107 static void port_param_show(struct port_params *params) 6108 { 6109 char buf[RTE_ETHER_ADDR_FMT_SIZE]; 6110 6111 printf("\t\tsystem priority: %u\n", params->system_priority); 6112 rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system); 6113 printf("\t\tsystem mac address: %s\n", buf); 6114 printf("\t\tport key: %u\n", params->key); 6115 printf("\t\tport priority: %u\n", params->port_priority); 6116 printf("\t\tport number: %u\n", params->port_number); 6117 } 6118 6119 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info) 6120 { 6121 char a_state[256] = { 0 }; 6122 char p_state[256] = { 0 }; 6123 int a_len = 0; 6124 int p_len = 0; 6125 uint32_t i; 6126 6127 static const char * const state[] = { 6128 "ACTIVE", 6129 "TIMEOUT", 6130 "AGGREGATION", 6131 "SYNCHRONIZATION", 6132 "COLLECTING", 6133 "DISTRIBUTING", 6134 "DEFAULTED", 6135 "EXPIRED" 6136 }; 6137 static const char * const selection[] = { 6138 "UNSELECTED", 6139 "STANDBY", 6140 "SELECTED" 6141 }; 6142 6143 for (i = 0; i < RTE_DIM(state); i++) { 6144 if ((info->actor_state >> i) & 1) 6145 a_len += snprintf(&a_state[a_len], 6146 RTE_DIM(a_state) - a_len, "%s ", 6147 state[i]); 6148 6149 if ((info->partner_state >> i) & 1) 6150 p_len += snprintf(&p_state[p_len], 6151 RTE_DIM(p_state) - p_len, "%s ", 6152 state[i]); 6153 } 6154 printf("\tAggregator port id: %u\n", info->agg_port_id); 6155 printf("\tselection: %s\n", selection[info->selected]); 6156 printf("\tActor detail info:\n"); 6157 port_param_show(&info->actor); 6158 printf("\t\tport state: %s\n", a_state); 6159 printf("\tPartner detail info:\n"); 6160 port_param_show(&info->partner); 6161 printf("\t\tport state: %s\n", p_state); 6162 printf("\n"); 6163 } 6164 6165 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf) 6166 { 6167 printf("\tfast period: %u ms\n", conf->fast_periodic_ms); 6168 printf("\tslow period: %u ms\n", conf->slow_periodic_ms); 6169 printf("\tshort timeout: %u ms\n", conf->short_timeout_ms); 6170 printf("\tlong timeout: %u ms\n", conf->long_timeout_ms); 6171 printf("\taggregate wait timeout: %u ms\n", 6172 conf->aggregate_wait_timeout_ms); 6173 printf("\ttx period: %u ms\n", conf->tx_period_ms); 6174 printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms); 6175 printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms); 6176 switch (conf->agg_selection) { 6177 case AGG_BANDWIDTH: 6178 printf("\taggregation mode: bandwidth\n"); 6179 break; 6180 case AGG_STABLE: 6181 printf("\taggregation mode: stable\n"); 6182 break; 6183 case AGG_COUNT: 6184 printf("\taggregation mode: count\n"); 6185 break; 6186 default: 6187 printf("\taggregation mode: invalid\n"); 6188 break; 6189 } 6190 6191 printf("\n"); 6192 } 6193 6194 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result, 6195 __rte_unused struct cmdline *cl, 6196 __rte_unused void *data) 6197 { 6198 struct cmd_show_bonding_lacp_info_result *res = parsed_result; 6199 struct rte_eth_bond_8023ad_slave_info slave_info; 6200 struct rte_eth_bond_8023ad_conf port_conf; 6201 portid_t slaves[RTE_MAX_ETHPORTS]; 6202 portid_t port_id = res->port_id; 6203 int num_active_slaves; 6204 int bonding_mode; 6205 int i; 6206 int ret; 6207 6208 bonding_mode = rte_eth_bond_mode_get(port_id); 6209 if (bonding_mode != BONDING_MODE_8023AD) { 6210 fprintf(stderr, "\tBonding mode is not mode 4\n"); 6211 return; 6212 } 6213 6214 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 6215 RTE_MAX_ETHPORTS); 6216 if (num_active_slaves < 0) { 6217 fprintf(stderr, "\tFailed to get active slave list for port = %u\n", 6218 port_id); 6219 return; 6220 } 6221 if (num_active_slaves == 0) 6222 fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n", 6223 port_id); 6224 6225 printf("\tIEEE802.3 port: %u\n", port_id); 6226 ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf); 6227 if (ret) { 6228 fprintf(stderr, "\tGet bonded device %u info failed\n", 6229 port_id); 6230 return; 6231 } 6232 lacp_conf_show(&port_conf); 6233 6234 for (i = 0; i < num_active_slaves; i++) { 6235 ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i], 6236 &slave_info); 6237 if (ret) { 6238 fprintf(stderr, "\tGet slave device %u info failed\n", 6239 slaves[i]); 6240 return; 6241 } 6242 printf("\tSlave Port: %u\n", slaves[i]); 6243 lacp_slave_info_show(&slave_info); 6244 } 6245 } 6246 6247 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show = 6248 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result, 6249 show, "show"); 6250 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding = 6251 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result, 6252 bonding, "bonding"); 6253 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp = 6254 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result, 6255 bonding, "lacp"); 6256 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info = 6257 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result, 6258 info, "info"); 6259 cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id = 6260 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result, 6261 port_id, RTE_UINT16); 6262 6263 cmdline_parse_inst_t cmd_show_bonding_lacp_info = { 6264 .f = cmd_show_bonding_lacp_info_parsed, 6265 .help_str = "show bonding lacp info <port_id> : " 6266 "Show bonding IEEE802.3 information for port_id", 6267 .data = NULL, 6268 .tokens = { 6269 (void *)&cmd_show_bonding_lacp_info_show, 6270 (void *)&cmd_show_bonding_lacp_info_bonding, 6271 (void *)&cmd_show_bonding_lacp_info_lacp, 6272 (void *)&cmd_show_bonding_lacp_info_info, 6273 (void *)&cmd_show_bonding_lacp_info_port_id, 6274 NULL 6275 } 6276 }; 6277 6278 /* *** SHOW NIC BONDING CONFIGURATION *** */ 6279 struct cmd_show_bonding_config_result { 6280 cmdline_fixed_string_t show; 6281 cmdline_fixed_string_t bonding; 6282 cmdline_fixed_string_t config; 6283 portid_t port_id; 6284 }; 6285 6286 static void cmd_show_bonding_config_parsed(void *parsed_result, 6287 __rte_unused struct cmdline *cl, 6288 __rte_unused void *data) 6289 { 6290 struct cmd_show_bonding_config_result *res = parsed_result; 6291 int bonding_mode, agg_mode; 6292 portid_t slaves[RTE_MAX_ETHPORTS]; 6293 int num_slaves, num_active_slaves; 6294 int primary_id; 6295 int i; 6296 portid_t port_id = res->port_id; 6297 6298 /* Display the bonding mode.*/ 6299 bonding_mode = rte_eth_bond_mode_get(port_id); 6300 if (bonding_mode < 0) { 6301 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n", 6302 port_id); 6303 return; 6304 } else 6305 printf("\tBonding mode: %d\n", bonding_mode); 6306 6307 if (bonding_mode == BONDING_MODE_BALANCE) { 6308 int balance_xmit_policy; 6309 6310 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 6311 if (balance_xmit_policy < 0) { 6312 fprintf(stderr, 6313 "\tFailed to get balance xmit policy for port = %d\n", 6314 port_id); 6315 return; 6316 } else { 6317 printf("\tBalance Xmit Policy: "); 6318 6319 switch (balance_xmit_policy) { 6320 case BALANCE_XMIT_POLICY_LAYER2: 6321 printf("BALANCE_XMIT_POLICY_LAYER2"); 6322 break; 6323 case BALANCE_XMIT_POLICY_LAYER23: 6324 printf("BALANCE_XMIT_POLICY_LAYER23"); 6325 break; 6326 case BALANCE_XMIT_POLICY_LAYER34: 6327 printf("BALANCE_XMIT_POLICY_LAYER34"); 6328 break; 6329 } 6330 printf("\n"); 6331 } 6332 } 6333 6334 if (bonding_mode == BONDING_MODE_8023AD) { 6335 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 6336 printf("\tIEEE802.3AD Aggregator Mode: "); 6337 switch (agg_mode) { 6338 case AGG_BANDWIDTH: 6339 printf("bandwidth"); 6340 break; 6341 case AGG_STABLE: 6342 printf("stable"); 6343 break; 6344 case AGG_COUNT: 6345 printf("count"); 6346 break; 6347 } 6348 printf("\n"); 6349 } 6350 6351 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 6352 6353 if (num_slaves < 0) { 6354 fprintf(stderr, "\tFailed to get slave list for port = %d\n", 6355 port_id); 6356 return; 6357 } 6358 if (num_slaves > 0) { 6359 printf("\tSlaves (%d): [", num_slaves); 6360 for (i = 0; i < num_slaves - 1; i++) 6361 printf("%d ", slaves[i]); 6362 6363 printf("%d]\n", slaves[num_slaves - 1]); 6364 } else { 6365 printf("\tSlaves: []\n"); 6366 6367 } 6368 6369 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 6370 RTE_MAX_ETHPORTS); 6371 6372 if (num_active_slaves < 0) { 6373 fprintf(stderr, 6374 "\tFailed to get active slave list for port = %d\n", 6375 port_id); 6376 return; 6377 } 6378 if (num_active_slaves > 0) { 6379 printf("\tActive Slaves (%d): [", num_active_slaves); 6380 for (i = 0; i < num_active_slaves - 1; i++) 6381 printf("%d ", slaves[i]); 6382 6383 printf("%d]\n", slaves[num_active_slaves - 1]); 6384 6385 } else { 6386 printf("\tActive Slaves: []\n"); 6387 6388 } 6389 6390 primary_id = rte_eth_bond_primary_get(port_id); 6391 if (primary_id < 0) { 6392 fprintf(stderr, "\tFailed to get primary slave for port = %d\n", 6393 port_id); 6394 return; 6395 } else 6396 printf("\tPrimary: [%d]\n", primary_id); 6397 6398 } 6399 6400 cmdline_parse_token_string_t cmd_showbonding_config_show = 6401 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6402 show, "show"); 6403 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 6404 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6405 bonding, "bonding"); 6406 cmdline_parse_token_string_t cmd_showbonding_config_config = 6407 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6408 config, "config"); 6409 cmdline_parse_token_num_t cmd_showbonding_config_port = 6410 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 6411 port_id, RTE_UINT16); 6412 6413 cmdline_parse_inst_t cmd_show_bonding_config = { 6414 .f = cmd_show_bonding_config_parsed, 6415 .help_str = "show bonding config <port_id>: " 6416 "Show the bonding config for port_id", 6417 .data = NULL, 6418 .tokens = { 6419 (void *)&cmd_showbonding_config_show, 6420 (void *)&cmd_showbonding_config_bonding, 6421 (void *)&cmd_showbonding_config_config, 6422 (void *)&cmd_showbonding_config_port, 6423 NULL 6424 } 6425 }; 6426 6427 /* *** SET BONDING PRIMARY *** */ 6428 struct cmd_set_bonding_primary_result { 6429 cmdline_fixed_string_t set; 6430 cmdline_fixed_string_t bonding; 6431 cmdline_fixed_string_t primary; 6432 portid_t slave_id; 6433 portid_t port_id; 6434 }; 6435 6436 static void cmd_set_bonding_primary_parsed(void *parsed_result, 6437 __rte_unused struct cmdline *cl, 6438 __rte_unused void *data) 6439 { 6440 struct cmd_set_bonding_primary_result *res = parsed_result; 6441 portid_t master_port_id = res->port_id; 6442 portid_t slave_port_id = res->slave_id; 6443 6444 /* Set the primary slave for a bonded device. */ 6445 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 6446 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n", 6447 master_port_id); 6448 return; 6449 } 6450 init_port_config(); 6451 } 6452 6453 cmdline_parse_token_string_t cmd_setbonding_primary_set = 6454 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6455 set, "set"); 6456 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 6457 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6458 bonding, "bonding"); 6459 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 6460 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6461 primary, "primary"); 6462 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 6463 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6464 slave_id, RTE_UINT16); 6465 cmdline_parse_token_num_t cmd_setbonding_primary_port = 6466 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6467 port_id, RTE_UINT16); 6468 6469 cmdline_parse_inst_t cmd_set_bonding_primary = { 6470 .f = cmd_set_bonding_primary_parsed, 6471 .help_str = "set bonding primary <slave_id> <port_id>: " 6472 "Set the primary slave for port_id", 6473 .data = NULL, 6474 .tokens = { 6475 (void *)&cmd_setbonding_primary_set, 6476 (void *)&cmd_setbonding_primary_bonding, 6477 (void *)&cmd_setbonding_primary_primary, 6478 (void *)&cmd_setbonding_primary_slave, 6479 (void *)&cmd_setbonding_primary_port, 6480 NULL 6481 } 6482 }; 6483 6484 /* *** ADD SLAVE *** */ 6485 struct cmd_add_bonding_slave_result { 6486 cmdline_fixed_string_t add; 6487 cmdline_fixed_string_t bonding; 6488 cmdline_fixed_string_t slave; 6489 portid_t slave_id; 6490 portid_t port_id; 6491 }; 6492 6493 static void cmd_add_bonding_slave_parsed(void *parsed_result, 6494 __rte_unused struct cmdline *cl, 6495 __rte_unused void *data) 6496 { 6497 struct cmd_add_bonding_slave_result *res = parsed_result; 6498 portid_t master_port_id = res->port_id; 6499 portid_t slave_port_id = res->slave_id; 6500 6501 /* add the slave for a bonded device. */ 6502 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 6503 fprintf(stderr, 6504 "\t Failed to add slave %d to master port = %d.\n", 6505 slave_port_id, master_port_id); 6506 return; 6507 } 6508 init_port_config(); 6509 set_port_slave_flag(slave_port_id); 6510 } 6511 6512 cmdline_parse_token_string_t cmd_addbonding_slave_add = 6513 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6514 add, "add"); 6515 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 6516 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6517 bonding, "bonding"); 6518 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 6519 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6520 slave, "slave"); 6521 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 6522 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6523 slave_id, RTE_UINT16); 6524 cmdline_parse_token_num_t cmd_addbonding_slave_port = 6525 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6526 port_id, RTE_UINT16); 6527 6528 cmdline_parse_inst_t cmd_add_bonding_slave = { 6529 .f = cmd_add_bonding_slave_parsed, 6530 .help_str = "add bonding slave <slave_id> <port_id>: " 6531 "Add a slave device to a bonded device", 6532 .data = NULL, 6533 .tokens = { 6534 (void *)&cmd_addbonding_slave_add, 6535 (void *)&cmd_addbonding_slave_bonding, 6536 (void *)&cmd_addbonding_slave_slave, 6537 (void *)&cmd_addbonding_slave_slaveid, 6538 (void *)&cmd_addbonding_slave_port, 6539 NULL 6540 } 6541 }; 6542 6543 /* *** REMOVE SLAVE *** */ 6544 struct cmd_remove_bonding_slave_result { 6545 cmdline_fixed_string_t remove; 6546 cmdline_fixed_string_t bonding; 6547 cmdline_fixed_string_t slave; 6548 portid_t slave_id; 6549 portid_t port_id; 6550 }; 6551 6552 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 6553 __rte_unused struct cmdline *cl, 6554 __rte_unused void *data) 6555 { 6556 struct cmd_remove_bonding_slave_result *res = parsed_result; 6557 portid_t master_port_id = res->port_id; 6558 portid_t slave_port_id = res->slave_id; 6559 6560 /* remove the slave from a bonded device. */ 6561 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 6562 fprintf(stderr, 6563 "\t Failed to remove slave %d from master port = %d.\n", 6564 slave_port_id, master_port_id); 6565 return; 6566 } 6567 init_port_config(); 6568 clear_port_slave_flag(slave_port_id); 6569 } 6570 6571 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 6572 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6573 remove, "remove"); 6574 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 6575 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6576 bonding, "bonding"); 6577 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 6578 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6579 slave, "slave"); 6580 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 6581 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6582 slave_id, RTE_UINT16); 6583 cmdline_parse_token_num_t cmd_removebonding_slave_port = 6584 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6585 port_id, RTE_UINT16); 6586 6587 cmdline_parse_inst_t cmd_remove_bonding_slave = { 6588 .f = cmd_remove_bonding_slave_parsed, 6589 .help_str = "remove bonding slave <slave_id> <port_id>: " 6590 "Remove a slave device from a bonded device", 6591 .data = NULL, 6592 .tokens = { 6593 (void *)&cmd_removebonding_slave_remove, 6594 (void *)&cmd_removebonding_slave_bonding, 6595 (void *)&cmd_removebonding_slave_slave, 6596 (void *)&cmd_removebonding_slave_slaveid, 6597 (void *)&cmd_removebonding_slave_port, 6598 NULL 6599 } 6600 }; 6601 6602 /* *** CREATE BONDED DEVICE *** */ 6603 struct cmd_create_bonded_device_result { 6604 cmdline_fixed_string_t create; 6605 cmdline_fixed_string_t bonded; 6606 cmdline_fixed_string_t device; 6607 uint8_t mode; 6608 uint8_t socket; 6609 }; 6610 6611 static int bond_dev_num = 0; 6612 6613 static void cmd_create_bonded_device_parsed(void *parsed_result, 6614 __rte_unused struct cmdline *cl, 6615 __rte_unused void *data) 6616 { 6617 struct cmd_create_bonded_device_result *res = parsed_result; 6618 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 6619 int port_id; 6620 int ret; 6621 6622 if (test_done == 0) { 6623 fprintf(stderr, "Please stop forwarding first\n"); 6624 return; 6625 } 6626 6627 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 6628 bond_dev_num++); 6629 6630 /* Create a new bonded device. */ 6631 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 6632 if (port_id < 0) { 6633 fprintf(stderr, "\t Failed to create bonded device.\n"); 6634 return; 6635 } else { 6636 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 6637 port_id); 6638 6639 /* Update number of ports */ 6640 nb_ports = rte_eth_dev_count_avail(); 6641 reconfig(port_id, res->socket); 6642 ret = rte_eth_promiscuous_enable(port_id); 6643 if (ret != 0) 6644 fprintf(stderr, 6645 "Failed to enable promiscuous mode for port %u: %s - ignore\n", 6646 port_id, rte_strerror(-ret)); 6647 6648 ports[port_id].need_setup = 0; 6649 ports[port_id].port_status = RTE_PORT_STOPPED; 6650 } 6651 6652 } 6653 6654 cmdline_parse_token_string_t cmd_createbonded_device_create = 6655 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6656 create, "create"); 6657 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 6658 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6659 bonded, "bonded"); 6660 cmdline_parse_token_string_t cmd_createbonded_device_device = 6661 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6662 device, "device"); 6663 cmdline_parse_token_num_t cmd_createbonded_device_mode = 6664 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6665 mode, RTE_UINT8); 6666 cmdline_parse_token_num_t cmd_createbonded_device_socket = 6667 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6668 socket, RTE_UINT8); 6669 6670 cmdline_parse_inst_t cmd_create_bonded_device = { 6671 .f = cmd_create_bonded_device_parsed, 6672 .help_str = "create bonded device <mode> <socket>: " 6673 "Create a new bonded device with specific bonding mode and socket", 6674 .data = NULL, 6675 .tokens = { 6676 (void *)&cmd_createbonded_device_create, 6677 (void *)&cmd_createbonded_device_bonded, 6678 (void *)&cmd_createbonded_device_device, 6679 (void *)&cmd_createbonded_device_mode, 6680 (void *)&cmd_createbonded_device_socket, 6681 NULL 6682 } 6683 }; 6684 6685 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 6686 struct cmd_set_bond_mac_addr_result { 6687 cmdline_fixed_string_t set; 6688 cmdline_fixed_string_t bonding; 6689 cmdline_fixed_string_t mac_addr; 6690 uint16_t port_num; 6691 struct rte_ether_addr address; 6692 }; 6693 6694 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 6695 __rte_unused struct cmdline *cl, 6696 __rte_unused void *data) 6697 { 6698 struct cmd_set_bond_mac_addr_result *res = parsed_result; 6699 int ret; 6700 6701 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 6702 return; 6703 6704 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 6705 6706 /* check the return value and print it if is < 0 */ 6707 if (ret < 0) 6708 fprintf(stderr, "set_bond_mac_addr error: (%s)\n", 6709 strerror(-ret)); 6710 } 6711 6712 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 6713 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 6714 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 6715 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 6716 "bonding"); 6717 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 6718 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 6719 "mac_addr"); 6720 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 6721 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 6722 port_num, RTE_UINT16); 6723 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 6724 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 6725 6726 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 6727 .f = cmd_set_bond_mac_addr_parsed, 6728 .data = (void *) 0, 6729 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 6730 .tokens = { 6731 (void *)&cmd_set_bond_mac_addr_set, 6732 (void *)&cmd_set_bond_mac_addr_bonding, 6733 (void *)&cmd_set_bond_mac_addr_mac, 6734 (void *)&cmd_set_bond_mac_addr_portnum, 6735 (void *)&cmd_set_bond_mac_addr_addr, 6736 NULL 6737 } 6738 }; 6739 6740 6741 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 6742 struct cmd_set_bond_mon_period_result { 6743 cmdline_fixed_string_t set; 6744 cmdline_fixed_string_t bonding; 6745 cmdline_fixed_string_t mon_period; 6746 uint16_t port_num; 6747 uint32_t period_ms; 6748 }; 6749 6750 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 6751 __rte_unused struct cmdline *cl, 6752 __rte_unused void *data) 6753 { 6754 struct cmd_set_bond_mon_period_result *res = parsed_result; 6755 int ret; 6756 6757 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 6758 6759 /* check the return value and print it if is < 0 */ 6760 if (ret < 0) 6761 fprintf(stderr, "set_bond_mac_addr error: (%s)\n", 6762 strerror(-ret)); 6763 } 6764 6765 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 6766 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6767 set, "set"); 6768 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 6769 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6770 bonding, "bonding"); 6771 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 6772 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6773 mon_period, "mon_period"); 6774 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 6775 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6776 port_num, RTE_UINT16); 6777 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 6778 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6779 period_ms, RTE_UINT32); 6780 6781 cmdline_parse_inst_t cmd_set_bond_mon_period = { 6782 .f = cmd_set_bond_mon_period_parsed, 6783 .data = (void *) 0, 6784 .help_str = "set bonding mon_period <port_id> <period_ms>", 6785 .tokens = { 6786 (void *)&cmd_set_bond_mon_period_set, 6787 (void *)&cmd_set_bond_mon_period_bonding, 6788 (void *)&cmd_set_bond_mon_period_mon_period, 6789 (void *)&cmd_set_bond_mon_period_portnum, 6790 (void *)&cmd_set_bond_mon_period_period_ms, 6791 NULL 6792 } 6793 }; 6794 6795 6796 6797 struct cmd_set_bonding_agg_mode_policy_result { 6798 cmdline_fixed_string_t set; 6799 cmdline_fixed_string_t bonding; 6800 cmdline_fixed_string_t agg_mode; 6801 uint16_t port_num; 6802 cmdline_fixed_string_t policy; 6803 }; 6804 6805 6806 static void 6807 cmd_set_bonding_agg_mode(void *parsed_result, 6808 __rte_unused struct cmdline *cl, 6809 __rte_unused void *data) 6810 { 6811 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 6812 uint8_t policy = AGG_BANDWIDTH; 6813 6814 if (!strcmp(res->policy, "bandwidth")) 6815 policy = AGG_BANDWIDTH; 6816 else if (!strcmp(res->policy, "stable")) 6817 policy = AGG_STABLE; 6818 else if (!strcmp(res->policy, "count")) 6819 policy = AGG_COUNT; 6820 6821 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 6822 } 6823 6824 6825 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 6826 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6827 set, "set"); 6828 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 6829 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6830 bonding, "bonding"); 6831 6832 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 6833 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6834 agg_mode, "agg_mode"); 6835 6836 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 6837 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6838 port_num, RTE_UINT16); 6839 6840 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 6841 TOKEN_STRING_INITIALIZER( 6842 struct cmd_set_bonding_balance_xmit_policy_result, 6843 policy, "stable#bandwidth#count"); 6844 6845 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 6846 .f = cmd_set_bonding_agg_mode, 6847 .data = (void *) 0, 6848 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 6849 .tokens = { 6850 (void *)&cmd_set_bonding_agg_mode_set, 6851 (void *)&cmd_set_bonding_agg_mode_bonding, 6852 (void *)&cmd_set_bonding_agg_mode_agg_mode, 6853 (void *)&cmd_set_bonding_agg_mode_portnum, 6854 (void *)&cmd_set_bonding_agg_mode_policy_string, 6855 NULL 6856 } 6857 }; 6858 6859 6860 #endif /* RTE_NET_BOND */ 6861 6862 /* *** SET FORWARDING MODE *** */ 6863 struct cmd_set_fwd_mode_result { 6864 cmdline_fixed_string_t set; 6865 cmdline_fixed_string_t fwd; 6866 cmdline_fixed_string_t mode; 6867 }; 6868 6869 static void cmd_set_fwd_mode_parsed(void *parsed_result, 6870 __rte_unused struct cmdline *cl, 6871 __rte_unused void *data) 6872 { 6873 struct cmd_set_fwd_mode_result *res = parsed_result; 6874 6875 retry_enabled = 0; 6876 set_pkt_forwarding_mode(res->mode); 6877 } 6878 6879 cmdline_parse_token_string_t cmd_setfwd_set = 6880 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 6881 cmdline_parse_token_string_t cmd_setfwd_fwd = 6882 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 6883 cmdline_parse_token_string_t cmd_setfwd_mode = 6884 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 6885 "" /* defined at init */); 6886 6887 cmdline_parse_inst_t cmd_set_fwd_mode = { 6888 .f = cmd_set_fwd_mode_parsed, 6889 .data = NULL, 6890 .help_str = NULL, /* defined at init */ 6891 .tokens = { 6892 (void *)&cmd_setfwd_set, 6893 (void *)&cmd_setfwd_fwd, 6894 (void *)&cmd_setfwd_mode, 6895 NULL, 6896 }, 6897 }; 6898 6899 static void cmd_set_fwd_mode_init(void) 6900 { 6901 char *modes, *c; 6902 static char token[128]; 6903 static char help[256]; 6904 cmdline_parse_token_string_t *token_struct; 6905 6906 modes = list_pkt_forwarding_modes(); 6907 snprintf(help, sizeof(help), "set fwd %s: " 6908 "Set packet forwarding mode", modes); 6909 cmd_set_fwd_mode.help_str = help; 6910 6911 /* string token separator is # */ 6912 for (c = token; *modes != '\0'; modes++) 6913 if (*modes == '|') 6914 *c++ = '#'; 6915 else 6916 *c++ = *modes; 6917 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 6918 token_struct->string_data.str = token; 6919 } 6920 6921 /* *** SET RETRY FORWARDING MODE *** */ 6922 struct cmd_set_fwd_retry_mode_result { 6923 cmdline_fixed_string_t set; 6924 cmdline_fixed_string_t fwd; 6925 cmdline_fixed_string_t mode; 6926 cmdline_fixed_string_t retry; 6927 }; 6928 6929 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 6930 __rte_unused struct cmdline *cl, 6931 __rte_unused void *data) 6932 { 6933 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 6934 6935 retry_enabled = 1; 6936 set_pkt_forwarding_mode(res->mode); 6937 } 6938 6939 cmdline_parse_token_string_t cmd_setfwd_retry_set = 6940 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6941 set, "set"); 6942 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 6943 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6944 fwd, "fwd"); 6945 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 6946 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6947 mode, 6948 "" /* defined at init */); 6949 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 6950 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6951 retry, "retry"); 6952 6953 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 6954 .f = cmd_set_fwd_retry_mode_parsed, 6955 .data = NULL, 6956 .help_str = NULL, /* defined at init */ 6957 .tokens = { 6958 (void *)&cmd_setfwd_retry_set, 6959 (void *)&cmd_setfwd_retry_fwd, 6960 (void *)&cmd_setfwd_retry_mode, 6961 (void *)&cmd_setfwd_retry_retry, 6962 NULL, 6963 }, 6964 }; 6965 6966 static void cmd_set_fwd_retry_mode_init(void) 6967 { 6968 char *modes, *c; 6969 static char token[128]; 6970 static char help[256]; 6971 cmdline_parse_token_string_t *token_struct; 6972 6973 modes = list_pkt_forwarding_retry_modes(); 6974 snprintf(help, sizeof(help), "set fwd %s retry: " 6975 "Set packet forwarding mode with retry", modes); 6976 cmd_set_fwd_retry_mode.help_str = help; 6977 6978 /* string token separator is # */ 6979 for (c = token; *modes != '\0'; modes++) 6980 if (*modes == '|') 6981 *c++ = '#'; 6982 else 6983 *c++ = *modes; 6984 token_struct = (cmdline_parse_token_string_t *) 6985 cmd_set_fwd_retry_mode.tokens[2]; 6986 token_struct->string_data.str = token; 6987 } 6988 6989 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 6990 struct cmd_set_burst_tx_retry_result { 6991 cmdline_fixed_string_t set; 6992 cmdline_fixed_string_t burst; 6993 cmdline_fixed_string_t tx; 6994 cmdline_fixed_string_t delay; 6995 uint32_t time; 6996 cmdline_fixed_string_t retry; 6997 uint32_t retry_num; 6998 }; 6999 7000 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 7001 __rte_unused struct cmdline *cl, 7002 __rte_unused void *data) 7003 { 7004 struct cmd_set_burst_tx_retry_result *res = parsed_result; 7005 7006 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 7007 && !strcmp(res->tx, "tx")) { 7008 if (!strcmp(res->delay, "delay")) 7009 burst_tx_delay_time = res->time; 7010 if (!strcmp(res->retry, "retry")) 7011 burst_tx_retry_num = res->retry_num; 7012 } 7013 7014 } 7015 7016 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 7017 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 7018 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 7019 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 7020 "burst"); 7021 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 7022 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 7023 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 7024 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 7025 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 7026 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, 7027 RTE_UINT32); 7028 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 7029 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 7030 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 7031 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, 7032 RTE_UINT32); 7033 7034 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 7035 .f = cmd_set_burst_tx_retry_parsed, 7036 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 7037 .tokens = { 7038 (void *)&cmd_set_burst_tx_retry_set, 7039 (void *)&cmd_set_burst_tx_retry_burst, 7040 (void *)&cmd_set_burst_tx_retry_tx, 7041 (void *)&cmd_set_burst_tx_retry_delay, 7042 (void *)&cmd_set_burst_tx_retry_time, 7043 (void *)&cmd_set_burst_tx_retry_retry, 7044 (void *)&cmd_set_burst_tx_retry_retry_num, 7045 NULL, 7046 }, 7047 }; 7048 7049 /* *** SET PROMISC MODE *** */ 7050 struct cmd_set_promisc_mode_result { 7051 cmdline_fixed_string_t set; 7052 cmdline_fixed_string_t promisc; 7053 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 7054 uint16_t port_num; /* valid if "allports" argument == 0 */ 7055 cmdline_fixed_string_t mode; 7056 }; 7057 7058 static void cmd_set_promisc_mode_parsed(void *parsed_result, 7059 __rte_unused struct cmdline *cl, 7060 void *allports) 7061 { 7062 struct cmd_set_promisc_mode_result *res = parsed_result; 7063 int enable; 7064 portid_t i; 7065 7066 if (!strcmp(res->mode, "on")) 7067 enable = 1; 7068 else 7069 enable = 0; 7070 7071 /* all ports */ 7072 if (allports) { 7073 RTE_ETH_FOREACH_DEV(i) 7074 eth_set_promisc_mode(i, enable); 7075 } else { 7076 eth_set_promisc_mode(res->port_num, enable); 7077 } 7078 } 7079 7080 cmdline_parse_token_string_t cmd_setpromisc_set = 7081 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 7082 cmdline_parse_token_string_t cmd_setpromisc_promisc = 7083 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 7084 "promisc"); 7085 cmdline_parse_token_string_t cmd_setpromisc_portall = 7086 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 7087 "all"); 7088 cmdline_parse_token_num_t cmd_setpromisc_portnum = 7089 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 7090 RTE_UINT16); 7091 cmdline_parse_token_string_t cmd_setpromisc_mode = 7092 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 7093 "on#off"); 7094 7095 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 7096 .f = cmd_set_promisc_mode_parsed, 7097 .data = (void *)1, 7098 .help_str = "set promisc all on|off: Set promisc mode for all ports", 7099 .tokens = { 7100 (void *)&cmd_setpromisc_set, 7101 (void *)&cmd_setpromisc_promisc, 7102 (void *)&cmd_setpromisc_portall, 7103 (void *)&cmd_setpromisc_mode, 7104 NULL, 7105 }, 7106 }; 7107 7108 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 7109 .f = cmd_set_promisc_mode_parsed, 7110 .data = (void *)0, 7111 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 7112 .tokens = { 7113 (void *)&cmd_setpromisc_set, 7114 (void *)&cmd_setpromisc_promisc, 7115 (void *)&cmd_setpromisc_portnum, 7116 (void *)&cmd_setpromisc_mode, 7117 NULL, 7118 }, 7119 }; 7120 7121 /* *** SET ALLMULTI MODE *** */ 7122 struct cmd_set_allmulti_mode_result { 7123 cmdline_fixed_string_t set; 7124 cmdline_fixed_string_t allmulti; 7125 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 7126 uint16_t port_num; /* valid if "allports" argument == 0 */ 7127 cmdline_fixed_string_t mode; 7128 }; 7129 7130 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 7131 __rte_unused struct cmdline *cl, 7132 void *allports) 7133 { 7134 struct cmd_set_allmulti_mode_result *res = parsed_result; 7135 int enable; 7136 portid_t i; 7137 7138 if (!strcmp(res->mode, "on")) 7139 enable = 1; 7140 else 7141 enable = 0; 7142 7143 /* all ports */ 7144 if (allports) { 7145 RTE_ETH_FOREACH_DEV(i) { 7146 eth_set_allmulticast_mode(i, enable); 7147 } 7148 } 7149 else { 7150 eth_set_allmulticast_mode(res->port_num, enable); 7151 } 7152 } 7153 7154 cmdline_parse_token_string_t cmd_setallmulti_set = 7155 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 7156 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 7157 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 7158 "allmulti"); 7159 cmdline_parse_token_string_t cmd_setallmulti_portall = 7160 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 7161 "all"); 7162 cmdline_parse_token_num_t cmd_setallmulti_portnum = 7163 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 7164 RTE_UINT16); 7165 cmdline_parse_token_string_t cmd_setallmulti_mode = 7166 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 7167 "on#off"); 7168 7169 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 7170 .f = cmd_set_allmulti_mode_parsed, 7171 .data = (void *)1, 7172 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 7173 .tokens = { 7174 (void *)&cmd_setallmulti_set, 7175 (void *)&cmd_setallmulti_allmulti, 7176 (void *)&cmd_setallmulti_portall, 7177 (void *)&cmd_setallmulti_mode, 7178 NULL, 7179 }, 7180 }; 7181 7182 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 7183 .f = cmd_set_allmulti_mode_parsed, 7184 .data = (void *)0, 7185 .help_str = "set allmulti <port_id> on|off: " 7186 "Set allmulti mode on port_id", 7187 .tokens = { 7188 (void *)&cmd_setallmulti_set, 7189 (void *)&cmd_setallmulti_allmulti, 7190 (void *)&cmd_setallmulti_portnum, 7191 (void *)&cmd_setallmulti_mode, 7192 NULL, 7193 }, 7194 }; 7195 7196 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */ 7197 struct cmd_link_flow_ctrl_show { 7198 cmdline_fixed_string_t show; 7199 cmdline_fixed_string_t port; 7200 portid_t port_id; 7201 cmdline_fixed_string_t flow_ctrl; 7202 }; 7203 7204 cmdline_parse_token_string_t cmd_lfc_show_show = 7205 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, 7206 show, "show"); 7207 cmdline_parse_token_string_t cmd_lfc_show_port = 7208 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, 7209 port, "port"); 7210 cmdline_parse_token_num_t cmd_lfc_show_portid = 7211 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show, 7212 port_id, RTE_UINT16); 7213 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl = 7214 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, 7215 flow_ctrl, "flow_ctrl"); 7216 7217 static void 7218 cmd_link_flow_ctrl_show_parsed(void *parsed_result, 7219 __rte_unused struct cmdline *cl, 7220 __rte_unused void *data) 7221 { 7222 struct cmd_link_flow_ctrl_show *res = parsed_result; 7223 static const char *info_border = "*********************"; 7224 struct rte_eth_fc_conf fc_conf; 7225 bool rx_fc_en = false; 7226 bool tx_fc_en = false; 7227 int ret; 7228 7229 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 7230 if (ret != 0) { 7231 fprintf(stderr, 7232 "Failed to get current flow ctrl information: err = %d\n", 7233 ret); 7234 return; 7235 } 7236 7237 if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL) 7238 rx_fc_en = true; 7239 if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL) 7240 tx_fc_en = true; 7241 7242 printf("\n%s Flow control infos for port %-2d %s\n", 7243 info_border, res->port_id, info_border); 7244 printf("FC mode:\n"); 7245 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off"); 7246 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off"); 7247 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off"); 7248 printf("Pause time: 0x%x\n", fc_conf.pause_time); 7249 printf("High waterline: 0x%x\n", fc_conf.high_water); 7250 printf("Low waterline: 0x%x\n", fc_conf.low_water); 7251 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off"); 7252 printf("Forward MAC control frames: %s\n", 7253 fc_conf.mac_ctrl_frame_fwd ? "on" : "off"); 7254 printf("\n%s************** End ***********%s\n", 7255 info_border, info_border); 7256 } 7257 7258 cmdline_parse_inst_t cmd_link_flow_control_show = { 7259 .f = cmd_link_flow_ctrl_show_parsed, 7260 .data = NULL, 7261 .help_str = "show port <port_id> flow_ctrl", 7262 .tokens = { 7263 (void *)&cmd_lfc_show_show, 7264 (void *)&cmd_lfc_show_port, 7265 (void *)&cmd_lfc_show_portid, 7266 (void *)&cmd_lfc_show_flow_ctrl, 7267 NULL, 7268 }, 7269 }; 7270 7271 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 7272 struct cmd_link_flow_ctrl_set_result { 7273 cmdline_fixed_string_t set; 7274 cmdline_fixed_string_t flow_ctrl; 7275 cmdline_fixed_string_t rx; 7276 cmdline_fixed_string_t rx_lfc_mode; 7277 cmdline_fixed_string_t tx; 7278 cmdline_fixed_string_t tx_lfc_mode; 7279 cmdline_fixed_string_t mac_ctrl_frame_fwd; 7280 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 7281 cmdline_fixed_string_t autoneg_str; 7282 cmdline_fixed_string_t autoneg; 7283 cmdline_fixed_string_t hw_str; 7284 uint32_t high_water; 7285 cmdline_fixed_string_t lw_str; 7286 uint32_t low_water; 7287 cmdline_fixed_string_t pt_str; 7288 uint16_t pause_time; 7289 cmdline_fixed_string_t xon_str; 7290 uint16_t send_xon; 7291 portid_t port_id; 7292 }; 7293 7294 cmdline_parse_token_string_t cmd_lfc_set_set = 7295 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7296 set, "set"); 7297 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 7298 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7299 flow_ctrl, "flow_ctrl"); 7300 cmdline_parse_token_string_t cmd_lfc_set_rx = 7301 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7302 rx, "rx"); 7303 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 7304 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7305 rx_lfc_mode, "on#off"); 7306 cmdline_parse_token_string_t cmd_lfc_set_tx = 7307 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7308 tx, "tx"); 7309 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 7310 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7311 tx_lfc_mode, "on#off"); 7312 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 7313 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7314 hw_str, "high_water"); 7315 cmdline_parse_token_num_t cmd_lfc_set_high_water = 7316 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7317 high_water, RTE_UINT32); 7318 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 7319 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7320 lw_str, "low_water"); 7321 cmdline_parse_token_num_t cmd_lfc_set_low_water = 7322 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7323 low_water, RTE_UINT32); 7324 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 7325 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7326 pt_str, "pause_time"); 7327 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 7328 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7329 pause_time, RTE_UINT16); 7330 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 7331 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7332 xon_str, "send_xon"); 7333 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 7334 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7335 send_xon, RTE_UINT16); 7336 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 7337 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7338 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 7339 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 7340 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7341 mac_ctrl_frame_fwd_mode, "on#off"); 7342 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 7343 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7344 autoneg_str, "autoneg"); 7345 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 7346 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7347 autoneg, "on#off"); 7348 cmdline_parse_token_num_t cmd_lfc_set_portid = 7349 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7350 port_id, RTE_UINT16); 7351 7352 /* forward declaration */ 7353 static void 7354 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 7355 void *data); 7356 7357 cmdline_parse_inst_t cmd_link_flow_control_set = { 7358 .f = cmd_link_flow_ctrl_set_parsed, 7359 .data = NULL, 7360 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 7361 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 7362 "autoneg on|off <port_id>: Configure the Ethernet flow control", 7363 .tokens = { 7364 (void *)&cmd_lfc_set_set, 7365 (void *)&cmd_lfc_set_flow_ctrl, 7366 (void *)&cmd_lfc_set_rx, 7367 (void *)&cmd_lfc_set_rx_mode, 7368 (void *)&cmd_lfc_set_tx, 7369 (void *)&cmd_lfc_set_tx_mode, 7370 (void *)&cmd_lfc_set_high_water, 7371 (void *)&cmd_lfc_set_low_water, 7372 (void *)&cmd_lfc_set_pause_time, 7373 (void *)&cmd_lfc_set_send_xon, 7374 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 7375 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 7376 (void *)&cmd_lfc_set_autoneg_str, 7377 (void *)&cmd_lfc_set_autoneg, 7378 (void *)&cmd_lfc_set_portid, 7379 NULL, 7380 }, 7381 }; 7382 7383 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 7384 .f = cmd_link_flow_ctrl_set_parsed, 7385 .data = (void *)&cmd_link_flow_control_set_rx, 7386 .help_str = "set flow_ctrl rx on|off <port_id>: " 7387 "Change rx flow control parameter", 7388 .tokens = { 7389 (void *)&cmd_lfc_set_set, 7390 (void *)&cmd_lfc_set_flow_ctrl, 7391 (void *)&cmd_lfc_set_rx, 7392 (void *)&cmd_lfc_set_rx_mode, 7393 (void *)&cmd_lfc_set_portid, 7394 NULL, 7395 }, 7396 }; 7397 7398 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 7399 .f = cmd_link_flow_ctrl_set_parsed, 7400 .data = (void *)&cmd_link_flow_control_set_tx, 7401 .help_str = "set flow_ctrl tx on|off <port_id>: " 7402 "Change tx flow control parameter", 7403 .tokens = { 7404 (void *)&cmd_lfc_set_set, 7405 (void *)&cmd_lfc_set_flow_ctrl, 7406 (void *)&cmd_lfc_set_tx, 7407 (void *)&cmd_lfc_set_tx_mode, 7408 (void *)&cmd_lfc_set_portid, 7409 NULL, 7410 }, 7411 }; 7412 7413 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 7414 .f = cmd_link_flow_ctrl_set_parsed, 7415 .data = (void *)&cmd_link_flow_control_set_hw, 7416 .help_str = "set flow_ctrl high_water <value> <port_id>: " 7417 "Change high water flow control parameter", 7418 .tokens = { 7419 (void *)&cmd_lfc_set_set, 7420 (void *)&cmd_lfc_set_flow_ctrl, 7421 (void *)&cmd_lfc_set_high_water_str, 7422 (void *)&cmd_lfc_set_high_water, 7423 (void *)&cmd_lfc_set_portid, 7424 NULL, 7425 }, 7426 }; 7427 7428 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 7429 .f = cmd_link_flow_ctrl_set_parsed, 7430 .data = (void *)&cmd_link_flow_control_set_lw, 7431 .help_str = "set flow_ctrl low_water <value> <port_id>: " 7432 "Change low water flow control parameter", 7433 .tokens = { 7434 (void *)&cmd_lfc_set_set, 7435 (void *)&cmd_lfc_set_flow_ctrl, 7436 (void *)&cmd_lfc_set_low_water_str, 7437 (void *)&cmd_lfc_set_low_water, 7438 (void *)&cmd_lfc_set_portid, 7439 NULL, 7440 }, 7441 }; 7442 7443 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 7444 .f = cmd_link_flow_ctrl_set_parsed, 7445 .data = (void *)&cmd_link_flow_control_set_pt, 7446 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 7447 "Change pause time flow control parameter", 7448 .tokens = { 7449 (void *)&cmd_lfc_set_set, 7450 (void *)&cmd_lfc_set_flow_ctrl, 7451 (void *)&cmd_lfc_set_pause_time_str, 7452 (void *)&cmd_lfc_set_pause_time, 7453 (void *)&cmd_lfc_set_portid, 7454 NULL, 7455 }, 7456 }; 7457 7458 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 7459 .f = cmd_link_flow_ctrl_set_parsed, 7460 .data = (void *)&cmd_link_flow_control_set_xon, 7461 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 7462 "Change send_xon flow control parameter", 7463 .tokens = { 7464 (void *)&cmd_lfc_set_set, 7465 (void *)&cmd_lfc_set_flow_ctrl, 7466 (void *)&cmd_lfc_set_send_xon_str, 7467 (void *)&cmd_lfc_set_send_xon, 7468 (void *)&cmd_lfc_set_portid, 7469 NULL, 7470 }, 7471 }; 7472 7473 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 7474 .f = cmd_link_flow_ctrl_set_parsed, 7475 .data = (void *)&cmd_link_flow_control_set_macfwd, 7476 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 7477 "Change mac ctrl fwd flow control parameter", 7478 .tokens = { 7479 (void *)&cmd_lfc_set_set, 7480 (void *)&cmd_lfc_set_flow_ctrl, 7481 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 7482 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 7483 (void *)&cmd_lfc_set_portid, 7484 NULL, 7485 }, 7486 }; 7487 7488 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 7489 .f = cmd_link_flow_ctrl_set_parsed, 7490 .data = (void *)&cmd_link_flow_control_set_autoneg, 7491 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 7492 "Change autoneg flow control parameter", 7493 .tokens = { 7494 (void *)&cmd_lfc_set_set, 7495 (void *)&cmd_lfc_set_flow_ctrl, 7496 (void *)&cmd_lfc_set_autoneg_str, 7497 (void *)&cmd_lfc_set_autoneg, 7498 (void *)&cmd_lfc_set_portid, 7499 NULL, 7500 }, 7501 }; 7502 7503 static void 7504 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 7505 __rte_unused struct cmdline *cl, 7506 void *data) 7507 { 7508 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 7509 cmdline_parse_inst_t *cmd = data; 7510 struct rte_eth_fc_conf fc_conf; 7511 int rx_fc_en = 0; 7512 int tx_fc_en = 0; 7513 int ret; 7514 7515 /* 7516 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 7517 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 7518 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 7519 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 7520 */ 7521 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 7522 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 7523 }; 7524 7525 /* Partial command line, retrieve current configuration */ 7526 if (cmd) { 7527 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 7528 if (ret != 0) { 7529 fprintf(stderr, 7530 "cannot get current flow ctrl parameters, return code = %d\n", 7531 ret); 7532 return; 7533 } 7534 7535 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 7536 (fc_conf.mode == RTE_FC_FULL)) 7537 rx_fc_en = 1; 7538 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 7539 (fc_conf.mode == RTE_FC_FULL)) 7540 tx_fc_en = 1; 7541 } 7542 7543 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 7544 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 7545 7546 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 7547 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 7548 7549 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 7550 7551 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 7552 fc_conf.high_water = res->high_water; 7553 7554 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 7555 fc_conf.low_water = res->low_water; 7556 7557 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 7558 fc_conf.pause_time = res->pause_time; 7559 7560 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 7561 fc_conf.send_xon = res->send_xon; 7562 7563 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 7564 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 7565 fc_conf.mac_ctrl_frame_fwd = 1; 7566 else 7567 fc_conf.mac_ctrl_frame_fwd = 0; 7568 } 7569 7570 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 7571 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 7572 7573 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 7574 if (ret != 0) 7575 fprintf(stderr, 7576 "bad flow control parameter, return code = %d\n", 7577 ret); 7578 } 7579 7580 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 7581 struct cmd_priority_flow_ctrl_set_result { 7582 cmdline_fixed_string_t set; 7583 cmdline_fixed_string_t pfc_ctrl; 7584 cmdline_fixed_string_t rx; 7585 cmdline_fixed_string_t rx_pfc_mode; 7586 cmdline_fixed_string_t tx; 7587 cmdline_fixed_string_t tx_pfc_mode; 7588 uint32_t high_water; 7589 uint32_t low_water; 7590 uint16_t pause_time; 7591 uint8_t priority; 7592 portid_t port_id; 7593 }; 7594 7595 static void 7596 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 7597 __rte_unused struct cmdline *cl, 7598 __rte_unused void *data) 7599 { 7600 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 7601 struct rte_eth_pfc_conf pfc_conf; 7602 int rx_fc_enable, tx_fc_enable; 7603 int ret; 7604 7605 /* 7606 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 7607 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 7608 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 7609 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 7610 */ 7611 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 7612 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 7613 }; 7614 7615 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf)); 7616 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 7617 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 7618 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 7619 pfc_conf.fc.high_water = res->high_water; 7620 pfc_conf.fc.low_water = res->low_water; 7621 pfc_conf.fc.pause_time = res->pause_time; 7622 pfc_conf.priority = res->priority; 7623 7624 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 7625 if (ret != 0) 7626 fprintf(stderr, 7627 "bad priority flow control parameter, return code = %d\n", 7628 ret); 7629 } 7630 7631 cmdline_parse_token_string_t cmd_pfc_set_set = 7632 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7633 set, "set"); 7634 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 7635 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7636 pfc_ctrl, "pfc_ctrl"); 7637 cmdline_parse_token_string_t cmd_pfc_set_rx = 7638 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7639 rx, "rx"); 7640 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 7641 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7642 rx_pfc_mode, "on#off"); 7643 cmdline_parse_token_string_t cmd_pfc_set_tx = 7644 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7645 tx, "tx"); 7646 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 7647 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7648 tx_pfc_mode, "on#off"); 7649 cmdline_parse_token_num_t cmd_pfc_set_high_water = 7650 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7651 high_water, RTE_UINT32); 7652 cmdline_parse_token_num_t cmd_pfc_set_low_water = 7653 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7654 low_water, RTE_UINT32); 7655 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 7656 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7657 pause_time, RTE_UINT16); 7658 cmdline_parse_token_num_t cmd_pfc_set_priority = 7659 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7660 priority, RTE_UINT8); 7661 cmdline_parse_token_num_t cmd_pfc_set_portid = 7662 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7663 port_id, RTE_UINT16); 7664 7665 cmdline_parse_inst_t cmd_priority_flow_control_set = { 7666 .f = cmd_priority_flow_ctrl_set_parsed, 7667 .data = NULL, 7668 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 7669 "<pause_time> <priority> <port_id>: " 7670 "Configure the Ethernet priority flow control", 7671 .tokens = { 7672 (void *)&cmd_pfc_set_set, 7673 (void *)&cmd_pfc_set_flow_ctrl, 7674 (void *)&cmd_pfc_set_rx, 7675 (void *)&cmd_pfc_set_rx_mode, 7676 (void *)&cmd_pfc_set_tx, 7677 (void *)&cmd_pfc_set_tx_mode, 7678 (void *)&cmd_pfc_set_high_water, 7679 (void *)&cmd_pfc_set_low_water, 7680 (void *)&cmd_pfc_set_pause_time, 7681 (void *)&cmd_pfc_set_priority, 7682 (void *)&cmd_pfc_set_portid, 7683 NULL, 7684 }, 7685 }; 7686 7687 /* *** RESET CONFIGURATION *** */ 7688 struct cmd_reset_result { 7689 cmdline_fixed_string_t reset; 7690 cmdline_fixed_string_t def; 7691 }; 7692 7693 static void cmd_reset_parsed(__rte_unused void *parsed_result, 7694 struct cmdline *cl, 7695 __rte_unused void *data) 7696 { 7697 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 7698 set_def_fwd_config(); 7699 } 7700 7701 cmdline_parse_token_string_t cmd_reset_set = 7702 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 7703 cmdline_parse_token_string_t cmd_reset_def = 7704 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 7705 "default"); 7706 7707 cmdline_parse_inst_t cmd_reset = { 7708 .f = cmd_reset_parsed, 7709 .data = NULL, 7710 .help_str = "set default: Reset default forwarding configuration", 7711 .tokens = { 7712 (void *)&cmd_reset_set, 7713 (void *)&cmd_reset_def, 7714 NULL, 7715 }, 7716 }; 7717 7718 /* *** START FORWARDING *** */ 7719 struct cmd_start_result { 7720 cmdline_fixed_string_t start; 7721 }; 7722 7723 cmdline_parse_token_string_t cmd_start_start = 7724 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 7725 7726 static void cmd_start_parsed(__rte_unused void *parsed_result, 7727 __rte_unused struct cmdline *cl, 7728 __rte_unused void *data) 7729 { 7730 start_packet_forwarding(0); 7731 } 7732 7733 cmdline_parse_inst_t cmd_start = { 7734 .f = cmd_start_parsed, 7735 .data = NULL, 7736 .help_str = "start: Start packet forwarding", 7737 .tokens = { 7738 (void *)&cmd_start_start, 7739 NULL, 7740 }, 7741 }; 7742 7743 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 7744 struct cmd_start_tx_first_result { 7745 cmdline_fixed_string_t start; 7746 cmdline_fixed_string_t tx_first; 7747 }; 7748 7749 static void 7750 cmd_start_tx_first_parsed(__rte_unused void *parsed_result, 7751 __rte_unused struct cmdline *cl, 7752 __rte_unused void *data) 7753 { 7754 start_packet_forwarding(1); 7755 } 7756 7757 cmdline_parse_token_string_t cmd_start_tx_first_start = 7758 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 7759 "start"); 7760 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 7761 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 7762 tx_first, "tx_first"); 7763 7764 cmdline_parse_inst_t cmd_start_tx_first = { 7765 .f = cmd_start_tx_first_parsed, 7766 .data = NULL, 7767 .help_str = "start tx_first: Start packet forwarding, " 7768 "after sending 1 burst of packets", 7769 .tokens = { 7770 (void *)&cmd_start_tx_first_start, 7771 (void *)&cmd_start_tx_first_tx_first, 7772 NULL, 7773 }, 7774 }; 7775 7776 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 7777 struct cmd_start_tx_first_n_result { 7778 cmdline_fixed_string_t start; 7779 cmdline_fixed_string_t tx_first; 7780 uint32_t tx_num; 7781 }; 7782 7783 static void 7784 cmd_start_tx_first_n_parsed(void *parsed_result, 7785 __rte_unused struct cmdline *cl, 7786 __rte_unused void *data) 7787 { 7788 struct cmd_start_tx_first_n_result *res = parsed_result; 7789 7790 start_packet_forwarding(res->tx_num); 7791 } 7792 7793 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 7794 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7795 start, "start"); 7796 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 7797 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7798 tx_first, "tx_first"); 7799 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 7800 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 7801 tx_num, RTE_UINT32); 7802 7803 cmdline_parse_inst_t cmd_start_tx_first_n = { 7804 .f = cmd_start_tx_first_n_parsed, 7805 .data = NULL, 7806 .help_str = "start tx_first <num>: " 7807 "packet forwarding, after sending <num> bursts of packets", 7808 .tokens = { 7809 (void *)&cmd_start_tx_first_n_start, 7810 (void *)&cmd_start_tx_first_n_tx_first, 7811 (void *)&cmd_start_tx_first_n_tx_num, 7812 NULL, 7813 }, 7814 }; 7815 7816 /* *** SET LINK UP *** */ 7817 struct cmd_set_link_up_result { 7818 cmdline_fixed_string_t set; 7819 cmdline_fixed_string_t link_up; 7820 cmdline_fixed_string_t port; 7821 portid_t port_id; 7822 }; 7823 7824 cmdline_parse_token_string_t cmd_set_link_up_set = 7825 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 7826 cmdline_parse_token_string_t cmd_set_link_up_link_up = 7827 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 7828 "link-up"); 7829 cmdline_parse_token_string_t cmd_set_link_up_port = 7830 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 7831 cmdline_parse_token_num_t cmd_set_link_up_port_id = 7832 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, 7833 RTE_UINT16); 7834 7835 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result, 7836 __rte_unused struct cmdline *cl, 7837 __rte_unused void *data) 7838 { 7839 struct cmd_set_link_up_result *res = parsed_result; 7840 dev_set_link_up(res->port_id); 7841 } 7842 7843 cmdline_parse_inst_t cmd_set_link_up = { 7844 .f = cmd_set_link_up_parsed, 7845 .data = NULL, 7846 .help_str = "set link-up port <port id>", 7847 .tokens = { 7848 (void *)&cmd_set_link_up_set, 7849 (void *)&cmd_set_link_up_link_up, 7850 (void *)&cmd_set_link_up_port, 7851 (void *)&cmd_set_link_up_port_id, 7852 NULL, 7853 }, 7854 }; 7855 7856 /* *** SET LINK DOWN *** */ 7857 struct cmd_set_link_down_result { 7858 cmdline_fixed_string_t set; 7859 cmdline_fixed_string_t link_down; 7860 cmdline_fixed_string_t port; 7861 portid_t port_id; 7862 }; 7863 7864 cmdline_parse_token_string_t cmd_set_link_down_set = 7865 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 7866 cmdline_parse_token_string_t cmd_set_link_down_link_down = 7867 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 7868 "link-down"); 7869 cmdline_parse_token_string_t cmd_set_link_down_port = 7870 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 7871 cmdline_parse_token_num_t cmd_set_link_down_port_id = 7872 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, 7873 RTE_UINT16); 7874 7875 static void cmd_set_link_down_parsed( 7876 __rte_unused void *parsed_result, 7877 __rte_unused struct cmdline *cl, 7878 __rte_unused void *data) 7879 { 7880 struct cmd_set_link_down_result *res = parsed_result; 7881 dev_set_link_down(res->port_id); 7882 } 7883 7884 cmdline_parse_inst_t cmd_set_link_down = { 7885 .f = cmd_set_link_down_parsed, 7886 .data = NULL, 7887 .help_str = "set link-down port <port id>", 7888 .tokens = { 7889 (void *)&cmd_set_link_down_set, 7890 (void *)&cmd_set_link_down_link_down, 7891 (void *)&cmd_set_link_down_port, 7892 (void *)&cmd_set_link_down_port_id, 7893 NULL, 7894 }, 7895 }; 7896 7897 /* *** SHOW CFG *** */ 7898 struct cmd_showcfg_result { 7899 cmdline_fixed_string_t show; 7900 cmdline_fixed_string_t cfg; 7901 cmdline_fixed_string_t what; 7902 }; 7903 7904 static void cmd_showcfg_parsed(void *parsed_result, 7905 __rte_unused struct cmdline *cl, 7906 __rte_unused void *data) 7907 { 7908 struct cmd_showcfg_result *res = parsed_result; 7909 if (!strcmp(res->what, "rxtx")) 7910 rxtx_config_display(); 7911 else if (!strcmp(res->what, "cores")) 7912 fwd_lcores_config_display(); 7913 else if (!strcmp(res->what, "fwd")) 7914 pkt_fwd_config_display(&cur_fwd_config); 7915 else if (!strcmp(res->what, "rxoffs")) 7916 show_rx_pkt_offsets(); 7917 else if (!strcmp(res->what, "rxpkts")) 7918 show_rx_pkt_segments(); 7919 else if (!strcmp(res->what, "txpkts")) 7920 show_tx_pkt_segments(); 7921 else if (!strcmp(res->what, "txtimes")) 7922 show_tx_pkt_times(); 7923 } 7924 7925 cmdline_parse_token_string_t cmd_showcfg_show = 7926 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 7927 cmdline_parse_token_string_t cmd_showcfg_port = 7928 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7929 cmdline_parse_token_string_t cmd_showcfg_what = 7930 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7931 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes"); 7932 7933 cmdline_parse_inst_t cmd_showcfg = { 7934 .f = cmd_showcfg_parsed, 7935 .data = NULL, 7936 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes", 7937 .tokens = { 7938 (void *)&cmd_showcfg_show, 7939 (void *)&cmd_showcfg_port, 7940 (void *)&cmd_showcfg_what, 7941 NULL, 7942 }, 7943 }; 7944 7945 /* *** SHOW ALL PORT INFO *** */ 7946 struct cmd_showportall_result { 7947 cmdline_fixed_string_t show; 7948 cmdline_fixed_string_t port; 7949 cmdline_fixed_string_t what; 7950 cmdline_fixed_string_t all; 7951 }; 7952 7953 static void cmd_showportall_parsed(void *parsed_result, 7954 __rte_unused struct cmdline *cl, 7955 __rte_unused void *data) 7956 { 7957 portid_t i; 7958 7959 struct cmd_showportall_result *res = parsed_result; 7960 if (!strcmp(res->show, "clear")) { 7961 if (!strcmp(res->what, "stats")) 7962 RTE_ETH_FOREACH_DEV(i) 7963 nic_stats_clear(i); 7964 else if (!strcmp(res->what, "xstats")) 7965 RTE_ETH_FOREACH_DEV(i) 7966 nic_xstats_clear(i); 7967 } else if (!strcmp(res->what, "info")) 7968 RTE_ETH_FOREACH_DEV(i) 7969 port_infos_display(i); 7970 else if (!strcmp(res->what, "summary")) { 7971 port_summary_header_display(); 7972 RTE_ETH_FOREACH_DEV(i) 7973 port_summary_display(i); 7974 } 7975 else if (!strcmp(res->what, "stats")) 7976 RTE_ETH_FOREACH_DEV(i) 7977 nic_stats_display(i); 7978 else if (!strcmp(res->what, "xstats")) 7979 RTE_ETH_FOREACH_DEV(i) 7980 nic_xstats_display(i); 7981 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) 7982 else if (!strcmp(res->what, "fdir")) 7983 RTE_ETH_FOREACH_DEV(i) 7984 fdir_get_infos(i); 7985 #endif 7986 else if (!strcmp(res->what, "dcb_tc")) 7987 RTE_ETH_FOREACH_DEV(i) 7988 port_dcb_info_display(i); 7989 } 7990 7991 cmdline_parse_token_string_t cmd_showportall_show = 7992 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7993 "show#clear"); 7994 cmdline_parse_token_string_t cmd_showportall_port = 7995 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7996 cmdline_parse_token_string_t cmd_showportall_what = 7997 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7998 "info#summary#stats#xstats#fdir#dcb_tc"); 7999 cmdline_parse_token_string_t cmd_showportall_all = 8000 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 8001 cmdline_parse_inst_t cmd_showportall = { 8002 .f = cmd_showportall_parsed, 8003 .data = NULL, 8004 .help_str = "show|clear port " 8005 "info|summary|stats|xstats|fdir|dcb_tc all", 8006 .tokens = { 8007 (void *)&cmd_showportall_show, 8008 (void *)&cmd_showportall_port, 8009 (void *)&cmd_showportall_what, 8010 (void *)&cmd_showportall_all, 8011 NULL, 8012 }, 8013 }; 8014 8015 /* *** SHOW PORT INFO *** */ 8016 struct cmd_showport_result { 8017 cmdline_fixed_string_t show; 8018 cmdline_fixed_string_t port; 8019 cmdline_fixed_string_t what; 8020 uint16_t portnum; 8021 }; 8022 8023 static void cmd_showport_parsed(void *parsed_result, 8024 __rte_unused struct cmdline *cl, 8025 __rte_unused void *data) 8026 { 8027 struct cmd_showport_result *res = parsed_result; 8028 if (!strcmp(res->show, "clear")) { 8029 if (!strcmp(res->what, "stats")) 8030 nic_stats_clear(res->portnum); 8031 else if (!strcmp(res->what, "xstats")) 8032 nic_xstats_clear(res->portnum); 8033 } else if (!strcmp(res->what, "info")) 8034 port_infos_display(res->portnum); 8035 else if (!strcmp(res->what, "summary")) { 8036 port_summary_header_display(); 8037 port_summary_display(res->portnum); 8038 } 8039 else if (!strcmp(res->what, "stats")) 8040 nic_stats_display(res->portnum); 8041 else if (!strcmp(res->what, "xstats")) 8042 nic_xstats_display(res->portnum); 8043 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) 8044 else if (!strcmp(res->what, "fdir")) 8045 fdir_get_infos(res->portnum); 8046 #endif 8047 else if (!strcmp(res->what, "dcb_tc")) 8048 port_dcb_info_display(res->portnum); 8049 } 8050 8051 cmdline_parse_token_string_t cmd_showport_show = 8052 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 8053 "show#clear"); 8054 cmdline_parse_token_string_t cmd_showport_port = 8055 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 8056 cmdline_parse_token_string_t cmd_showport_what = 8057 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 8058 "info#summary#stats#xstats#fdir#dcb_tc"); 8059 cmdline_parse_token_num_t cmd_showport_portnum = 8060 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16); 8061 8062 cmdline_parse_inst_t cmd_showport = { 8063 .f = cmd_showport_parsed, 8064 .data = NULL, 8065 .help_str = "show|clear port " 8066 "info|summary|stats|xstats|fdir|dcb_tc " 8067 "<port_id>", 8068 .tokens = { 8069 (void *)&cmd_showport_show, 8070 (void *)&cmd_showport_port, 8071 (void *)&cmd_showport_what, 8072 (void *)&cmd_showport_portnum, 8073 NULL, 8074 }, 8075 }; 8076 8077 /* *** show port representors information *** */ 8078 struct cmd_representor_info_result { 8079 cmdline_fixed_string_t cmd_show; 8080 cmdline_fixed_string_t cmd_port; 8081 cmdline_fixed_string_t cmd_info; 8082 cmdline_fixed_string_t cmd_keyword; 8083 portid_t cmd_pid; 8084 }; 8085 8086 static void 8087 cmd_representor_info_parsed(void *parsed_result, 8088 __rte_unused struct cmdline *cl, 8089 __rte_unused void *data) 8090 { 8091 struct cmd_representor_info_result *res = parsed_result; 8092 struct rte_eth_representor_info *info; 8093 struct rte_eth_representor_range *range; 8094 uint32_t range_diff; 8095 uint32_t i; 8096 int ret; 8097 int num; 8098 8099 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 8100 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid); 8101 return; 8102 } 8103 8104 ret = rte_eth_representor_info_get(res->cmd_pid, NULL); 8105 if (ret < 0) { 8106 fprintf(stderr, 8107 "Failed to get the number of representor info ranges for port %hu: %s\n", 8108 res->cmd_pid, rte_strerror(-ret)); 8109 return; 8110 } 8111 num = ret; 8112 8113 info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0])); 8114 if (info == NULL) { 8115 fprintf(stderr, 8116 "Failed to allocate memory for representor info for port %hu\n", 8117 res->cmd_pid); 8118 return; 8119 } 8120 info->nb_ranges_alloc = num; 8121 8122 ret = rte_eth_representor_info_get(res->cmd_pid, info); 8123 if (ret < 0) { 8124 fprintf(stderr, 8125 "Failed to get the representor info for port %hu: %s\n", 8126 res->cmd_pid, rte_strerror(-ret)); 8127 free(info); 8128 return; 8129 } 8130 8131 printf("Port controller: %hu\n", info->controller); 8132 printf("Port PF: %hu\n", info->pf); 8133 8134 printf("Ranges: %u\n", info->nb_ranges); 8135 for (i = 0; i < info->nb_ranges; i++) { 8136 range = &info->ranges[i]; 8137 range_diff = range->id_end - range->id_base; 8138 8139 printf("%u. ", i + 1); 8140 printf("'%s' ", range->name); 8141 if (range_diff > 0) 8142 printf("[%u-%u]: ", range->id_base, range->id_end); 8143 else 8144 printf("[%u]: ", range->id_base); 8145 8146 printf("Controller %d, PF %d", range->controller, range->pf); 8147 8148 switch (range->type) { 8149 case RTE_ETH_REPRESENTOR_NONE: 8150 printf(", NONE\n"); 8151 break; 8152 case RTE_ETH_REPRESENTOR_VF: 8153 if (range_diff > 0) 8154 printf(", VF %d..%d\n", range->vf, 8155 range->vf + range_diff); 8156 else 8157 printf(", VF %d\n", range->vf); 8158 break; 8159 case RTE_ETH_REPRESENTOR_SF: 8160 printf(", SF %d\n", range->sf); 8161 break; 8162 case RTE_ETH_REPRESENTOR_PF: 8163 if (range_diff > 0) 8164 printf("..%d\n", range->pf + range_diff); 8165 else 8166 printf("\n"); 8167 break; 8168 default: 8169 printf(", UNKNOWN TYPE %d\n", range->type); 8170 break; 8171 } 8172 } 8173 8174 free(info); 8175 } 8176 8177 cmdline_parse_token_string_t cmd_representor_info_show = 8178 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result, 8179 cmd_show, "show"); 8180 cmdline_parse_token_string_t cmd_representor_info_port = 8181 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result, 8182 cmd_port, "port"); 8183 cmdline_parse_token_string_t cmd_representor_info_info = 8184 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result, 8185 cmd_info, "info"); 8186 cmdline_parse_token_num_t cmd_representor_info_pid = 8187 TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result, 8188 cmd_pid, RTE_UINT16); 8189 cmdline_parse_token_string_t cmd_representor_info_keyword = 8190 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result, 8191 cmd_keyword, "representor"); 8192 8193 cmdline_parse_inst_t cmd_representor_info = { 8194 .f = cmd_representor_info_parsed, 8195 .data = NULL, 8196 .help_str = "show port info <port_id> representor", 8197 .tokens = { 8198 (void *)&cmd_representor_info_show, 8199 (void *)&cmd_representor_info_port, 8200 (void *)&cmd_representor_info_info, 8201 (void *)&cmd_representor_info_pid, 8202 (void *)&cmd_representor_info_keyword, 8203 NULL, 8204 }, 8205 }; 8206 8207 8208 /* *** SHOW DEVICE INFO *** */ 8209 struct cmd_showdevice_result { 8210 cmdline_fixed_string_t show; 8211 cmdline_fixed_string_t device; 8212 cmdline_fixed_string_t what; 8213 cmdline_fixed_string_t identifier; 8214 }; 8215 8216 static void cmd_showdevice_parsed(void *parsed_result, 8217 __rte_unused struct cmdline *cl, 8218 __rte_unused void *data) 8219 { 8220 struct cmd_showdevice_result *res = parsed_result; 8221 if (!strcmp(res->what, "info")) { 8222 if (!strcmp(res->identifier, "all")) 8223 device_infos_display(NULL); 8224 else 8225 device_infos_display(res->identifier); 8226 } 8227 } 8228 8229 cmdline_parse_token_string_t cmd_showdevice_show = 8230 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show, 8231 "show"); 8232 cmdline_parse_token_string_t cmd_showdevice_device = 8233 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device"); 8234 cmdline_parse_token_string_t cmd_showdevice_what = 8235 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what, 8236 "info"); 8237 cmdline_parse_token_string_t cmd_showdevice_identifier = 8238 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, 8239 identifier, NULL); 8240 8241 cmdline_parse_inst_t cmd_showdevice = { 8242 .f = cmd_showdevice_parsed, 8243 .data = NULL, 8244 .help_str = "show device info <identifier>|all", 8245 .tokens = { 8246 (void *)&cmd_showdevice_show, 8247 (void *)&cmd_showdevice_device, 8248 (void *)&cmd_showdevice_what, 8249 (void *)&cmd_showdevice_identifier, 8250 NULL, 8251 }, 8252 }; 8253 8254 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */ 8255 struct cmd_showeeprom_result { 8256 cmdline_fixed_string_t show; 8257 cmdline_fixed_string_t port; 8258 uint16_t portnum; 8259 cmdline_fixed_string_t type; 8260 }; 8261 8262 static void cmd_showeeprom_parsed(void *parsed_result, 8263 __rte_unused struct cmdline *cl, 8264 __rte_unused void *data) 8265 { 8266 struct cmd_showeeprom_result *res = parsed_result; 8267 8268 if (!strcmp(res->type, "eeprom")) 8269 port_eeprom_display(res->portnum); 8270 else if (!strcmp(res->type, "module_eeprom")) 8271 port_module_eeprom_display(res->portnum); 8272 else 8273 fprintf(stderr, "Unknown argument\n"); 8274 } 8275 8276 cmdline_parse_token_string_t cmd_showeeprom_show = 8277 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show"); 8278 cmdline_parse_token_string_t cmd_showeeprom_port = 8279 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port"); 8280 cmdline_parse_token_num_t cmd_showeeprom_portnum = 8281 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, 8282 RTE_UINT16); 8283 cmdline_parse_token_string_t cmd_showeeprom_type = 8284 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom"); 8285 8286 cmdline_parse_inst_t cmd_showeeprom = { 8287 .f = cmd_showeeprom_parsed, 8288 .data = NULL, 8289 .help_str = "show port <port_id> module_eeprom|eeprom", 8290 .tokens = { 8291 (void *)&cmd_showeeprom_show, 8292 (void *)&cmd_showeeprom_port, 8293 (void *)&cmd_showeeprom_portnum, 8294 (void *)&cmd_showeeprom_type, 8295 NULL, 8296 }, 8297 }; 8298 8299 /* *** SHOW QUEUE INFO *** */ 8300 struct cmd_showqueue_result { 8301 cmdline_fixed_string_t show; 8302 cmdline_fixed_string_t type; 8303 cmdline_fixed_string_t what; 8304 uint16_t portnum; 8305 uint16_t queuenum; 8306 }; 8307 8308 static void 8309 cmd_showqueue_parsed(void *parsed_result, 8310 __rte_unused struct cmdline *cl, 8311 __rte_unused void *data) 8312 { 8313 struct cmd_showqueue_result *res = parsed_result; 8314 8315 if (!strcmp(res->type, "rxq")) 8316 rx_queue_infos_display(res->portnum, res->queuenum); 8317 else if (!strcmp(res->type, "txq")) 8318 tx_queue_infos_display(res->portnum, res->queuenum); 8319 } 8320 8321 cmdline_parse_token_string_t cmd_showqueue_show = 8322 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 8323 cmdline_parse_token_string_t cmd_showqueue_type = 8324 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 8325 cmdline_parse_token_string_t cmd_showqueue_what = 8326 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 8327 cmdline_parse_token_num_t cmd_showqueue_portnum = 8328 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, 8329 RTE_UINT16); 8330 cmdline_parse_token_num_t cmd_showqueue_queuenum = 8331 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, 8332 RTE_UINT16); 8333 8334 cmdline_parse_inst_t cmd_showqueue = { 8335 .f = cmd_showqueue_parsed, 8336 .data = NULL, 8337 .help_str = "show rxq|txq info <port_id> <queue_id>", 8338 .tokens = { 8339 (void *)&cmd_showqueue_show, 8340 (void *)&cmd_showqueue_type, 8341 (void *)&cmd_showqueue_what, 8342 (void *)&cmd_showqueue_portnum, 8343 (void *)&cmd_showqueue_queuenum, 8344 NULL, 8345 }, 8346 }; 8347 8348 /* show/clear fwd engine statistics */ 8349 struct fwd_result { 8350 cmdline_fixed_string_t action; 8351 cmdline_fixed_string_t fwd; 8352 cmdline_fixed_string_t stats; 8353 cmdline_fixed_string_t all; 8354 }; 8355 8356 cmdline_parse_token_string_t cmd_fwd_action = 8357 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear"); 8358 cmdline_parse_token_string_t cmd_fwd_fwd = 8359 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd"); 8360 cmdline_parse_token_string_t cmd_fwd_stats = 8361 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats"); 8362 cmdline_parse_token_string_t cmd_fwd_all = 8363 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all"); 8364 8365 static void 8366 cmd_showfwdall_parsed(void *parsed_result, 8367 __rte_unused struct cmdline *cl, 8368 __rte_unused void *data) 8369 { 8370 struct fwd_result *res = parsed_result; 8371 8372 if (!strcmp(res->action, "show")) 8373 fwd_stats_display(); 8374 else 8375 fwd_stats_reset(); 8376 } 8377 8378 static cmdline_parse_inst_t cmd_showfwdall = { 8379 .f = cmd_showfwdall_parsed, 8380 .data = NULL, 8381 .help_str = "show|clear fwd stats all", 8382 .tokens = { 8383 (void *)&cmd_fwd_action, 8384 (void *)&cmd_fwd_fwd, 8385 (void *)&cmd_fwd_stats, 8386 (void *)&cmd_fwd_all, 8387 NULL, 8388 }, 8389 }; 8390 8391 /* *** READ PORT REGISTER *** */ 8392 struct cmd_read_reg_result { 8393 cmdline_fixed_string_t read; 8394 cmdline_fixed_string_t reg; 8395 portid_t port_id; 8396 uint32_t reg_off; 8397 }; 8398 8399 static void 8400 cmd_read_reg_parsed(void *parsed_result, 8401 __rte_unused struct cmdline *cl, 8402 __rte_unused void *data) 8403 { 8404 struct cmd_read_reg_result *res = parsed_result; 8405 port_reg_display(res->port_id, res->reg_off); 8406 } 8407 8408 cmdline_parse_token_string_t cmd_read_reg_read = 8409 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 8410 cmdline_parse_token_string_t cmd_read_reg_reg = 8411 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 8412 cmdline_parse_token_num_t cmd_read_reg_port_id = 8413 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16); 8414 cmdline_parse_token_num_t cmd_read_reg_reg_off = 8415 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32); 8416 8417 cmdline_parse_inst_t cmd_read_reg = { 8418 .f = cmd_read_reg_parsed, 8419 .data = NULL, 8420 .help_str = "read reg <port_id> <reg_off>", 8421 .tokens = { 8422 (void *)&cmd_read_reg_read, 8423 (void *)&cmd_read_reg_reg, 8424 (void *)&cmd_read_reg_port_id, 8425 (void *)&cmd_read_reg_reg_off, 8426 NULL, 8427 }, 8428 }; 8429 8430 /* *** READ PORT REGISTER BIT FIELD *** */ 8431 struct cmd_read_reg_bit_field_result { 8432 cmdline_fixed_string_t read; 8433 cmdline_fixed_string_t regfield; 8434 portid_t port_id; 8435 uint32_t reg_off; 8436 uint8_t bit1_pos; 8437 uint8_t bit2_pos; 8438 }; 8439 8440 static void 8441 cmd_read_reg_bit_field_parsed(void *parsed_result, 8442 __rte_unused struct cmdline *cl, 8443 __rte_unused void *data) 8444 { 8445 struct cmd_read_reg_bit_field_result *res = parsed_result; 8446 port_reg_bit_field_display(res->port_id, res->reg_off, 8447 res->bit1_pos, res->bit2_pos); 8448 } 8449 8450 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 8451 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 8452 "read"); 8453 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 8454 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 8455 regfield, "regfield"); 8456 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 8457 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 8458 RTE_UINT16); 8459 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 8460 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 8461 RTE_UINT32); 8462 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 8463 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 8464 RTE_UINT8); 8465 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 8466 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 8467 RTE_UINT8); 8468 8469 cmdline_parse_inst_t cmd_read_reg_bit_field = { 8470 .f = cmd_read_reg_bit_field_parsed, 8471 .data = NULL, 8472 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 8473 "Read register bit field between bit_x and bit_y included", 8474 .tokens = { 8475 (void *)&cmd_read_reg_bit_field_read, 8476 (void *)&cmd_read_reg_bit_field_regfield, 8477 (void *)&cmd_read_reg_bit_field_port_id, 8478 (void *)&cmd_read_reg_bit_field_reg_off, 8479 (void *)&cmd_read_reg_bit_field_bit1_pos, 8480 (void *)&cmd_read_reg_bit_field_bit2_pos, 8481 NULL, 8482 }, 8483 }; 8484 8485 /* *** READ PORT REGISTER BIT *** */ 8486 struct cmd_read_reg_bit_result { 8487 cmdline_fixed_string_t read; 8488 cmdline_fixed_string_t regbit; 8489 portid_t port_id; 8490 uint32_t reg_off; 8491 uint8_t bit_pos; 8492 }; 8493 8494 static void 8495 cmd_read_reg_bit_parsed(void *parsed_result, 8496 __rte_unused struct cmdline *cl, 8497 __rte_unused void *data) 8498 { 8499 struct cmd_read_reg_bit_result *res = parsed_result; 8500 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 8501 } 8502 8503 cmdline_parse_token_string_t cmd_read_reg_bit_read = 8504 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 8505 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 8506 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 8507 regbit, "regbit"); 8508 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 8509 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, 8510 RTE_UINT16); 8511 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 8512 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, 8513 RTE_UINT32); 8514 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 8515 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, 8516 RTE_UINT8); 8517 8518 cmdline_parse_inst_t cmd_read_reg_bit = { 8519 .f = cmd_read_reg_bit_parsed, 8520 .data = NULL, 8521 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 8522 .tokens = { 8523 (void *)&cmd_read_reg_bit_read, 8524 (void *)&cmd_read_reg_bit_regbit, 8525 (void *)&cmd_read_reg_bit_port_id, 8526 (void *)&cmd_read_reg_bit_reg_off, 8527 (void *)&cmd_read_reg_bit_bit_pos, 8528 NULL, 8529 }, 8530 }; 8531 8532 /* *** WRITE PORT REGISTER *** */ 8533 struct cmd_write_reg_result { 8534 cmdline_fixed_string_t write; 8535 cmdline_fixed_string_t reg; 8536 portid_t port_id; 8537 uint32_t reg_off; 8538 uint32_t value; 8539 }; 8540 8541 static void 8542 cmd_write_reg_parsed(void *parsed_result, 8543 __rte_unused struct cmdline *cl, 8544 __rte_unused void *data) 8545 { 8546 struct cmd_write_reg_result *res = parsed_result; 8547 port_reg_set(res->port_id, res->reg_off, res->value); 8548 } 8549 8550 cmdline_parse_token_string_t cmd_write_reg_write = 8551 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 8552 cmdline_parse_token_string_t cmd_write_reg_reg = 8553 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 8554 cmdline_parse_token_num_t cmd_write_reg_port_id = 8555 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16); 8556 cmdline_parse_token_num_t cmd_write_reg_reg_off = 8557 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32); 8558 cmdline_parse_token_num_t cmd_write_reg_value = 8559 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32); 8560 8561 cmdline_parse_inst_t cmd_write_reg = { 8562 .f = cmd_write_reg_parsed, 8563 .data = NULL, 8564 .help_str = "write reg <port_id> <reg_off> <reg_value>", 8565 .tokens = { 8566 (void *)&cmd_write_reg_write, 8567 (void *)&cmd_write_reg_reg, 8568 (void *)&cmd_write_reg_port_id, 8569 (void *)&cmd_write_reg_reg_off, 8570 (void *)&cmd_write_reg_value, 8571 NULL, 8572 }, 8573 }; 8574 8575 /* *** WRITE PORT REGISTER BIT FIELD *** */ 8576 struct cmd_write_reg_bit_field_result { 8577 cmdline_fixed_string_t write; 8578 cmdline_fixed_string_t regfield; 8579 portid_t port_id; 8580 uint32_t reg_off; 8581 uint8_t bit1_pos; 8582 uint8_t bit2_pos; 8583 uint32_t value; 8584 }; 8585 8586 static void 8587 cmd_write_reg_bit_field_parsed(void *parsed_result, 8588 __rte_unused struct cmdline *cl, 8589 __rte_unused void *data) 8590 { 8591 struct cmd_write_reg_bit_field_result *res = parsed_result; 8592 port_reg_bit_field_set(res->port_id, res->reg_off, 8593 res->bit1_pos, res->bit2_pos, res->value); 8594 } 8595 8596 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 8597 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 8598 "write"); 8599 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 8600 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 8601 regfield, "regfield"); 8602 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 8603 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 8604 RTE_UINT16); 8605 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 8606 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 8607 RTE_UINT32); 8608 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 8609 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 8610 RTE_UINT8); 8611 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 8612 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 8613 RTE_UINT8); 8614 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 8615 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 8616 RTE_UINT32); 8617 8618 cmdline_parse_inst_t cmd_write_reg_bit_field = { 8619 .f = cmd_write_reg_bit_field_parsed, 8620 .data = NULL, 8621 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 8622 "<reg_value>: " 8623 "Set register bit field between bit_x and bit_y included", 8624 .tokens = { 8625 (void *)&cmd_write_reg_bit_field_write, 8626 (void *)&cmd_write_reg_bit_field_regfield, 8627 (void *)&cmd_write_reg_bit_field_port_id, 8628 (void *)&cmd_write_reg_bit_field_reg_off, 8629 (void *)&cmd_write_reg_bit_field_bit1_pos, 8630 (void *)&cmd_write_reg_bit_field_bit2_pos, 8631 (void *)&cmd_write_reg_bit_field_value, 8632 NULL, 8633 }, 8634 }; 8635 8636 /* *** WRITE PORT REGISTER BIT *** */ 8637 struct cmd_write_reg_bit_result { 8638 cmdline_fixed_string_t write; 8639 cmdline_fixed_string_t regbit; 8640 portid_t port_id; 8641 uint32_t reg_off; 8642 uint8_t bit_pos; 8643 uint8_t value; 8644 }; 8645 8646 static void 8647 cmd_write_reg_bit_parsed(void *parsed_result, 8648 __rte_unused struct cmdline *cl, 8649 __rte_unused void *data) 8650 { 8651 struct cmd_write_reg_bit_result *res = parsed_result; 8652 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 8653 } 8654 8655 cmdline_parse_token_string_t cmd_write_reg_bit_write = 8656 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 8657 "write"); 8658 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 8659 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 8660 regbit, "regbit"); 8661 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 8662 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, 8663 RTE_UINT16); 8664 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 8665 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, 8666 RTE_UINT32); 8667 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 8668 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, 8669 RTE_UINT8); 8670 cmdline_parse_token_num_t cmd_write_reg_bit_value = 8671 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, 8672 RTE_UINT8); 8673 8674 cmdline_parse_inst_t cmd_write_reg_bit = { 8675 .f = cmd_write_reg_bit_parsed, 8676 .data = NULL, 8677 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 8678 "0 <= bit_x <= 31", 8679 .tokens = { 8680 (void *)&cmd_write_reg_bit_write, 8681 (void *)&cmd_write_reg_bit_regbit, 8682 (void *)&cmd_write_reg_bit_port_id, 8683 (void *)&cmd_write_reg_bit_reg_off, 8684 (void *)&cmd_write_reg_bit_bit_pos, 8685 (void *)&cmd_write_reg_bit_value, 8686 NULL, 8687 }, 8688 }; 8689 8690 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 8691 struct cmd_read_rxd_txd_result { 8692 cmdline_fixed_string_t read; 8693 cmdline_fixed_string_t rxd_txd; 8694 portid_t port_id; 8695 uint16_t queue_id; 8696 uint16_t desc_id; 8697 }; 8698 8699 static void 8700 cmd_read_rxd_txd_parsed(void *parsed_result, 8701 __rte_unused struct cmdline *cl, 8702 __rte_unused void *data) 8703 { 8704 struct cmd_read_rxd_txd_result *res = parsed_result; 8705 8706 if (!strcmp(res->rxd_txd, "rxd")) 8707 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 8708 else if (!strcmp(res->rxd_txd, "txd")) 8709 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 8710 } 8711 8712 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 8713 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 8714 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 8715 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 8716 "rxd#txd"); 8717 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 8718 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, 8719 RTE_UINT16); 8720 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 8721 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, 8722 RTE_UINT16); 8723 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 8724 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, 8725 RTE_UINT16); 8726 8727 cmdline_parse_inst_t cmd_read_rxd_txd = { 8728 .f = cmd_read_rxd_txd_parsed, 8729 .data = NULL, 8730 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 8731 .tokens = { 8732 (void *)&cmd_read_rxd_txd_read, 8733 (void *)&cmd_read_rxd_txd_rxd_txd, 8734 (void *)&cmd_read_rxd_txd_port_id, 8735 (void *)&cmd_read_rxd_txd_queue_id, 8736 (void *)&cmd_read_rxd_txd_desc_id, 8737 NULL, 8738 }, 8739 }; 8740 8741 /* *** QUIT *** */ 8742 struct cmd_quit_result { 8743 cmdline_fixed_string_t quit; 8744 }; 8745 8746 static void cmd_quit_parsed(__rte_unused void *parsed_result, 8747 struct cmdline *cl, 8748 __rte_unused void *data) 8749 { 8750 cmdline_quit(cl); 8751 } 8752 8753 cmdline_parse_token_string_t cmd_quit_quit = 8754 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 8755 8756 cmdline_parse_inst_t cmd_quit = { 8757 .f = cmd_quit_parsed, 8758 .data = NULL, 8759 .help_str = "quit: Exit application", 8760 .tokens = { 8761 (void *)&cmd_quit_quit, 8762 NULL, 8763 }, 8764 }; 8765 8766 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 8767 struct cmd_mac_addr_result { 8768 cmdline_fixed_string_t mac_addr_cmd; 8769 cmdline_fixed_string_t what; 8770 uint16_t port_num; 8771 struct rte_ether_addr address; 8772 }; 8773 8774 static void cmd_mac_addr_parsed(void *parsed_result, 8775 __rte_unused struct cmdline *cl, 8776 __rte_unused void *data) 8777 { 8778 struct cmd_mac_addr_result *res = parsed_result; 8779 int ret; 8780 8781 if (strcmp(res->what, "add") == 0) 8782 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 8783 else if (strcmp(res->what, "set") == 0) 8784 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 8785 &res->address); 8786 else 8787 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 8788 8789 /* check the return value and print it if is < 0 */ 8790 if(ret < 0) 8791 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret)); 8792 8793 } 8794 8795 cmdline_parse_token_string_t cmd_mac_addr_cmd = 8796 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 8797 "mac_addr"); 8798 cmdline_parse_token_string_t cmd_mac_addr_what = 8799 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 8800 "add#remove#set"); 8801 cmdline_parse_token_num_t cmd_mac_addr_portnum = 8802 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 8803 RTE_UINT16); 8804 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 8805 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 8806 8807 cmdline_parse_inst_t cmd_mac_addr = { 8808 .f = cmd_mac_addr_parsed, 8809 .data = (void *)0, 8810 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 8811 "Add/Remove/Set MAC address on port_id", 8812 .tokens = { 8813 (void *)&cmd_mac_addr_cmd, 8814 (void *)&cmd_mac_addr_what, 8815 (void *)&cmd_mac_addr_portnum, 8816 (void *)&cmd_mac_addr_addr, 8817 NULL, 8818 }, 8819 }; 8820 8821 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 8822 struct cmd_eth_peer_result { 8823 cmdline_fixed_string_t set; 8824 cmdline_fixed_string_t eth_peer; 8825 portid_t port_id; 8826 cmdline_fixed_string_t peer_addr; 8827 }; 8828 8829 static void cmd_set_eth_peer_parsed(void *parsed_result, 8830 __rte_unused struct cmdline *cl, 8831 __rte_unused void *data) 8832 { 8833 struct cmd_eth_peer_result *res = parsed_result; 8834 8835 if (test_done == 0) { 8836 fprintf(stderr, "Please stop forwarding first\n"); 8837 return; 8838 } 8839 if (!strcmp(res->eth_peer, "eth-peer")) { 8840 set_fwd_eth_peer(res->port_id, res->peer_addr); 8841 fwd_config_setup(); 8842 } 8843 } 8844 cmdline_parse_token_string_t cmd_eth_peer_set = 8845 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 8846 cmdline_parse_token_string_t cmd_eth_peer = 8847 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 8848 cmdline_parse_token_num_t cmd_eth_peer_port_id = 8849 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, 8850 RTE_UINT16); 8851 cmdline_parse_token_string_t cmd_eth_peer_addr = 8852 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 8853 8854 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 8855 .f = cmd_set_eth_peer_parsed, 8856 .data = NULL, 8857 .help_str = "set eth-peer <port_id> <peer_mac>", 8858 .tokens = { 8859 (void *)&cmd_eth_peer_set, 8860 (void *)&cmd_eth_peer, 8861 (void *)&cmd_eth_peer_port_id, 8862 (void *)&cmd_eth_peer_addr, 8863 NULL, 8864 }, 8865 }; 8866 8867 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 8868 struct cmd_set_qmap_result { 8869 cmdline_fixed_string_t set; 8870 cmdline_fixed_string_t qmap; 8871 cmdline_fixed_string_t what; 8872 portid_t port_id; 8873 uint16_t queue_id; 8874 uint8_t map_value; 8875 }; 8876 8877 static void 8878 cmd_set_qmap_parsed(void *parsed_result, 8879 __rte_unused struct cmdline *cl, 8880 __rte_unused void *data) 8881 { 8882 struct cmd_set_qmap_result *res = parsed_result; 8883 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 8884 8885 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 8886 } 8887 8888 cmdline_parse_token_string_t cmd_setqmap_set = 8889 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8890 set, "set"); 8891 cmdline_parse_token_string_t cmd_setqmap_qmap = 8892 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8893 qmap, "stat_qmap"); 8894 cmdline_parse_token_string_t cmd_setqmap_what = 8895 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8896 what, "tx#rx"); 8897 cmdline_parse_token_num_t cmd_setqmap_portid = 8898 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8899 port_id, RTE_UINT16); 8900 cmdline_parse_token_num_t cmd_setqmap_queueid = 8901 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8902 queue_id, RTE_UINT16); 8903 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 8904 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8905 map_value, RTE_UINT8); 8906 8907 cmdline_parse_inst_t cmd_set_qmap = { 8908 .f = cmd_set_qmap_parsed, 8909 .data = NULL, 8910 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 8911 "Set statistics mapping value on tx|rx queue_id of port_id", 8912 .tokens = { 8913 (void *)&cmd_setqmap_set, 8914 (void *)&cmd_setqmap_qmap, 8915 (void *)&cmd_setqmap_what, 8916 (void *)&cmd_setqmap_portid, 8917 (void *)&cmd_setqmap_queueid, 8918 (void *)&cmd_setqmap_mapvalue, 8919 NULL, 8920 }, 8921 }; 8922 8923 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 8924 struct cmd_set_xstats_hide_zero_result { 8925 cmdline_fixed_string_t keyword; 8926 cmdline_fixed_string_t name; 8927 cmdline_fixed_string_t on_off; 8928 }; 8929 8930 static void 8931 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 8932 __rte_unused struct cmdline *cl, 8933 __rte_unused void *data) 8934 { 8935 struct cmd_set_xstats_hide_zero_result *res; 8936 uint16_t on_off = 0; 8937 8938 res = parsed_result; 8939 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8940 set_xstats_hide_zero(on_off); 8941 } 8942 8943 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 8944 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8945 keyword, "set"); 8946 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 8947 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8948 name, "xstats-hide-zero"); 8949 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 8950 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8951 on_off, "on#off"); 8952 8953 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 8954 .f = cmd_set_xstats_hide_zero_parsed, 8955 .data = NULL, 8956 .help_str = "set xstats-hide-zero on|off", 8957 .tokens = { 8958 (void *)&cmd_set_xstats_hide_zero_keyword, 8959 (void *)&cmd_set_xstats_hide_zero_name, 8960 (void *)&cmd_set_xstats_hide_zero_on_off, 8961 NULL, 8962 }, 8963 }; 8964 8965 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */ 8966 struct cmd_set_record_core_cycles_result { 8967 cmdline_fixed_string_t keyword; 8968 cmdline_fixed_string_t name; 8969 cmdline_fixed_string_t on_off; 8970 }; 8971 8972 static void 8973 cmd_set_record_core_cycles_parsed(void *parsed_result, 8974 __rte_unused struct cmdline *cl, 8975 __rte_unused void *data) 8976 { 8977 struct cmd_set_record_core_cycles_result *res; 8978 uint16_t on_off = 0; 8979 8980 res = parsed_result; 8981 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8982 set_record_core_cycles(on_off); 8983 } 8984 8985 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword = 8986 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8987 keyword, "set"); 8988 cmdline_parse_token_string_t cmd_set_record_core_cycles_name = 8989 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8990 name, "record-core-cycles"); 8991 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off = 8992 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8993 on_off, "on#off"); 8994 8995 cmdline_parse_inst_t cmd_set_record_core_cycles = { 8996 .f = cmd_set_record_core_cycles_parsed, 8997 .data = NULL, 8998 .help_str = "set record-core-cycles on|off", 8999 .tokens = { 9000 (void *)&cmd_set_record_core_cycles_keyword, 9001 (void *)&cmd_set_record_core_cycles_name, 9002 (void *)&cmd_set_record_core_cycles_on_off, 9003 NULL, 9004 }, 9005 }; 9006 9007 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */ 9008 struct cmd_set_record_burst_stats_result { 9009 cmdline_fixed_string_t keyword; 9010 cmdline_fixed_string_t name; 9011 cmdline_fixed_string_t on_off; 9012 }; 9013 9014 static void 9015 cmd_set_record_burst_stats_parsed(void *parsed_result, 9016 __rte_unused struct cmdline *cl, 9017 __rte_unused void *data) 9018 { 9019 struct cmd_set_record_burst_stats_result *res; 9020 uint16_t on_off = 0; 9021 9022 res = parsed_result; 9023 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 9024 set_record_burst_stats(on_off); 9025 } 9026 9027 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword = 9028 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 9029 keyword, "set"); 9030 cmdline_parse_token_string_t cmd_set_record_burst_stats_name = 9031 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 9032 name, "record-burst-stats"); 9033 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off = 9034 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 9035 on_off, "on#off"); 9036 9037 cmdline_parse_inst_t cmd_set_record_burst_stats = { 9038 .f = cmd_set_record_burst_stats_parsed, 9039 .data = NULL, 9040 .help_str = "set record-burst-stats on|off", 9041 .tokens = { 9042 (void *)&cmd_set_record_burst_stats_keyword, 9043 (void *)&cmd_set_record_burst_stats_name, 9044 (void *)&cmd_set_record_burst_stats_on_off, 9045 NULL, 9046 }, 9047 }; 9048 9049 /* *** CONFIGURE UNICAST HASH TABLE *** */ 9050 struct cmd_set_uc_hash_table { 9051 cmdline_fixed_string_t set; 9052 cmdline_fixed_string_t port; 9053 portid_t port_id; 9054 cmdline_fixed_string_t what; 9055 struct rte_ether_addr address; 9056 cmdline_fixed_string_t mode; 9057 }; 9058 9059 static void 9060 cmd_set_uc_hash_parsed(void *parsed_result, 9061 __rte_unused struct cmdline *cl, 9062 __rte_unused void *data) 9063 { 9064 int ret=0; 9065 struct cmd_set_uc_hash_table *res = parsed_result; 9066 9067 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 9068 9069 if (strcmp(res->what, "uta") == 0) 9070 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 9071 &res->address,(uint8_t)is_on); 9072 if (ret < 0) 9073 fprintf(stderr, 9074 "bad unicast hash table parameter, return code = %d\n", 9075 ret); 9076 9077 } 9078 9079 cmdline_parse_token_string_t cmd_set_uc_hash_set = 9080 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 9081 set, "set"); 9082 cmdline_parse_token_string_t cmd_set_uc_hash_port = 9083 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 9084 port, "port"); 9085 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 9086 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 9087 port_id, RTE_UINT16); 9088 cmdline_parse_token_string_t cmd_set_uc_hash_what = 9089 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 9090 what, "uta"); 9091 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 9092 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 9093 address); 9094 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 9095 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 9096 mode, "on#off"); 9097 9098 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 9099 .f = cmd_set_uc_hash_parsed, 9100 .data = NULL, 9101 .help_str = "set port <port_id> uta <mac_addr> on|off)", 9102 .tokens = { 9103 (void *)&cmd_set_uc_hash_set, 9104 (void *)&cmd_set_uc_hash_port, 9105 (void *)&cmd_set_uc_hash_portid, 9106 (void *)&cmd_set_uc_hash_what, 9107 (void *)&cmd_set_uc_hash_mac, 9108 (void *)&cmd_set_uc_hash_mode, 9109 NULL, 9110 }, 9111 }; 9112 9113 struct cmd_set_uc_all_hash_table { 9114 cmdline_fixed_string_t set; 9115 cmdline_fixed_string_t port; 9116 portid_t port_id; 9117 cmdline_fixed_string_t what; 9118 cmdline_fixed_string_t value; 9119 cmdline_fixed_string_t mode; 9120 }; 9121 9122 static void 9123 cmd_set_uc_all_hash_parsed(void *parsed_result, 9124 __rte_unused struct cmdline *cl, 9125 __rte_unused void *data) 9126 { 9127 int ret=0; 9128 struct cmd_set_uc_all_hash_table *res = parsed_result; 9129 9130 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 9131 9132 if ((strcmp(res->what, "uta") == 0) && 9133 (strcmp(res->value, "all") == 0)) 9134 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 9135 if (ret < 0) 9136 fprintf(stderr, 9137 "bad unicast hash table parameter, return code = %d\n", 9138 ret); 9139 } 9140 9141 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 9142 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 9143 set, "set"); 9144 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 9145 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 9146 port, "port"); 9147 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 9148 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 9149 port_id, RTE_UINT16); 9150 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 9151 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 9152 what, "uta"); 9153 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 9154 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 9155 value,"all"); 9156 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 9157 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 9158 mode, "on#off"); 9159 9160 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 9161 .f = cmd_set_uc_all_hash_parsed, 9162 .data = NULL, 9163 .help_str = "set port <port_id> uta all on|off", 9164 .tokens = { 9165 (void *)&cmd_set_uc_all_hash_set, 9166 (void *)&cmd_set_uc_all_hash_port, 9167 (void *)&cmd_set_uc_all_hash_portid, 9168 (void *)&cmd_set_uc_all_hash_what, 9169 (void *)&cmd_set_uc_all_hash_value, 9170 (void *)&cmd_set_uc_all_hash_mode, 9171 NULL, 9172 }, 9173 }; 9174 9175 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 9176 struct cmd_set_vf_traffic { 9177 cmdline_fixed_string_t set; 9178 cmdline_fixed_string_t port; 9179 portid_t port_id; 9180 cmdline_fixed_string_t vf; 9181 uint8_t vf_id; 9182 cmdline_fixed_string_t what; 9183 cmdline_fixed_string_t mode; 9184 }; 9185 9186 static void 9187 cmd_set_vf_traffic_parsed(void *parsed_result, 9188 __rte_unused struct cmdline *cl, 9189 __rte_unused void *data) 9190 { 9191 struct cmd_set_vf_traffic *res = parsed_result; 9192 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 9193 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 9194 9195 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 9196 } 9197 9198 cmdline_parse_token_string_t cmd_setvf_traffic_set = 9199 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 9200 set, "set"); 9201 cmdline_parse_token_string_t cmd_setvf_traffic_port = 9202 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 9203 port, "port"); 9204 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 9205 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 9206 port_id, RTE_UINT16); 9207 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 9208 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 9209 vf, "vf"); 9210 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 9211 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 9212 vf_id, RTE_UINT8); 9213 cmdline_parse_token_string_t cmd_setvf_traffic_what = 9214 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 9215 what, "tx#rx"); 9216 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 9217 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 9218 mode, "on#off"); 9219 9220 cmdline_parse_inst_t cmd_set_vf_traffic = { 9221 .f = cmd_set_vf_traffic_parsed, 9222 .data = NULL, 9223 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 9224 .tokens = { 9225 (void *)&cmd_setvf_traffic_set, 9226 (void *)&cmd_setvf_traffic_port, 9227 (void *)&cmd_setvf_traffic_portid, 9228 (void *)&cmd_setvf_traffic_vf, 9229 (void *)&cmd_setvf_traffic_vfid, 9230 (void *)&cmd_setvf_traffic_what, 9231 (void *)&cmd_setvf_traffic_mode, 9232 NULL, 9233 }, 9234 }; 9235 9236 /* *** CONFIGURE VF RECEIVE MODE *** */ 9237 struct cmd_set_vf_rxmode { 9238 cmdline_fixed_string_t set; 9239 cmdline_fixed_string_t port; 9240 portid_t port_id; 9241 cmdline_fixed_string_t vf; 9242 uint8_t vf_id; 9243 cmdline_fixed_string_t what; 9244 cmdline_fixed_string_t mode; 9245 cmdline_fixed_string_t on; 9246 }; 9247 9248 static void 9249 cmd_set_vf_rxmode_parsed(void *parsed_result, 9250 __rte_unused struct cmdline *cl, 9251 __rte_unused void *data) 9252 { 9253 int ret = -ENOTSUP; 9254 uint16_t vf_rxmode = 0; 9255 struct cmd_set_vf_rxmode *res = parsed_result; 9256 9257 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 9258 if (!strcmp(res->what,"rxmode")) { 9259 if (!strcmp(res->mode, "AUPE")) 9260 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG; 9261 else if (!strcmp(res->mode, "ROPE")) 9262 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC; 9263 else if (!strcmp(res->mode, "BAM")) 9264 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST; 9265 else if (!strncmp(res->mode, "MPE",3)) 9266 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST; 9267 } 9268 9269 RTE_SET_USED(is_on); 9270 9271 #ifdef RTE_NET_IXGBE 9272 if (ret == -ENOTSUP) 9273 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 9274 vf_rxmode, (uint8_t)is_on); 9275 #endif 9276 #ifdef RTE_NET_BNXT 9277 if (ret == -ENOTSUP) 9278 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 9279 vf_rxmode, (uint8_t)is_on); 9280 #endif 9281 if (ret < 0) 9282 fprintf(stderr, 9283 "bad VF receive mode parameter, return code = %d\n", 9284 ret); 9285 } 9286 9287 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 9288 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 9289 set, "set"); 9290 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 9291 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 9292 port, "port"); 9293 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 9294 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 9295 port_id, RTE_UINT16); 9296 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 9297 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 9298 vf, "vf"); 9299 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 9300 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 9301 vf_id, RTE_UINT8); 9302 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 9303 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 9304 what, "rxmode"); 9305 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 9306 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 9307 mode, "AUPE#ROPE#BAM#MPE"); 9308 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 9309 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 9310 on, "on#off"); 9311 9312 cmdline_parse_inst_t cmd_set_vf_rxmode = { 9313 .f = cmd_set_vf_rxmode_parsed, 9314 .data = NULL, 9315 .help_str = "set port <port_id> vf <vf_id> rxmode " 9316 "AUPE|ROPE|BAM|MPE on|off", 9317 .tokens = { 9318 (void *)&cmd_set_vf_rxmode_set, 9319 (void *)&cmd_set_vf_rxmode_port, 9320 (void *)&cmd_set_vf_rxmode_portid, 9321 (void *)&cmd_set_vf_rxmode_vf, 9322 (void *)&cmd_set_vf_rxmode_vfid, 9323 (void *)&cmd_set_vf_rxmode_what, 9324 (void *)&cmd_set_vf_rxmode_mode, 9325 (void *)&cmd_set_vf_rxmode_on, 9326 NULL, 9327 }, 9328 }; 9329 9330 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 9331 struct cmd_vf_mac_addr_result { 9332 cmdline_fixed_string_t mac_addr_cmd; 9333 cmdline_fixed_string_t what; 9334 cmdline_fixed_string_t port; 9335 uint16_t port_num; 9336 cmdline_fixed_string_t vf; 9337 uint8_t vf_num; 9338 struct rte_ether_addr address; 9339 }; 9340 9341 static void cmd_vf_mac_addr_parsed(void *parsed_result, 9342 __rte_unused struct cmdline *cl, 9343 __rte_unused void *data) 9344 { 9345 struct cmd_vf_mac_addr_result *res = parsed_result; 9346 int ret = -ENOTSUP; 9347 9348 if (strcmp(res->what, "add") != 0) 9349 return; 9350 9351 #ifdef RTE_NET_I40E 9352 if (ret == -ENOTSUP) 9353 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 9354 &res->address); 9355 #endif 9356 #ifdef RTE_NET_BNXT 9357 if (ret == -ENOTSUP) 9358 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 9359 res->vf_num); 9360 #endif 9361 9362 if(ret < 0) 9363 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 9364 9365 } 9366 9367 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 9368 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 9369 mac_addr_cmd,"mac_addr"); 9370 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 9371 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 9372 what,"add"); 9373 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 9374 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 9375 port,"port"); 9376 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 9377 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 9378 port_num, RTE_UINT16); 9379 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 9380 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 9381 vf,"vf"); 9382 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 9383 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 9384 vf_num, RTE_UINT8); 9385 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 9386 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 9387 address); 9388 9389 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 9390 .f = cmd_vf_mac_addr_parsed, 9391 .data = (void *)0, 9392 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 9393 "Add MAC address filtering for a VF on port_id", 9394 .tokens = { 9395 (void *)&cmd_vf_mac_addr_cmd, 9396 (void *)&cmd_vf_mac_addr_what, 9397 (void *)&cmd_vf_mac_addr_port, 9398 (void *)&cmd_vf_mac_addr_portnum, 9399 (void *)&cmd_vf_mac_addr_vf, 9400 (void *)&cmd_vf_mac_addr_vfnum, 9401 (void *)&cmd_vf_mac_addr_addr, 9402 NULL, 9403 }, 9404 }; 9405 9406 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 9407 struct cmd_vf_rx_vlan_filter { 9408 cmdline_fixed_string_t rx_vlan; 9409 cmdline_fixed_string_t what; 9410 uint16_t vlan_id; 9411 cmdline_fixed_string_t port; 9412 portid_t port_id; 9413 cmdline_fixed_string_t vf; 9414 uint64_t vf_mask; 9415 }; 9416 9417 static void 9418 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 9419 __rte_unused struct cmdline *cl, 9420 __rte_unused void *data) 9421 { 9422 struct cmd_vf_rx_vlan_filter *res = parsed_result; 9423 int ret = -ENOTSUP; 9424 9425 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 9426 9427 #ifdef RTE_NET_IXGBE 9428 if (ret == -ENOTSUP) 9429 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 9430 res->vlan_id, res->vf_mask, is_add); 9431 #endif 9432 #ifdef RTE_NET_I40E 9433 if (ret == -ENOTSUP) 9434 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 9435 res->vlan_id, res->vf_mask, is_add); 9436 #endif 9437 #ifdef RTE_NET_BNXT 9438 if (ret == -ENOTSUP) 9439 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 9440 res->vlan_id, res->vf_mask, is_add); 9441 #endif 9442 9443 switch (ret) { 9444 case 0: 9445 break; 9446 case -EINVAL: 9447 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n", 9448 res->vlan_id, res->vf_mask); 9449 break; 9450 case -ENODEV: 9451 fprintf(stderr, "invalid port_id %d\n", res->port_id); 9452 break; 9453 case -ENOTSUP: 9454 fprintf(stderr, "function not implemented or supported\n"); 9455 break; 9456 default: 9457 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 9458 } 9459 } 9460 9461 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 9462 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9463 rx_vlan, "rx_vlan"); 9464 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 9465 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9466 what, "add#rm"); 9467 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 9468 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9469 vlan_id, RTE_UINT16); 9470 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 9471 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9472 port, "port"); 9473 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 9474 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9475 port_id, RTE_UINT16); 9476 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 9477 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9478 vf, "vf"); 9479 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 9480 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9481 vf_mask, RTE_UINT64); 9482 9483 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 9484 .f = cmd_vf_rx_vlan_filter_parsed, 9485 .data = NULL, 9486 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 9487 "(vf_mask = hexadecimal VF mask)", 9488 .tokens = { 9489 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 9490 (void *)&cmd_vf_rx_vlan_filter_what, 9491 (void *)&cmd_vf_rx_vlan_filter_vlanid, 9492 (void *)&cmd_vf_rx_vlan_filter_port, 9493 (void *)&cmd_vf_rx_vlan_filter_portid, 9494 (void *)&cmd_vf_rx_vlan_filter_vf, 9495 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 9496 NULL, 9497 }, 9498 }; 9499 9500 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 9501 struct cmd_queue_rate_limit_result { 9502 cmdline_fixed_string_t set; 9503 cmdline_fixed_string_t port; 9504 uint16_t port_num; 9505 cmdline_fixed_string_t queue; 9506 uint8_t queue_num; 9507 cmdline_fixed_string_t rate; 9508 uint16_t rate_num; 9509 }; 9510 9511 static void cmd_queue_rate_limit_parsed(void *parsed_result, 9512 __rte_unused struct cmdline *cl, 9513 __rte_unused void *data) 9514 { 9515 struct cmd_queue_rate_limit_result *res = parsed_result; 9516 int ret = 0; 9517 9518 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 9519 && (strcmp(res->queue, "queue") == 0) 9520 && (strcmp(res->rate, "rate") == 0)) 9521 ret = set_queue_rate_limit(res->port_num, res->queue_num, 9522 res->rate_num); 9523 if (ret < 0) 9524 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n", 9525 strerror(-ret)); 9526 9527 } 9528 9529 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 9530 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9531 set, "set"); 9532 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 9533 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9534 port, "port"); 9535 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 9536 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9537 port_num, RTE_UINT16); 9538 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 9539 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9540 queue, "queue"); 9541 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 9542 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9543 queue_num, RTE_UINT8); 9544 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 9545 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9546 rate, "rate"); 9547 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 9548 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9549 rate_num, RTE_UINT16); 9550 9551 cmdline_parse_inst_t cmd_queue_rate_limit = { 9552 .f = cmd_queue_rate_limit_parsed, 9553 .data = (void *)0, 9554 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 9555 "Set rate limit for a queue on port_id", 9556 .tokens = { 9557 (void *)&cmd_queue_rate_limit_set, 9558 (void *)&cmd_queue_rate_limit_port, 9559 (void *)&cmd_queue_rate_limit_portnum, 9560 (void *)&cmd_queue_rate_limit_queue, 9561 (void *)&cmd_queue_rate_limit_queuenum, 9562 (void *)&cmd_queue_rate_limit_rate, 9563 (void *)&cmd_queue_rate_limit_ratenum, 9564 NULL, 9565 }, 9566 }; 9567 9568 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 9569 struct cmd_vf_rate_limit_result { 9570 cmdline_fixed_string_t set; 9571 cmdline_fixed_string_t port; 9572 uint16_t port_num; 9573 cmdline_fixed_string_t vf; 9574 uint8_t vf_num; 9575 cmdline_fixed_string_t rate; 9576 uint16_t rate_num; 9577 cmdline_fixed_string_t q_msk; 9578 uint64_t q_msk_val; 9579 }; 9580 9581 static void cmd_vf_rate_limit_parsed(void *parsed_result, 9582 __rte_unused struct cmdline *cl, 9583 __rte_unused void *data) 9584 { 9585 struct cmd_vf_rate_limit_result *res = parsed_result; 9586 int ret = 0; 9587 9588 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 9589 && (strcmp(res->vf, "vf") == 0) 9590 && (strcmp(res->rate, "rate") == 0) 9591 && (strcmp(res->q_msk, "queue_mask") == 0)) 9592 ret = set_vf_rate_limit(res->port_num, res->vf_num, 9593 res->rate_num, res->q_msk_val); 9594 if (ret < 0) 9595 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n", 9596 strerror(-ret)); 9597 9598 } 9599 9600 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 9601 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9602 set, "set"); 9603 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 9604 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9605 port, "port"); 9606 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 9607 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9608 port_num, RTE_UINT16); 9609 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 9610 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9611 vf, "vf"); 9612 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 9613 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9614 vf_num, RTE_UINT8); 9615 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 9616 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9617 rate, "rate"); 9618 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 9619 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9620 rate_num, RTE_UINT16); 9621 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 9622 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9623 q_msk, "queue_mask"); 9624 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 9625 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9626 q_msk_val, RTE_UINT64); 9627 9628 cmdline_parse_inst_t cmd_vf_rate_limit = { 9629 .f = cmd_vf_rate_limit_parsed, 9630 .data = (void *)0, 9631 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 9632 "queue_mask <queue_mask_value>: " 9633 "Set rate limit for queues of VF on port_id", 9634 .tokens = { 9635 (void *)&cmd_vf_rate_limit_set, 9636 (void *)&cmd_vf_rate_limit_port, 9637 (void *)&cmd_vf_rate_limit_portnum, 9638 (void *)&cmd_vf_rate_limit_vf, 9639 (void *)&cmd_vf_rate_limit_vfnum, 9640 (void *)&cmd_vf_rate_limit_rate, 9641 (void *)&cmd_vf_rate_limit_ratenum, 9642 (void *)&cmd_vf_rate_limit_q_msk, 9643 (void *)&cmd_vf_rate_limit_q_msk_val, 9644 NULL, 9645 }, 9646 }; 9647 9648 /* *** CONFIGURE TUNNEL UDP PORT *** */ 9649 struct cmd_tunnel_udp_config { 9650 cmdline_fixed_string_t rx_vxlan_port; 9651 cmdline_fixed_string_t what; 9652 uint16_t udp_port; 9653 portid_t port_id; 9654 }; 9655 9656 static void 9657 cmd_tunnel_udp_config_parsed(void *parsed_result, 9658 __rte_unused struct cmdline *cl, 9659 __rte_unused void *data) 9660 { 9661 struct cmd_tunnel_udp_config *res = parsed_result; 9662 struct rte_eth_udp_tunnel tunnel_udp; 9663 int ret; 9664 9665 tunnel_udp.udp_port = res->udp_port; 9666 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9667 9668 if (!strcmp(res->what, "add")) 9669 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9670 &tunnel_udp); 9671 else 9672 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9673 &tunnel_udp); 9674 9675 if (ret < 0) 9676 fprintf(stderr, "udp tunneling add error: (%s)\n", 9677 strerror(-ret)); 9678 } 9679 9680 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port = 9681 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9682 rx_vxlan_port, "rx_vxlan_port"); 9683 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 9684 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9685 what, "add#rm"); 9686 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 9687 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9688 udp_port, RTE_UINT16); 9689 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 9690 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9691 port_id, RTE_UINT16); 9692 9693 cmdline_parse_inst_t cmd_tunnel_udp_config = { 9694 .f = cmd_tunnel_udp_config_parsed, 9695 .data = (void *)0, 9696 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 9697 "Add/Remove a tunneling UDP port filter", 9698 .tokens = { 9699 (void *)&cmd_tunnel_udp_config_rx_vxlan_port, 9700 (void *)&cmd_tunnel_udp_config_what, 9701 (void *)&cmd_tunnel_udp_config_udp_port, 9702 (void *)&cmd_tunnel_udp_config_port_id, 9703 NULL, 9704 }, 9705 }; 9706 9707 struct cmd_config_tunnel_udp_port { 9708 cmdline_fixed_string_t port; 9709 cmdline_fixed_string_t config; 9710 portid_t port_id; 9711 cmdline_fixed_string_t udp_tunnel_port; 9712 cmdline_fixed_string_t action; 9713 cmdline_fixed_string_t tunnel_type; 9714 uint16_t udp_port; 9715 }; 9716 9717 static void 9718 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 9719 __rte_unused struct cmdline *cl, 9720 __rte_unused void *data) 9721 { 9722 struct cmd_config_tunnel_udp_port *res = parsed_result; 9723 struct rte_eth_udp_tunnel tunnel_udp; 9724 int ret = 0; 9725 9726 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9727 return; 9728 9729 tunnel_udp.udp_port = res->udp_port; 9730 9731 if (!strcmp(res->tunnel_type, "vxlan")) { 9732 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9733 } else if (!strcmp(res->tunnel_type, "geneve")) { 9734 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 9735 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) { 9736 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 9737 } else if (!strcmp(res->tunnel_type, "ecpri")) { 9738 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI; 9739 } else { 9740 fprintf(stderr, "Invalid tunnel type\n"); 9741 return; 9742 } 9743 9744 if (!strcmp(res->action, "add")) 9745 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9746 &tunnel_udp); 9747 else 9748 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9749 &tunnel_udp); 9750 9751 if (ret < 0) 9752 fprintf(stderr, "udp tunneling port add error: (%s)\n", 9753 strerror(-ret)); 9754 } 9755 9756 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 9757 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 9758 "port"); 9759 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 9760 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 9761 "config"); 9762 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 9763 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 9764 RTE_UINT16); 9765 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 9766 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 9767 udp_tunnel_port, 9768 "udp_tunnel_port"); 9769 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 9770 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 9771 "add#rm"); 9772 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 9773 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 9774 "vxlan#geneve#vxlan-gpe#ecpri"); 9775 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 9776 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 9777 RTE_UINT16); 9778 9779 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 9780 .f = cmd_cfg_tunnel_udp_port_parsed, 9781 .data = NULL, 9782 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|" 9783 "geneve|vxlan-gpe|ecpri <udp_port>", 9784 .tokens = { 9785 (void *)&cmd_config_tunnel_udp_port_port, 9786 (void *)&cmd_config_tunnel_udp_port_config, 9787 (void *)&cmd_config_tunnel_udp_port_port_id, 9788 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 9789 (void *)&cmd_config_tunnel_udp_port_action, 9790 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 9791 (void *)&cmd_config_tunnel_udp_port_value, 9792 NULL, 9793 }, 9794 }; 9795 9796 /* ******************************************************************************** */ 9797 9798 struct cmd_dump_result { 9799 cmdline_fixed_string_t dump; 9800 }; 9801 9802 static void 9803 dump_struct_sizes(void) 9804 { 9805 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9806 DUMP_SIZE(struct rte_mbuf); 9807 DUMP_SIZE(struct rte_mempool); 9808 DUMP_SIZE(struct rte_ring); 9809 #undef DUMP_SIZE 9810 } 9811 9812 9813 /* Dump the socket memory statistics on console */ 9814 static void 9815 dump_socket_mem(FILE *f) 9816 { 9817 struct rte_malloc_socket_stats socket_stats; 9818 unsigned int i; 9819 size_t total = 0; 9820 size_t alloc = 0; 9821 size_t free = 0; 9822 unsigned int n_alloc = 0; 9823 unsigned int n_free = 0; 9824 static size_t last_allocs; 9825 static size_t last_total; 9826 9827 9828 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) { 9829 if (rte_malloc_get_socket_stats(i, &socket_stats) || 9830 !socket_stats.heap_totalsz_bytes) 9831 continue; 9832 total += socket_stats.heap_totalsz_bytes; 9833 alloc += socket_stats.heap_allocsz_bytes; 9834 free += socket_stats.heap_freesz_bytes; 9835 n_alloc += socket_stats.alloc_count; 9836 n_free += socket_stats.free_count; 9837 fprintf(f, 9838 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 9839 i, 9840 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024), 9841 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024), 9842 (double)socket_stats.heap_allocsz_bytes * 100 / 9843 (double)socket_stats.heap_totalsz_bytes, 9844 (double)socket_stats.heap_freesz_bytes / (1024 * 1024), 9845 socket_stats.alloc_count, 9846 socket_stats.free_count); 9847 } 9848 fprintf(f, 9849 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 9850 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024), 9851 total ? ((double)alloc * 100 / (double)total) : 0, 9852 (double)free / (1024 * 1024), 9853 n_alloc, n_free); 9854 if (last_allocs) 9855 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n", 9856 ((double)total - (double)last_total) / (1024 * 1024), 9857 (double)(alloc - (double)last_allocs) / 1024 / 1024); 9858 last_allocs = alloc; 9859 last_total = total; 9860 } 9861 9862 static void cmd_dump_parsed(void *parsed_result, 9863 __rte_unused struct cmdline *cl, 9864 __rte_unused void *data) 9865 { 9866 struct cmd_dump_result *res = parsed_result; 9867 9868 if (!strcmp(res->dump, "dump_physmem")) 9869 rte_dump_physmem_layout(stdout); 9870 else if (!strcmp(res->dump, "dump_socket_mem")) 9871 dump_socket_mem(stdout); 9872 else if (!strcmp(res->dump, "dump_memzone")) 9873 rte_memzone_dump(stdout); 9874 else if (!strcmp(res->dump, "dump_struct_sizes")) 9875 dump_struct_sizes(); 9876 else if (!strcmp(res->dump, "dump_ring")) 9877 rte_ring_list_dump(stdout); 9878 else if (!strcmp(res->dump, "dump_mempool")) 9879 rte_mempool_list_dump(stdout); 9880 else if (!strcmp(res->dump, "dump_devargs")) 9881 rte_devargs_dump(stdout); 9882 else if (!strcmp(res->dump, "dump_log_types")) 9883 rte_log_dump(stdout); 9884 } 9885 9886 cmdline_parse_token_string_t cmd_dump_dump = 9887 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9888 "dump_physmem#" 9889 "dump_memzone#" 9890 "dump_socket_mem#" 9891 "dump_struct_sizes#" 9892 "dump_ring#" 9893 "dump_mempool#" 9894 "dump_devargs#" 9895 "dump_log_types"); 9896 9897 cmdline_parse_inst_t cmd_dump = { 9898 .f = cmd_dump_parsed, /* function to call */ 9899 .data = NULL, /* 2nd arg of func */ 9900 .help_str = "Dump status", 9901 .tokens = { /* token list, NULL terminated */ 9902 (void *)&cmd_dump_dump, 9903 NULL, 9904 }, 9905 }; 9906 9907 /* ******************************************************************************** */ 9908 9909 struct cmd_dump_one_result { 9910 cmdline_fixed_string_t dump; 9911 cmdline_fixed_string_t name; 9912 }; 9913 9914 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9915 __rte_unused void *data) 9916 { 9917 struct cmd_dump_one_result *res = parsed_result; 9918 9919 if (!strcmp(res->dump, "dump_ring")) { 9920 struct rte_ring *r; 9921 r = rte_ring_lookup(res->name); 9922 if (r == NULL) { 9923 cmdline_printf(cl, "Cannot find ring\n"); 9924 return; 9925 } 9926 rte_ring_dump(stdout, r); 9927 } else if (!strcmp(res->dump, "dump_mempool")) { 9928 struct rte_mempool *mp; 9929 mp = rte_mempool_lookup(res->name); 9930 if (mp == NULL) { 9931 cmdline_printf(cl, "Cannot find mempool\n"); 9932 return; 9933 } 9934 rte_mempool_dump(stdout, mp); 9935 } 9936 } 9937 9938 cmdline_parse_token_string_t cmd_dump_one_dump = 9939 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9940 "dump_ring#dump_mempool"); 9941 9942 cmdline_parse_token_string_t cmd_dump_one_name = 9943 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9944 9945 cmdline_parse_inst_t cmd_dump_one = { 9946 .f = cmd_dump_one_parsed, /* function to call */ 9947 .data = NULL, /* 2nd arg of func */ 9948 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9949 .tokens = { /* token list, NULL terminated */ 9950 (void *)&cmd_dump_one_dump, 9951 (void *)&cmd_dump_one_name, 9952 NULL, 9953 }, 9954 }; 9955 9956 /* *** queue region set *** */ 9957 struct cmd_queue_region_result { 9958 cmdline_fixed_string_t set; 9959 cmdline_fixed_string_t port; 9960 portid_t port_id; 9961 cmdline_fixed_string_t cmd; 9962 cmdline_fixed_string_t region; 9963 uint8_t region_id; 9964 cmdline_fixed_string_t queue_start_index; 9965 uint8_t queue_id; 9966 cmdline_fixed_string_t queue_num; 9967 uint8_t queue_num_value; 9968 }; 9969 9970 static void 9971 cmd_queue_region_parsed(void *parsed_result, 9972 __rte_unused struct cmdline *cl, 9973 __rte_unused void *data) 9974 { 9975 struct cmd_queue_region_result *res = parsed_result; 9976 int ret = -ENOTSUP; 9977 #ifdef RTE_NET_I40E 9978 struct rte_pmd_i40e_queue_region_conf region_conf; 9979 enum rte_pmd_i40e_queue_region_op op_type; 9980 #endif 9981 9982 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9983 return; 9984 9985 #ifdef RTE_NET_I40E 9986 memset(®ion_conf, 0, sizeof(region_conf)); 9987 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 9988 region_conf.region_id = res->region_id; 9989 region_conf.queue_num = res->queue_num_value; 9990 region_conf.queue_start_index = res->queue_id; 9991 9992 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9993 op_type, ®ion_conf); 9994 #endif 9995 9996 switch (ret) { 9997 case 0: 9998 break; 9999 case -ENOTSUP: 10000 fprintf(stderr, "function not implemented or supported\n"); 10001 break; 10002 default: 10003 fprintf(stderr, "queue region config error: (%s)\n", 10004 strerror(-ret)); 10005 } 10006 } 10007 10008 cmdline_parse_token_string_t cmd_queue_region_set = 10009 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 10010 set, "set"); 10011 cmdline_parse_token_string_t cmd_queue_region_port = 10012 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 10013 cmdline_parse_token_num_t cmd_queue_region_port_id = 10014 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 10015 port_id, RTE_UINT16); 10016 cmdline_parse_token_string_t cmd_queue_region_cmd = 10017 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 10018 cmd, "queue-region"); 10019 cmdline_parse_token_string_t cmd_queue_region_id = 10020 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 10021 region, "region_id"); 10022 cmdline_parse_token_num_t cmd_queue_region_index = 10023 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 10024 region_id, RTE_UINT8); 10025 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 10026 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 10027 queue_start_index, "queue_start_index"); 10028 cmdline_parse_token_num_t cmd_queue_region_queue_id = 10029 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 10030 queue_id, RTE_UINT8); 10031 cmdline_parse_token_string_t cmd_queue_region_queue_num = 10032 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 10033 queue_num, "queue_num"); 10034 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 10035 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 10036 queue_num_value, RTE_UINT8); 10037 10038 cmdline_parse_inst_t cmd_queue_region = { 10039 .f = cmd_queue_region_parsed, 10040 .data = NULL, 10041 .help_str = "set port <port_id> queue-region region_id <value> " 10042 "queue_start_index <value> queue_num <value>: Set a queue region", 10043 .tokens = { 10044 (void *)&cmd_queue_region_set, 10045 (void *)&cmd_queue_region_port, 10046 (void *)&cmd_queue_region_port_id, 10047 (void *)&cmd_queue_region_cmd, 10048 (void *)&cmd_queue_region_id, 10049 (void *)&cmd_queue_region_index, 10050 (void *)&cmd_queue_region_queue_start_index, 10051 (void *)&cmd_queue_region_queue_id, 10052 (void *)&cmd_queue_region_queue_num, 10053 (void *)&cmd_queue_region_queue_num_value, 10054 NULL, 10055 }, 10056 }; 10057 10058 /* *** queue region and flowtype set *** */ 10059 struct cmd_region_flowtype_result { 10060 cmdline_fixed_string_t set; 10061 cmdline_fixed_string_t port; 10062 portid_t port_id; 10063 cmdline_fixed_string_t cmd; 10064 cmdline_fixed_string_t region; 10065 uint8_t region_id; 10066 cmdline_fixed_string_t flowtype; 10067 uint8_t flowtype_id; 10068 }; 10069 10070 static void 10071 cmd_region_flowtype_parsed(void *parsed_result, 10072 __rte_unused struct cmdline *cl, 10073 __rte_unused void *data) 10074 { 10075 struct cmd_region_flowtype_result *res = parsed_result; 10076 int ret = -ENOTSUP; 10077 #ifdef RTE_NET_I40E 10078 struct rte_pmd_i40e_queue_region_conf region_conf; 10079 enum rte_pmd_i40e_queue_region_op op_type; 10080 #endif 10081 10082 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10083 return; 10084 10085 #ifdef RTE_NET_I40E 10086 memset(®ion_conf, 0, sizeof(region_conf)); 10087 10088 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 10089 region_conf.region_id = res->region_id; 10090 region_conf.hw_flowtype = res->flowtype_id; 10091 10092 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10093 op_type, ®ion_conf); 10094 #endif 10095 10096 switch (ret) { 10097 case 0: 10098 break; 10099 case -ENOTSUP: 10100 fprintf(stderr, "function not implemented or supported\n"); 10101 break; 10102 default: 10103 fprintf(stderr, "region flowtype config error: (%s)\n", 10104 strerror(-ret)); 10105 } 10106 } 10107 10108 cmdline_parse_token_string_t cmd_region_flowtype_set = 10109 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 10110 set, "set"); 10111 cmdline_parse_token_string_t cmd_region_flowtype_port = 10112 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 10113 port, "port"); 10114 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 10115 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 10116 port_id, RTE_UINT16); 10117 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 10118 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 10119 cmd, "queue-region"); 10120 cmdline_parse_token_string_t cmd_region_flowtype_index = 10121 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 10122 region, "region_id"); 10123 cmdline_parse_token_num_t cmd_region_flowtype_id = 10124 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 10125 region_id, RTE_UINT8); 10126 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 10127 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 10128 flowtype, "flowtype"); 10129 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 10130 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 10131 flowtype_id, RTE_UINT8); 10132 cmdline_parse_inst_t cmd_region_flowtype = { 10133 .f = cmd_region_flowtype_parsed, 10134 .data = NULL, 10135 .help_str = "set port <port_id> queue-region region_id <value> " 10136 "flowtype <value>: Set a flowtype region index", 10137 .tokens = { 10138 (void *)&cmd_region_flowtype_set, 10139 (void *)&cmd_region_flowtype_port, 10140 (void *)&cmd_region_flowtype_port_index, 10141 (void *)&cmd_region_flowtype_cmd, 10142 (void *)&cmd_region_flowtype_index, 10143 (void *)&cmd_region_flowtype_id, 10144 (void *)&cmd_region_flowtype_flow_index, 10145 (void *)&cmd_region_flowtype_flow_id, 10146 NULL, 10147 }, 10148 }; 10149 10150 /* *** User Priority (UP) to queue region (region_id) set *** */ 10151 struct cmd_user_priority_region_result { 10152 cmdline_fixed_string_t set; 10153 cmdline_fixed_string_t port; 10154 portid_t port_id; 10155 cmdline_fixed_string_t cmd; 10156 cmdline_fixed_string_t user_priority; 10157 uint8_t user_priority_id; 10158 cmdline_fixed_string_t region; 10159 uint8_t region_id; 10160 }; 10161 10162 static void 10163 cmd_user_priority_region_parsed(void *parsed_result, 10164 __rte_unused struct cmdline *cl, 10165 __rte_unused void *data) 10166 { 10167 struct cmd_user_priority_region_result *res = parsed_result; 10168 int ret = -ENOTSUP; 10169 #ifdef RTE_NET_I40E 10170 struct rte_pmd_i40e_queue_region_conf region_conf; 10171 enum rte_pmd_i40e_queue_region_op op_type; 10172 #endif 10173 10174 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10175 return; 10176 10177 #ifdef RTE_NET_I40E 10178 memset(®ion_conf, 0, sizeof(region_conf)); 10179 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 10180 region_conf.user_priority = res->user_priority_id; 10181 region_conf.region_id = res->region_id; 10182 10183 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10184 op_type, ®ion_conf); 10185 #endif 10186 10187 switch (ret) { 10188 case 0: 10189 break; 10190 case -ENOTSUP: 10191 fprintf(stderr, "function not implemented or supported\n"); 10192 break; 10193 default: 10194 fprintf(stderr, "user_priority region config error: (%s)\n", 10195 strerror(-ret)); 10196 } 10197 } 10198 10199 cmdline_parse_token_string_t cmd_user_priority_region_set = 10200 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10201 set, "set"); 10202 cmdline_parse_token_string_t cmd_user_priority_region_port = 10203 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10204 port, "port"); 10205 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 10206 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10207 port_id, RTE_UINT16); 10208 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 10209 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10210 cmd, "queue-region"); 10211 cmdline_parse_token_string_t cmd_user_priority_region_UP = 10212 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10213 user_priority, "UP"); 10214 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 10215 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10216 user_priority_id, RTE_UINT8); 10217 cmdline_parse_token_string_t cmd_user_priority_region_region = 10218 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10219 region, "region_id"); 10220 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 10221 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10222 region_id, RTE_UINT8); 10223 10224 cmdline_parse_inst_t cmd_user_priority_region = { 10225 .f = cmd_user_priority_region_parsed, 10226 .data = NULL, 10227 .help_str = "set port <port_id> queue-region UP <value> " 10228 "region_id <value>: Set the mapping of User Priority (UP) " 10229 "to queue region (region_id) ", 10230 .tokens = { 10231 (void *)&cmd_user_priority_region_set, 10232 (void *)&cmd_user_priority_region_port, 10233 (void *)&cmd_user_priority_region_port_index, 10234 (void *)&cmd_user_priority_region_cmd, 10235 (void *)&cmd_user_priority_region_UP, 10236 (void *)&cmd_user_priority_region_UP_id, 10237 (void *)&cmd_user_priority_region_region, 10238 (void *)&cmd_user_priority_region_region_id, 10239 NULL, 10240 }, 10241 }; 10242 10243 /* *** flush all queue region related configuration *** */ 10244 struct cmd_flush_queue_region_result { 10245 cmdline_fixed_string_t set; 10246 cmdline_fixed_string_t port; 10247 portid_t port_id; 10248 cmdline_fixed_string_t cmd; 10249 cmdline_fixed_string_t flush; 10250 cmdline_fixed_string_t what; 10251 }; 10252 10253 static void 10254 cmd_flush_queue_region_parsed(void *parsed_result, 10255 __rte_unused struct cmdline *cl, 10256 __rte_unused void *data) 10257 { 10258 struct cmd_flush_queue_region_result *res = parsed_result; 10259 int ret = -ENOTSUP; 10260 #ifdef RTE_NET_I40E 10261 struct rte_pmd_i40e_queue_region_conf region_conf; 10262 enum rte_pmd_i40e_queue_region_op op_type; 10263 #endif 10264 10265 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10266 return; 10267 10268 #ifdef RTE_NET_I40E 10269 memset(®ion_conf, 0, sizeof(region_conf)); 10270 10271 if (strcmp(res->what, "on") == 0) 10272 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 10273 else 10274 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 10275 10276 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10277 op_type, ®ion_conf); 10278 #endif 10279 10280 switch (ret) { 10281 case 0: 10282 break; 10283 case -ENOTSUP: 10284 fprintf(stderr, "function not implemented or supported\n"); 10285 break; 10286 default: 10287 fprintf(stderr, "queue region config flush error: (%s)\n", 10288 strerror(-ret)); 10289 } 10290 } 10291 10292 cmdline_parse_token_string_t cmd_flush_queue_region_set = 10293 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10294 set, "set"); 10295 cmdline_parse_token_string_t cmd_flush_queue_region_port = 10296 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10297 port, "port"); 10298 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 10299 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 10300 port_id, RTE_UINT16); 10301 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 10302 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10303 cmd, "queue-region"); 10304 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 10305 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10306 flush, "flush"); 10307 cmdline_parse_token_string_t cmd_flush_queue_region_what = 10308 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10309 what, "on#off"); 10310 10311 cmdline_parse_inst_t cmd_flush_queue_region = { 10312 .f = cmd_flush_queue_region_parsed, 10313 .data = NULL, 10314 .help_str = "set port <port_id> queue-region flush on|off" 10315 ": flush all queue region related configuration", 10316 .tokens = { 10317 (void *)&cmd_flush_queue_region_set, 10318 (void *)&cmd_flush_queue_region_port, 10319 (void *)&cmd_flush_queue_region_port_index, 10320 (void *)&cmd_flush_queue_region_cmd, 10321 (void *)&cmd_flush_queue_region_flush, 10322 (void *)&cmd_flush_queue_region_what, 10323 NULL, 10324 }, 10325 }; 10326 10327 /* *** get all queue region related configuration info *** */ 10328 struct cmd_show_queue_region_info { 10329 cmdline_fixed_string_t show; 10330 cmdline_fixed_string_t port; 10331 portid_t port_id; 10332 cmdline_fixed_string_t cmd; 10333 }; 10334 10335 static void 10336 cmd_show_queue_region_info_parsed(void *parsed_result, 10337 __rte_unused struct cmdline *cl, 10338 __rte_unused void *data) 10339 { 10340 struct cmd_show_queue_region_info *res = parsed_result; 10341 int ret = -ENOTSUP; 10342 #ifdef RTE_NET_I40E 10343 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 10344 enum rte_pmd_i40e_queue_region_op op_type; 10345 #endif 10346 10347 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10348 return; 10349 10350 #ifdef RTE_NET_I40E 10351 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 10352 10353 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 10354 10355 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10356 op_type, &rte_pmd_regions); 10357 10358 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 10359 #endif 10360 10361 switch (ret) { 10362 case 0: 10363 break; 10364 case -ENOTSUP: 10365 fprintf(stderr, "function not implemented or supported\n"); 10366 break; 10367 default: 10368 fprintf(stderr, "queue region config info show error: (%s)\n", 10369 strerror(-ret)); 10370 } 10371 } 10372 10373 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 10374 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10375 show, "show"); 10376 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 10377 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10378 port, "port"); 10379 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 10380 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 10381 port_id, RTE_UINT16); 10382 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 10383 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10384 cmd, "queue-region"); 10385 10386 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 10387 .f = cmd_show_queue_region_info_parsed, 10388 .data = NULL, 10389 .help_str = "show port <port_id> queue-region" 10390 ": show all queue region related configuration info", 10391 .tokens = { 10392 (void *)&cmd_show_queue_region_info_get, 10393 (void *)&cmd_show_queue_region_info_port, 10394 (void *)&cmd_show_queue_region_info_port_index, 10395 (void *)&cmd_show_queue_region_info_cmd, 10396 NULL, 10397 }, 10398 }; 10399 10400 /* *** Filters Control *** */ 10401 10402 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10403 do { \ 10404 if ((ip_addr).family == AF_INET) \ 10405 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10406 else { \ 10407 fprintf(stderr, "invalid parameter.\n"); \ 10408 return; \ 10409 } \ 10410 } while (0) 10411 10412 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10413 do { \ 10414 if ((ip_addr).family == AF_INET6) \ 10415 rte_memcpy(&(ip), \ 10416 &((ip_addr).addr.ipv6), \ 10417 sizeof(struct in6_addr)); \ 10418 else { \ 10419 fprintf(stderr, "invalid parameter.\n"); \ 10420 return; \ 10421 } \ 10422 } while (0) 10423 10424 #ifdef RTE_NET_I40E 10425 10426 static uint16_t 10427 str2flowtype(char *string) 10428 { 10429 uint8_t i = 0; 10430 static const struct { 10431 char str[32]; 10432 uint16_t type; 10433 } flowtype_str[] = { 10434 {"raw", RTE_ETH_FLOW_RAW}, 10435 {"ipv4", RTE_ETH_FLOW_IPV4}, 10436 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10437 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10438 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10439 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10440 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10441 {"ipv6", RTE_ETH_FLOW_IPV6}, 10442 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10443 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10444 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10445 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10446 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10447 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10448 }; 10449 10450 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10451 if (!strcmp(flowtype_str[i].str, string)) 10452 return flowtype_str[i].type; 10453 } 10454 10455 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10456 return (uint16_t)atoi(string); 10457 10458 return RTE_ETH_FLOW_UNKNOWN; 10459 } 10460 10461 /* *** deal with flow director filter *** */ 10462 struct cmd_flow_director_result { 10463 cmdline_fixed_string_t flow_director_filter; 10464 portid_t port_id; 10465 cmdline_fixed_string_t mode; 10466 cmdline_fixed_string_t mode_value; 10467 cmdline_fixed_string_t ops; 10468 cmdline_fixed_string_t flow; 10469 cmdline_fixed_string_t flow_type; 10470 cmdline_fixed_string_t drop; 10471 cmdline_fixed_string_t queue; 10472 uint16_t queue_id; 10473 cmdline_fixed_string_t fd_id; 10474 uint32_t fd_id_value; 10475 cmdline_fixed_string_t packet; 10476 char filepath[]; 10477 }; 10478 10479 static void 10480 cmd_flow_director_filter_parsed(void *parsed_result, 10481 __rte_unused struct cmdline *cl, 10482 __rte_unused void *data) 10483 { 10484 struct cmd_flow_director_result *res = parsed_result; 10485 int ret = 0; 10486 struct rte_pmd_i40e_flow_type_mapping 10487 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 10488 struct rte_pmd_i40e_pkt_template_conf conf; 10489 uint16_t flow_type = str2flowtype(res->flow_type); 10490 uint16_t i, port = res->port_id; 10491 uint8_t add; 10492 10493 memset(&conf, 0, sizeof(conf)); 10494 10495 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 10496 fprintf(stderr, "Invalid flow type specified.\n"); 10497 return; 10498 } 10499 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 10500 mapping); 10501 if (ret) 10502 return; 10503 if (mapping[flow_type].pctype == 0ULL) { 10504 fprintf(stderr, "Invalid flow type specified.\n"); 10505 return; 10506 } 10507 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 10508 if (mapping[flow_type].pctype & (1ULL << i)) { 10509 conf.input.pctype = i; 10510 break; 10511 } 10512 } 10513 10514 conf.input.packet = open_file(res->filepath, 10515 &conf.input.length); 10516 if (!conf.input.packet) 10517 return; 10518 if (!strcmp(res->drop, "drop")) 10519 conf.action.behavior = 10520 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 10521 else 10522 conf.action.behavior = 10523 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 10524 conf.action.report_status = 10525 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 10526 conf.action.rx_queue = res->queue_id; 10527 conf.soft_id = res->fd_id_value; 10528 add = strcmp(res->ops, "del") ? 1 : 0; 10529 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 10530 &conf, 10531 add); 10532 if (ret < 0) 10533 fprintf(stderr, "flow director config error: (%s)\n", 10534 strerror(-ret)); 10535 close_file(conf.input.packet); 10536 } 10537 10538 cmdline_parse_token_string_t cmd_flow_director_filter = 10539 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10540 flow_director_filter, "flow_director_filter"); 10541 cmdline_parse_token_num_t cmd_flow_director_port_id = 10542 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10543 port_id, RTE_UINT16); 10544 cmdline_parse_token_string_t cmd_flow_director_ops = 10545 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10546 ops, "add#del#update"); 10547 cmdline_parse_token_string_t cmd_flow_director_flow = 10548 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10549 flow, "flow"); 10550 cmdline_parse_token_string_t cmd_flow_director_flow_type = 10551 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10552 flow_type, NULL); 10553 cmdline_parse_token_string_t cmd_flow_director_drop = 10554 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10555 drop, "drop#fwd"); 10556 cmdline_parse_token_string_t cmd_flow_director_queue = 10557 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10558 queue, "queue"); 10559 cmdline_parse_token_num_t cmd_flow_director_queue_id = 10560 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10561 queue_id, RTE_UINT16); 10562 cmdline_parse_token_string_t cmd_flow_director_fd_id = 10563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10564 fd_id, "fd_id"); 10565 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 10566 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10567 fd_id_value, RTE_UINT32); 10568 10569 cmdline_parse_token_string_t cmd_flow_director_mode = 10570 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10571 mode, "mode"); 10572 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 10573 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10574 mode_value, "raw"); 10575 cmdline_parse_token_string_t cmd_flow_director_packet = 10576 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10577 packet, "packet"); 10578 cmdline_parse_token_string_t cmd_flow_director_filepath = 10579 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10580 filepath, NULL); 10581 10582 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 10583 .f = cmd_flow_director_filter_parsed, 10584 .data = NULL, 10585 .help_str = "flow_director_filter ... : Add or delete a raw flow " 10586 "director entry on NIC", 10587 .tokens = { 10588 (void *)&cmd_flow_director_filter, 10589 (void *)&cmd_flow_director_port_id, 10590 (void *)&cmd_flow_director_mode, 10591 (void *)&cmd_flow_director_mode_raw, 10592 (void *)&cmd_flow_director_ops, 10593 (void *)&cmd_flow_director_flow, 10594 (void *)&cmd_flow_director_flow_type, 10595 (void *)&cmd_flow_director_drop, 10596 (void *)&cmd_flow_director_queue, 10597 (void *)&cmd_flow_director_queue_id, 10598 (void *)&cmd_flow_director_fd_id, 10599 (void *)&cmd_flow_director_fd_id_value, 10600 (void *)&cmd_flow_director_packet, 10601 (void *)&cmd_flow_director_filepath, 10602 NULL, 10603 }, 10604 }; 10605 10606 #endif /* RTE_NET_I40E */ 10607 10608 /* *** deal with flow director mask *** */ 10609 struct cmd_flow_director_mask_result { 10610 cmdline_fixed_string_t flow_director_mask; 10611 portid_t port_id; 10612 cmdline_fixed_string_t mode; 10613 cmdline_fixed_string_t mode_value; 10614 cmdline_fixed_string_t vlan; 10615 uint16_t vlan_mask; 10616 cmdline_fixed_string_t src_mask; 10617 cmdline_ipaddr_t ipv4_src; 10618 cmdline_ipaddr_t ipv6_src; 10619 uint16_t port_src; 10620 cmdline_fixed_string_t dst_mask; 10621 cmdline_ipaddr_t ipv4_dst; 10622 cmdline_ipaddr_t ipv6_dst; 10623 uint16_t port_dst; 10624 cmdline_fixed_string_t mac; 10625 uint8_t mac_addr_byte_mask; 10626 cmdline_fixed_string_t tunnel_id; 10627 uint32_t tunnel_id_mask; 10628 cmdline_fixed_string_t tunnel_type; 10629 uint8_t tunnel_type_mask; 10630 }; 10631 10632 static void 10633 cmd_flow_director_mask_parsed(void *parsed_result, 10634 __rte_unused struct cmdline *cl, 10635 __rte_unused void *data) 10636 { 10637 struct cmd_flow_director_mask_result *res = parsed_result; 10638 struct rte_eth_fdir_masks *mask; 10639 struct rte_port *port; 10640 10641 port = &ports[res->port_id]; 10642 /** Check if the port is not started **/ 10643 if (port->port_status != RTE_PORT_STOPPED) { 10644 fprintf(stderr, "Please stop port %d first\n", res->port_id); 10645 return; 10646 } 10647 10648 mask = &port->dev_conf.fdir_conf.mask; 10649 10650 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10651 if (strcmp(res->mode_value, "MAC-VLAN")) { 10652 fprintf(stderr, "Please set mode to MAC-VLAN.\n"); 10653 return; 10654 } 10655 10656 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10657 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10658 if (strcmp(res->mode_value, "Tunnel")) { 10659 fprintf(stderr, "Please set mode to Tunnel.\n"); 10660 return; 10661 } 10662 10663 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10664 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 10665 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 10666 mask->tunnel_type_mask = res->tunnel_type_mask; 10667 } else { 10668 if (strcmp(res->mode_value, "IP")) { 10669 fprintf(stderr, "Please set mode to IP.\n"); 10670 return; 10671 } 10672 10673 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10674 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 10675 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 10676 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 10677 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 10678 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 10679 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 10680 } 10681 10682 cmd_reconfig_device_queue(res->port_id, 1, 1); 10683 } 10684 10685 cmdline_parse_token_string_t cmd_flow_director_mask = 10686 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10687 flow_director_mask, "flow_director_mask"); 10688 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 10689 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10690 port_id, RTE_UINT16); 10691 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 10692 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10693 vlan, "vlan"); 10694 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 10695 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10696 vlan_mask, RTE_UINT16); 10697 cmdline_parse_token_string_t cmd_flow_director_mask_src = 10698 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10699 src_mask, "src_mask"); 10700 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 10701 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10702 ipv4_src); 10703 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 10704 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10705 ipv6_src); 10706 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 10707 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10708 port_src, RTE_UINT16); 10709 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 10710 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10711 dst_mask, "dst_mask"); 10712 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 10713 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10714 ipv4_dst); 10715 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 10716 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10717 ipv6_dst); 10718 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 10719 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10720 port_dst, RTE_UINT16); 10721 10722 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 10723 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10724 mode, "mode"); 10725 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 10726 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10727 mode_value, "IP"); 10728 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 10729 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10730 mode_value, "MAC-VLAN"); 10731 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 10732 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10733 mode_value, "Tunnel"); 10734 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 10735 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10736 mac, "mac"); 10737 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 10738 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10739 mac_addr_byte_mask, RTE_UINT8); 10740 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 10741 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10742 tunnel_type, "tunnel-type"); 10743 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 10744 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10745 tunnel_type_mask, RTE_UINT8); 10746 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 10747 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10748 tunnel_id, "tunnel-id"); 10749 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 10750 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10751 tunnel_id_mask, RTE_UINT32); 10752 10753 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 10754 .f = cmd_flow_director_mask_parsed, 10755 .data = NULL, 10756 .help_str = "flow_director_mask ... : " 10757 "Set IP mode flow director's mask on NIC", 10758 .tokens = { 10759 (void *)&cmd_flow_director_mask, 10760 (void *)&cmd_flow_director_mask_port_id, 10761 (void *)&cmd_flow_director_mask_mode, 10762 (void *)&cmd_flow_director_mask_mode_ip, 10763 (void *)&cmd_flow_director_mask_vlan, 10764 (void *)&cmd_flow_director_mask_vlan_value, 10765 (void *)&cmd_flow_director_mask_src, 10766 (void *)&cmd_flow_director_mask_ipv4_src, 10767 (void *)&cmd_flow_director_mask_ipv6_src, 10768 (void *)&cmd_flow_director_mask_port_src, 10769 (void *)&cmd_flow_director_mask_dst, 10770 (void *)&cmd_flow_director_mask_ipv4_dst, 10771 (void *)&cmd_flow_director_mask_ipv6_dst, 10772 (void *)&cmd_flow_director_mask_port_dst, 10773 NULL, 10774 }, 10775 }; 10776 10777 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 10778 .f = cmd_flow_director_mask_parsed, 10779 .data = NULL, 10780 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 10781 "flow director's mask on NIC", 10782 .tokens = { 10783 (void *)&cmd_flow_director_mask, 10784 (void *)&cmd_flow_director_mask_port_id, 10785 (void *)&cmd_flow_director_mask_mode, 10786 (void *)&cmd_flow_director_mask_mode_mac_vlan, 10787 (void *)&cmd_flow_director_mask_vlan, 10788 (void *)&cmd_flow_director_mask_vlan_value, 10789 NULL, 10790 }, 10791 }; 10792 10793 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 10794 .f = cmd_flow_director_mask_parsed, 10795 .data = NULL, 10796 .help_str = "flow_director_mask ... : Set tunnel mode " 10797 "flow director's mask on NIC", 10798 .tokens = { 10799 (void *)&cmd_flow_director_mask, 10800 (void *)&cmd_flow_director_mask_port_id, 10801 (void *)&cmd_flow_director_mask_mode, 10802 (void *)&cmd_flow_director_mask_mode_tunnel, 10803 (void *)&cmd_flow_director_mask_vlan, 10804 (void *)&cmd_flow_director_mask_vlan_value, 10805 (void *)&cmd_flow_director_mask_mac, 10806 (void *)&cmd_flow_director_mask_mac_value, 10807 (void *)&cmd_flow_director_mask_tunnel_type, 10808 (void *)&cmd_flow_director_mask_tunnel_type_value, 10809 (void *)&cmd_flow_director_mask_tunnel_id, 10810 (void *)&cmd_flow_director_mask_tunnel_id_value, 10811 NULL, 10812 }, 10813 }; 10814 10815 /* *** deal with flow director flexible payload configuration *** */ 10816 struct cmd_flow_director_flexpayload_result { 10817 cmdline_fixed_string_t flow_director_flexpayload; 10818 portid_t port_id; 10819 cmdline_fixed_string_t payload_layer; 10820 cmdline_fixed_string_t payload_cfg; 10821 }; 10822 10823 static inline int 10824 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 10825 { 10826 char s[256]; 10827 const char *p, *p0 = q_arg; 10828 char *end; 10829 unsigned long int_fld; 10830 char *str_fld[max_num]; 10831 int i; 10832 unsigned size; 10833 int ret = -1; 10834 10835 p = strchr(p0, '('); 10836 if (p == NULL) 10837 return -1; 10838 ++p; 10839 p0 = strchr(p, ')'); 10840 if (p0 == NULL) 10841 return -1; 10842 10843 size = p0 - p; 10844 if (size >= sizeof(s)) 10845 return -1; 10846 10847 snprintf(s, sizeof(s), "%.*s", size, p); 10848 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10849 if (ret < 0 || ret > max_num) 10850 return -1; 10851 for (i = 0; i < ret; i++) { 10852 errno = 0; 10853 int_fld = strtoul(str_fld[i], &end, 0); 10854 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 10855 return -1; 10856 offsets[i] = (uint16_t)int_fld; 10857 } 10858 return ret; 10859 } 10860 10861 static void 10862 cmd_flow_director_flxpld_parsed(void *parsed_result, 10863 __rte_unused struct cmdline *cl, 10864 __rte_unused void *data) 10865 { 10866 struct cmd_flow_director_flexpayload_result *res = parsed_result; 10867 struct rte_eth_flex_payload_cfg flex_cfg; 10868 struct rte_port *port; 10869 int ret = 0; 10870 10871 port = &ports[res->port_id]; 10872 /** Check if the port is not started **/ 10873 if (port->port_status != RTE_PORT_STOPPED) { 10874 fprintf(stderr, "Please stop port %d first\n", res->port_id); 10875 return; 10876 } 10877 10878 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 10879 10880 if (!strcmp(res->payload_layer, "raw")) 10881 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 10882 else if (!strcmp(res->payload_layer, "l2")) 10883 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 10884 else if (!strcmp(res->payload_layer, "l3")) 10885 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 10886 else if (!strcmp(res->payload_layer, "l4")) 10887 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 10888 10889 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 10890 RTE_ETH_FDIR_MAX_FLEXLEN); 10891 if (ret < 0) { 10892 fprintf(stderr, "error: Cannot parse flex payload input.\n"); 10893 return; 10894 } 10895 10896 fdir_set_flex_payload(res->port_id, &flex_cfg); 10897 cmd_reconfig_device_queue(res->port_id, 1, 1); 10898 } 10899 10900 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 10901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10902 flow_director_flexpayload, 10903 "flow_director_flex_payload"); 10904 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 10905 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10906 port_id, RTE_UINT16); 10907 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 10908 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10909 payload_layer, "raw#l2#l3#l4"); 10910 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 10911 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10912 payload_cfg, NULL); 10913 10914 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 10915 .f = cmd_flow_director_flxpld_parsed, 10916 .data = NULL, 10917 .help_str = "flow_director_flexpayload ... : " 10918 "Set flow director's flex payload on NIC", 10919 .tokens = { 10920 (void *)&cmd_flow_director_flexpayload, 10921 (void *)&cmd_flow_director_flexpayload_port_id, 10922 (void *)&cmd_flow_director_flexpayload_payload_layer, 10923 (void *)&cmd_flow_director_flexpayload_payload_cfg, 10924 NULL, 10925 }, 10926 }; 10927 10928 /* Generic flow interface command. */ 10929 extern cmdline_parse_inst_t cmd_flow; 10930 10931 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 10932 struct cmd_mcast_addr_result { 10933 cmdline_fixed_string_t mcast_addr_cmd; 10934 cmdline_fixed_string_t what; 10935 uint16_t port_num; 10936 struct rte_ether_addr mc_addr; 10937 }; 10938 10939 static void cmd_mcast_addr_parsed(void *parsed_result, 10940 __rte_unused struct cmdline *cl, 10941 __rte_unused void *data) 10942 { 10943 struct cmd_mcast_addr_result *res = parsed_result; 10944 10945 if (!rte_is_multicast_ether_addr(&res->mc_addr)) { 10946 fprintf(stderr, 10947 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n", 10948 RTE_ETHER_ADDR_BYTES(&res->mc_addr)); 10949 return; 10950 } 10951 if (strcmp(res->what, "add") == 0) 10952 mcast_addr_add(res->port_num, &res->mc_addr); 10953 else 10954 mcast_addr_remove(res->port_num, &res->mc_addr); 10955 } 10956 10957 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 10958 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 10959 mcast_addr_cmd, "mcast_addr"); 10960 cmdline_parse_token_string_t cmd_mcast_addr_what = 10961 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 10962 "add#remove"); 10963 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 10964 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, 10965 RTE_UINT16); 10966 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 10967 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 10968 10969 cmdline_parse_inst_t cmd_mcast_addr = { 10970 .f = cmd_mcast_addr_parsed, 10971 .data = (void *)0, 10972 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 10973 "Add/Remove multicast MAC address on port_id", 10974 .tokens = { 10975 (void *)&cmd_mcast_addr_cmd, 10976 (void *)&cmd_mcast_addr_what, 10977 (void *)&cmd_mcast_addr_portnum, 10978 (void *)&cmd_mcast_addr_addr, 10979 NULL, 10980 }, 10981 }; 10982 10983 /* vf vlan anti spoof configuration */ 10984 10985 /* Common result structure for vf vlan anti spoof */ 10986 struct cmd_vf_vlan_anti_spoof_result { 10987 cmdline_fixed_string_t set; 10988 cmdline_fixed_string_t vf; 10989 cmdline_fixed_string_t vlan; 10990 cmdline_fixed_string_t antispoof; 10991 portid_t port_id; 10992 uint32_t vf_id; 10993 cmdline_fixed_string_t on_off; 10994 }; 10995 10996 /* Common CLI fields for vf vlan anti spoof enable disable */ 10997 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 10998 TOKEN_STRING_INITIALIZER 10999 (struct cmd_vf_vlan_anti_spoof_result, 11000 set, "set"); 11001 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 11002 TOKEN_STRING_INITIALIZER 11003 (struct cmd_vf_vlan_anti_spoof_result, 11004 vf, "vf"); 11005 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 11006 TOKEN_STRING_INITIALIZER 11007 (struct cmd_vf_vlan_anti_spoof_result, 11008 vlan, "vlan"); 11009 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 11010 TOKEN_STRING_INITIALIZER 11011 (struct cmd_vf_vlan_anti_spoof_result, 11012 antispoof, "antispoof"); 11013 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 11014 TOKEN_NUM_INITIALIZER 11015 (struct cmd_vf_vlan_anti_spoof_result, 11016 port_id, RTE_UINT16); 11017 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 11018 TOKEN_NUM_INITIALIZER 11019 (struct cmd_vf_vlan_anti_spoof_result, 11020 vf_id, RTE_UINT32); 11021 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 11022 TOKEN_STRING_INITIALIZER 11023 (struct cmd_vf_vlan_anti_spoof_result, 11024 on_off, "on#off"); 11025 11026 static void 11027 cmd_set_vf_vlan_anti_spoof_parsed( 11028 void *parsed_result, 11029 __rte_unused struct cmdline *cl, 11030 __rte_unused void *data) 11031 { 11032 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 11033 int ret = -ENOTSUP; 11034 11035 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11036 11037 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11038 return; 11039 11040 #ifdef RTE_NET_IXGBE 11041 if (ret == -ENOTSUP) 11042 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 11043 res->vf_id, is_on); 11044 #endif 11045 #ifdef RTE_NET_I40E 11046 if (ret == -ENOTSUP) 11047 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 11048 res->vf_id, is_on); 11049 #endif 11050 #ifdef RTE_NET_BNXT 11051 if (ret == -ENOTSUP) 11052 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 11053 res->vf_id, is_on); 11054 #endif 11055 11056 switch (ret) { 11057 case 0: 11058 break; 11059 case -EINVAL: 11060 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 11061 break; 11062 case -ENODEV: 11063 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11064 break; 11065 case -ENOTSUP: 11066 fprintf(stderr, "function not implemented\n"); 11067 break; 11068 default: 11069 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11070 } 11071 } 11072 11073 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 11074 .f = cmd_set_vf_vlan_anti_spoof_parsed, 11075 .data = NULL, 11076 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 11077 .tokens = { 11078 (void *)&cmd_vf_vlan_anti_spoof_set, 11079 (void *)&cmd_vf_vlan_anti_spoof_vf, 11080 (void *)&cmd_vf_vlan_anti_spoof_vlan, 11081 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 11082 (void *)&cmd_vf_vlan_anti_spoof_port_id, 11083 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 11084 (void *)&cmd_vf_vlan_anti_spoof_on_off, 11085 NULL, 11086 }, 11087 }; 11088 11089 /* vf mac anti spoof configuration */ 11090 11091 /* Common result structure for vf mac anti spoof */ 11092 struct cmd_vf_mac_anti_spoof_result { 11093 cmdline_fixed_string_t set; 11094 cmdline_fixed_string_t vf; 11095 cmdline_fixed_string_t mac; 11096 cmdline_fixed_string_t antispoof; 11097 portid_t port_id; 11098 uint32_t vf_id; 11099 cmdline_fixed_string_t on_off; 11100 }; 11101 11102 /* Common CLI fields for vf mac anti spoof enable disable */ 11103 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 11104 TOKEN_STRING_INITIALIZER 11105 (struct cmd_vf_mac_anti_spoof_result, 11106 set, "set"); 11107 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 11108 TOKEN_STRING_INITIALIZER 11109 (struct cmd_vf_mac_anti_spoof_result, 11110 vf, "vf"); 11111 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 11112 TOKEN_STRING_INITIALIZER 11113 (struct cmd_vf_mac_anti_spoof_result, 11114 mac, "mac"); 11115 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 11116 TOKEN_STRING_INITIALIZER 11117 (struct cmd_vf_mac_anti_spoof_result, 11118 antispoof, "antispoof"); 11119 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 11120 TOKEN_NUM_INITIALIZER 11121 (struct cmd_vf_mac_anti_spoof_result, 11122 port_id, RTE_UINT16); 11123 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 11124 TOKEN_NUM_INITIALIZER 11125 (struct cmd_vf_mac_anti_spoof_result, 11126 vf_id, RTE_UINT32); 11127 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 11128 TOKEN_STRING_INITIALIZER 11129 (struct cmd_vf_mac_anti_spoof_result, 11130 on_off, "on#off"); 11131 11132 static void 11133 cmd_set_vf_mac_anti_spoof_parsed( 11134 void *parsed_result, 11135 __rte_unused struct cmdline *cl, 11136 __rte_unused void *data) 11137 { 11138 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 11139 int ret = -ENOTSUP; 11140 11141 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11142 11143 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11144 return; 11145 11146 #ifdef RTE_NET_IXGBE 11147 if (ret == -ENOTSUP) 11148 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 11149 res->vf_id, is_on); 11150 #endif 11151 #ifdef RTE_NET_I40E 11152 if (ret == -ENOTSUP) 11153 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 11154 res->vf_id, is_on); 11155 #endif 11156 #ifdef RTE_NET_BNXT 11157 if (ret == -ENOTSUP) 11158 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 11159 res->vf_id, is_on); 11160 #endif 11161 11162 switch (ret) { 11163 case 0: 11164 break; 11165 case -EINVAL: 11166 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 11167 res->vf_id, is_on); 11168 break; 11169 case -ENODEV: 11170 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11171 break; 11172 case -ENOTSUP: 11173 fprintf(stderr, "function not implemented\n"); 11174 break; 11175 default: 11176 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11177 } 11178 } 11179 11180 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 11181 .f = cmd_set_vf_mac_anti_spoof_parsed, 11182 .data = NULL, 11183 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 11184 .tokens = { 11185 (void *)&cmd_vf_mac_anti_spoof_set, 11186 (void *)&cmd_vf_mac_anti_spoof_vf, 11187 (void *)&cmd_vf_mac_anti_spoof_mac, 11188 (void *)&cmd_vf_mac_anti_spoof_antispoof, 11189 (void *)&cmd_vf_mac_anti_spoof_port_id, 11190 (void *)&cmd_vf_mac_anti_spoof_vf_id, 11191 (void *)&cmd_vf_mac_anti_spoof_on_off, 11192 NULL, 11193 }, 11194 }; 11195 11196 /* vf vlan strip queue configuration */ 11197 11198 /* Common result structure for vf mac anti spoof */ 11199 struct cmd_vf_vlan_stripq_result { 11200 cmdline_fixed_string_t set; 11201 cmdline_fixed_string_t vf; 11202 cmdline_fixed_string_t vlan; 11203 cmdline_fixed_string_t stripq; 11204 portid_t port_id; 11205 uint16_t vf_id; 11206 cmdline_fixed_string_t on_off; 11207 }; 11208 11209 /* Common CLI fields for vf vlan strip enable disable */ 11210 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 11211 TOKEN_STRING_INITIALIZER 11212 (struct cmd_vf_vlan_stripq_result, 11213 set, "set"); 11214 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 11215 TOKEN_STRING_INITIALIZER 11216 (struct cmd_vf_vlan_stripq_result, 11217 vf, "vf"); 11218 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 11219 TOKEN_STRING_INITIALIZER 11220 (struct cmd_vf_vlan_stripq_result, 11221 vlan, "vlan"); 11222 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 11223 TOKEN_STRING_INITIALIZER 11224 (struct cmd_vf_vlan_stripq_result, 11225 stripq, "stripq"); 11226 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 11227 TOKEN_NUM_INITIALIZER 11228 (struct cmd_vf_vlan_stripq_result, 11229 port_id, RTE_UINT16); 11230 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 11231 TOKEN_NUM_INITIALIZER 11232 (struct cmd_vf_vlan_stripq_result, 11233 vf_id, RTE_UINT16); 11234 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 11235 TOKEN_STRING_INITIALIZER 11236 (struct cmd_vf_vlan_stripq_result, 11237 on_off, "on#off"); 11238 11239 static void 11240 cmd_set_vf_vlan_stripq_parsed( 11241 void *parsed_result, 11242 __rte_unused struct cmdline *cl, 11243 __rte_unused void *data) 11244 { 11245 struct cmd_vf_vlan_stripq_result *res = parsed_result; 11246 int ret = -ENOTSUP; 11247 11248 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11249 11250 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11251 return; 11252 11253 #ifdef RTE_NET_IXGBE 11254 if (ret == -ENOTSUP) 11255 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 11256 res->vf_id, is_on); 11257 #endif 11258 #ifdef RTE_NET_I40E 11259 if (ret == -ENOTSUP) 11260 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 11261 res->vf_id, is_on); 11262 #endif 11263 #ifdef RTE_NET_BNXT 11264 if (ret == -ENOTSUP) 11265 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 11266 res->vf_id, is_on); 11267 #endif 11268 11269 switch (ret) { 11270 case 0: 11271 break; 11272 case -EINVAL: 11273 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 11274 res->vf_id, is_on); 11275 break; 11276 case -ENODEV: 11277 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11278 break; 11279 case -ENOTSUP: 11280 fprintf(stderr, "function not implemented\n"); 11281 break; 11282 default: 11283 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11284 } 11285 } 11286 11287 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 11288 .f = cmd_set_vf_vlan_stripq_parsed, 11289 .data = NULL, 11290 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 11291 .tokens = { 11292 (void *)&cmd_vf_vlan_stripq_set, 11293 (void *)&cmd_vf_vlan_stripq_vf, 11294 (void *)&cmd_vf_vlan_stripq_vlan, 11295 (void *)&cmd_vf_vlan_stripq_stripq, 11296 (void *)&cmd_vf_vlan_stripq_port_id, 11297 (void *)&cmd_vf_vlan_stripq_vf_id, 11298 (void *)&cmd_vf_vlan_stripq_on_off, 11299 NULL, 11300 }, 11301 }; 11302 11303 /* vf vlan insert configuration */ 11304 11305 /* Common result structure for vf vlan insert */ 11306 struct cmd_vf_vlan_insert_result { 11307 cmdline_fixed_string_t set; 11308 cmdline_fixed_string_t vf; 11309 cmdline_fixed_string_t vlan; 11310 cmdline_fixed_string_t insert; 11311 portid_t port_id; 11312 uint16_t vf_id; 11313 uint16_t vlan_id; 11314 }; 11315 11316 /* Common CLI fields for vf vlan insert enable disable */ 11317 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 11318 TOKEN_STRING_INITIALIZER 11319 (struct cmd_vf_vlan_insert_result, 11320 set, "set"); 11321 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 11322 TOKEN_STRING_INITIALIZER 11323 (struct cmd_vf_vlan_insert_result, 11324 vf, "vf"); 11325 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 11326 TOKEN_STRING_INITIALIZER 11327 (struct cmd_vf_vlan_insert_result, 11328 vlan, "vlan"); 11329 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 11330 TOKEN_STRING_INITIALIZER 11331 (struct cmd_vf_vlan_insert_result, 11332 insert, "insert"); 11333 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 11334 TOKEN_NUM_INITIALIZER 11335 (struct cmd_vf_vlan_insert_result, 11336 port_id, RTE_UINT16); 11337 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 11338 TOKEN_NUM_INITIALIZER 11339 (struct cmd_vf_vlan_insert_result, 11340 vf_id, RTE_UINT16); 11341 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 11342 TOKEN_NUM_INITIALIZER 11343 (struct cmd_vf_vlan_insert_result, 11344 vlan_id, RTE_UINT16); 11345 11346 static void 11347 cmd_set_vf_vlan_insert_parsed( 11348 void *parsed_result, 11349 __rte_unused struct cmdline *cl, 11350 __rte_unused void *data) 11351 { 11352 struct cmd_vf_vlan_insert_result *res = parsed_result; 11353 int ret = -ENOTSUP; 11354 11355 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11356 return; 11357 11358 #ifdef RTE_NET_IXGBE 11359 if (ret == -ENOTSUP) 11360 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 11361 res->vlan_id); 11362 #endif 11363 #ifdef RTE_NET_I40E 11364 if (ret == -ENOTSUP) 11365 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 11366 res->vlan_id); 11367 #endif 11368 #ifdef RTE_NET_BNXT 11369 if (ret == -ENOTSUP) 11370 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 11371 res->vlan_id); 11372 #endif 11373 11374 switch (ret) { 11375 case 0: 11376 break; 11377 case -EINVAL: 11378 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n", 11379 res->vf_id, res->vlan_id); 11380 break; 11381 case -ENODEV: 11382 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11383 break; 11384 case -ENOTSUP: 11385 fprintf(stderr, "function not implemented\n"); 11386 break; 11387 default: 11388 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11389 } 11390 } 11391 11392 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 11393 .f = cmd_set_vf_vlan_insert_parsed, 11394 .data = NULL, 11395 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 11396 .tokens = { 11397 (void *)&cmd_vf_vlan_insert_set, 11398 (void *)&cmd_vf_vlan_insert_vf, 11399 (void *)&cmd_vf_vlan_insert_vlan, 11400 (void *)&cmd_vf_vlan_insert_insert, 11401 (void *)&cmd_vf_vlan_insert_port_id, 11402 (void *)&cmd_vf_vlan_insert_vf_id, 11403 (void *)&cmd_vf_vlan_insert_vlan_id, 11404 NULL, 11405 }, 11406 }; 11407 11408 /* tx loopback configuration */ 11409 11410 /* Common result structure for tx loopback */ 11411 struct cmd_tx_loopback_result { 11412 cmdline_fixed_string_t set; 11413 cmdline_fixed_string_t tx; 11414 cmdline_fixed_string_t loopback; 11415 portid_t port_id; 11416 cmdline_fixed_string_t on_off; 11417 }; 11418 11419 /* Common CLI fields for tx loopback enable disable */ 11420 cmdline_parse_token_string_t cmd_tx_loopback_set = 11421 TOKEN_STRING_INITIALIZER 11422 (struct cmd_tx_loopback_result, 11423 set, "set"); 11424 cmdline_parse_token_string_t cmd_tx_loopback_tx = 11425 TOKEN_STRING_INITIALIZER 11426 (struct cmd_tx_loopback_result, 11427 tx, "tx"); 11428 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 11429 TOKEN_STRING_INITIALIZER 11430 (struct cmd_tx_loopback_result, 11431 loopback, "loopback"); 11432 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 11433 TOKEN_NUM_INITIALIZER 11434 (struct cmd_tx_loopback_result, 11435 port_id, RTE_UINT16); 11436 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 11437 TOKEN_STRING_INITIALIZER 11438 (struct cmd_tx_loopback_result, 11439 on_off, "on#off"); 11440 11441 static void 11442 cmd_set_tx_loopback_parsed( 11443 void *parsed_result, 11444 __rte_unused struct cmdline *cl, 11445 __rte_unused void *data) 11446 { 11447 struct cmd_tx_loopback_result *res = parsed_result; 11448 int ret = -ENOTSUP; 11449 11450 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11451 11452 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11453 return; 11454 11455 #ifdef RTE_NET_IXGBE 11456 if (ret == -ENOTSUP) 11457 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 11458 #endif 11459 #ifdef RTE_NET_I40E 11460 if (ret == -ENOTSUP) 11461 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 11462 #endif 11463 #ifdef RTE_NET_BNXT 11464 if (ret == -ENOTSUP) 11465 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 11466 #endif 11467 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA 11468 if (ret == -ENOTSUP) 11469 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 11470 #endif 11471 11472 switch (ret) { 11473 case 0: 11474 break; 11475 case -EINVAL: 11476 fprintf(stderr, "invalid is_on %d\n", is_on); 11477 break; 11478 case -ENODEV: 11479 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11480 break; 11481 case -ENOTSUP: 11482 fprintf(stderr, "function not implemented\n"); 11483 break; 11484 default: 11485 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11486 } 11487 } 11488 11489 cmdline_parse_inst_t cmd_set_tx_loopback = { 11490 .f = cmd_set_tx_loopback_parsed, 11491 .data = NULL, 11492 .help_str = "set tx loopback <port_id> on|off", 11493 .tokens = { 11494 (void *)&cmd_tx_loopback_set, 11495 (void *)&cmd_tx_loopback_tx, 11496 (void *)&cmd_tx_loopback_loopback, 11497 (void *)&cmd_tx_loopback_port_id, 11498 (void *)&cmd_tx_loopback_on_off, 11499 NULL, 11500 }, 11501 }; 11502 11503 /* all queues drop enable configuration */ 11504 11505 /* Common result structure for all queues drop enable */ 11506 struct cmd_all_queues_drop_en_result { 11507 cmdline_fixed_string_t set; 11508 cmdline_fixed_string_t all; 11509 cmdline_fixed_string_t queues; 11510 cmdline_fixed_string_t drop; 11511 portid_t port_id; 11512 cmdline_fixed_string_t on_off; 11513 }; 11514 11515 /* Common CLI fields for tx loopback enable disable */ 11516 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 11517 TOKEN_STRING_INITIALIZER 11518 (struct cmd_all_queues_drop_en_result, 11519 set, "set"); 11520 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 11521 TOKEN_STRING_INITIALIZER 11522 (struct cmd_all_queues_drop_en_result, 11523 all, "all"); 11524 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 11525 TOKEN_STRING_INITIALIZER 11526 (struct cmd_all_queues_drop_en_result, 11527 queues, "queues"); 11528 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 11529 TOKEN_STRING_INITIALIZER 11530 (struct cmd_all_queues_drop_en_result, 11531 drop, "drop"); 11532 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 11533 TOKEN_NUM_INITIALIZER 11534 (struct cmd_all_queues_drop_en_result, 11535 port_id, RTE_UINT16); 11536 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 11537 TOKEN_STRING_INITIALIZER 11538 (struct cmd_all_queues_drop_en_result, 11539 on_off, "on#off"); 11540 11541 static void 11542 cmd_set_all_queues_drop_en_parsed( 11543 void *parsed_result, 11544 __rte_unused struct cmdline *cl, 11545 __rte_unused void *data) 11546 { 11547 struct cmd_all_queues_drop_en_result *res = parsed_result; 11548 int ret = -ENOTSUP; 11549 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11550 11551 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11552 return; 11553 11554 #ifdef RTE_NET_IXGBE 11555 if (ret == -ENOTSUP) 11556 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 11557 #endif 11558 #ifdef RTE_NET_BNXT 11559 if (ret == -ENOTSUP) 11560 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 11561 #endif 11562 switch (ret) { 11563 case 0: 11564 break; 11565 case -EINVAL: 11566 fprintf(stderr, "invalid is_on %d\n", is_on); 11567 break; 11568 case -ENODEV: 11569 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11570 break; 11571 case -ENOTSUP: 11572 fprintf(stderr, "function not implemented\n"); 11573 break; 11574 default: 11575 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11576 } 11577 } 11578 11579 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 11580 .f = cmd_set_all_queues_drop_en_parsed, 11581 .data = NULL, 11582 .help_str = "set all queues drop <port_id> on|off", 11583 .tokens = { 11584 (void *)&cmd_all_queues_drop_en_set, 11585 (void *)&cmd_all_queues_drop_en_all, 11586 (void *)&cmd_all_queues_drop_en_queues, 11587 (void *)&cmd_all_queues_drop_en_drop, 11588 (void *)&cmd_all_queues_drop_en_port_id, 11589 (void *)&cmd_all_queues_drop_en_on_off, 11590 NULL, 11591 }, 11592 }; 11593 11594 /* vf split drop enable configuration */ 11595 11596 /* Common result structure for vf split drop enable */ 11597 struct cmd_vf_split_drop_en_result { 11598 cmdline_fixed_string_t set; 11599 cmdline_fixed_string_t vf; 11600 cmdline_fixed_string_t split; 11601 cmdline_fixed_string_t drop; 11602 portid_t port_id; 11603 uint16_t vf_id; 11604 cmdline_fixed_string_t on_off; 11605 }; 11606 11607 /* Common CLI fields for vf split drop enable disable */ 11608 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 11609 TOKEN_STRING_INITIALIZER 11610 (struct cmd_vf_split_drop_en_result, 11611 set, "set"); 11612 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 11613 TOKEN_STRING_INITIALIZER 11614 (struct cmd_vf_split_drop_en_result, 11615 vf, "vf"); 11616 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 11617 TOKEN_STRING_INITIALIZER 11618 (struct cmd_vf_split_drop_en_result, 11619 split, "split"); 11620 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 11621 TOKEN_STRING_INITIALIZER 11622 (struct cmd_vf_split_drop_en_result, 11623 drop, "drop"); 11624 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 11625 TOKEN_NUM_INITIALIZER 11626 (struct cmd_vf_split_drop_en_result, 11627 port_id, RTE_UINT16); 11628 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 11629 TOKEN_NUM_INITIALIZER 11630 (struct cmd_vf_split_drop_en_result, 11631 vf_id, RTE_UINT16); 11632 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 11633 TOKEN_STRING_INITIALIZER 11634 (struct cmd_vf_split_drop_en_result, 11635 on_off, "on#off"); 11636 11637 static void 11638 cmd_set_vf_split_drop_en_parsed( 11639 void *parsed_result, 11640 __rte_unused struct cmdline *cl, 11641 __rte_unused void *data) 11642 { 11643 struct cmd_vf_split_drop_en_result *res = parsed_result; 11644 int ret = -ENOTSUP; 11645 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11646 11647 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11648 return; 11649 11650 #ifdef RTE_NET_IXGBE 11651 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 11652 is_on); 11653 #endif 11654 switch (ret) { 11655 case 0: 11656 break; 11657 case -EINVAL: 11658 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 11659 res->vf_id, is_on); 11660 break; 11661 case -ENODEV: 11662 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11663 break; 11664 case -ENOTSUP: 11665 fprintf(stderr, "not supported on port %d\n", res->port_id); 11666 break; 11667 default: 11668 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11669 } 11670 } 11671 11672 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 11673 .f = cmd_set_vf_split_drop_en_parsed, 11674 .data = NULL, 11675 .help_str = "set vf split drop <port_id> <vf_id> on|off", 11676 .tokens = { 11677 (void *)&cmd_vf_split_drop_en_set, 11678 (void *)&cmd_vf_split_drop_en_vf, 11679 (void *)&cmd_vf_split_drop_en_split, 11680 (void *)&cmd_vf_split_drop_en_drop, 11681 (void *)&cmd_vf_split_drop_en_port_id, 11682 (void *)&cmd_vf_split_drop_en_vf_id, 11683 (void *)&cmd_vf_split_drop_en_on_off, 11684 NULL, 11685 }, 11686 }; 11687 11688 /* vf mac address configuration */ 11689 11690 /* Common result structure for vf mac address */ 11691 struct cmd_set_vf_mac_addr_result { 11692 cmdline_fixed_string_t set; 11693 cmdline_fixed_string_t vf; 11694 cmdline_fixed_string_t mac; 11695 cmdline_fixed_string_t addr; 11696 portid_t port_id; 11697 uint16_t vf_id; 11698 struct rte_ether_addr mac_addr; 11699 11700 }; 11701 11702 /* Common CLI fields for vf split drop enable disable */ 11703 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 11704 TOKEN_STRING_INITIALIZER 11705 (struct cmd_set_vf_mac_addr_result, 11706 set, "set"); 11707 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 11708 TOKEN_STRING_INITIALIZER 11709 (struct cmd_set_vf_mac_addr_result, 11710 vf, "vf"); 11711 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 11712 TOKEN_STRING_INITIALIZER 11713 (struct cmd_set_vf_mac_addr_result, 11714 mac, "mac"); 11715 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 11716 TOKEN_STRING_INITIALIZER 11717 (struct cmd_set_vf_mac_addr_result, 11718 addr, "addr"); 11719 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 11720 TOKEN_NUM_INITIALIZER 11721 (struct cmd_set_vf_mac_addr_result, 11722 port_id, RTE_UINT16); 11723 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 11724 TOKEN_NUM_INITIALIZER 11725 (struct cmd_set_vf_mac_addr_result, 11726 vf_id, RTE_UINT16); 11727 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 11728 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 11729 mac_addr); 11730 11731 static void 11732 cmd_set_vf_mac_addr_parsed( 11733 void *parsed_result, 11734 __rte_unused struct cmdline *cl, 11735 __rte_unused void *data) 11736 { 11737 struct cmd_set_vf_mac_addr_result *res = parsed_result; 11738 int ret = -ENOTSUP; 11739 11740 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11741 return; 11742 11743 #ifdef RTE_NET_IXGBE 11744 if (ret == -ENOTSUP) 11745 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 11746 &res->mac_addr); 11747 #endif 11748 #ifdef RTE_NET_I40E 11749 if (ret == -ENOTSUP) 11750 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 11751 &res->mac_addr); 11752 #endif 11753 #ifdef RTE_NET_BNXT 11754 if (ret == -ENOTSUP) 11755 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 11756 &res->mac_addr); 11757 #endif 11758 11759 switch (ret) { 11760 case 0: 11761 break; 11762 case -EINVAL: 11763 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id); 11764 break; 11765 case -ENODEV: 11766 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11767 break; 11768 case -ENOTSUP: 11769 fprintf(stderr, "function not implemented\n"); 11770 break; 11771 default: 11772 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11773 } 11774 } 11775 11776 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 11777 .f = cmd_set_vf_mac_addr_parsed, 11778 .data = NULL, 11779 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 11780 .tokens = { 11781 (void *)&cmd_set_vf_mac_addr_set, 11782 (void *)&cmd_set_vf_mac_addr_vf, 11783 (void *)&cmd_set_vf_mac_addr_mac, 11784 (void *)&cmd_set_vf_mac_addr_addr, 11785 (void *)&cmd_set_vf_mac_addr_port_id, 11786 (void *)&cmd_set_vf_mac_addr_vf_id, 11787 (void *)&cmd_set_vf_mac_addr_mac_addr, 11788 NULL, 11789 }, 11790 }; 11791 11792 /* MACsec configuration */ 11793 11794 /* Common result structure for MACsec offload enable */ 11795 struct cmd_macsec_offload_on_result { 11796 cmdline_fixed_string_t set; 11797 cmdline_fixed_string_t macsec; 11798 cmdline_fixed_string_t offload; 11799 portid_t port_id; 11800 cmdline_fixed_string_t on; 11801 cmdline_fixed_string_t encrypt; 11802 cmdline_fixed_string_t en_on_off; 11803 cmdline_fixed_string_t replay_protect; 11804 cmdline_fixed_string_t rp_on_off; 11805 }; 11806 11807 /* Common CLI fields for MACsec offload disable */ 11808 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 11809 TOKEN_STRING_INITIALIZER 11810 (struct cmd_macsec_offload_on_result, 11811 set, "set"); 11812 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 11813 TOKEN_STRING_INITIALIZER 11814 (struct cmd_macsec_offload_on_result, 11815 macsec, "macsec"); 11816 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 11817 TOKEN_STRING_INITIALIZER 11818 (struct cmd_macsec_offload_on_result, 11819 offload, "offload"); 11820 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 11821 TOKEN_NUM_INITIALIZER 11822 (struct cmd_macsec_offload_on_result, 11823 port_id, RTE_UINT16); 11824 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 11825 TOKEN_STRING_INITIALIZER 11826 (struct cmd_macsec_offload_on_result, 11827 on, "on"); 11828 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 11829 TOKEN_STRING_INITIALIZER 11830 (struct cmd_macsec_offload_on_result, 11831 encrypt, "encrypt"); 11832 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 11833 TOKEN_STRING_INITIALIZER 11834 (struct cmd_macsec_offload_on_result, 11835 en_on_off, "on#off"); 11836 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 11837 TOKEN_STRING_INITIALIZER 11838 (struct cmd_macsec_offload_on_result, 11839 replay_protect, "replay-protect"); 11840 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 11841 TOKEN_STRING_INITIALIZER 11842 (struct cmd_macsec_offload_on_result, 11843 rp_on_off, "on#off"); 11844 11845 static void 11846 cmd_set_macsec_offload_on_parsed( 11847 void *parsed_result, 11848 __rte_unused struct cmdline *cl, 11849 __rte_unused void *data) 11850 { 11851 struct cmd_macsec_offload_on_result *res = parsed_result; 11852 int ret = -ENOTSUP; 11853 portid_t port_id = res->port_id; 11854 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 11855 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 11856 struct rte_eth_dev_info dev_info; 11857 11858 if (port_id_is_invalid(port_id, ENABLED_WARN)) 11859 return; 11860 if (!port_is_stopped(port_id)) { 11861 fprintf(stderr, "Please stop port %d first\n", port_id); 11862 return; 11863 } 11864 11865 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11866 if (ret != 0) 11867 return; 11868 11869 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 11870 #ifdef RTE_NET_IXGBE 11871 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 11872 #endif 11873 } 11874 RTE_SET_USED(en); 11875 RTE_SET_USED(rp); 11876 11877 switch (ret) { 11878 case 0: 11879 ports[port_id].dev_conf.txmode.offloads |= 11880 DEV_TX_OFFLOAD_MACSEC_INSERT; 11881 cmd_reconfig_device_queue(port_id, 1, 1); 11882 break; 11883 case -ENODEV: 11884 fprintf(stderr, "invalid port_id %d\n", port_id); 11885 break; 11886 case -ENOTSUP: 11887 fprintf(stderr, "not supported on port %d\n", port_id); 11888 break; 11889 default: 11890 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11891 } 11892 } 11893 11894 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 11895 .f = cmd_set_macsec_offload_on_parsed, 11896 .data = NULL, 11897 .help_str = "set macsec offload <port_id> on " 11898 "encrypt on|off replay-protect on|off", 11899 .tokens = { 11900 (void *)&cmd_macsec_offload_on_set, 11901 (void *)&cmd_macsec_offload_on_macsec, 11902 (void *)&cmd_macsec_offload_on_offload, 11903 (void *)&cmd_macsec_offload_on_port_id, 11904 (void *)&cmd_macsec_offload_on_on, 11905 (void *)&cmd_macsec_offload_on_encrypt, 11906 (void *)&cmd_macsec_offload_on_en_on_off, 11907 (void *)&cmd_macsec_offload_on_replay_protect, 11908 (void *)&cmd_macsec_offload_on_rp_on_off, 11909 NULL, 11910 }, 11911 }; 11912 11913 /* Common result structure for MACsec offload disable */ 11914 struct cmd_macsec_offload_off_result { 11915 cmdline_fixed_string_t set; 11916 cmdline_fixed_string_t macsec; 11917 cmdline_fixed_string_t offload; 11918 portid_t port_id; 11919 cmdline_fixed_string_t off; 11920 }; 11921 11922 /* Common CLI fields for MACsec offload disable */ 11923 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 11924 TOKEN_STRING_INITIALIZER 11925 (struct cmd_macsec_offload_off_result, 11926 set, "set"); 11927 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 11928 TOKEN_STRING_INITIALIZER 11929 (struct cmd_macsec_offload_off_result, 11930 macsec, "macsec"); 11931 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 11932 TOKEN_STRING_INITIALIZER 11933 (struct cmd_macsec_offload_off_result, 11934 offload, "offload"); 11935 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 11936 TOKEN_NUM_INITIALIZER 11937 (struct cmd_macsec_offload_off_result, 11938 port_id, RTE_UINT16); 11939 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 11940 TOKEN_STRING_INITIALIZER 11941 (struct cmd_macsec_offload_off_result, 11942 off, "off"); 11943 11944 static void 11945 cmd_set_macsec_offload_off_parsed( 11946 void *parsed_result, 11947 __rte_unused struct cmdline *cl, 11948 __rte_unused void *data) 11949 { 11950 struct cmd_macsec_offload_off_result *res = parsed_result; 11951 int ret = -ENOTSUP; 11952 struct rte_eth_dev_info dev_info; 11953 portid_t port_id = res->port_id; 11954 11955 if (port_id_is_invalid(port_id, ENABLED_WARN)) 11956 return; 11957 if (!port_is_stopped(port_id)) { 11958 fprintf(stderr, "Please stop port %d first\n", port_id); 11959 return; 11960 } 11961 11962 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11963 if (ret != 0) 11964 return; 11965 11966 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 11967 #ifdef RTE_NET_IXGBE 11968 ret = rte_pmd_ixgbe_macsec_disable(port_id); 11969 #endif 11970 } 11971 switch (ret) { 11972 case 0: 11973 ports[port_id].dev_conf.txmode.offloads &= 11974 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 11975 cmd_reconfig_device_queue(port_id, 1, 1); 11976 break; 11977 case -ENODEV: 11978 fprintf(stderr, "invalid port_id %d\n", port_id); 11979 break; 11980 case -ENOTSUP: 11981 fprintf(stderr, "not supported on port %d\n", port_id); 11982 break; 11983 default: 11984 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11985 } 11986 } 11987 11988 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 11989 .f = cmd_set_macsec_offload_off_parsed, 11990 .data = NULL, 11991 .help_str = "set macsec offload <port_id> off", 11992 .tokens = { 11993 (void *)&cmd_macsec_offload_off_set, 11994 (void *)&cmd_macsec_offload_off_macsec, 11995 (void *)&cmd_macsec_offload_off_offload, 11996 (void *)&cmd_macsec_offload_off_port_id, 11997 (void *)&cmd_macsec_offload_off_off, 11998 NULL, 11999 }, 12000 }; 12001 12002 /* Common result structure for MACsec secure connection configure */ 12003 struct cmd_macsec_sc_result { 12004 cmdline_fixed_string_t set; 12005 cmdline_fixed_string_t macsec; 12006 cmdline_fixed_string_t sc; 12007 cmdline_fixed_string_t tx_rx; 12008 portid_t port_id; 12009 struct rte_ether_addr mac; 12010 uint16_t pi; 12011 }; 12012 12013 /* Common CLI fields for MACsec secure connection configure */ 12014 cmdline_parse_token_string_t cmd_macsec_sc_set = 12015 TOKEN_STRING_INITIALIZER 12016 (struct cmd_macsec_sc_result, 12017 set, "set"); 12018 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 12019 TOKEN_STRING_INITIALIZER 12020 (struct cmd_macsec_sc_result, 12021 macsec, "macsec"); 12022 cmdline_parse_token_string_t cmd_macsec_sc_sc = 12023 TOKEN_STRING_INITIALIZER 12024 (struct cmd_macsec_sc_result, 12025 sc, "sc"); 12026 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 12027 TOKEN_STRING_INITIALIZER 12028 (struct cmd_macsec_sc_result, 12029 tx_rx, "tx#rx"); 12030 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 12031 TOKEN_NUM_INITIALIZER 12032 (struct cmd_macsec_sc_result, 12033 port_id, RTE_UINT16); 12034 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 12035 TOKEN_ETHERADDR_INITIALIZER 12036 (struct cmd_macsec_sc_result, 12037 mac); 12038 cmdline_parse_token_num_t cmd_macsec_sc_pi = 12039 TOKEN_NUM_INITIALIZER 12040 (struct cmd_macsec_sc_result, 12041 pi, RTE_UINT16); 12042 12043 static void 12044 cmd_set_macsec_sc_parsed( 12045 void *parsed_result, 12046 __rte_unused struct cmdline *cl, 12047 __rte_unused void *data) 12048 { 12049 struct cmd_macsec_sc_result *res = parsed_result; 12050 int ret = -ENOTSUP; 12051 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 12052 12053 #ifdef RTE_NET_IXGBE 12054 ret = is_tx ? 12055 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 12056 res->mac.addr_bytes) : 12057 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 12058 res->mac.addr_bytes, res->pi); 12059 #endif 12060 RTE_SET_USED(is_tx); 12061 12062 switch (ret) { 12063 case 0: 12064 break; 12065 case -ENODEV: 12066 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12067 break; 12068 case -ENOTSUP: 12069 fprintf(stderr, "not supported on port %d\n", res->port_id); 12070 break; 12071 default: 12072 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12073 } 12074 } 12075 12076 cmdline_parse_inst_t cmd_set_macsec_sc = { 12077 .f = cmd_set_macsec_sc_parsed, 12078 .data = NULL, 12079 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 12080 .tokens = { 12081 (void *)&cmd_macsec_sc_set, 12082 (void *)&cmd_macsec_sc_macsec, 12083 (void *)&cmd_macsec_sc_sc, 12084 (void *)&cmd_macsec_sc_tx_rx, 12085 (void *)&cmd_macsec_sc_port_id, 12086 (void *)&cmd_macsec_sc_mac, 12087 (void *)&cmd_macsec_sc_pi, 12088 NULL, 12089 }, 12090 }; 12091 12092 /* Common result structure for MACsec secure connection configure */ 12093 struct cmd_macsec_sa_result { 12094 cmdline_fixed_string_t set; 12095 cmdline_fixed_string_t macsec; 12096 cmdline_fixed_string_t sa; 12097 cmdline_fixed_string_t tx_rx; 12098 portid_t port_id; 12099 uint8_t idx; 12100 uint8_t an; 12101 uint32_t pn; 12102 cmdline_fixed_string_t key; 12103 }; 12104 12105 /* Common CLI fields for MACsec secure connection configure */ 12106 cmdline_parse_token_string_t cmd_macsec_sa_set = 12107 TOKEN_STRING_INITIALIZER 12108 (struct cmd_macsec_sa_result, 12109 set, "set"); 12110 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 12111 TOKEN_STRING_INITIALIZER 12112 (struct cmd_macsec_sa_result, 12113 macsec, "macsec"); 12114 cmdline_parse_token_string_t cmd_macsec_sa_sa = 12115 TOKEN_STRING_INITIALIZER 12116 (struct cmd_macsec_sa_result, 12117 sa, "sa"); 12118 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 12119 TOKEN_STRING_INITIALIZER 12120 (struct cmd_macsec_sa_result, 12121 tx_rx, "tx#rx"); 12122 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 12123 TOKEN_NUM_INITIALIZER 12124 (struct cmd_macsec_sa_result, 12125 port_id, RTE_UINT16); 12126 cmdline_parse_token_num_t cmd_macsec_sa_idx = 12127 TOKEN_NUM_INITIALIZER 12128 (struct cmd_macsec_sa_result, 12129 idx, RTE_UINT8); 12130 cmdline_parse_token_num_t cmd_macsec_sa_an = 12131 TOKEN_NUM_INITIALIZER 12132 (struct cmd_macsec_sa_result, 12133 an, RTE_UINT8); 12134 cmdline_parse_token_num_t cmd_macsec_sa_pn = 12135 TOKEN_NUM_INITIALIZER 12136 (struct cmd_macsec_sa_result, 12137 pn, RTE_UINT32); 12138 cmdline_parse_token_string_t cmd_macsec_sa_key = 12139 TOKEN_STRING_INITIALIZER 12140 (struct cmd_macsec_sa_result, 12141 key, NULL); 12142 12143 static void 12144 cmd_set_macsec_sa_parsed( 12145 void *parsed_result, 12146 __rte_unused struct cmdline *cl, 12147 __rte_unused void *data) 12148 { 12149 struct cmd_macsec_sa_result *res = parsed_result; 12150 int ret = -ENOTSUP; 12151 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 12152 uint8_t key[16] = { 0 }; 12153 uint8_t xdgt0; 12154 uint8_t xdgt1; 12155 int key_len; 12156 int i; 12157 12158 key_len = strlen(res->key) / 2; 12159 if (key_len > 16) 12160 key_len = 16; 12161 12162 for (i = 0; i < key_len; i++) { 12163 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 12164 if (xdgt0 == 0xFF) 12165 return; 12166 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 12167 if (xdgt1 == 0xFF) 12168 return; 12169 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 12170 } 12171 12172 #ifdef RTE_NET_IXGBE 12173 ret = is_tx ? 12174 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 12175 res->idx, res->an, res->pn, key) : 12176 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 12177 res->idx, res->an, res->pn, key); 12178 #endif 12179 RTE_SET_USED(is_tx); 12180 RTE_SET_USED(key); 12181 12182 switch (ret) { 12183 case 0: 12184 break; 12185 case -EINVAL: 12186 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an); 12187 break; 12188 case -ENODEV: 12189 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12190 break; 12191 case -ENOTSUP: 12192 fprintf(stderr, "not supported on port %d\n", res->port_id); 12193 break; 12194 default: 12195 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12196 } 12197 } 12198 12199 cmdline_parse_inst_t cmd_set_macsec_sa = { 12200 .f = cmd_set_macsec_sa_parsed, 12201 .data = NULL, 12202 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 12203 .tokens = { 12204 (void *)&cmd_macsec_sa_set, 12205 (void *)&cmd_macsec_sa_macsec, 12206 (void *)&cmd_macsec_sa_sa, 12207 (void *)&cmd_macsec_sa_tx_rx, 12208 (void *)&cmd_macsec_sa_port_id, 12209 (void *)&cmd_macsec_sa_idx, 12210 (void *)&cmd_macsec_sa_an, 12211 (void *)&cmd_macsec_sa_pn, 12212 (void *)&cmd_macsec_sa_key, 12213 NULL, 12214 }, 12215 }; 12216 12217 /* VF unicast promiscuous mode configuration */ 12218 12219 /* Common result structure for VF unicast promiscuous mode */ 12220 struct cmd_vf_promisc_result { 12221 cmdline_fixed_string_t set; 12222 cmdline_fixed_string_t vf; 12223 cmdline_fixed_string_t promisc; 12224 portid_t port_id; 12225 uint32_t vf_id; 12226 cmdline_fixed_string_t on_off; 12227 }; 12228 12229 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 12230 cmdline_parse_token_string_t cmd_vf_promisc_set = 12231 TOKEN_STRING_INITIALIZER 12232 (struct cmd_vf_promisc_result, 12233 set, "set"); 12234 cmdline_parse_token_string_t cmd_vf_promisc_vf = 12235 TOKEN_STRING_INITIALIZER 12236 (struct cmd_vf_promisc_result, 12237 vf, "vf"); 12238 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 12239 TOKEN_STRING_INITIALIZER 12240 (struct cmd_vf_promisc_result, 12241 promisc, "promisc"); 12242 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 12243 TOKEN_NUM_INITIALIZER 12244 (struct cmd_vf_promisc_result, 12245 port_id, RTE_UINT16); 12246 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 12247 TOKEN_NUM_INITIALIZER 12248 (struct cmd_vf_promisc_result, 12249 vf_id, RTE_UINT32); 12250 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 12251 TOKEN_STRING_INITIALIZER 12252 (struct cmd_vf_promisc_result, 12253 on_off, "on#off"); 12254 12255 static void 12256 cmd_set_vf_promisc_parsed( 12257 void *parsed_result, 12258 __rte_unused struct cmdline *cl, 12259 __rte_unused void *data) 12260 { 12261 struct cmd_vf_promisc_result *res = parsed_result; 12262 int ret = -ENOTSUP; 12263 12264 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12265 12266 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12267 return; 12268 12269 #ifdef RTE_NET_I40E 12270 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 12271 res->vf_id, is_on); 12272 #endif 12273 12274 switch (ret) { 12275 case 0: 12276 break; 12277 case -EINVAL: 12278 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 12279 break; 12280 case -ENODEV: 12281 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12282 break; 12283 case -ENOTSUP: 12284 fprintf(stderr, "function not implemented\n"); 12285 break; 12286 default: 12287 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12288 } 12289 } 12290 12291 cmdline_parse_inst_t cmd_set_vf_promisc = { 12292 .f = cmd_set_vf_promisc_parsed, 12293 .data = NULL, 12294 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 12295 "Set unicast promiscuous mode for a VF from the PF", 12296 .tokens = { 12297 (void *)&cmd_vf_promisc_set, 12298 (void *)&cmd_vf_promisc_vf, 12299 (void *)&cmd_vf_promisc_promisc, 12300 (void *)&cmd_vf_promisc_port_id, 12301 (void *)&cmd_vf_promisc_vf_id, 12302 (void *)&cmd_vf_promisc_on_off, 12303 NULL, 12304 }, 12305 }; 12306 12307 /* VF multicast promiscuous mode configuration */ 12308 12309 /* Common result structure for VF multicast promiscuous mode */ 12310 struct cmd_vf_allmulti_result { 12311 cmdline_fixed_string_t set; 12312 cmdline_fixed_string_t vf; 12313 cmdline_fixed_string_t allmulti; 12314 portid_t port_id; 12315 uint32_t vf_id; 12316 cmdline_fixed_string_t on_off; 12317 }; 12318 12319 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 12320 cmdline_parse_token_string_t cmd_vf_allmulti_set = 12321 TOKEN_STRING_INITIALIZER 12322 (struct cmd_vf_allmulti_result, 12323 set, "set"); 12324 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 12325 TOKEN_STRING_INITIALIZER 12326 (struct cmd_vf_allmulti_result, 12327 vf, "vf"); 12328 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 12329 TOKEN_STRING_INITIALIZER 12330 (struct cmd_vf_allmulti_result, 12331 allmulti, "allmulti"); 12332 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 12333 TOKEN_NUM_INITIALIZER 12334 (struct cmd_vf_allmulti_result, 12335 port_id, RTE_UINT16); 12336 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 12337 TOKEN_NUM_INITIALIZER 12338 (struct cmd_vf_allmulti_result, 12339 vf_id, RTE_UINT32); 12340 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 12341 TOKEN_STRING_INITIALIZER 12342 (struct cmd_vf_allmulti_result, 12343 on_off, "on#off"); 12344 12345 static void 12346 cmd_set_vf_allmulti_parsed( 12347 void *parsed_result, 12348 __rte_unused struct cmdline *cl, 12349 __rte_unused void *data) 12350 { 12351 struct cmd_vf_allmulti_result *res = parsed_result; 12352 int ret = -ENOTSUP; 12353 12354 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12355 12356 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12357 return; 12358 12359 #ifdef RTE_NET_I40E 12360 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 12361 res->vf_id, is_on); 12362 #endif 12363 12364 switch (ret) { 12365 case 0: 12366 break; 12367 case -EINVAL: 12368 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 12369 break; 12370 case -ENODEV: 12371 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12372 break; 12373 case -ENOTSUP: 12374 fprintf(stderr, "function not implemented\n"); 12375 break; 12376 default: 12377 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12378 } 12379 } 12380 12381 cmdline_parse_inst_t cmd_set_vf_allmulti = { 12382 .f = cmd_set_vf_allmulti_parsed, 12383 .data = NULL, 12384 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 12385 "Set multicast promiscuous mode for a VF from the PF", 12386 .tokens = { 12387 (void *)&cmd_vf_allmulti_set, 12388 (void *)&cmd_vf_allmulti_vf, 12389 (void *)&cmd_vf_allmulti_allmulti, 12390 (void *)&cmd_vf_allmulti_port_id, 12391 (void *)&cmd_vf_allmulti_vf_id, 12392 (void *)&cmd_vf_allmulti_on_off, 12393 NULL, 12394 }, 12395 }; 12396 12397 /* vf broadcast mode configuration */ 12398 12399 /* Common result structure for vf broadcast */ 12400 struct cmd_set_vf_broadcast_result { 12401 cmdline_fixed_string_t set; 12402 cmdline_fixed_string_t vf; 12403 cmdline_fixed_string_t broadcast; 12404 portid_t port_id; 12405 uint16_t vf_id; 12406 cmdline_fixed_string_t on_off; 12407 }; 12408 12409 /* Common CLI fields for vf broadcast enable disable */ 12410 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 12411 TOKEN_STRING_INITIALIZER 12412 (struct cmd_set_vf_broadcast_result, 12413 set, "set"); 12414 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 12415 TOKEN_STRING_INITIALIZER 12416 (struct cmd_set_vf_broadcast_result, 12417 vf, "vf"); 12418 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 12419 TOKEN_STRING_INITIALIZER 12420 (struct cmd_set_vf_broadcast_result, 12421 broadcast, "broadcast"); 12422 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 12423 TOKEN_NUM_INITIALIZER 12424 (struct cmd_set_vf_broadcast_result, 12425 port_id, RTE_UINT16); 12426 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 12427 TOKEN_NUM_INITIALIZER 12428 (struct cmd_set_vf_broadcast_result, 12429 vf_id, RTE_UINT16); 12430 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 12431 TOKEN_STRING_INITIALIZER 12432 (struct cmd_set_vf_broadcast_result, 12433 on_off, "on#off"); 12434 12435 static void 12436 cmd_set_vf_broadcast_parsed( 12437 void *parsed_result, 12438 __rte_unused struct cmdline *cl, 12439 __rte_unused void *data) 12440 { 12441 struct cmd_set_vf_broadcast_result *res = parsed_result; 12442 int ret = -ENOTSUP; 12443 12444 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12445 12446 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12447 return; 12448 12449 #ifdef RTE_NET_I40E 12450 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 12451 res->vf_id, is_on); 12452 #endif 12453 12454 switch (ret) { 12455 case 0: 12456 break; 12457 case -EINVAL: 12458 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 12459 res->vf_id, is_on); 12460 break; 12461 case -ENODEV: 12462 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12463 break; 12464 case -ENOTSUP: 12465 fprintf(stderr, "function not implemented\n"); 12466 break; 12467 default: 12468 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12469 } 12470 } 12471 12472 cmdline_parse_inst_t cmd_set_vf_broadcast = { 12473 .f = cmd_set_vf_broadcast_parsed, 12474 .data = NULL, 12475 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 12476 .tokens = { 12477 (void *)&cmd_set_vf_broadcast_set, 12478 (void *)&cmd_set_vf_broadcast_vf, 12479 (void *)&cmd_set_vf_broadcast_broadcast, 12480 (void *)&cmd_set_vf_broadcast_port_id, 12481 (void *)&cmd_set_vf_broadcast_vf_id, 12482 (void *)&cmd_set_vf_broadcast_on_off, 12483 NULL, 12484 }, 12485 }; 12486 12487 /* vf vlan tag configuration */ 12488 12489 /* Common result structure for vf vlan tag */ 12490 struct cmd_set_vf_vlan_tag_result { 12491 cmdline_fixed_string_t set; 12492 cmdline_fixed_string_t vf; 12493 cmdline_fixed_string_t vlan; 12494 cmdline_fixed_string_t tag; 12495 portid_t port_id; 12496 uint16_t vf_id; 12497 cmdline_fixed_string_t on_off; 12498 }; 12499 12500 /* Common CLI fields for vf vlan tag enable disable */ 12501 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 12502 TOKEN_STRING_INITIALIZER 12503 (struct cmd_set_vf_vlan_tag_result, 12504 set, "set"); 12505 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 12506 TOKEN_STRING_INITIALIZER 12507 (struct cmd_set_vf_vlan_tag_result, 12508 vf, "vf"); 12509 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 12510 TOKEN_STRING_INITIALIZER 12511 (struct cmd_set_vf_vlan_tag_result, 12512 vlan, "vlan"); 12513 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 12514 TOKEN_STRING_INITIALIZER 12515 (struct cmd_set_vf_vlan_tag_result, 12516 tag, "tag"); 12517 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 12518 TOKEN_NUM_INITIALIZER 12519 (struct cmd_set_vf_vlan_tag_result, 12520 port_id, RTE_UINT16); 12521 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 12522 TOKEN_NUM_INITIALIZER 12523 (struct cmd_set_vf_vlan_tag_result, 12524 vf_id, RTE_UINT16); 12525 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 12526 TOKEN_STRING_INITIALIZER 12527 (struct cmd_set_vf_vlan_tag_result, 12528 on_off, "on#off"); 12529 12530 static void 12531 cmd_set_vf_vlan_tag_parsed( 12532 void *parsed_result, 12533 __rte_unused struct cmdline *cl, 12534 __rte_unused void *data) 12535 { 12536 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 12537 int ret = -ENOTSUP; 12538 12539 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12540 12541 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12542 return; 12543 12544 #ifdef RTE_NET_I40E 12545 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 12546 res->vf_id, is_on); 12547 #endif 12548 12549 switch (ret) { 12550 case 0: 12551 break; 12552 case -EINVAL: 12553 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 12554 res->vf_id, is_on); 12555 break; 12556 case -ENODEV: 12557 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12558 break; 12559 case -ENOTSUP: 12560 fprintf(stderr, "function not implemented\n"); 12561 break; 12562 default: 12563 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12564 } 12565 } 12566 12567 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 12568 .f = cmd_set_vf_vlan_tag_parsed, 12569 .data = NULL, 12570 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 12571 .tokens = { 12572 (void *)&cmd_set_vf_vlan_tag_set, 12573 (void *)&cmd_set_vf_vlan_tag_vf, 12574 (void *)&cmd_set_vf_vlan_tag_vlan, 12575 (void *)&cmd_set_vf_vlan_tag_tag, 12576 (void *)&cmd_set_vf_vlan_tag_port_id, 12577 (void *)&cmd_set_vf_vlan_tag_vf_id, 12578 (void *)&cmd_set_vf_vlan_tag_on_off, 12579 NULL, 12580 }, 12581 }; 12582 12583 /* Common definition of VF and TC TX bandwidth configuration */ 12584 struct cmd_vf_tc_bw_result { 12585 cmdline_fixed_string_t set; 12586 cmdline_fixed_string_t vf; 12587 cmdline_fixed_string_t tc; 12588 cmdline_fixed_string_t tx; 12589 cmdline_fixed_string_t min_bw; 12590 cmdline_fixed_string_t max_bw; 12591 cmdline_fixed_string_t strict_link_prio; 12592 portid_t port_id; 12593 uint16_t vf_id; 12594 uint8_t tc_no; 12595 uint32_t bw; 12596 cmdline_fixed_string_t bw_list; 12597 uint8_t tc_map; 12598 }; 12599 12600 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 12601 TOKEN_STRING_INITIALIZER 12602 (struct cmd_vf_tc_bw_result, 12603 set, "set"); 12604 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 12605 TOKEN_STRING_INITIALIZER 12606 (struct cmd_vf_tc_bw_result, 12607 vf, "vf"); 12608 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 12609 TOKEN_STRING_INITIALIZER 12610 (struct cmd_vf_tc_bw_result, 12611 tc, "tc"); 12612 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 12613 TOKEN_STRING_INITIALIZER 12614 (struct cmd_vf_tc_bw_result, 12615 tx, "tx"); 12616 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 12617 TOKEN_STRING_INITIALIZER 12618 (struct cmd_vf_tc_bw_result, 12619 strict_link_prio, "strict-link-priority"); 12620 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 12621 TOKEN_STRING_INITIALIZER 12622 (struct cmd_vf_tc_bw_result, 12623 min_bw, "min-bandwidth"); 12624 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 12625 TOKEN_STRING_INITIALIZER 12626 (struct cmd_vf_tc_bw_result, 12627 max_bw, "max-bandwidth"); 12628 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 12629 TOKEN_NUM_INITIALIZER 12630 (struct cmd_vf_tc_bw_result, 12631 port_id, RTE_UINT16); 12632 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 12633 TOKEN_NUM_INITIALIZER 12634 (struct cmd_vf_tc_bw_result, 12635 vf_id, RTE_UINT16); 12636 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 12637 TOKEN_NUM_INITIALIZER 12638 (struct cmd_vf_tc_bw_result, 12639 tc_no, RTE_UINT8); 12640 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 12641 TOKEN_NUM_INITIALIZER 12642 (struct cmd_vf_tc_bw_result, 12643 bw, RTE_UINT32); 12644 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 12645 TOKEN_STRING_INITIALIZER 12646 (struct cmd_vf_tc_bw_result, 12647 bw_list, NULL); 12648 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 12649 TOKEN_NUM_INITIALIZER 12650 (struct cmd_vf_tc_bw_result, 12651 tc_map, RTE_UINT8); 12652 12653 /* VF max bandwidth setting */ 12654 static void 12655 cmd_vf_max_bw_parsed( 12656 void *parsed_result, 12657 __rte_unused struct cmdline *cl, 12658 __rte_unused void *data) 12659 { 12660 struct cmd_vf_tc_bw_result *res = parsed_result; 12661 int ret = -ENOTSUP; 12662 12663 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12664 return; 12665 12666 #ifdef RTE_NET_I40E 12667 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 12668 res->vf_id, res->bw); 12669 #endif 12670 12671 switch (ret) { 12672 case 0: 12673 break; 12674 case -EINVAL: 12675 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n", 12676 res->vf_id, res->bw); 12677 break; 12678 case -ENODEV: 12679 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12680 break; 12681 case -ENOTSUP: 12682 fprintf(stderr, "function not implemented\n"); 12683 break; 12684 default: 12685 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12686 } 12687 } 12688 12689 cmdline_parse_inst_t cmd_vf_max_bw = { 12690 .f = cmd_vf_max_bw_parsed, 12691 .data = NULL, 12692 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 12693 .tokens = { 12694 (void *)&cmd_vf_tc_bw_set, 12695 (void *)&cmd_vf_tc_bw_vf, 12696 (void *)&cmd_vf_tc_bw_tx, 12697 (void *)&cmd_vf_tc_bw_max_bw, 12698 (void *)&cmd_vf_tc_bw_port_id, 12699 (void *)&cmd_vf_tc_bw_vf_id, 12700 (void *)&cmd_vf_tc_bw_bw, 12701 NULL, 12702 }, 12703 }; 12704 12705 static int 12706 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 12707 uint8_t *tc_num, 12708 char *str) 12709 { 12710 uint32_t size; 12711 const char *p, *p0 = str; 12712 char s[256]; 12713 char *end; 12714 char *str_fld[16]; 12715 uint16_t i; 12716 int ret; 12717 12718 p = strchr(p0, '('); 12719 if (p == NULL) { 12720 fprintf(stderr, 12721 "The bandwidth-list should be '(bw1, bw2, ...)'\n"); 12722 return -1; 12723 } 12724 p++; 12725 p0 = strchr(p, ')'); 12726 if (p0 == NULL) { 12727 fprintf(stderr, 12728 "The bandwidth-list should be '(bw1, bw2, ...)'\n"); 12729 return -1; 12730 } 12731 size = p0 - p; 12732 if (size >= sizeof(s)) { 12733 fprintf(stderr, 12734 "The string size exceeds the internal buffer size\n"); 12735 return -1; 12736 } 12737 snprintf(s, sizeof(s), "%.*s", size, p); 12738 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 12739 if (ret <= 0) { 12740 fprintf(stderr, "Failed to get the bandwidth list.\n"); 12741 return -1; 12742 } 12743 *tc_num = ret; 12744 for (i = 0; i < ret; i++) 12745 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 12746 12747 return 0; 12748 } 12749 12750 /* TC min bandwidth setting */ 12751 static void 12752 cmd_vf_tc_min_bw_parsed( 12753 void *parsed_result, 12754 __rte_unused struct cmdline *cl, 12755 __rte_unused void *data) 12756 { 12757 struct cmd_vf_tc_bw_result *res = parsed_result; 12758 uint8_t tc_num; 12759 uint8_t bw[16]; 12760 int ret = -ENOTSUP; 12761 12762 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12763 return; 12764 12765 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 12766 if (ret) 12767 return; 12768 12769 #ifdef RTE_NET_I40E 12770 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 12771 tc_num, bw); 12772 #endif 12773 12774 switch (ret) { 12775 case 0: 12776 break; 12777 case -EINVAL: 12778 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id); 12779 break; 12780 case -ENODEV: 12781 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12782 break; 12783 case -ENOTSUP: 12784 fprintf(stderr, "function not implemented\n"); 12785 break; 12786 default: 12787 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12788 } 12789 } 12790 12791 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 12792 .f = cmd_vf_tc_min_bw_parsed, 12793 .data = NULL, 12794 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 12795 " <bw1, bw2, ...>", 12796 .tokens = { 12797 (void *)&cmd_vf_tc_bw_set, 12798 (void *)&cmd_vf_tc_bw_vf, 12799 (void *)&cmd_vf_tc_bw_tc, 12800 (void *)&cmd_vf_tc_bw_tx, 12801 (void *)&cmd_vf_tc_bw_min_bw, 12802 (void *)&cmd_vf_tc_bw_port_id, 12803 (void *)&cmd_vf_tc_bw_vf_id, 12804 (void *)&cmd_vf_tc_bw_bw_list, 12805 NULL, 12806 }, 12807 }; 12808 12809 static void 12810 cmd_tc_min_bw_parsed( 12811 void *parsed_result, 12812 __rte_unused struct cmdline *cl, 12813 __rte_unused void *data) 12814 { 12815 struct cmd_vf_tc_bw_result *res = parsed_result; 12816 struct rte_port *port; 12817 uint8_t tc_num; 12818 uint8_t bw[16]; 12819 int ret = -ENOTSUP; 12820 12821 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12822 return; 12823 12824 port = &ports[res->port_id]; 12825 /** Check if the port is not started **/ 12826 if (port->port_status != RTE_PORT_STOPPED) { 12827 fprintf(stderr, "Please stop port %d first\n", res->port_id); 12828 return; 12829 } 12830 12831 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 12832 if (ret) 12833 return; 12834 12835 #ifdef RTE_NET_IXGBE 12836 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 12837 #endif 12838 12839 switch (ret) { 12840 case 0: 12841 break; 12842 case -EINVAL: 12843 fprintf(stderr, "invalid bandwidth\n"); 12844 break; 12845 case -ENODEV: 12846 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12847 break; 12848 case -ENOTSUP: 12849 fprintf(stderr, "function not implemented\n"); 12850 break; 12851 default: 12852 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12853 } 12854 } 12855 12856 cmdline_parse_inst_t cmd_tc_min_bw = { 12857 .f = cmd_tc_min_bw_parsed, 12858 .data = NULL, 12859 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 12860 .tokens = { 12861 (void *)&cmd_vf_tc_bw_set, 12862 (void *)&cmd_vf_tc_bw_tc, 12863 (void *)&cmd_vf_tc_bw_tx, 12864 (void *)&cmd_vf_tc_bw_min_bw, 12865 (void *)&cmd_vf_tc_bw_port_id, 12866 (void *)&cmd_vf_tc_bw_bw_list, 12867 NULL, 12868 }, 12869 }; 12870 12871 /* TC max bandwidth setting */ 12872 static void 12873 cmd_vf_tc_max_bw_parsed( 12874 void *parsed_result, 12875 __rte_unused struct cmdline *cl, 12876 __rte_unused void *data) 12877 { 12878 struct cmd_vf_tc_bw_result *res = parsed_result; 12879 int ret = -ENOTSUP; 12880 12881 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12882 return; 12883 12884 #ifdef RTE_NET_I40E 12885 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 12886 res->tc_no, res->bw); 12887 #endif 12888 12889 switch (ret) { 12890 case 0: 12891 break; 12892 case -EINVAL: 12893 fprintf(stderr, 12894 "invalid vf_id %d, tc_no %d or bandwidth %d\n", 12895 res->vf_id, res->tc_no, res->bw); 12896 break; 12897 case -ENODEV: 12898 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12899 break; 12900 case -ENOTSUP: 12901 fprintf(stderr, "function not implemented\n"); 12902 break; 12903 default: 12904 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12905 } 12906 } 12907 12908 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 12909 .f = cmd_vf_tc_max_bw_parsed, 12910 .data = NULL, 12911 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 12912 " <bandwidth>", 12913 .tokens = { 12914 (void *)&cmd_vf_tc_bw_set, 12915 (void *)&cmd_vf_tc_bw_vf, 12916 (void *)&cmd_vf_tc_bw_tc, 12917 (void *)&cmd_vf_tc_bw_tx, 12918 (void *)&cmd_vf_tc_bw_max_bw, 12919 (void *)&cmd_vf_tc_bw_port_id, 12920 (void *)&cmd_vf_tc_bw_vf_id, 12921 (void *)&cmd_vf_tc_bw_tc_no, 12922 (void *)&cmd_vf_tc_bw_bw, 12923 NULL, 12924 }, 12925 }; 12926 12927 /** Set VXLAN encapsulation details */ 12928 struct cmd_set_vxlan_result { 12929 cmdline_fixed_string_t set; 12930 cmdline_fixed_string_t vxlan; 12931 cmdline_fixed_string_t pos_token; 12932 cmdline_fixed_string_t ip_version; 12933 uint32_t vlan_present:1; 12934 uint32_t vni; 12935 uint16_t udp_src; 12936 uint16_t udp_dst; 12937 cmdline_ipaddr_t ip_src; 12938 cmdline_ipaddr_t ip_dst; 12939 uint16_t tci; 12940 uint8_t tos; 12941 uint8_t ttl; 12942 struct rte_ether_addr eth_src; 12943 struct rte_ether_addr eth_dst; 12944 }; 12945 12946 cmdline_parse_token_string_t cmd_set_vxlan_set = 12947 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 12948 cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 12949 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 12950 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl = 12951 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 12952 "vxlan-tos-ttl"); 12953 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 12954 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 12955 "vxlan-with-vlan"); 12956 cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 12957 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12958 "ip-version"); 12959 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 12960 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 12961 "ipv4#ipv6"); 12962 cmdline_parse_token_string_t cmd_set_vxlan_vni = 12963 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12964 "vni"); 12965 cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 12966 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32); 12967 cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 12968 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12969 "udp-src"); 12970 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 12971 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16); 12972 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 12973 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12974 "udp-dst"); 12975 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 12976 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16); 12977 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos = 12978 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12979 "ip-tos"); 12980 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value = 12981 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8); 12982 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl = 12983 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12984 "ip-ttl"); 12985 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value = 12986 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8); 12987 cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 12988 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12989 "ip-src"); 12990 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 12991 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 12992 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 12993 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12994 "ip-dst"); 12995 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 12996 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 12997 cmdline_parse_token_string_t cmd_set_vxlan_vlan = 12998 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12999 "vlan-tci"); 13000 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 13001 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16); 13002 cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 13003 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 13004 "eth-src"); 13005 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 13006 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 13007 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 13008 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 13009 "eth-dst"); 13010 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 13011 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 13012 13013 static void cmd_set_vxlan_parsed(void *parsed_result, 13014 __rte_unused struct cmdline *cl, 13015 __rte_unused void *data) 13016 { 13017 struct cmd_set_vxlan_result *res = parsed_result; 13018 union { 13019 uint32_t vxlan_id; 13020 uint8_t vni[4]; 13021 } id = { 13022 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 13023 }; 13024 13025 vxlan_encap_conf.select_tos_ttl = 0; 13026 if (strcmp(res->vxlan, "vxlan") == 0) 13027 vxlan_encap_conf.select_vlan = 0; 13028 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 13029 vxlan_encap_conf.select_vlan = 1; 13030 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) { 13031 vxlan_encap_conf.select_vlan = 0; 13032 vxlan_encap_conf.select_tos_ttl = 1; 13033 } 13034 if (strcmp(res->ip_version, "ipv4") == 0) 13035 vxlan_encap_conf.select_ipv4 = 1; 13036 else if (strcmp(res->ip_version, "ipv6") == 0) 13037 vxlan_encap_conf.select_ipv4 = 0; 13038 else 13039 return; 13040 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 13041 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 13042 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 13043 vxlan_encap_conf.ip_tos = res->tos; 13044 vxlan_encap_conf.ip_ttl = res->ttl; 13045 if (vxlan_encap_conf.select_ipv4) { 13046 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 13047 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 13048 } else { 13049 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 13050 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 13051 } 13052 if (vxlan_encap_conf.select_vlan) 13053 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13054 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 13055 RTE_ETHER_ADDR_LEN); 13056 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13057 RTE_ETHER_ADDR_LEN); 13058 } 13059 13060 cmdline_parse_inst_t cmd_set_vxlan = { 13061 .f = cmd_set_vxlan_parsed, 13062 .data = NULL, 13063 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 13064 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 13065 " eth-src <eth-src> eth-dst <eth-dst>", 13066 .tokens = { 13067 (void *)&cmd_set_vxlan_set, 13068 (void *)&cmd_set_vxlan_vxlan, 13069 (void *)&cmd_set_vxlan_ip_version, 13070 (void *)&cmd_set_vxlan_ip_version_value, 13071 (void *)&cmd_set_vxlan_vni, 13072 (void *)&cmd_set_vxlan_vni_value, 13073 (void *)&cmd_set_vxlan_udp_src, 13074 (void *)&cmd_set_vxlan_udp_src_value, 13075 (void *)&cmd_set_vxlan_udp_dst, 13076 (void *)&cmd_set_vxlan_udp_dst_value, 13077 (void *)&cmd_set_vxlan_ip_src, 13078 (void *)&cmd_set_vxlan_ip_src_value, 13079 (void *)&cmd_set_vxlan_ip_dst, 13080 (void *)&cmd_set_vxlan_ip_dst_value, 13081 (void *)&cmd_set_vxlan_eth_src, 13082 (void *)&cmd_set_vxlan_eth_src_value, 13083 (void *)&cmd_set_vxlan_eth_dst, 13084 (void *)&cmd_set_vxlan_eth_dst_value, 13085 NULL, 13086 }, 13087 }; 13088 13089 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = { 13090 .f = cmd_set_vxlan_parsed, 13091 .data = NULL, 13092 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src" 13093 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>" 13094 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 13095 " eth-dst <eth-dst>", 13096 .tokens = { 13097 (void *)&cmd_set_vxlan_set, 13098 (void *)&cmd_set_vxlan_vxlan_tos_ttl, 13099 (void *)&cmd_set_vxlan_ip_version, 13100 (void *)&cmd_set_vxlan_ip_version_value, 13101 (void *)&cmd_set_vxlan_vni, 13102 (void *)&cmd_set_vxlan_vni_value, 13103 (void *)&cmd_set_vxlan_udp_src, 13104 (void *)&cmd_set_vxlan_udp_src_value, 13105 (void *)&cmd_set_vxlan_udp_dst, 13106 (void *)&cmd_set_vxlan_udp_dst_value, 13107 (void *)&cmd_set_vxlan_ip_tos, 13108 (void *)&cmd_set_vxlan_ip_tos_value, 13109 (void *)&cmd_set_vxlan_ip_ttl, 13110 (void *)&cmd_set_vxlan_ip_ttl_value, 13111 (void *)&cmd_set_vxlan_ip_src, 13112 (void *)&cmd_set_vxlan_ip_src_value, 13113 (void *)&cmd_set_vxlan_ip_dst, 13114 (void *)&cmd_set_vxlan_ip_dst_value, 13115 (void *)&cmd_set_vxlan_eth_src, 13116 (void *)&cmd_set_vxlan_eth_src_value, 13117 (void *)&cmd_set_vxlan_eth_dst, 13118 (void *)&cmd_set_vxlan_eth_dst_value, 13119 NULL, 13120 }, 13121 }; 13122 13123 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 13124 .f = cmd_set_vxlan_parsed, 13125 .data = NULL, 13126 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 13127 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 13128 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 13129 " <eth-dst>", 13130 .tokens = { 13131 (void *)&cmd_set_vxlan_set, 13132 (void *)&cmd_set_vxlan_vxlan_with_vlan, 13133 (void *)&cmd_set_vxlan_ip_version, 13134 (void *)&cmd_set_vxlan_ip_version_value, 13135 (void *)&cmd_set_vxlan_vni, 13136 (void *)&cmd_set_vxlan_vni_value, 13137 (void *)&cmd_set_vxlan_udp_src, 13138 (void *)&cmd_set_vxlan_udp_src_value, 13139 (void *)&cmd_set_vxlan_udp_dst, 13140 (void *)&cmd_set_vxlan_udp_dst_value, 13141 (void *)&cmd_set_vxlan_ip_src, 13142 (void *)&cmd_set_vxlan_ip_src_value, 13143 (void *)&cmd_set_vxlan_ip_dst, 13144 (void *)&cmd_set_vxlan_ip_dst_value, 13145 (void *)&cmd_set_vxlan_vlan, 13146 (void *)&cmd_set_vxlan_vlan_value, 13147 (void *)&cmd_set_vxlan_eth_src, 13148 (void *)&cmd_set_vxlan_eth_src_value, 13149 (void *)&cmd_set_vxlan_eth_dst, 13150 (void *)&cmd_set_vxlan_eth_dst_value, 13151 NULL, 13152 }, 13153 }; 13154 13155 /** Set NVGRE encapsulation details */ 13156 struct cmd_set_nvgre_result { 13157 cmdline_fixed_string_t set; 13158 cmdline_fixed_string_t nvgre; 13159 cmdline_fixed_string_t pos_token; 13160 cmdline_fixed_string_t ip_version; 13161 uint32_t tni; 13162 cmdline_ipaddr_t ip_src; 13163 cmdline_ipaddr_t ip_dst; 13164 uint16_t tci; 13165 struct rte_ether_addr eth_src; 13166 struct rte_ether_addr eth_dst; 13167 }; 13168 13169 cmdline_parse_token_string_t cmd_set_nvgre_set = 13170 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 13171 cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 13172 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 13173 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 13174 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 13175 "nvgre-with-vlan"); 13176 cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 13177 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 13178 "ip-version"); 13179 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 13180 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 13181 "ipv4#ipv6"); 13182 cmdline_parse_token_string_t cmd_set_nvgre_tni = 13183 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 13184 "tni"); 13185 cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 13186 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32); 13187 cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 13188 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 13189 "ip-src"); 13190 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 13191 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 13192 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 13193 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 13194 "ip-dst"); 13195 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 13196 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 13197 cmdline_parse_token_string_t cmd_set_nvgre_vlan = 13198 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 13199 "vlan-tci"); 13200 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 13201 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16); 13202 cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 13203 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 13204 "eth-src"); 13205 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 13206 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 13207 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 13208 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 13209 "eth-dst"); 13210 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 13211 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 13212 13213 static void cmd_set_nvgre_parsed(void *parsed_result, 13214 __rte_unused struct cmdline *cl, 13215 __rte_unused void *data) 13216 { 13217 struct cmd_set_nvgre_result *res = parsed_result; 13218 union { 13219 uint32_t nvgre_tni; 13220 uint8_t tni[4]; 13221 } id = { 13222 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 13223 }; 13224 13225 if (strcmp(res->nvgre, "nvgre") == 0) 13226 nvgre_encap_conf.select_vlan = 0; 13227 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 13228 nvgre_encap_conf.select_vlan = 1; 13229 if (strcmp(res->ip_version, "ipv4") == 0) 13230 nvgre_encap_conf.select_ipv4 = 1; 13231 else if (strcmp(res->ip_version, "ipv6") == 0) 13232 nvgre_encap_conf.select_ipv4 = 0; 13233 else 13234 return; 13235 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 13236 if (nvgre_encap_conf.select_ipv4) { 13237 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 13238 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 13239 } else { 13240 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 13241 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 13242 } 13243 if (nvgre_encap_conf.select_vlan) 13244 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13245 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 13246 RTE_ETHER_ADDR_LEN); 13247 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13248 RTE_ETHER_ADDR_LEN); 13249 } 13250 13251 cmdline_parse_inst_t cmd_set_nvgre = { 13252 .f = cmd_set_nvgre_parsed, 13253 .data = NULL, 13254 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 13255 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 13256 " eth-dst <eth-dst>", 13257 .tokens = { 13258 (void *)&cmd_set_nvgre_set, 13259 (void *)&cmd_set_nvgre_nvgre, 13260 (void *)&cmd_set_nvgre_ip_version, 13261 (void *)&cmd_set_nvgre_ip_version_value, 13262 (void *)&cmd_set_nvgre_tni, 13263 (void *)&cmd_set_nvgre_tni_value, 13264 (void *)&cmd_set_nvgre_ip_src, 13265 (void *)&cmd_set_nvgre_ip_src_value, 13266 (void *)&cmd_set_nvgre_ip_dst, 13267 (void *)&cmd_set_nvgre_ip_dst_value, 13268 (void *)&cmd_set_nvgre_eth_src, 13269 (void *)&cmd_set_nvgre_eth_src_value, 13270 (void *)&cmd_set_nvgre_eth_dst, 13271 (void *)&cmd_set_nvgre_eth_dst_value, 13272 NULL, 13273 }, 13274 }; 13275 13276 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 13277 .f = cmd_set_nvgre_parsed, 13278 .data = NULL, 13279 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 13280 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 13281 " eth-src <eth-src> eth-dst <eth-dst>", 13282 .tokens = { 13283 (void *)&cmd_set_nvgre_set, 13284 (void *)&cmd_set_nvgre_nvgre_with_vlan, 13285 (void *)&cmd_set_nvgre_ip_version, 13286 (void *)&cmd_set_nvgre_ip_version_value, 13287 (void *)&cmd_set_nvgre_tni, 13288 (void *)&cmd_set_nvgre_tni_value, 13289 (void *)&cmd_set_nvgre_ip_src, 13290 (void *)&cmd_set_nvgre_ip_src_value, 13291 (void *)&cmd_set_nvgre_ip_dst, 13292 (void *)&cmd_set_nvgre_ip_dst_value, 13293 (void *)&cmd_set_nvgre_vlan, 13294 (void *)&cmd_set_nvgre_vlan_value, 13295 (void *)&cmd_set_nvgre_eth_src, 13296 (void *)&cmd_set_nvgre_eth_src_value, 13297 (void *)&cmd_set_nvgre_eth_dst, 13298 (void *)&cmd_set_nvgre_eth_dst_value, 13299 NULL, 13300 }, 13301 }; 13302 13303 /** Set L2 encapsulation details */ 13304 struct cmd_set_l2_encap_result { 13305 cmdline_fixed_string_t set; 13306 cmdline_fixed_string_t l2_encap; 13307 cmdline_fixed_string_t pos_token; 13308 cmdline_fixed_string_t ip_version; 13309 uint32_t vlan_present:1; 13310 uint16_t tci; 13311 struct rte_ether_addr eth_src; 13312 struct rte_ether_addr eth_dst; 13313 }; 13314 13315 cmdline_parse_token_string_t cmd_set_l2_encap_set = 13316 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); 13317 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = 13318 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); 13319 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = 13320 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, 13321 "l2_encap-with-vlan"); 13322 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = 13323 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13324 "ip-version"); 13325 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = 13326 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, 13327 "ipv4#ipv6"); 13328 cmdline_parse_token_string_t cmd_set_l2_encap_vlan = 13329 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13330 "vlan-tci"); 13331 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = 13332 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16); 13333 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = 13334 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13335 "eth-src"); 13336 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = 13337 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); 13338 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = 13339 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13340 "eth-dst"); 13341 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = 13342 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); 13343 13344 static void cmd_set_l2_encap_parsed(void *parsed_result, 13345 __rte_unused struct cmdline *cl, 13346 __rte_unused void *data) 13347 { 13348 struct cmd_set_l2_encap_result *res = parsed_result; 13349 13350 if (strcmp(res->l2_encap, "l2_encap") == 0) 13351 l2_encap_conf.select_vlan = 0; 13352 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) 13353 l2_encap_conf.select_vlan = 1; 13354 if (strcmp(res->ip_version, "ipv4") == 0) 13355 l2_encap_conf.select_ipv4 = 1; 13356 else if (strcmp(res->ip_version, "ipv6") == 0) 13357 l2_encap_conf.select_ipv4 = 0; 13358 else 13359 return; 13360 if (l2_encap_conf.select_vlan) 13361 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13362 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, 13363 RTE_ETHER_ADDR_LEN); 13364 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13365 RTE_ETHER_ADDR_LEN); 13366 } 13367 13368 cmdline_parse_inst_t cmd_set_l2_encap = { 13369 .f = cmd_set_l2_encap_parsed, 13370 .data = NULL, 13371 .help_str = "set l2_encap ip-version ipv4|ipv6" 13372 " eth-src <eth-src> eth-dst <eth-dst>", 13373 .tokens = { 13374 (void *)&cmd_set_l2_encap_set, 13375 (void *)&cmd_set_l2_encap_l2_encap, 13376 (void *)&cmd_set_l2_encap_ip_version, 13377 (void *)&cmd_set_l2_encap_ip_version_value, 13378 (void *)&cmd_set_l2_encap_eth_src, 13379 (void *)&cmd_set_l2_encap_eth_src_value, 13380 (void *)&cmd_set_l2_encap_eth_dst, 13381 (void *)&cmd_set_l2_encap_eth_dst_value, 13382 NULL, 13383 }, 13384 }; 13385 13386 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { 13387 .f = cmd_set_l2_encap_parsed, 13388 .data = NULL, 13389 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" 13390 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 13391 .tokens = { 13392 (void *)&cmd_set_l2_encap_set, 13393 (void *)&cmd_set_l2_encap_l2_encap_with_vlan, 13394 (void *)&cmd_set_l2_encap_ip_version, 13395 (void *)&cmd_set_l2_encap_ip_version_value, 13396 (void *)&cmd_set_l2_encap_vlan, 13397 (void *)&cmd_set_l2_encap_vlan_value, 13398 (void *)&cmd_set_l2_encap_eth_src, 13399 (void *)&cmd_set_l2_encap_eth_src_value, 13400 (void *)&cmd_set_l2_encap_eth_dst, 13401 (void *)&cmd_set_l2_encap_eth_dst_value, 13402 NULL, 13403 }, 13404 }; 13405 13406 /** Set L2 decapsulation details */ 13407 struct cmd_set_l2_decap_result { 13408 cmdline_fixed_string_t set; 13409 cmdline_fixed_string_t l2_decap; 13410 cmdline_fixed_string_t pos_token; 13411 uint32_t vlan_present:1; 13412 }; 13413 13414 cmdline_parse_token_string_t cmd_set_l2_decap_set = 13415 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); 13416 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = 13417 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 13418 "l2_decap"); 13419 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = 13420 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 13421 "l2_decap-with-vlan"); 13422 13423 static void cmd_set_l2_decap_parsed(void *parsed_result, 13424 __rte_unused struct cmdline *cl, 13425 __rte_unused void *data) 13426 { 13427 struct cmd_set_l2_decap_result *res = parsed_result; 13428 13429 if (strcmp(res->l2_decap, "l2_decap") == 0) 13430 l2_decap_conf.select_vlan = 0; 13431 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) 13432 l2_decap_conf.select_vlan = 1; 13433 } 13434 13435 cmdline_parse_inst_t cmd_set_l2_decap = { 13436 .f = cmd_set_l2_decap_parsed, 13437 .data = NULL, 13438 .help_str = "set l2_decap", 13439 .tokens = { 13440 (void *)&cmd_set_l2_decap_set, 13441 (void *)&cmd_set_l2_decap_l2_decap, 13442 NULL, 13443 }, 13444 }; 13445 13446 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { 13447 .f = cmd_set_l2_decap_parsed, 13448 .data = NULL, 13449 .help_str = "set l2_decap-with-vlan", 13450 .tokens = { 13451 (void *)&cmd_set_l2_decap_set, 13452 (void *)&cmd_set_l2_decap_l2_decap_with_vlan, 13453 NULL, 13454 }, 13455 }; 13456 13457 /** Set MPLSoGRE encapsulation details */ 13458 struct cmd_set_mplsogre_encap_result { 13459 cmdline_fixed_string_t set; 13460 cmdline_fixed_string_t mplsogre; 13461 cmdline_fixed_string_t pos_token; 13462 cmdline_fixed_string_t ip_version; 13463 uint32_t vlan_present:1; 13464 uint32_t label; 13465 cmdline_ipaddr_t ip_src; 13466 cmdline_ipaddr_t ip_dst; 13467 uint16_t tci; 13468 struct rte_ether_addr eth_src; 13469 struct rte_ether_addr eth_dst; 13470 }; 13471 13472 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = 13473 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, 13474 "set"); 13475 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = 13476 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, 13477 "mplsogre_encap"); 13478 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = 13479 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13480 mplsogre, "mplsogre_encap-with-vlan"); 13481 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = 13482 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13483 pos_token, "ip-version"); 13484 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = 13485 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13486 ip_version, "ipv4#ipv6"); 13487 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = 13488 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13489 pos_token, "label"); 13490 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = 13491 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, 13492 RTE_UINT32); 13493 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = 13494 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13495 pos_token, "ip-src"); 13496 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = 13497 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); 13498 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = 13499 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13500 pos_token, "ip-dst"); 13501 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = 13502 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); 13503 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = 13504 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13505 pos_token, "vlan-tci"); 13506 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = 13507 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, 13508 RTE_UINT16); 13509 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = 13510 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13511 pos_token, "eth-src"); 13512 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = 13513 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13514 eth_src); 13515 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = 13516 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13517 pos_token, "eth-dst"); 13518 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = 13519 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13520 eth_dst); 13521 13522 static void cmd_set_mplsogre_encap_parsed(void *parsed_result, 13523 __rte_unused struct cmdline *cl, 13524 __rte_unused void *data) 13525 { 13526 struct cmd_set_mplsogre_encap_result *res = parsed_result; 13527 union { 13528 uint32_t mplsogre_label; 13529 uint8_t label[4]; 13530 } id = { 13531 .mplsogre_label = rte_cpu_to_be_32(res->label<<12), 13532 }; 13533 13534 if (strcmp(res->mplsogre, "mplsogre_encap") == 0) 13535 mplsogre_encap_conf.select_vlan = 0; 13536 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) 13537 mplsogre_encap_conf.select_vlan = 1; 13538 if (strcmp(res->ip_version, "ipv4") == 0) 13539 mplsogre_encap_conf.select_ipv4 = 1; 13540 else if (strcmp(res->ip_version, "ipv6") == 0) 13541 mplsogre_encap_conf.select_ipv4 = 0; 13542 else 13543 return; 13544 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3); 13545 if (mplsogre_encap_conf.select_ipv4) { 13546 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); 13547 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); 13548 } else { 13549 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); 13550 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); 13551 } 13552 if (mplsogre_encap_conf.select_vlan) 13553 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13554 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, 13555 RTE_ETHER_ADDR_LEN); 13556 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13557 RTE_ETHER_ADDR_LEN); 13558 } 13559 13560 cmdline_parse_inst_t cmd_set_mplsogre_encap = { 13561 .f = cmd_set_mplsogre_encap_parsed, 13562 .data = NULL, 13563 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" 13564 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 13565 " eth-dst <eth-dst>", 13566 .tokens = { 13567 (void *)&cmd_set_mplsogre_encap_set, 13568 (void *)&cmd_set_mplsogre_encap_mplsogre_encap, 13569 (void *)&cmd_set_mplsogre_encap_ip_version, 13570 (void *)&cmd_set_mplsogre_encap_ip_version_value, 13571 (void *)&cmd_set_mplsogre_encap_label, 13572 (void *)&cmd_set_mplsogre_encap_label_value, 13573 (void *)&cmd_set_mplsogre_encap_ip_src, 13574 (void *)&cmd_set_mplsogre_encap_ip_src_value, 13575 (void *)&cmd_set_mplsogre_encap_ip_dst, 13576 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 13577 (void *)&cmd_set_mplsogre_encap_eth_src, 13578 (void *)&cmd_set_mplsogre_encap_eth_src_value, 13579 (void *)&cmd_set_mplsogre_encap_eth_dst, 13580 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 13581 NULL, 13582 }, 13583 }; 13584 13585 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { 13586 .f = cmd_set_mplsogre_encap_parsed, 13587 .data = NULL, 13588 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" 13589 " label <label> ip-src <ip-src> ip-dst <ip-dst>" 13590 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 13591 .tokens = { 13592 (void *)&cmd_set_mplsogre_encap_set, 13593 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, 13594 (void *)&cmd_set_mplsogre_encap_ip_version, 13595 (void *)&cmd_set_mplsogre_encap_ip_version_value, 13596 (void *)&cmd_set_mplsogre_encap_label, 13597 (void *)&cmd_set_mplsogre_encap_label_value, 13598 (void *)&cmd_set_mplsogre_encap_ip_src, 13599 (void *)&cmd_set_mplsogre_encap_ip_src_value, 13600 (void *)&cmd_set_mplsogre_encap_ip_dst, 13601 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 13602 (void *)&cmd_set_mplsogre_encap_vlan, 13603 (void *)&cmd_set_mplsogre_encap_vlan_value, 13604 (void *)&cmd_set_mplsogre_encap_eth_src, 13605 (void *)&cmd_set_mplsogre_encap_eth_src_value, 13606 (void *)&cmd_set_mplsogre_encap_eth_dst, 13607 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 13608 NULL, 13609 }, 13610 }; 13611 13612 /** Set MPLSoGRE decapsulation details */ 13613 struct cmd_set_mplsogre_decap_result { 13614 cmdline_fixed_string_t set; 13615 cmdline_fixed_string_t mplsogre; 13616 cmdline_fixed_string_t pos_token; 13617 cmdline_fixed_string_t ip_version; 13618 uint32_t vlan_present:1; 13619 }; 13620 13621 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = 13622 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, 13623 "set"); 13624 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = 13625 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, 13626 "mplsogre_decap"); 13627 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = 13628 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 13629 mplsogre, "mplsogre_decap-with-vlan"); 13630 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = 13631 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 13632 pos_token, "ip-version"); 13633 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = 13634 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 13635 ip_version, "ipv4#ipv6"); 13636 13637 static void cmd_set_mplsogre_decap_parsed(void *parsed_result, 13638 __rte_unused struct cmdline *cl, 13639 __rte_unused void *data) 13640 { 13641 struct cmd_set_mplsogre_decap_result *res = parsed_result; 13642 13643 if (strcmp(res->mplsogre, "mplsogre_decap") == 0) 13644 mplsogre_decap_conf.select_vlan = 0; 13645 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) 13646 mplsogre_decap_conf.select_vlan = 1; 13647 if (strcmp(res->ip_version, "ipv4") == 0) 13648 mplsogre_decap_conf.select_ipv4 = 1; 13649 else if (strcmp(res->ip_version, "ipv6") == 0) 13650 mplsogre_decap_conf.select_ipv4 = 0; 13651 } 13652 13653 cmdline_parse_inst_t cmd_set_mplsogre_decap = { 13654 .f = cmd_set_mplsogre_decap_parsed, 13655 .data = NULL, 13656 .help_str = "set mplsogre_decap ip-version ipv4|ipv6", 13657 .tokens = { 13658 (void *)&cmd_set_mplsogre_decap_set, 13659 (void *)&cmd_set_mplsogre_decap_mplsogre_decap, 13660 (void *)&cmd_set_mplsogre_decap_ip_version, 13661 (void *)&cmd_set_mplsogre_decap_ip_version_value, 13662 NULL, 13663 }, 13664 }; 13665 13666 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { 13667 .f = cmd_set_mplsogre_decap_parsed, 13668 .data = NULL, 13669 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", 13670 .tokens = { 13671 (void *)&cmd_set_mplsogre_decap_set, 13672 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, 13673 (void *)&cmd_set_mplsogre_decap_ip_version, 13674 (void *)&cmd_set_mplsogre_decap_ip_version_value, 13675 NULL, 13676 }, 13677 }; 13678 13679 /** Set MPLSoUDP encapsulation details */ 13680 struct cmd_set_mplsoudp_encap_result { 13681 cmdline_fixed_string_t set; 13682 cmdline_fixed_string_t mplsoudp; 13683 cmdline_fixed_string_t pos_token; 13684 cmdline_fixed_string_t ip_version; 13685 uint32_t vlan_present:1; 13686 uint32_t label; 13687 uint16_t udp_src; 13688 uint16_t udp_dst; 13689 cmdline_ipaddr_t ip_src; 13690 cmdline_ipaddr_t ip_dst; 13691 uint16_t tci; 13692 struct rte_ether_addr eth_src; 13693 struct rte_ether_addr eth_dst; 13694 }; 13695 13696 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = 13697 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, 13698 "set"); 13699 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = 13700 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, 13701 "mplsoudp_encap"); 13702 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = 13703 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13704 mplsoudp, "mplsoudp_encap-with-vlan"); 13705 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = 13706 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13707 pos_token, "ip-version"); 13708 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = 13709 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13710 ip_version, "ipv4#ipv6"); 13711 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = 13712 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13713 pos_token, "label"); 13714 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = 13715 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, 13716 RTE_UINT32); 13717 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = 13718 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13719 pos_token, "udp-src"); 13720 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = 13721 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, 13722 RTE_UINT16); 13723 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = 13724 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13725 pos_token, "udp-dst"); 13726 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = 13727 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, 13728 RTE_UINT16); 13729 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = 13730 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13731 pos_token, "ip-src"); 13732 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = 13733 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); 13734 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = 13735 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13736 pos_token, "ip-dst"); 13737 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = 13738 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); 13739 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = 13740 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13741 pos_token, "vlan-tci"); 13742 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = 13743 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, 13744 RTE_UINT16); 13745 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = 13746 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13747 pos_token, "eth-src"); 13748 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = 13749 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13750 eth_src); 13751 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = 13752 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13753 pos_token, "eth-dst"); 13754 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = 13755 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13756 eth_dst); 13757 13758 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, 13759 __rte_unused struct cmdline *cl, 13760 __rte_unused void *data) 13761 { 13762 struct cmd_set_mplsoudp_encap_result *res = parsed_result; 13763 union { 13764 uint32_t mplsoudp_label; 13765 uint8_t label[4]; 13766 } id = { 13767 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12), 13768 }; 13769 13770 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) 13771 mplsoudp_encap_conf.select_vlan = 0; 13772 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) 13773 mplsoudp_encap_conf.select_vlan = 1; 13774 if (strcmp(res->ip_version, "ipv4") == 0) 13775 mplsoudp_encap_conf.select_ipv4 = 1; 13776 else if (strcmp(res->ip_version, "ipv6") == 0) 13777 mplsoudp_encap_conf.select_ipv4 = 0; 13778 else 13779 return; 13780 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3); 13781 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 13782 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 13783 if (mplsoudp_encap_conf.select_ipv4) { 13784 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); 13785 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); 13786 } else { 13787 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); 13788 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); 13789 } 13790 if (mplsoudp_encap_conf.select_vlan) 13791 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13792 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, 13793 RTE_ETHER_ADDR_LEN); 13794 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13795 RTE_ETHER_ADDR_LEN); 13796 } 13797 13798 cmdline_parse_inst_t cmd_set_mplsoudp_encap = { 13799 .f = cmd_set_mplsoudp_encap_parsed, 13800 .data = NULL, 13801 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" 13802 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" 13803 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", 13804 .tokens = { 13805 (void *)&cmd_set_mplsoudp_encap_set, 13806 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, 13807 (void *)&cmd_set_mplsoudp_encap_ip_version, 13808 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 13809 (void *)&cmd_set_mplsoudp_encap_label, 13810 (void *)&cmd_set_mplsoudp_encap_label_value, 13811 (void *)&cmd_set_mplsoudp_encap_udp_src, 13812 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 13813 (void *)&cmd_set_mplsoudp_encap_udp_dst, 13814 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 13815 (void *)&cmd_set_mplsoudp_encap_ip_src, 13816 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 13817 (void *)&cmd_set_mplsoudp_encap_ip_dst, 13818 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 13819 (void *)&cmd_set_mplsoudp_encap_eth_src, 13820 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 13821 (void *)&cmd_set_mplsoudp_encap_eth_dst, 13822 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 13823 NULL, 13824 }, 13825 }; 13826 13827 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { 13828 .f = cmd_set_mplsoudp_encap_parsed, 13829 .data = NULL, 13830 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" 13831 " label <label> udp-src <udp-src> udp-dst <udp-dst>" 13832 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 13833 " eth-src <eth-src> eth-dst <eth-dst>", 13834 .tokens = { 13835 (void *)&cmd_set_mplsoudp_encap_set, 13836 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, 13837 (void *)&cmd_set_mplsoudp_encap_ip_version, 13838 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 13839 (void *)&cmd_set_mplsoudp_encap_label, 13840 (void *)&cmd_set_mplsoudp_encap_label_value, 13841 (void *)&cmd_set_mplsoudp_encap_udp_src, 13842 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 13843 (void *)&cmd_set_mplsoudp_encap_udp_dst, 13844 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 13845 (void *)&cmd_set_mplsoudp_encap_ip_src, 13846 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 13847 (void *)&cmd_set_mplsoudp_encap_ip_dst, 13848 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 13849 (void *)&cmd_set_mplsoudp_encap_vlan, 13850 (void *)&cmd_set_mplsoudp_encap_vlan_value, 13851 (void *)&cmd_set_mplsoudp_encap_eth_src, 13852 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 13853 (void *)&cmd_set_mplsoudp_encap_eth_dst, 13854 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 13855 NULL, 13856 }, 13857 }; 13858 13859 /** Set MPLSoUDP decapsulation details */ 13860 struct cmd_set_mplsoudp_decap_result { 13861 cmdline_fixed_string_t set; 13862 cmdline_fixed_string_t mplsoudp; 13863 cmdline_fixed_string_t pos_token; 13864 cmdline_fixed_string_t ip_version; 13865 uint32_t vlan_present:1; 13866 }; 13867 13868 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = 13869 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, 13870 "set"); 13871 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = 13872 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, 13873 "mplsoudp_decap"); 13874 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = 13875 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 13876 mplsoudp, "mplsoudp_decap-with-vlan"); 13877 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = 13878 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 13879 pos_token, "ip-version"); 13880 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = 13881 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 13882 ip_version, "ipv4#ipv6"); 13883 13884 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, 13885 __rte_unused struct cmdline *cl, 13886 __rte_unused void *data) 13887 { 13888 struct cmd_set_mplsoudp_decap_result *res = parsed_result; 13889 13890 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) 13891 mplsoudp_decap_conf.select_vlan = 0; 13892 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) 13893 mplsoudp_decap_conf.select_vlan = 1; 13894 if (strcmp(res->ip_version, "ipv4") == 0) 13895 mplsoudp_decap_conf.select_ipv4 = 1; 13896 else if (strcmp(res->ip_version, "ipv6") == 0) 13897 mplsoudp_decap_conf.select_ipv4 = 0; 13898 } 13899 13900 cmdline_parse_inst_t cmd_set_mplsoudp_decap = { 13901 .f = cmd_set_mplsoudp_decap_parsed, 13902 .data = NULL, 13903 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", 13904 .tokens = { 13905 (void *)&cmd_set_mplsoudp_decap_set, 13906 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, 13907 (void *)&cmd_set_mplsoudp_decap_ip_version, 13908 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 13909 NULL, 13910 }, 13911 }; 13912 13913 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { 13914 .f = cmd_set_mplsoudp_decap_parsed, 13915 .data = NULL, 13916 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", 13917 .tokens = { 13918 (void *)&cmd_set_mplsoudp_decap_set, 13919 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, 13920 (void *)&cmd_set_mplsoudp_decap_ip_version, 13921 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 13922 NULL, 13923 }, 13924 }; 13925 13926 /** Set connection tracking object common details */ 13927 struct cmd_set_conntrack_common_result { 13928 cmdline_fixed_string_t set; 13929 cmdline_fixed_string_t conntrack; 13930 cmdline_fixed_string_t common; 13931 cmdline_fixed_string_t peer; 13932 cmdline_fixed_string_t is_orig; 13933 cmdline_fixed_string_t enable; 13934 cmdline_fixed_string_t live; 13935 cmdline_fixed_string_t sack; 13936 cmdline_fixed_string_t cack; 13937 cmdline_fixed_string_t last_dir; 13938 cmdline_fixed_string_t liberal; 13939 cmdline_fixed_string_t state; 13940 cmdline_fixed_string_t max_ack_win; 13941 cmdline_fixed_string_t retrans; 13942 cmdline_fixed_string_t last_win; 13943 cmdline_fixed_string_t last_seq; 13944 cmdline_fixed_string_t last_ack; 13945 cmdline_fixed_string_t last_end; 13946 cmdline_fixed_string_t last_index; 13947 uint8_t stat; 13948 uint8_t factor; 13949 uint16_t peer_port; 13950 uint32_t is_original; 13951 uint32_t en; 13952 uint32_t is_live; 13953 uint32_t s_ack; 13954 uint32_t c_ack; 13955 uint32_t ld; 13956 uint32_t lb; 13957 uint8_t re_num; 13958 uint8_t li; 13959 uint16_t lw; 13960 uint32_t ls; 13961 uint32_t la; 13962 uint32_t le; 13963 }; 13964 13965 cmdline_parse_token_string_t cmd_set_conntrack_set = 13966 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13967 set, "set"); 13968 cmdline_parse_token_string_t cmd_set_conntrack_conntrack = 13969 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13970 conntrack, "conntrack"); 13971 cmdline_parse_token_string_t cmd_set_conntrack_common_com = 13972 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13973 common, "com"); 13974 cmdline_parse_token_string_t cmd_set_conntrack_common_peer = 13975 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13976 peer, "peer"); 13977 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value = 13978 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13979 peer_port, RTE_UINT16); 13980 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig = 13981 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13982 is_orig, "is_orig"); 13983 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value = 13984 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13985 is_original, RTE_UINT32); 13986 cmdline_parse_token_string_t cmd_set_conntrack_common_enable = 13987 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13988 enable, "enable"); 13989 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value = 13990 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13991 en, RTE_UINT32); 13992 cmdline_parse_token_string_t cmd_set_conntrack_common_live = 13993 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13994 live, "live"); 13995 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value = 13996 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13997 is_live, RTE_UINT32); 13998 cmdline_parse_token_string_t cmd_set_conntrack_common_sack = 13999 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14000 sack, "sack"); 14001 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value = 14002 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14003 s_ack, RTE_UINT32); 14004 cmdline_parse_token_string_t cmd_set_conntrack_common_cack = 14005 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14006 cack, "cack"); 14007 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value = 14008 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14009 c_ack, RTE_UINT32); 14010 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir = 14011 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14012 last_dir, "last_dir"); 14013 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value = 14014 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14015 ld, RTE_UINT32); 14016 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal = 14017 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14018 liberal, "liberal"); 14019 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value = 14020 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14021 lb, RTE_UINT32); 14022 cmdline_parse_token_string_t cmd_set_conntrack_common_state = 14023 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14024 state, "state"); 14025 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value = 14026 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14027 stat, RTE_UINT8); 14028 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin = 14029 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14030 max_ack_win, "max_ack_win"); 14031 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value = 14032 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14033 factor, RTE_UINT8); 14034 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans = 14035 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14036 retrans, "r_lim"); 14037 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value = 14038 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14039 re_num, RTE_UINT8); 14040 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win = 14041 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14042 last_win, "last_win"); 14043 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value = 14044 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14045 lw, RTE_UINT16); 14046 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq = 14047 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14048 last_seq, "last_seq"); 14049 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value = 14050 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14051 ls, RTE_UINT32); 14052 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack = 14053 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14054 last_ack, "last_ack"); 14055 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value = 14056 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14057 la, RTE_UINT32); 14058 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end = 14059 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14060 last_end, "last_end"); 14061 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value = 14062 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14063 le, RTE_UINT32); 14064 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index = 14065 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14066 last_index, "last_index"); 14067 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value = 14068 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14069 li, RTE_UINT8); 14070 14071 static void cmd_set_conntrack_common_parsed(void *parsed_result, 14072 __rte_unused struct cmdline *cl, 14073 __rte_unused void *data) 14074 { 14075 struct cmd_set_conntrack_common_result *res = parsed_result; 14076 14077 /* No need to swap to big endian. */ 14078 conntrack_context.peer_port = res->peer_port; 14079 conntrack_context.is_original_dir = res->is_original; 14080 conntrack_context.enable = res->en; 14081 conntrack_context.live_connection = res->is_live; 14082 conntrack_context.selective_ack = res->s_ack; 14083 conntrack_context.challenge_ack_passed = res->c_ack; 14084 conntrack_context.last_direction = res->ld; 14085 conntrack_context.liberal_mode = res->lb; 14086 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat; 14087 conntrack_context.max_ack_window = res->factor; 14088 conntrack_context.retransmission_limit = res->re_num; 14089 conntrack_context.last_window = res->lw; 14090 conntrack_context.last_index = 14091 (enum rte_flow_conntrack_tcp_last_index)res->li; 14092 conntrack_context.last_seq = res->ls; 14093 conntrack_context.last_ack = res->la; 14094 conntrack_context.last_end = res->le; 14095 } 14096 14097 cmdline_parse_inst_t cmd_set_conntrack_common = { 14098 .f = cmd_set_conntrack_common_parsed, 14099 .data = NULL, 14100 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>" 14101 " live <ack_seen> sack <en> cack <passed> last_dir <dir>" 14102 " liberal <en> state <s> max_ack_win <factor> r_lim <num>" 14103 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>" 14104 " last_index <flag>", 14105 .tokens = { 14106 (void *)&cmd_set_conntrack_set, 14107 (void *)&cmd_set_conntrack_conntrack, 14108 (void *)&cmd_set_conntrack_common_com, 14109 (void *)&cmd_set_conntrack_common_peer, 14110 (void *)&cmd_set_conntrack_common_peer_value, 14111 (void *)&cmd_set_conntrack_common_is_orig, 14112 (void *)&cmd_set_conntrack_common_is_orig_value, 14113 (void *)&cmd_set_conntrack_common_enable, 14114 (void *)&cmd_set_conntrack_common_enable_value, 14115 (void *)&cmd_set_conntrack_common_live, 14116 (void *)&cmd_set_conntrack_common_live_value, 14117 (void *)&cmd_set_conntrack_common_sack, 14118 (void *)&cmd_set_conntrack_common_sack_value, 14119 (void *)&cmd_set_conntrack_common_cack, 14120 (void *)&cmd_set_conntrack_common_cack_value, 14121 (void *)&cmd_set_conntrack_common_last_dir, 14122 (void *)&cmd_set_conntrack_common_last_dir_value, 14123 (void *)&cmd_set_conntrack_common_liberal, 14124 (void *)&cmd_set_conntrack_common_liberal_value, 14125 (void *)&cmd_set_conntrack_common_state, 14126 (void *)&cmd_set_conntrack_common_state_value, 14127 (void *)&cmd_set_conntrack_common_max_ackwin, 14128 (void *)&cmd_set_conntrack_common_max_ackwin_value, 14129 (void *)&cmd_set_conntrack_common_retrans, 14130 (void *)&cmd_set_conntrack_common_retrans_value, 14131 (void *)&cmd_set_conntrack_common_last_win, 14132 (void *)&cmd_set_conntrack_common_last_win_value, 14133 (void *)&cmd_set_conntrack_common_last_seq, 14134 (void *)&cmd_set_conntrack_common_last_seq_value, 14135 (void *)&cmd_set_conntrack_common_last_ack, 14136 (void *)&cmd_set_conntrack_common_last_ack_value, 14137 (void *)&cmd_set_conntrack_common_last_end, 14138 (void *)&cmd_set_conntrack_common_last_end_value, 14139 (void *)&cmd_set_conntrack_common_last_index, 14140 (void *)&cmd_set_conntrack_common_last_index_value, 14141 NULL, 14142 }, 14143 }; 14144 14145 /** Set connection tracking object both directions' details */ 14146 struct cmd_set_conntrack_dir_result { 14147 cmdline_fixed_string_t set; 14148 cmdline_fixed_string_t conntrack; 14149 cmdline_fixed_string_t dir; 14150 cmdline_fixed_string_t scale; 14151 cmdline_fixed_string_t fin; 14152 cmdline_fixed_string_t ack_seen; 14153 cmdline_fixed_string_t unack; 14154 cmdline_fixed_string_t sent_end; 14155 cmdline_fixed_string_t reply_end; 14156 cmdline_fixed_string_t max_win; 14157 cmdline_fixed_string_t max_ack; 14158 uint32_t factor; 14159 uint32_t f; 14160 uint32_t as; 14161 uint32_t un; 14162 uint32_t se; 14163 uint32_t re; 14164 uint32_t mw; 14165 uint32_t ma; 14166 }; 14167 14168 cmdline_parse_token_string_t cmd_set_conntrack_dir_set = 14169 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14170 set, "set"); 14171 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack = 14172 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14173 conntrack, "conntrack"); 14174 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir = 14175 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14176 dir, "orig#rply"); 14177 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale = 14178 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14179 scale, "scale"); 14180 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value = 14181 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14182 factor, RTE_UINT32); 14183 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin = 14184 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14185 fin, "fin"); 14186 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value = 14187 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14188 f, RTE_UINT32); 14189 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack = 14190 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14191 ack_seen, "acked"); 14192 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value = 14193 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14194 as, RTE_UINT32); 14195 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data = 14196 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14197 unack, "unack_data"); 14198 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value = 14199 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14200 un, RTE_UINT32); 14201 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end = 14202 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14203 sent_end, "sent_end"); 14204 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value = 14205 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14206 se, RTE_UINT32); 14207 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end = 14208 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14209 reply_end, "reply_end"); 14210 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value = 14211 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14212 re, RTE_UINT32); 14213 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win = 14214 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14215 max_win, "max_win"); 14216 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value = 14217 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14218 mw, RTE_UINT32); 14219 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack = 14220 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14221 max_ack, "max_ack"); 14222 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value = 14223 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14224 ma, RTE_UINT32); 14225 14226 static void cmd_set_conntrack_dir_parsed(void *parsed_result, 14227 __rte_unused struct cmdline *cl, 14228 __rte_unused void *data) 14229 { 14230 struct cmd_set_conntrack_dir_result *res = parsed_result; 14231 struct rte_flow_tcp_dir_param *dir = NULL; 14232 14233 if (strcmp(res->dir, "orig") == 0) 14234 dir = &conntrack_context.original_dir; 14235 else if (strcmp(res->dir, "rply") == 0) 14236 dir = &conntrack_context.reply_dir; 14237 else 14238 return; 14239 dir->scale = res->factor; 14240 dir->close_initiated = res->f; 14241 dir->last_ack_seen = res->as; 14242 dir->data_unacked = res->un; 14243 dir->sent_end = res->se; 14244 dir->reply_end = res->re; 14245 dir->max_ack = res->ma; 14246 dir->max_win = res->mw; 14247 } 14248 14249 cmdline_parse_inst_t cmd_set_conntrack_dir = { 14250 .f = cmd_set_conntrack_dir_parsed, 14251 .data = NULL, 14252 .help_str = "set conntrack orig|rply scale <factor> fin <sent>" 14253 " acked <seen> unack_data <unack> sent_end <sent>" 14254 " reply_end <reply> max_win <win> max_ack <ack>", 14255 .tokens = { 14256 (void *)&cmd_set_conntrack_set, 14257 (void *)&cmd_set_conntrack_conntrack, 14258 (void *)&cmd_set_conntrack_dir_dir, 14259 (void *)&cmd_set_conntrack_dir_scale, 14260 (void *)&cmd_set_conntrack_dir_scale_value, 14261 (void *)&cmd_set_conntrack_dir_fin, 14262 (void *)&cmd_set_conntrack_dir_fin_value, 14263 (void *)&cmd_set_conntrack_dir_ack, 14264 (void *)&cmd_set_conntrack_dir_ack_value, 14265 (void *)&cmd_set_conntrack_dir_unack_data, 14266 (void *)&cmd_set_conntrack_dir_unack_data_value, 14267 (void *)&cmd_set_conntrack_dir_sent_end, 14268 (void *)&cmd_set_conntrack_dir_sent_end_value, 14269 (void *)&cmd_set_conntrack_dir_reply_end, 14270 (void *)&cmd_set_conntrack_dir_reply_end_value, 14271 (void *)&cmd_set_conntrack_dir_max_win, 14272 (void *)&cmd_set_conntrack_dir_max_win_value, 14273 (void *)&cmd_set_conntrack_dir_max_ack, 14274 (void *)&cmd_set_conntrack_dir_max_ack_value, 14275 NULL, 14276 }, 14277 }; 14278 14279 /* Strict link priority scheduling mode setting */ 14280 static void 14281 cmd_strict_link_prio_parsed( 14282 void *parsed_result, 14283 __rte_unused struct cmdline *cl, 14284 __rte_unused void *data) 14285 { 14286 struct cmd_vf_tc_bw_result *res = parsed_result; 14287 int ret = -ENOTSUP; 14288 14289 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14290 return; 14291 14292 #ifdef RTE_NET_I40E 14293 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 14294 #endif 14295 14296 switch (ret) { 14297 case 0: 14298 break; 14299 case -EINVAL: 14300 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map); 14301 break; 14302 case -ENODEV: 14303 fprintf(stderr, "invalid port_id %d\n", res->port_id); 14304 break; 14305 case -ENOTSUP: 14306 fprintf(stderr, "function not implemented\n"); 14307 break; 14308 default: 14309 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 14310 } 14311 } 14312 14313 cmdline_parse_inst_t cmd_strict_link_prio = { 14314 .f = cmd_strict_link_prio_parsed, 14315 .data = NULL, 14316 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 14317 .tokens = { 14318 (void *)&cmd_vf_tc_bw_set, 14319 (void *)&cmd_vf_tc_bw_tx, 14320 (void *)&cmd_vf_tc_bw_strict_link_prio, 14321 (void *)&cmd_vf_tc_bw_port_id, 14322 (void *)&cmd_vf_tc_bw_tc_map, 14323 NULL, 14324 }, 14325 }; 14326 14327 /* Load dynamic device personalization*/ 14328 struct cmd_ddp_add_result { 14329 cmdline_fixed_string_t ddp; 14330 cmdline_fixed_string_t add; 14331 portid_t port_id; 14332 char filepath[]; 14333 }; 14334 14335 cmdline_parse_token_string_t cmd_ddp_add_ddp = 14336 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 14337 cmdline_parse_token_string_t cmd_ddp_add_add = 14338 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 14339 cmdline_parse_token_num_t cmd_ddp_add_port_id = 14340 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, 14341 RTE_UINT16); 14342 cmdline_parse_token_string_t cmd_ddp_add_filepath = 14343 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 14344 14345 static void 14346 cmd_ddp_add_parsed( 14347 void *parsed_result, 14348 __rte_unused struct cmdline *cl, 14349 __rte_unused void *data) 14350 { 14351 struct cmd_ddp_add_result *res = parsed_result; 14352 uint8_t *buff; 14353 uint32_t size; 14354 char *filepath; 14355 char *file_fld[2]; 14356 int file_num; 14357 int ret = -ENOTSUP; 14358 14359 if (!all_ports_stopped()) { 14360 fprintf(stderr, "Please stop all ports first\n"); 14361 return; 14362 } 14363 14364 filepath = strdup(res->filepath); 14365 if (filepath == NULL) { 14366 fprintf(stderr, "Failed to allocate memory\n"); 14367 return; 14368 } 14369 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 14370 14371 buff = open_file(file_fld[0], &size); 14372 if (!buff) { 14373 free((void *)filepath); 14374 return; 14375 } 14376 14377 #ifdef RTE_NET_I40E 14378 if (ret == -ENOTSUP) 14379 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 14380 buff, size, 14381 RTE_PMD_I40E_PKG_OP_WR_ADD); 14382 #endif 14383 14384 if (ret == -EEXIST) 14385 fprintf(stderr, "Profile has already existed.\n"); 14386 else if (ret < 0) 14387 fprintf(stderr, "Failed to load profile.\n"); 14388 else if (file_num == 2) 14389 save_file(file_fld[1], buff, size); 14390 14391 close_file(buff); 14392 free((void *)filepath); 14393 } 14394 14395 cmdline_parse_inst_t cmd_ddp_add = { 14396 .f = cmd_ddp_add_parsed, 14397 .data = NULL, 14398 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 14399 .tokens = { 14400 (void *)&cmd_ddp_add_ddp, 14401 (void *)&cmd_ddp_add_add, 14402 (void *)&cmd_ddp_add_port_id, 14403 (void *)&cmd_ddp_add_filepath, 14404 NULL, 14405 }, 14406 }; 14407 14408 /* Delete dynamic device personalization*/ 14409 struct cmd_ddp_del_result { 14410 cmdline_fixed_string_t ddp; 14411 cmdline_fixed_string_t del; 14412 portid_t port_id; 14413 char filepath[]; 14414 }; 14415 14416 cmdline_parse_token_string_t cmd_ddp_del_ddp = 14417 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 14418 cmdline_parse_token_string_t cmd_ddp_del_del = 14419 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 14420 cmdline_parse_token_num_t cmd_ddp_del_port_id = 14421 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16); 14422 cmdline_parse_token_string_t cmd_ddp_del_filepath = 14423 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 14424 14425 static void 14426 cmd_ddp_del_parsed( 14427 void *parsed_result, 14428 __rte_unused struct cmdline *cl, 14429 __rte_unused void *data) 14430 { 14431 struct cmd_ddp_del_result *res = parsed_result; 14432 uint8_t *buff; 14433 uint32_t size; 14434 int ret = -ENOTSUP; 14435 14436 if (!all_ports_stopped()) { 14437 fprintf(stderr, "Please stop all ports first\n"); 14438 return; 14439 } 14440 14441 buff = open_file(res->filepath, &size); 14442 if (!buff) 14443 return; 14444 14445 #ifdef RTE_NET_I40E 14446 if (ret == -ENOTSUP) 14447 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 14448 buff, size, 14449 RTE_PMD_I40E_PKG_OP_WR_DEL); 14450 #endif 14451 14452 if (ret == -EACCES) 14453 fprintf(stderr, "Profile does not exist.\n"); 14454 else if (ret < 0) 14455 fprintf(stderr, "Failed to delete profile.\n"); 14456 14457 close_file(buff); 14458 } 14459 14460 cmdline_parse_inst_t cmd_ddp_del = { 14461 .f = cmd_ddp_del_parsed, 14462 .data = NULL, 14463 .help_str = "ddp del <port_id> <backup_profile_path>", 14464 .tokens = { 14465 (void *)&cmd_ddp_del_ddp, 14466 (void *)&cmd_ddp_del_del, 14467 (void *)&cmd_ddp_del_port_id, 14468 (void *)&cmd_ddp_del_filepath, 14469 NULL, 14470 }, 14471 }; 14472 14473 /* Get dynamic device personalization profile info */ 14474 struct cmd_ddp_info_result { 14475 cmdline_fixed_string_t ddp; 14476 cmdline_fixed_string_t get; 14477 cmdline_fixed_string_t info; 14478 char filepath[]; 14479 }; 14480 14481 cmdline_parse_token_string_t cmd_ddp_info_ddp = 14482 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 14483 cmdline_parse_token_string_t cmd_ddp_info_get = 14484 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 14485 cmdline_parse_token_string_t cmd_ddp_info_info = 14486 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 14487 cmdline_parse_token_string_t cmd_ddp_info_filepath = 14488 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 14489 14490 static void 14491 cmd_ddp_info_parsed( 14492 void *parsed_result, 14493 __rte_unused struct cmdline *cl, 14494 __rte_unused void *data) 14495 { 14496 struct cmd_ddp_info_result *res = parsed_result; 14497 uint8_t *pkg; 14498 uint32_t pkg_size; 14499 int ret = -ENOTSUP; 14500 #ifdef RTE_NET_I40E 14501 uint32_t i, j, n; 14502 uint8_t *buff; 14503 uint32_t buff_size = 0; 14504 struct rte_pmd_i40e_profile_info info; 14505 uint32_t dev_num = 0; 14506 struct rte_pmd_i40e_ddp_device_id *devs; 14507 uint32_t proto_num = 0; 14508 struct rte_pmd_i40e_proto_info *proto = NULL; 14509 uint32_t pctype_num = 0; 14510 struct rte_pmd_i40e_ptype_info *pctype; 14511 uint32_t ptype_num = 0; 14512 struct rte_pmd_i40e_ptype_info *ptype; 14513 uint8_t proto_id; 14514 14515 #endif 14516 14517 pkg = open_file(res->filepath, &pkg_size); 14518 if (!pkg) 14519 return; 14520 14521 #ifdef RTE_NET_I40E 14522 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14523 (uint8_t *)&info, sizeof(info), 14524 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 14525 if (!ret) { 14526 printf("Global Track id: 0x%x\n", info.track_id); 14527 printf("Global Version: %d.%d.%d.%d\n", 14528 info.version.major, 14529 info.version.minor, 14530 info.version.update, 14531 info.version.draft); 14532 printf("Global Package name: %s\n\n", info.name); 14533 } 14534 14535 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14536 (uint8_t *)&info, sizeof(info), 14537 RTE_PMD_I40E_PKG_INFO_HEADER); 14538 if (!ret) { 14539 printf("i40e Profile Track id: 0x%x\n", info.track_id); 14540 printf("i40e Profile Version: %d.%d.%d.%d\n", 14541 info.version.major, 14542 info.version.minor, 14543 info.version.update, 14544 info.version.draft); 14545 printf("i40e Profile name: %s\n\n", info.name); 14546 } 14547 14548 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14549 (uint8_t *)&buff_size, sizeof(buff_size), 14550 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 14551 if (!ret && buff_size) { 14552 buff = (uint8_t *)malloc(buff_size); 14553 if (buff) { 14554 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14555 buff, buff_size, 14556 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 14557 if (!ret) 14558 printf("Package Notes:\n%s\n\n", buff); 14559 free(buff); 14560 } 14561 } 14562 14563 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14564 (uint8_t *)&dev_num, sizeof(dev_num), 14565 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 14566 if (!ret && dev_num) { 14567 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 14568 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 14569 if (devs) { 14570 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14571 (uint8_t *)devs, buff_size, 14572 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 14573 if (!ret) { 14574 printf("List of supported devices:\n"); 14575 for (i = 0; i < dev_num; i++) { 14576 printf(" %04X:%04X %04X:%04X\n", 14577 devs[i].vendor_dev_id >> 16, 14578 devs[i].vendor_dev_id & 0xFFFF, 14579 devs[i].sub_vendor_dev_id >> 16, 14580 devs[i].sub_vendor_dev_id & 0xFFFF); 14581 } 14582 printf("\n"); 14583 } 14584 free(devs); 14585 } 14586 } 14587 14588 /* get information about protocols and packet types */ 14589 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14590 (uint8_t *)&proto_num, sizeof(proto_num), 14591 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 14592 if (ret || !proto_num) 14593 goto no_print_return; 14594 14595 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 14596 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 14597 if (!proto) 14598 goto no_print_return; 14599 14600 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 14601 buff_size, 14602 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 14603 if (!ret) { 14604 printf("List of used protocols:\n"); 14605 for (i = 0; i < proto_num; i++) 14606 printf(" %2u: %s\n", proto[i].proto_id, 14607 proto[i].name); 14608 printf("\n"); 14609 } 14610 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14611 (uint8_t *)&pctype_num, sizeof(pctype_num), 14612 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 14613 if (ret || !pctype_num) 14614 goto no_print_pctypes; 14615 14616 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 14617 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 14618 if (!pctype) 14619 goto no_print_pctypes; 14620 14621 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 14622 buff_size, 14623 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 14624 if (ret) { 14625 free(pctype); 14626 goto no_print_pctypes; 14627 } 14628 14629 printf("List of defined packet classification types:\n"); 14630 for (i = 0; i < pctype_num; i++) { 14631 printf(" %2u:", pctype[i].ptype_id); 14632 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 14633 proto_id = pctype[i].protocols[j]; 14634 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 14635 for (n = 0; n < proto_num; n++) { 14636 if (proto[n].proto_id == proto_id) { 14637 printf(" %s", proto[n].name); 14638 break; 14639 } 14640 } 14641 } 14642 } 14643 printf("\n"); 14644 } 14645 printf("\n"); 14646 free(pctype); 14647 14648 no_print_pctypes: 14649 14650 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 14651 sizeof(ptype_num), 14652 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 14653 if (ret || !ptype_num) 14654 goto no_print_return; 14655 14656 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 14657 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 14658 if (!ptype) 14659 goto no_print_return; 14660 14661 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 14662 buff_size, 14663 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 14664 if (ret) { 14665 free(ptype); 14666 goto no_print_return; 14667 } 14668 printf("List of defined packet types:\n"); 14669 for (i = 0; i < ptype_num; i++) { 14670 printf(" %2u:", ptype[i].ptype_id); 14671 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 14672 proto_id = ptype[i].protocols[j]; 14673 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 14674 for (n = 0; n < proto_num; n++) { 14675 if (proto[n].proto_id == proto_id) { 14676 printf(" %s", proto[n].name); 14677 break; 14678 } 14679 } 14680 } 14681 } 14682 printf("\n"); 14683 } 14684 free(ptype); 14685 printf("\n"); 14686 14687 ret = 0; 14688 no_print_return: 14689 if (proto) 14690 free(proto); 14691 #endif 14692 if (ret == -ENOTSUP) 14693 fprintf(stderr, "Function not supported in PMD driver\n"); 14694 close_file(pkg); 14695 } 14696 14697 cmdline_parse_inst_t cmd_ddp_get_info = { 14698 .f = cmd_ddp_info_parsed, 14699 .data = NULL, 14700 .help_str = "ddp get info <profile_path>", 14701 .tokens = { 14702 (void *)&cmd_ddp_info_ddp, 14703 (void *)&cmd_ddp_info_get, 14704 (void *)&cmd_ddp_info_info, 14705 (void *)&cmd_ddp_info_filepath, 14706 NULL, 14707 }, 14708 }; 14709 14710 /* Get dynamic device personalization profile info list*/ 14711 #define PROFILE_INFO_SIZE 48 14712 #define MAX_PROFILE_NUM 16 14713 14714 struct cmd_ddp_get_list_result { 14715 cmdline_fixed_string_t ddp; 14716 cmdline_fixed_string_t get; 14717 cmdline_fixed_string_t list; 14718 portid_t port_id; 14719 }; 14720 14721 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 14722 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 14723 cmdline_parse_token_string_t cmd_ddp_get_list_get = 14724 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 14725 cmdline_parse_token_string_t cmd_ddp_get_list_list = 14726 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 14727 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 14728 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, 14729 RTE_UINT16); 14730 14731 static void 14732 cmd_ddp_get_list_parsed( 14733 __rte_unused void *parsed_result, 14734 __rte_unused struct cmdline *cl, 14735 __rte_unused void *data) 14736 { 14737 #ifdef RTE_NET_I40E 14738 struct cmd_ddp_get_list_result *res = parsed_result; 14739 struct rte_pmd_i40e_profile_list *p_list; 14740 struct rte_pmd_i40e_profile_info *p_info; 14741 uint32_t p_num; 14742 uint32_t size; 14743 uint32_t i; 14744 #endif 14745 int ret = -ENOTSUP; 14746 14747 #ifdef RTE_NET_I40E 14748 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 14749 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 14750 if (!p_list) { 14751 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__); 14752 return; 14753 } 14754 14755 if (ret == -ENOTSUP) 14756 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 14757 (uint8_t *)p_list, size); 14758 14759 if (!ret) { 14760 p_num = p_list->p_count; 14761 printf("Profile number is: %d\n\n", p_num); 14762 14763 for (i = 0; i < p_num; i++) { 14764 p_info = &p_list->p_info[i]; 14765 printf("Profile %d:\n", i); 14766 printf("Track id: 0x%x\n", p_info->track_id); 14767 printf("Version: %d.%d.%d.%d\n", 14768 p_info->version.major, 14769 p_info->version.minor, 14770 p_info->version.update, 14771 p_info->version.draft); 14772 printf("Profile name: %s\n\n", p_info->name); 14773 } 14774 } 14775 14776 free(p_list); 14777 #endif 14778 14779 if (ret < 0) 14780 fprintf(stderr, "Failed to get ddp list\n"); 14781 } 14782 14783 cmdline_parse_inst_t cmd_ddp_get_list = { 14784 .f = cmd_ddp_get_list_parsed, 14785 .data = NULL, 14786 .help_str = "ddp get list <port_id>", 14787 .tokens = { 14788 (void *)&cmd_ddp_get_list_ddp, 14789 (void *)&cmd_ddp_get_list_get, 14790 (void *)&cmd_ddp_get_list_list, 14791 (void *)&cmd_ddp_get_list_port_id, 14792 NULL, 14793 }, 14794 }; 14795 14796 /* Configure input set */ 14797 struct cmd_cfg_input_set_result { 14798 cmdline_fixed_string_t port; 14799 cmdline_fixed_string_t cfg; 14800 portid_t port_id; 14801 cmdline_fixed_string_t pctype; 14802 uint8_t pctype_id; 14803 cmdline_fixed_string_t inset_type; 14804 cmdline_fixed_string_t opt; 14805 cmdline_fixed_string_t field; 14806 uint8_t field_idx; 14807 }; 14808 14809 static void 14810 cmd_cfg_input_set_parsed( 14811 __rte_unused void *parsed_result, 14812 __rte_unused struct cmdline *cl, 14813 __rte_unused void *data) 14814 { 14815 #ifdef RTE_NET_I40E 14816 struct cmd_cfg_input_set_result *res = parsed_result; 14817 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 14818 struct rte_pmd_i40e_inset inset; 14819 #endif 14820 int ret = -ENOTSUP; 14821 14822 if (!all_ports_stopped()) { 14823 fprintf(stderr, "Please stop all ports first\n"); 14824 return; 14825 } 14826 14827 #ifdef RTE_NET_I40E 14828 if (!strcmp(res->inset_type, "hash_inset")) 14829 inset_type = INSET_HASH; 14830 else if (!strcmp(res->inset_type, "fdir_inset")) 14831 inset_type = INSET_FDIR; 14832 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 14833 inset_type = INSET_FDIR_FLX; 14834 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 14835 &inset, inset_type); 14836 if (ret) { 14837 fprintf(stderr, "Failed to get input set.\n"); 14838 return; 14839 } 14840 14841 if (!strcmp(res->opt, "get")) { 14842 ret = rte_pmd_i40e_inset_field_get(inset.inset, 14843 res->field_idx); 14844 if (ret) 14845 printf("Field index %d is enabled.\n", res->field_idx); 14846 else 14847 printf("Field index %d is disabled.\n", res->field_idx); 14848 return; 14849 } else if (!strcmp(res->opt, "set")) 14850 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 14851 res->field_idx); 14852 else if (!strcmp(res->opt, "clear")) 14853 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 14854 res->field_idx); 14855 if (ret) { 14856 fprintf(stderr, "Failed to configure input set field.\n"); 14857 return; 14858 } 14859 14860 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 14861 &inset, inset_type); 14862 if (ret) { 14863 fprintf(stderr, "Failed to set input set.\n"); 14864 return; 14865 } 14866 #endif 14867 14868 if (ret == -ENOTSUP) 14869 fprintf(stderr, "Function not supported\n"); 14870 } 14871 14872 cmdline_parse_token_string_t cmd_cfg_input_set_port = 14873 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14874 port, "port"); 14875 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 14876 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14877 cfg, "config"); 14878 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 14879 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 14880 port_id, RTE_UINT16); 14881 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 14882 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14883 pctype, "pctype"); 14884 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 14885 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 14886 pctype_id, RTE_UINT8); 14887 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 14888 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14889 inset_type, 14890 "hash_inset#fdir_inset#fdir_flx_inset"); 14891 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 14892 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14893 opt, "get#set#clear"); 14894 cmdline_parse_token_string_t cmd_cfg_input_set_field = 14895 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14896 field, "field"); 14897 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 14898 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 14899 field_idx, RTE_UINT8); 14900 14901 cmdline_parse_inst_t cmd_cfg_input_set = { 14902 .f = cmd_cfg_input_set_parsed, 14903 .data = NULL, 14904 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 14905 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 14906 .tokens = { 14907 (void *)&cmd_cfg_input_set_port, 14908 (void *)&cmd_cfg_input_set_cfg, 14909 (void *)&cmd_cfg_input_set_port_id, 14910 (void *)&cmd_cfg_input_set_pctype, 14911 (void *)&cmd_cfg_input_set_pctype_id, 14912 (void *)&cmd_cfg_input_set_inset_type, 14913 (void *)&cmd_cfg_input_set_opt, 14914 (void *)&cmd_cfg_input_set_field, 14915 (void *)&cmd_cfg_input_set_field_idx, 14916 NULL, 14917 }, 14918 }; 14919 14920 /* Clear input set */ 14921 struct cmd_clear_input_set_result { 14922 cmdline_fixed_string_t port; 14923 cmdline_fixed_string_t cfg; 14924 portid_t port_id; 14925 cmdline_fixed_string_t pctype; 14926 uint8_t pctype_id; 14927 cmdline_fixed_string_t inset_type; 14928 cmdline_fixed_string_t clear; 14929 cmdline_fixed_string_t all; 14930 }; 14931 14932 static void 14933 cmd_clear_input_set_parsed( 14934 __rte_unused void *parsed_result, 14935 __rte_unused struct cmdline *cl, 14936 __rte_unused void *data) 14937 { 14938 #ifdef RTE_NET_I40E 14939 struct cmd_clear_input_set_result *res = parsed_result; 14940 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 14941 struct rte_pmd_i40e_inset inset; 14942 #endif 14943 int ret = -ENOTSUP; 14944 14945 if (!all_ports_stopped()) { 14946 fprintf(stderr, "Please stop all ports first\n"); 14947 return; 14948 } 14949 14950 #ifdef RTE_NET_I40E 14951 if (!strcmp(res->inset_type, "hash_inset")) 14952 inset_type = INSET_HASH; 14953 else if (!strcmp(res->inset_type, "fdir_inset")) 14954 inset_type = INSET_FDIR; 14955 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 14956 inset_type = INSET_FDIR_FLX; 14957 14958 memset(&inset, 0, sizeof(inset)); 14959 14960 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 14961 &inset, inset_type); 14962 if (ret) { 14963 fprintf(stderr, "Failed to clear input set.\n"); 14964 return; 14965 } 14966 14967 #endif 14968 14969 if (ret == -ENOTSUP) 14970 fprintf(stderr, "Function not supported\n"); 14971 } 14972 14973 cmdline_parse_token_string_t cmd_clear_input_set_port = 14974 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14975 port, "port"); 14976 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 14977 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14978 cfg, "config"); 14979 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 14980 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 14981 port_id, RTE_UINT16); 14982 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 14983 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14984 pctype, "pctype"); 14985 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 14986 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 14987 pctype_id, RTE_UINT8); 14988 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 14989 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14990 inset_type, 14991 "hash_inset#fdir_inset#fdir_flx_inset"); 14992 cmdline_parse_token_string_t cmd_clear_input_set_clear = 14993 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14994 clear, "clear"); 14995 cmdline_parse_token_string_t cmd_clear_input_set_all = 14996 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14997 all, "all"); 14998 14999 cmdline_parse_inst_t cmd_clear_input_set = { 15000 .f = cmd_clear_input_set_parsed, 15001 .data = NULL, 15002 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 15003 "fdir_inset|fdir_flx_inset clear all", 15004 .tokens = { 15005 (void *)&cmd_clear_input_set_port, 15006 (void *)&cmd_clear_input_set_cfg, 15007 (void *)&cmd_clear_input_set_port_id, 15008 (void *)&cmd_clear_input_set_pctype, 15009 (void *)&cmd_clear_input_set_pctype_id, 15010 (void *)&cmd_clear_input_set_inset_type, 15011 (void *)&cmd_clear_input_set_clear, 15012 (void *)&cmd_clear_input_set_all, 15013 NULL, 15014 }, 15015 }; 15016 15017 /* show vf stats */ 15018 15019 /* Common result structure for show vf stats */ 15020 struct cmd_show_vf_stats_result { 15021 cmdline_fixed_string_t show; 15022 cmdline_fixed_string_t vf; 15023 cmdline_fixed_string_t stats; 15024 portid_t port_id; 15025 uint16_t vf_id; 15026 }; 15027 15028 /* Common CLI fields show vf stats*/ 15029 cmdline_parse_token_string_t cmd_show_vf_stats_show = 15030 TOKEN_STRING_INITIALIZER 15031 (struct cmd_show_vf_stats_result, 15032 show, "show"); 15033 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 15034 TOKEN_STRING_INITIALIZER 15035 (struct cmd_show_vf_stats_result, 15036 vf, "vf"); 15037 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 15038 TOKEN_STRING_INITIALIZER 15039 (struct cmd_show_vf_stats_result, 15040 stats, "stats"); 15041 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 15042 TOKEN_NUM_INITIALIZER 15043 (struct cmd_show_vf_stats_result, 15044 port_id, RTE_UINT16); 15045 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 15046 TOKEN_NUM_INITIALIZER 15047 (struct cmd_show_vf_stats_result, 15048 vf_id, RTE_UINT16); 15049 15050 static void 15051 cmd_show_vf_stats_parsed( 15052 void *parsed_result, 15053 __rte_unused struct cmdline *cl, 15054 __rte_unused void *data) 15055 { 15056 struct cmd_show_vf_stats_result *res = parsed_result; 15057 struct rte_eth_stats stats; 15058 int ret = -ENOTSUP; 15059 static const char *nic_stats_border = "########################"; 15060 15061 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15062 return; 15063 15064 memset(&stats, 0, sizeof(stats)); 15065 15066 #ifdef RTE_NET_I40E 15067 if (ret == -ENOTSUP) 15068 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 15069 res->vf_id, 15070 &stats); 15071 #endif 15072 #ifdef RTE_NET_BNXT 15073 if (ret == -ENOTSUP) 15074 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 15075 res->vf_id, 15076 &stats); 15077 #endif 15078 15079 switch (ret) { 15080 case 0: 15081 break; 15082 case -EINVAL: 15083 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 15084 break; 15085 case -ENODEV: 15086 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15087 break; 15088 case -ENOTSUP: 15089 fprintf(stderr, "function not implemented\n"); 15090 break; 15091 default: 15092 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15093 } 15094 15095 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 15096 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 15097 15098 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 15099 "%-"PRIu64"\n", 15100 stats.ipackets, stats.imissed, stats.ibytes); 15101 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 15102 printf(" RX-nombuf: %-10"PRIu64"\n", 15103 stats.rx_nombuf); 15104 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 15105 "%-"PRIu64"\n", 15106 stats.opackets, stats.oerrors, stats.obytes); 15107 15108 printf(" %s############################%s\n", 15109 nic_stats_border, nic_stats_border); 15110 } 15111 15112 cmdline_parse_inst_t cmd_show_vf_stats = { 15113 .f = cmd_show_vf_stats_parsed, 15114 .data = NULL, 15115 .help_str = "show vf stats <port_id> <vf_id>", 15116 .tokens = { 15117 (void *)&cmd_show_vf_stats_show, 15118 (void *)&cmd_show_vf_stats_vf, 15119 (void *)&cmd_show_vf_stats_stats, 15120 (void *)&cmd_show_vf_stats_port_id, 15121 (void *)&cmd_show_vf_stats_vf_id, 15122 NULL, 15123 }, 15124 }; 15125 15126 /* clear vf stats */ 15127 15128 /* Common result structure for clear vf stats */ 15129 struct cmd_clear_vf_stats_result { 15130 cmdline_fixed_string_t clear; 15131 cmdline_fixed_string_t vf; 15132 cmdline_fixed_string_t stats; 15133 portid_t port_id; 15134 uint16_t vf_id; 15135 }; 15136 15137 /* Common CLI fields clear vf stats*/ 15138 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 15139 TOKEN_STRING_INITIALIZER 15140 (struct cmd_clear_vf_stats_result, 15141 clear, "clear"); 15142 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 15143 TOKEN_STRING_INITIALIZER 15144 (struct cmd_clear_vf_stats_result, 15145 vf, "vf"); 15146 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 15147 TOKEN_STRING_INITIALIZER 15148 (struct cmd_clear_vf_stats_result, 15149 stats, "stats"); 15150 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 15151 TOKEN_NUM_INITIALIZER 15152 (struct cmd_clear_vf_stats_result, 15153 port_id, RTE_UINT16); 15154 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 15155 TOKEN_NUM_INITIALIZER 15156 (struct cmd_clear_vf_stats_result, 15157 vf_id, RTE_UINT16); 15158 15159 static void 15160 cmd_clear_vf_stats_parsed( 15161 void *parsed_result, 15162 __rte_unused struct cmdline *cl, 15163 __rte_unused void *data) 15164 { 15165 struct cmd_clear_vf_stats_result *res = parsed_result; 15166 int ret = -ENOTSUP; 15167 15168 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15169 return; 15170 15171 #ifdef RTE_NET_I40E 15172 if (ret == -ENOTSUP) 15173 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 15174 res->vf_id); 15175 #endif 15176 #ifdef RTE_NET_BNXT 15177 if (ret == -ENOTSUP) 15178 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 15179 res->vf_id); 15180 #endif 15181 15182 switch (ret) { 15183 case 0: 15184 break; 15185 case -EINVAL: 15186 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 15187 break; 15188 case -ENODEV: 15189 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15190 break; 15191 case -ENOTSUP: 15192 fprintf(stderr, "function not implemented\n"); 15193 break; 15194 default: 15195 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15196 } 15197 } 15198 15199 cmdline_parse_inst_t cmd_clear_vf_stats = { 15200 .f = cmd_clear_vf_stats_parsed, 15201 .data = NULL, 15202 .help_str = "clear vf stats <port_id> <vf_id>", 15203 .tokens = { 15204 (void *)&cmd_clear_vf_stats_clear, 15205 (void *)&cmd_clear_vf_stats_vf, 15206 (void *)&cmd_clear_vf_stats_stats, 15207 (void *)&cmd_clear_vf_stats_port_id, 15208 (void *)&cmd_clear_vf_stats_vf_id, 15209 NULL, 15210 }, 15211 }; 15212 15213 /* port config pctype mapping reset */ 15214 15215 /* Common result structure for port config pctype mapping reset */ 15216 struct cmd_pctype_mapping_reset_result { 15217 cmdline_fixed_string_t port; 15218 cmdline_fixed_string_t config; 15219 portid_t port_id; 15220 cmdline_fixed_string_t pctype; 15221 cmdline_fixed_string_t mapping; 15222 cmdline_fixed_string_t reset; 15223 }; 15224 15225 /* Common CLI fields for port config pctype mapping reset*/ 15226 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 15227 TOKEN_STRING_INITIALIZER 15228 (struct cmd_pctype_mapping_reset_result, 15229 port, "port"); 15230 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 15231 TOKEN_STRING_INITIALIZER 15232 (struct cmd_pctype_mapping_reset_result, 15233 config, "config"); 15234 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 15235 TOKEN_NUM_INITIALIZER 15236 (struct cmd_pctype_mapping_reset_result, 15237 port_id, RTE_UINT16); 15238 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 15239 TOKEN_STRING_INITIALIZER 15240 (struct cmd_pctype_mapping_reset_result, 15241 pctype, "pctype"); 15242 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 15243 TOKEN_STRING_INITIALIZER 15244 (struct cmd_pctype_mapping_reset_result, 15245 mapping, "mapping"); 15246 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 15247 TOKEN_STRING_INITIALIZER 15248 (struct cmd_pctype_mapping_reset_result, 15249 reset, "reset"); 15250 15251 static void 15252 cmd_pctype_mapping_reset_parsed( 15253 void *parsed_result, 15254 __rte_unused struct cmdline *cl, 15255 __rte_unused void *data) 15256 { 15257 struct cmd_pctype_mapping_reset_result *res = parsed_result; 15258 int ret = -ENOTSUP; 15259 15260 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15261 return; 15262 15263 #ifdef RTE_NET_I40E 15264 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 15265 #endif 15266 15267 switch (ret) { 15268 case 0: 15269 break; 15270 case -ENODEV: 15271 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15272 break; 15273 case -ENOTSUP: 15274 fprintf(stderr, "function not implemented\n"); 15275 break; 15276 default: 15277 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15278 } 15279 } 15280 15281 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 15282 .f = cmd_pctype_mapping_reset_parsed, 15283 .data = NULL, 15284 .help_str = "port config <port_id> pctype mapping reset", 15285 .tokens = { 15286 (void *)&cmd_pctype_mapping_reset_port, 15287 (void *)&cmd_pctype_mapping_reset_config, 15288 (void *)&cmd_pctype_mapping_reset_port_id, 15289 (void *)&cmd_pctype_mapping_reset_pctype, 15290 (void *)&cmd_pctype_mapping_reset_mapping, 15291 (void *)&cmd_pctype_mapping_reset_reset, 15292 NULL, 15293 }, 15294 }; 15295 15296 /* show port pctype mapping */ 15297 15298 /* Common result structure for show port pctype mapping */ 15299 struct cmd_pctype_mapping_get_result { 15300 cmdline_fixed_string_t show; 15301 cmdline_fixed_string_t port; 15302 portid_t port_id; 15303 cmdline_fixed_string_t pctype; 15304 cmdline_fixed_string_t mapping; 15305 }; 15306 15307 /* Common CLI fields for pctype mapping get */ 15308 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 15309 TOKEN_STRING_INITIALIZER 15310 (struct cmd_pctype_mapping_get_result, 15311 show, "show"); 15312 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 15313 TOKEN_STRING_INITIALIZER 15314 (struct cmd_pctype_mapping_get_result, 15315 port, "port"); 15316 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 15317 TOKEN_NUM_INITIALIZER 15318 (struct cmd_pctype_mapping_get_result, 15319 port_id, RTE_UINT16); 15320 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 15321 TOKEN_STRING_INITIALIZER 15322 (struct cmd_pctype_mapping_get_result, 15323 pctype, "pctype"); 15324 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 15325 TOKEN_STRING_INITIALIZER 15326 (struct cmd_pctype_mapping_get_result, 15327 mapping, "mapping"); 15328 15329 static void 15330 cmd_pctype_mapping_get_parsed( 15331 void *parsed_result, 15332 __rte_unused struct cmdline *cl, 15333 __rte_unused void *data) 15334 { 15335 struct cmd_pctype_mapping_get_result *res = parsed_result; 15336 int ret = -ENOTSUP; 15337 #ifdef RTE_NET_I40E 15338 struct rte_pmd_i40e_flow_type_mapping 15339 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 15340 int i, j, first_pctype; 15341 #endif 15342 15343 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15344 return; 15345 15346 #ifdef RTE_NET_I40E 15347 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 15348 #endif 15349 15350 switch (ret) { 15351 case 0: 15352 break; 15353 case -ENODEV: 15354 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15355 return; 15356 case -ENOTSUP: 15357 fprintf(stderr, "function not implemented\n"); 15358 return; 15359 default: 15360 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15361 return; 15362 } 15363 15364 #ifdef RTE_NET_I40E 15365 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 15366 if (mapping[i].pctype != 0ULL) { 15367 first_pctype = 1; 15368 15369 printf("pctype: "); 15370 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 15371 if (mapping[i].pctype & (1ULL << j)) { 15372 printf(first_pctype ? 15373 "%02d" : ",%02d", j); 15374 first_pctype = 0; 15375 } 15376 } 15377 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 15378 } 15379 } 15380 #endif 15381 } 15382 15383 cmdline_parse_inst_t cmd_pctype_mapping_get = { 15384 .f = cmd_pctype_mapping_get_parsed, 15385 .data = NULL, 15386 .help_str = "show port <port_id> pctype mapping", 15387 .tokens = { 15388 (void *)&cmd_pctype_mapping_get_show, 15389 (void *)&cmd_pctype_mapping_get_port, 15390 (void *)&cmd_pctype_mapping_get_port_id, 15391 (void *)&cmd_pctype_mapping_get_pctype, 15392 (void *)&cmd_pctype_mapping_get_mapping, 15393 NULL, 15394 }, 15395 }; 15396 15397 /* port config pctype mapping update */ 15398 15399 /* Common result structure for port config pctype mapping update */ 15400 struct cmd_pctype_mapping_update_result { 15401 cmdline_fixed_string_t port; 15402 cmdline_fixed_string_t config; 15403 portid_t port_id; 15404 cmdline_fixed_string_t pctype; 15405 cmdline_fixed_string_t mapping; 15406 cmdline_fixed_string_t update; 15407 cmdline_fixed_string_t pctype_list; 15408 uint16_t flow_type; 15409 }; 15410 15411 /* Common CLI fields for pctype mapping update*/ 15412 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 15413 TOKEN_STRING_INITIALIZER 15414 (struct cmd_pctype_mapping_update_result, 15415 port, "port"); 15416 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 15417 TOKEN_STRING_INITIALIZER 15418 (struct cmd_pctype_mapping_update_result, 15419 config, "config"); 15420 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 15421 TOKEN_NUM_INITIALIZER 15422 (struct cmd_pctype_mapping_update_result, 15423 port_id, RTE_UINT16); 15424 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 15425 TOKEN_STRING_INITIALIZER 15426 (struct cmd_pctype_mapping_update_result, 15427 pctype, "pctype"); 15428 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 15429 TOKEN_STRING_INITIALIZER 15430 (struct cmd_pctype_mapping_update_result, 15431 mapping, "mapping"); 15432 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 15433 TOKEN_STRING_INITIALIZER 15434 (struct cmd_pctype_mapping_update_result, 15435 update, "update"); 15436 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 15437 TOKEN_STRING_INITIALIZER 15438 (struct cmd_pctype_mapping_update_result, 15439 pctype_list, NULL); 15440 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 15441 TOKEN_NUM_INITIALIZER 15442 (struct cmd_pctype_mapping_update_result, 15443 flow_type, RTE_UINT16); 15444 15445 static void 15446 cmd_pctype_mapping_update_parsed( 15447 void *parsed_result, 15448 __rte_unused struct cmdline *cl, 15449 __rte_unused void *data) 15450 { 15451 struct cmd_pctype_mapping_update_result *res = parsed_result; 15452 int ret = -ENOTSUP; 15453 #ifdef RTE_NET_I40E 15454 struct rte_pmd_i40e_flow_type_mapping mapping; 15455 unsigned int i; 15456 unsigned int nb_item; 15457 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 15458 #endif 15459 15460 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15461 return; 15462 15463 #ifdef RTE_NET_I40E 15464 nb_item = parse_item_list(res->pctype_list, "pctypes", 15465 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 15466 mapping.flow_type = res->flow_type; 15467 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 15468 mapping.pctype |= (1ULL << pctype_list[i]); 15469 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 15470 &mapping, 15471 1, 15472 0); 15473 #endif 15474 15475 switch (ret) { 15476 case 0: 15477 break; 15478 case -EINVAL: 15479 fprintf(stderr, "invalid pctype or flow type\n"); 15480 break; 15481 case -ENODEV: 15482 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15483 break; 15484 case -ENOTSUP: 15485 fprintf(stderr, "function not implemented\n"); 15486 break; 15487 default: 15488 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15489 } 15490 } 15491 15492 cmdline_parse_inst_t cmd_pctype_mapping_update = { 15493 .f = cmd_pctype_mapping_update_parsed, 15494 .data = NULL, 15495 .help_str = "port config <port_id> pctype mapping update" 15496 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 15497 .tokens = { 15498 (void *)&cmd_pctype_mapping_update_port, 15499 (void *)&cmd_pctype_mapping_update_config, 15500 (void *)&cmd_pctype_mapping_update_port_id, 15501 (void *)&cmd_pctype_mapping_update_pctype, 15502 (void *)&cmd_pctype_mapping_update_mapping, 15503 (void *)&cmd_pctype_mapping_update_update, 15504 (void *)&cmd_pctype_mapping_update_pc_type, 15505 (void *)&cmd_pctype_mapping_update_flow_type, 15506 NULL, 15507 }, 15508 }; 15509 15510 /* ptype mapping get */ 15511 15512 /* Common result structure for ptype mapping get */ 15513 struct cmd_ptype_mapping_get_result { 15514 cmdline_fixed_string_t ptype; 15515 cmdline_fixed_string_t mapping; 15516 cmdline_fixed_string_t get; 15517 portid_t port_id; 15518 uint8_t valid_only; 15519 }; 15520 15521 /* Common CLI fields for ptype mapping get */ 15522 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 15523 TOKEN_STRING_INITIALIZER 15524 (struct cmd_ptype_mapping_get_result, 15525 ptype, "ptype"); 15526 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 15527 TOKEN_STRING_INITIALIZER 15528 (struct cmd_ptype_mapping_get_result, 15529 mapping, "mapping"); 15530 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 15531 TOKEN_STRING_INITIALIZER 15532 (struct cmd_ptype_mapping_get_result, 15533 get, "get"); 15534 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 15535 TOKEN_NUM_INITIALIZER 15536 (struct cmd_ptype_mapping_get_result, 15537 port_id, RTE_UINT16); 15538 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 15539 TOKEN_NUM_INITIALIZER 15540 (struct cmd_ptype_mapping_get_result, 15541 valid_only, RTE_UINT8); 15542 15543 static void 15544 cmd_ptype_mapping_get_parsed( 15545 void *parsed_result, 15546 __rte_unused struct cmdline *cl, 15547 __rte_unused void *data) 15548 { 15549 struct cmd_ptype_mapping_get_result *res = parsed_result; 15550 int ret = -ENOTSUP; 15551 #ifdef RTE_NET_I40E 15552 int max_ptype_num = 256; 15553 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 15554 uint16_t count; 15555 int i; 15556 #endif 15557 15558 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15559 return; 15560 15561 #ifdef RTE_NET_I40E 15562 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 15563 mapping, 15564 max_ptype_num, 15565 &count, 15566 res->valid_only); 15567 #endif 15568 15569 switch (ret) { 15570 case 0: 15571 break; 15572 case -ENODEV: 15573 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15574 break; 15575 case -ENOTSUP: 15576 fprintf(stderr, "function not implemented\n"); 15577 break; 15578 default: 15579 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15580 } 15581 15582 #ifdef RTE_NET_I40E 15583 if (!ret) { 15584 for (i = 0; i < count; i++) 15585 printf("%3d\t0x%08x\n", 15586 mapping[i].hw_ptype, mapping[i].sw_ptype); 15587 } 15588 #endif 15589 } 15590 15591 cmdline_parse_inst_t cmd_ptype_mapping_get = { 15592 .f = cmd_ptype_mapping_get_parsed, 15593 .data = NULL, 15594 .help_str = "ptype mapping get <port_id> <valid_only>", 15595 .tokens = { 15596 (void *)&cmd_ptype_mapping_get_ptype, 15597 (void *)&cmd_ptype_mapping_get_mapping, 15598 (void *)&cmd_ptype_mapping_get_get, 15599 (void *)&cmd_ptype_mapping_get_port_id, 15600 (void *)&cmd_ptype_mapping_get_valid_only, 15601 NULL, 15602 }, 15603 }; 15604 15605 /* ptype mapping replace */ 15606 15607 /* Common result structure for ptype mapping replace */ 15608 struct cmd_ptype_mapping_replace_result { 15609 cmdline_fixed_string_t ptype; 15610 cmdline_fixed_string_t mapping; 15611 cmdline_fixed_string_t replace; 15612 portid_t port_id; 15613 uint32_t target; 15614 uint8_t mask; 15615 uint32_t pkt_type; 15616 }; 15617 15618 /* Common CLI fields for ptype mapping replace */ 15619 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 15620 TOKEN_STRING_INITIALIZER 15621 (struct cmd_ptype_mapping_replace_result, 15622 ptype, "ptype"); 15623 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 15624 TOKEN_STRING_INITIALIZER 15625 (struct cmd_ptype_mapping_replace_result, 15626 mapping, "mapping"); 15627 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 15628 TOKEN_STRING_INITIALIZER 15629 (struct cmd_ptype_mapping_replace_result, 15630 replace, "replace"); 15631 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 15632 TOKEN_NUM_INITIALIZER 15633 (struct cmd_ptype_mapping_replace_result, 15634 port_id, RTE_UINT16); 15635 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 15636 TOKEN_NUM_INITIALIZER 15637 (struct cmd_ptype_mapping_replace_result, 15638 target, RTE_UINT32); 15639 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 15640 TOKEN_NUM_INITIALIZER 15641 (struct cmd_ptype_mapping_replace_result, 15642 mask, RTE_UINT8); 15643 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 15644 TOKEN_NUM_INITIALIZER 15645 (struct cmd_ptype_mapping_replace_result, 15646 pkt_type, RTE_UINT32); 15647 15648 static void 15649 cmd_ptype_mapping_replace_parsed( 15650 void *parsed_result, 15651 __rte_unused struct cmdline *cl, 15652 __rte_unused void *data) 15653 { 15654 struct cmd_ptype_mapping_replace_result *res = parsed_result; 15655 int ret = -ENOTSUP; 15656 15657 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15658 return; 15659 15660 #ifdef RTE_NET_I40E 15661 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 15662 res->target, 15663 res->mask, 15664 res->pkt_type); 15665 #endif 15666 15667 switch (ret) { 15668 case 0: 15669 break; 15670 case -EINVAL: 15671 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n", 15672 res->target, res->pkt_type); 15673 break; 15674 case -ENODEV: 15675 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15676 break; 15677 case -ENOTSUP: 15678 fprintf(stderr, "function not implemented\n"); 15679 break; 15680 default: 15681 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15682 } 15683 } 15684 15685 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 15686 .f = cmd_ptype_mapping_replace_parsed, 15687 .data = NULL, 15688 .help_str = 15689 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 15690 .tokens = { 15691 (void *)&cmd_ptype_mapping_replace_ptype, 15692 (void *)&cmd_ptype_mapping_replace_mapping, 15693 (void *)&cmd_ptype_mapping_replace_replace, 15694 (void *)&cmd_ptype_mapping_replace_port_id, 15695 (void *)&cmd_ptype_mapping_replace_target, 15696 (void *)&cmd_ptype_mapping_replace_mask, 15697 (void *)&cmd_ptype_mapping_replace_pkt_type, 15698 NULL, 15699 }, 15700 }; 15701 15702 /* ptype mapping reset */ 15703 15704 /* Common result structure for ptype mapping reset */ 15705 struct cmd_ptype_mapping_reset_result { 15706 cmdline_fixed_string_t ptype; 15707 cmdline_fixed_string_t mapping; 15708 cmdline_fixed_string_t reset; 15709 portid_t port_id; 15710 }; 15711 15712 /* Common CLI fields for ptype mapping reset*/ 15713 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 15714 TOKEN_STRING_INITIALIZER 15715 (struct cmd_ptype_mapping_reset_result, 15716 ptype, "ptype"); 15717 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 15718 TOKEN_STRING_INITIALIZER 15719 (struct cmd_ptype_mapping_reset_result, 15720 mapping, "mapping"); 15721 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 15722 TOKEN_STRING_INITIALIZER 15723 (struct cmd_ptype_mapping_reset_result, 15724 reset, "reset"); 15725 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 15726 TOKEN_NUM_INITIALIZER 15727 (struct cmd_ptype_mapping_reset_result, 15728 port_id, RTE_UINT16); 15729 15730 static void 15731 cmd_ptype_mapping_reset_parsed( 15732 void *parsed_result, 15733 __rte_unused struct cmdline *cl, 15734 __rte_unused void *data) 15735 { 15736 struct cmd_ptype_mapping_reset_result *res = parsed_result; 15737 int ret = -ENOTSUP; 15738 15739 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15740 return; 15741 15742 #ifdef RTE_NET_I40E 15743 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 15744 #endif 15745 15746 switch (ret) { 15747 case 0: 15748 break; 15749 case -ENODEV: 15750 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15751 break; 15752 case -ENOTSUP: 15753 fprintf(stderr, "function not implemented\n"); 15754 break; 15755 default: 15756 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15757 } 15758 } 15759 15760 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 15761 .f = cmd_ptype_mapping_reset_parsed, 15762 .data = NULL, 15763 .help_str = "ptype mapping reset <port_id>", 15764 .tokens = { 15765 (void *)&cmd_ptype_mapping_reset_ptype, 15766 (void *)&cmd_ptype_mapping_reset_mapping, 15767 (void *)&cmd_ptype_mapping_reset_reset, 15768 (void *)&cmd_ptype_mapping_reset_port_id, 15769 NULL, 15770 }, 15771 }; 15772 15773 /* ptype mapping update */ 15774 15775 /* Common result structure for ptype mapping update */ 15776 struct cmd_ptype_mapping_update_result { 15777 cmdline_fixed_string_t ptype; 15778 cmdline_fixed_string_t mapping; 15779 cmdline_fixed_string_t reset; 15780 portid_t port_id; 15781 uint8_t hw_ptype; 15782 uint32_t sw_ptype; 15783 }; 15784 15785 /* Common CLI fields for ptype mapping update*/ 15786 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 15787 TOKEN_STRING_INITIALIZER 15788 (struct cmd_ptype_mapping_update_result, 15789 ptype, "ptype"); 15790 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 15791 TOKEN_STRING_INITIALIZER 15792 (struct cmd_ptype_mapping_update_result, 15793 mapping, "mapping"); 15794 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 15795 TOKEN_STRING_INITIALIZER 15796 (struct cmd_ptype_mapping_update_result, 15797 reset, "update"); 15798 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 15799 TOKEN_NUM_INITIALIZER 15800 (struct cmd_ptype_mapping_update_result, 15801 port_id, RTE_UINT16); 15802 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 15803 TOKEN_NUM_INITIALIZER 15804 (struct cmd_ptype_mapping_update_result, 15805 hw_ptype, RTE_UINT8); 15806 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 15807 TOKEN_NUM_INITIALIZER 15808 (struct cmd_ptype_mapping_update_result, 15809 sw_ptype, RTE_UINT32); 15810 15811 static void 15812 cmd_ptype_mapping_update_parsed( 15813 void *parsed_result, 15814 __rte_unused struct cmdline *cl, 15815 __rte_unused void *data) 15816 { 15817 struct cmd_ptype_mapping_update_result *res = parsed_result; 15818 int ret = -ENOTSUP; 15819 #ifdef RTE_NET_I40E 15820 struct rte_pmd_i40e_ptype_mapping mapping; 15821 #endif 15822 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15823 return; 15824 15825 #ifdef RTE_NET_I40E 15826 mapping.hw_ptype = res->hw_ptype; 15827 mapping.sw_ptype = res->sw_ptype; 15828 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 15829 &mapping, 15830 1, 15831 0); 15832 #endif 15833 15834 switch (ret) { 15835 case 0: 15836 break; 15837 case -EINVAL: 15838 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype); 15839 break; 15840 case -ENODEV: 15841 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15842 break; 15843 case -ENOTSUP: 15844 fprintf(stderr, "function not implemented\n"); 15845 break; 15846 default: 15847 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15848 } 15849 } 15850 15851 cmdline_parse_inst_t cmd_ptype_mapping_update = { 15852 .f = cmd_ptype_mapping_update_parsed, 15853 .data = NULL, 15854 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 15855 .tokens = { 15856 (void *)&cmd_ptype_mapping_update_ptype, 15857 (void *)&cmd_ptype_mapping_update_mapping, 15858 (void *)&cmd_ptype_mapping_update_update, 15859 (void *)&cmd_ptype_mapping_update_port_id, 15860 (void *)&cmd_ptype_mapping_update_hw_ptype, 15861 (void *)&cmd_ptype_mapping_update_sw_ptype, 15862 NULL, 15863 }, 15864 }; 15865 15866 /* Common result structure for file commands */ 15867 struct cmd_cmdfile_result { 15868 cmdline_fixed_string_t load; 15869 cmdline_fixed_string_t filename; 15870 }; 15871 15872 /* Common CLI fields for file commands */ 15873 cmdline_parse_token_string_t cmd_load_cmdfile = 15874 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 15875 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 15876 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 15877 15878 static void 15879 cmd_load_from_file_parsed( 15880 void *parsed_result, 15881 __rte_unused struct cmdline *cl, 15882 __rte_unused void *data) 15883 { 15884 struct cmd_cmdfile_result *res = parsed_result; 15885 15886 cmdline_read_from_file(res->filename); 15887 } 15888 15889 cmdline_parse_inst_t cmd_load_from_file = { 15890 .f = cmd_load_from_file_parsed, 15891 .data = NULL, 15892 .help_str = "load <filename>", 15893 .tokens = { 15894 (void *)&cmd_load_cmdfile, 15895 (void *)&cmd_load_cmdfile_filename, 15896 NULL, 15897 }, 15898 }; 15899 15900 /* Get Rx offloads capabilities */ 15901 struct cmd_rx_offload_get_capa_result { 15902 cmdline_fixed_string_t show; 15903 cmdline_fixed_string_t port; 15904 portid_t port_id; 15905 cmdline_fixed_string_t rx_offload; 15906 cmdline_fixed_string_t capabilities; 15907 }; 15908 15909 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 15910 TOKEN_STRING_INITIALIZER 15911 (struct cmd_rx_offload_get_capa_result, 15912 show, "show"); 15913 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 15914 TOKEN_STRING_INITIALIZER 15915 (struct cmd_rx_offload_get_capa_result, 15916 port, "port"); 15917 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 15918 TOKEN_NUM_INITIALIZER 15919 (struct cmd_rx_offload_get_capa_result, 15920 port_id, RTE_UINT16); 15921 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 15922 TOKEN_STRING_INITIALIZER 15923 (struct cmd_rx_offload_get_capa_result, 15924 rx_offload, "rx_offload"); 15925 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 15926 TOKEN_STRING_INITIALIZER 15927 (struct cmd_rx_offload_get_capa_result, 15928 capabilities, "capabilities"); 15929 15930 static void 15931 print_rx_offloads(uint64_t offloads) 15932 { 15933 uint64_t single_offload; 15934 int begin; 15935 int end; 15936 int bit; 15937 15938 if (offloads == 0) 15939 return; 15940 15941 begin = __builtin_ctzll(offloads); 15942 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 15943 15944 single_offload = 1ULL << begin; 15945 for (bit = begin; bit < end; bit++) { 15946 if (offloads & single_offload) 15947 printf(" %s", 15948 rte_eth_dev_rx_offload_name(single_offload)); 15949 single_offload <<= 1; 15950 } 15951 } 15952 15953 static void 15954 cmd_rx_offload_get_capa_parsed( 15955 void *parsed_result, 15956 __rte_unused struct cmdline *cl, 15957 __rte_unused void *data) 15958 { 15959 struct cmd_rx_offload_get_capa_result *res = parsed_result; 15960 struct rte_eth_dev_info dev_info; 15961 portid_t port_id = res->port_id; 15962 uint64_t queue_offloads; 15963 uint64_t port_offloads; 15964 int ret; 15965 15966 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15967 if (ret != 0) 15968 return; 15969 15970 queue_offloads = dev_info.rx_queue_offload_capa; 15971 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 15972 15973 printf("Rx Offloading Capabilities of port %d :\n", port_id); 15974 printf(" Per Queue :"); 15975 print_rx_offloads(queue_offloads); 15976 15977 printf("\n"); 15978 printf(" Per Port :"); 15979 print_rx_offloads(port_offloads); 15980 printf("\n\n"); 15981 } 15982 15983 cmdline_parse_inst_t cmd_rx_offload_get_capa = { 15984 .f = cmd_rx_offload_get_capa_parsed, 15985 .data = NULL, 15986 .help_str = "show port <port_id> rx_offload capabilities", 15987 .tokens = { 15988 (void *)&cmd_rx_offload_get_capa_show, 15989 (void *)&cmd_rx_offload_get_capa_port, 15990 (void *)&cmd_rx_offload_get_capa_port_id, 15991 (void *)&cmd_rx_offload_get_capa_rx_offload, 15992 (void *)&cmd_rx_offload_get_capa_capabilities, 15993 NULL, 15994 } 15995 }; 15996 15997 /* Get Rx offloads configuration */ 15998 struct cmd_rx_offload_get_configuration_result { 15999 cmdline_fixed_string_t show; 16000 cmdline_fixed_string_t port; 16001 portid_t port_id; 16002 cmdline_fixed_string_t rx_offload; 16003 cmdline_fixed_string_t configuration; 16004 }; 16005 16006 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 16007 TOKEN_STRING_INITIALIZER 16008 (struct cmd_rx_offload_get_configuration_result, 16009 show, "show"); 16010 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 16011 TOKEN_STRING_INITIALIZER 16012 (struct cmd_rx_offload_get_configuration_result, 16013 port, "port"); 16014 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 16015 TOKEN_NUM_INITIALIZER 16016 (struct cmd_rx_offload_get_configuration_result, 16017 port_id, RTE_UINT16); 16018 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 16019 TOKEN_STRING_INITIALIZER 16020 (struct cmd_rx_offload_get_configuration_result, 16021 rx_offload, "rx_offload"); 16022 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 16023 TOKEN_STRING_INITIALIZER 16024 (struct cmd_rx_offload_get_configuration_result, 16025 configuration, "configuration"); 16026 16027 static void 16028 cmd_rx_offload_get_configuration_parsed( 16029 void *parsed_result, 16030 __rte_unused struct cmdline *cl, 16031 __rte_unused void *data) 16032 { 16033 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 16034 struct rte_eth_dev_info dev_info; 16035 portid_t port_id = res->port_id; 16036 struct rte_port *port = &ports[port_id]; 16037 uint64_t port_offloads; 16038 uint64_t queue_offloads; 16039 uint16_t nb_rx_queues; 16040 int q; 16041 int ret; 16042 16043 printf("Rx Offloading Configuration of port %d :\n", port_id); 16044 16045 port_offloads = port->dev_conf.rxmode.offloads; 16046 printf(" Port :"); 16047 print_rx_offloads(port_offloads); 16048 printf("\n"); 16049 16050 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16051 if (ret != 0) 16052 return; 16053 16054 nb_rx_queues = dev_info.nb_rx_queues; 16055 for (q = 0; q < nb_rx_queues; q++) { 16056 queue_offloads = port->rx_conf[q].offloads; 16057 printf(" Queue[%2d] :", q); 16058 print_rx_offloads(queue_offloads); 16059 printf("\n"); 16060 } 16061 printf("\n"); 16062 } 16063 16064 cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 16065 .f = cmd_rx_offload_get_configuration_parsed, 16066 .data = NULL, 16067 .help_str = "show port <port_id> rx_offload configuration", 16068 .tokens = { 16069 (void *)&cmd_rx_offload_get_configuration_show, 16070 (void *)&cmd_rx_offload_get_configuration_port, 16071 (void *)&cmd_rx_offload_get_configuration_port_id, 16072 (void *)&cmd_rx_offload_get_configuration_rx_offload, 16073 (void *)&cmd_rx_offload_get_configuration_configuration, 16074 NULL, 16075 } 16076 }; 16077 16078 /* Enable/Disable a per port offloading */ 16079 struct cmd_config_per_port_rx_offload_result { 16080 cmdline_fixed_string_t port; 16081 cmdline_fixed_string_t config; 16082 portid_t port_id; 16083 cmdline_fixed_string_t rx_offload; 16084 cmdline_fixed_string_t offload; 16085 cmdline_fixed_string_t on_off; 16086 }; 16087 16088 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 16089 TOKEN_STRING_INITIALIZER 16090 (struct cmd_config_per_port_rx_offload_result, 16091 port, "port"); 16092 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 16093 TOKEN_STRING_INITIALIZER 16094 (struct cmd_config_per_port_rx_offload_result, 16095 config, "config"); 16096 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 16097 TOKEN_NUM_INITIALIZER 16098 (struct cmd_config_per_port_rx_offload_result, 16099 port_id, RTE_UINT16); 16100 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 16101 TOKEN_STRING_INITIALIZER 16102 (struct cmd_config_per_port_rx_offload_result, 16103 rx_offload, "rx_offload"); 16104 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 16105 TOKEN_STRING_INITIALIZER 16106 (struct cmd_config_per_port_rx_offload_result, 16107 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 16108 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 16109 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 16110 "scatter#buffer_split#timestamp#security#" 16111 "keep_crc#rss_hash"); 16112 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 16113 TOKEN_STRING_INITIALIZER 16114 (struct cmd_config_per_port_rx_offload_result, 16115 on_off, "on#off"); 16116 16117 static uint64_t 16118 search_rx_offload(const char *name) 16119 { 16120 uint64_t single_offload; 16121 const char *single_name; 16122 int found = 0; 16123 unsigned int bit; 16124 16125 single_offload = 1; 16126 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 16127 single_name = rte_eth_dev_rx_offload_name(single_offload); 16128 if (!strcasecmp(single_name, name)) { 16129 found = 1; 16130 break; 16131 } 16132 single_offload <<= 1; 16133 } 16134 16135 if (found) 16136 return single_offload; 16137 16138 return 0; 16139 } 16140 16141 static void 16142 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 16143 __rte_unused struct cmdline *cl, 16144 __rte_unused void *data) 16145 { 16146 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 16147 portid_t port_id = res->port_id; 16148 struct rte_eth_dev_info dev_info; 16149 struct rte_port *port = &ports[port_id]; 16150 uint64_t single_offload; 16151 uint16_t nb_rx_queues; 16152 int q; 16153 int ret; 16154 16155 if (port->port_status != RTE_PORT_STOPPED) { 16156 fprintf(stderr, 16157 "Error: Can't config offload when Port %d is not stopped\n", 16158 port_id); 16159 return; 16160 } 16161 16162 single_offload = search_rx_offload(res->offload); 16163 if (single_offload == 0) { 16164 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 16165 return; 16166 } 16167 16168 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16169 if (ret != 0) 16170 return; 16171 16172 nb_rx_queues = dev_info.nb_rx_queues; 16173 if (!strcmp(res->on_off, "on")) { 16174 port->dev_conf.rxmode.offloads |= single_offload; 16175 for (q = 0; q < nb_rx_queues; q++) 16176 port->rx_conf[q].offloads |= single_offload; 16177 } else { 16178 port->dev_conf.rxmode.offloads &= ~single_offload; 16179 for (q = 0; q < nb_rx_queues; q++) 16180 port->rx_conf[q].offloads &= ~single_offload; 16181 } 16182 16183 cmd_reconfig_device_queue(port_id, 1, 1); 16184 } 16185 16186 cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 16187 .f = cmd_config_per_port_rx_offload_parsed, 16188 .data = NULL, 16189 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 16190 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 16191 "macsec_strip|header_split|vlan_filter|vlan_extend|" 16192 "jumbo_frame|scatter|buffer_split|timestamp|security|" 16193 "keep_crc|rss_hash on|off", 16194 .tokens = { 16195 (void *)&cmd_config_per_port_rx_offload_result_port, 16196 (void *)&cmd_config_per_port_rx_offload_result_config, 16197 (void *)&cmd_config_per_port_rx_offload_result_port_id, 16198 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 16199 (void *)&cmd_config_per_port_rx_offload_result_offload, 16200 (void *)&cmd_config_per_port_rx_offload_result_on_off, 16201 NULL, 16202 } 16203 }; 16204 16205 /* Enable/Disable a per queue offloading */ 16206 struct cmd_config_per_queue_rx_offload_result { 16207 cmdline_fixed_string_t port; 16208 portid_t port_id; 16209 cmdline_fixed_string_t rxq; 16210 uint16_t queue_id; 16211 cmdline_fixed_string_t rx_offload; 16212 cmdline_fixed_string_t offload; 16213 cmdline_fixed_string_t on_off; 16214 }; 16215 16216 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 16217 TOKEN_STRING_INITIALIZER 16218 (struct cmd_config_per_queue_rx_offload_result, 16219 port, "port"); 16220 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 16221 TOKEN_NUM_INITIALIZER 16222 (struct cmd_config_per_queue_rx_offload_result, 16223 port_id, RTE_UINT16); 16224 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 16225 TOKEN_STRING_INITIALIZER 16226 (struct cmd_config_per_queue_rx_offload_result, 16227 rxq, "rxq"); 16228 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 16229 TOKEN_NUM_INITIALIZER 16230 (struct cmd_config_per_queue_rx_offload_result, 16231 queue_id, RTE_UINT16); 16232 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 16233 TOKEN_STRING_INITIALIZER 16234 (struct cmd_config_per_queue_rx_offload_result, 16235 rx_offload, "rx_offload"); 16236 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 16237 TOKEN_STRING_INITIALIZER 16238 (struct cmd_config_per_queue_rx_offload_result, 16239 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 16240 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 16241 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 16242 "scatter#buffer_split#timestamp#security#keep_crc"); 16243 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 16244 TOKEN_STRING_INITIALIZER 16245 (struct cmd_config_per_queue_rx_offload_result, 16246 on_off, "on#off"); 16247 16248 static void 16249 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 16250 __rte_unused struct cmdline *cl, 16251 __rte_unused void *data) 16252 { 16253 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 16254 struct rte_eth_dev_info dev_info; 16255 portid_t port_id = res->port_id; 16256 uint16_t queue_id = res->queue_id; 16257 struct rte_port *port = &ports[port_id]; 16258 uint64_t single_offload; 16259 int ret; 16260 16261 if (port->port_status != RTE_PORT_STOPPED) { 16262 fprintf(stderr, 16263 "Error: Can't config offload when Port %d is not stopped\n", 16264 port_id); 16265 return; 16266 } 16267 16268 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16269 if (ret != 0) 16270 return; 16271 16272 if (queue_id >= dev_info.nb_rx_queues) { 16273 fprintf(stderr, 16274 "Error: input queue_id should be 0 ... %d\n", 16275 dev_info.nb_rx_queues - 1); 16276 return; 16277 } 16278 16279 single_offload = search_rx_offload(res->offload); 16280 if (single_offload == 0) { 16281 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 16282 return; 16283 } 16284 16285 if (!strcmp(res->on_off, "on")) 16286 port->rx_conf[queue_id].offloads |= single_offload; 16287 else 16288 port->rx_conf[queue_id].offloads &= ~single_offload; 16289 16290 cmd_reconfig_device_queue(port_id, 1, 1); 16291 } 16292 16293 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 16294 .f = cmd_config_per_queue_rx_offload_parsed, 16295 .data = NULL, 16296 .help_str = "port <port_id> rxq <queue_id> rx_offload " 16297 "vlan_strip|ipv4_cksum|" 16298 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 16299 "macsec_strip|header_split|vlan_filter|vlan_extend|" 16300 "jumbo_frame|scatter|buffer_split|timestamp|security|" 16301 "keep_crc on|off", 16302 .tokens = { 16303 (void *)&cmd_config_per_queue_rx_offload_result_port, 16304 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 16305 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 16306 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 16307 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 16308 (void *)&cmd_config_per_queue_rx_offload_result_offload, 16309 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 16310 NULL, 16311 } 16312 }; 16313 16314 /* Get Tx offloads capabilities */ 16315 struct cmd_tx_offload_get_capa_result { 16316 cmdline_fixed_string_t show; 16317 cmdline_fixed_string_t port; 16318 portid_t port_id; 16319 cmdline_fixed_string_t tx_offload; 16320 cmdline_fixed_string_t capabilities; 16321 }; 16322 16323 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 16324 TOKEN_STRING_INITIALIZER 16325 (struct cmd_tx_offload_get_capa_result, 16326 show, "show"); 16327 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 16328 TOKEN_STRING_INITIALIZER 16329 (struct cmd_tx_offload_get_capa_result, 16330 port, "port"); 16331 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 16332 TOKEN_NUM_INITIALIZER 16333 (struct cmd_tx_offload_get_capa_result, 16334 port_id, RTE_UINT16); 16335 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 16336 TOKEN_STRING_INITIALIZER 16337 (struct cmd_tx_offload_get_capa_result, 16338 tx_offload, "tx_offload"); 16339 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 16340 TOKEN_STRING_INITIALIZER 16341 (struct cmd_tx_offload_get_capa_result, 16342 capabilities, "capabilities"); 16343 16344 static void 16345 print_tx_offloads(uint64_t offloads) 16346 { 16347 uint64_t single_offload; 16348 int begin; 16349 int end; 16350 int bit; 16351 16352 if (offloads == 0) 16353 return; 16354 16355 begin = __builtin_ctzll(offloads); 16356 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 16357 16358 single_offload = 1ULL << begin; 16359 for (bit = begin; bit < end; bit++) { 16360 if (offloads & single_offload) 16361 printf(" %s", 16362 rte_eth_dev_tx_offload_name(single_offload)); 16363 single_offload <<= 1; 16364 } 16365 } 16366 16367 static void 16368 cmd_tx_offload_get_capa_parsed( 16369 void *parsed_result, 16370 __rte_unused struct cmdline *cl, 16371 __rte_unused void *data) 16372 { 16373 struct cmd_tx_offload_get_capa_result *res = parsed_result; 16374 struct rte_eth_dev_info dev_info; 16375 portid_t port_id = res->port_id; 16376 uint64_t queue_offloads; 16377 uint64_t port_offloads; 16378 int ret; 16379 16380 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16381 if (ret != 0) 16382 return; 16383 16384 queue_offloads = dev_info.tx_queue_offload_capa; 16385 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 16386 16387 printf("Tx Offloading Capabilities of port %d :\n", port_id); 16388 printf(" Per Queue :"); 16389 print_tx_offloads(queue_offloads); 16390 16391 printf("\n"); 16392 printf(" Per Port :"); 16393 print_tx_offloads(port_offloads); 16394 printf("\n\n"); 16395 } 16396 16397 cmdline_parse_inst_t cmd_tx_offload_get_capa = { 16398 .f = cmd_tx_offload_get_capa_parsed, 16399 .data = NULL, 16400 .help_str = "show port <port_id> tx_offload capabilities", 16401 .tokens = { 16402 (void *)&cmd_tx_offload_get_capa_show, 16403 (void *)&cmd_tx_offload_get_capa_port, 16404 (void *)&cmd_tx_offload_get_capa_port_id, 16405 (void *)&cmd_tx_offload_get_capa_tx_offload, 16406 (void *)&cmd_tx_offload_get_capa_capabilities, 16407 NULL, 16408 } 16409 }; 16410 16411 /* Get Tx offloads configuration */ 16412 struct cmd_tx_offload_get_configuration_result { 16413 cmdline_fixed_string_t show; 16414 cmdline_fixed_string_t port; 16415 portid_t port_id; 16416 cmdline_fixed_string_t tx_offload; 16417 cmdline_fixed_string_t configuration; 16418 }; 16419 16420 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 16421 TOKEN_STRING_INITIALIZER 16422 (struct cmd_tx_offload_get_configuration_result, 16423 show, "show"); 16424 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 16425 TOKEN_STRING_INITIALIZER 16426 (struct cmd_tx_offload_get_configuration_result, 16427 port, "port"); 16428 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 16429 TOKEN_NUM_INITIALIZER 16430 (struct cmd_tx_offload_get_configuration_result, 16431 port_id, RTE_UINT16); 16432 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 16433 TOKEN_STRING_INITIALIZER 16434 (struct cmd_tx_offload_get_configuration_result, 16435 tx_offload, "tx_offload"); 16436 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 16437 TOKEN_STRING_INITIALIZER 16438 (struct cmd_tx_offload_get_configuration_result, 16439 configuration, "configuration"); 16440 16441 static void 16442 cmd_tx_offload_get_configuration_parsed( 16443 void *parsed_result, 16444 __rte_unused struct cmdline *cl, 16445 __rte_unused void *data) 16446 { 16447 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 16448 struct rte_eth_dev_info dev_info; 16449 portid_t port_id = res->port_id; 16450 struct rte_port *port = &ports[port_id]; 16451 uint64_t port_offloads; 16452 uint64_t queue_offloads; 16453 uint16_t nb_tx_queues; 16454 int q; 16455 int ret; 16456 16457 printf("Tx Offloading Configuration of port %d :\n", port_id); 16458 16459 port_offloads = port->dev_conf.txmode.offloads; 16460 printf(" Port :"); 16461 print_tx_offloads(port_offloads); 16462 printf("\n"); 16463 16464 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16465 if (ret != 0) 16466 return; 16467 16468 nb_tx_queues = dev_info.nb_tx_queues; 16469 for (q = 0; q < nb_tx_queues; q++) { 16470 queue_offloads = port->tx_conf[q].offloads; 16471 printf(" Queue[%2d] :", q); 16472 print_tx_offloads(queue_offloads); 16473 printf("\n"); 16474 } 16475 printf("\n"); 16476 } 16477 16478 cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 16479 .f = cmd_tx_offload_get_configuration_parsed, 16480 .data = NULL, 16481 .help_str = "show port <port_id> tx_offload configuration", 16482 .tokens = { 16483 (void *)&cmd_tx_offload_get_configuration_show, 16484 (void *)&cmd_tx_offload_get_configuration_port, 16485 (void *)&cmd_tx_offload_get_configuration_port_id, 16486 (void *)&cmd_tx_offload_get_configuration_tx_offload, 16487 (void *)&cmd_tx_offload_get_configuration_configuration, 16488 NULL, 16489 } 16490 }; 16491 16492 /* Enable/Disable a per port offloading */ 16493 struct cmd_config_per_port_tx_offload_result { 16494 cmdline_fixed_string_t port; 16495 cmdline_fixed_string_t config; 16496 portid_t port_id; 16497 cmdline_fixed_string_t tx_offload; 16498 cmdline_fixed_string_t offload; 16499 cmdline_fixed_string_t on_off; 16500 }; 16501 16502 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 16503 TOKEN_STRING_INITIALIZER 16504 (struct cmd_config_per_port_tx_offload_result, 16505 port, "port"); 16506 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 16507 TOKEN_STRING_INITIALIZER 16508 (struct cmd_config_per_port_tx_offload_result, 16509 config, "config"); 16510 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 16511 TOKEN_NUM_INITIALIZER 16512 (struct cmd_config_per_port_tx_offload_result, 16513 port_id, RTE_UINT16); 16514 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 16515 TOKEN_STRING_INITIALIZER 16516 (struct cmd_config_per_port_tx_offload_result, 16517 tx_offload, "tx_offload"); 16518 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 16519 TOKEN_STRING_INITIALIZER 16520 (struct cmd_config_per_port_tx_offload_result, 16521 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 16522 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 16523 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 16524 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 16525 "mt_lockfree#multi_segs#mbuf_fast_free#security#" 16526 "send_on_timestamp"); 16527 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = 16528 TOKEN_STRING_INITIALIZER 16529 (struct cmd_config_per_port_tx_offload_result, 16530 on_off, "on#off"); 16531 16532 static uint64_t 16533 search_tx_offload(const char *name) 16534 { 16535 uint64_t single_offload; 16536 const char *single_name; 16537 int found = 0; 16538 unsigned int bit; 16539 16540 single_offload = 1; 16541 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 16542 single_name = rte_eth_dev_tx_offload_name(single_offload); 16543 if (single_name == NULL) 16544 break; 16545 if (!strcasecmp(single_name, name)) { 16546 found = 1; 16547 break; 16548 } else if (!strcasecmp(single_name, "UNKNOWN")) 16549 break; 16550 single_offload <<= 1; 16551 } 16552 16553 if (found) 16554 return single_offload; 16555 16556 return 0; 16557 } 16558 16559 static void 16560 cmd_config_per_port_tx_offload_parsed(void *parsed_result, 16561 __rte_unused struct cmdline *cl, 16562 __rte_unused void *data) 16563 { 16564 struct cmd_config_per_port_tx_offload_result *res = parsed_result; 16565 portid_t port_id = res->port_id; 16566 struct rte_eth_dev_info dev_info; 16567 struct rte_port *port = &ports[port_id]; 16568 uint64_t single_offload; 16569 uint16_t nb_tx_queues; 16570 int q; 16571 int ret; 16572 16573 if (port->port_status != RTE_PORT_STOPPED) { 16574 fprintf(stderr, 16575 "Error: Can't config offload when Port %d is not stopped\n", 16576 port_id); 16577 return; 16578 } 16579 16580 single_offload = search_tx_offload(res->offload); 16581 if (single_offload == 0) { 16582 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 16583 return; 16584 } 16585 16586 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16587 if (ret != 0) 16588 return; 16589 16590 nb_tx_queues = dev_info.nb_tx_queues; 16591 if (!strcmp(res->on_off, "on")) { 16592 port->dev_conf.txmode.offloads |= single_offload; 16593 for (q = 0; q < nb_tx_queues; q++) 16594 port->tx_conf[q].offloads |= single_offload; 16595 } else { 16596 port->dev_conf.txmode.offloads &= ~single_offload; 16597 for (q = 0; q < nb_tx_queues; q++) 16598 port->tx_conf[q].offloads &= ~single_offload; 16599 } 16600 16601 cmd_reconfig_device_queue(port_id, 1, 1); 16602 } 16603 16604 cmdline_parse_inst_t cmd_config_per_port_tx_offload = { 16605 .f = cmd_config_per_port_tx_offload_parsed, 16606 .data = NULL, 16607 .help_str = "port config <port_id> tx_offload " 16608 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 16609 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 16610 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 16611 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 16612 "mt_lockfree|multi_segs|mbuf_fast_free|security|" 16613 "send_on_timestamp on|off", 16614 .tokens = { 16615 (void *)&cmd_config_per_port_tx_offload_result_port, 16616 (void *)&cmd_config_per_port_tx_offload_result_config, 16617 (void *)&cmd_config_per_port_tx_offload_result_port_id, 16618 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 16619 (void *)&cmd_config_per_port_tx_offload_result_offload, 16620 (void *)&cmd_config_per_port_tx_offload_result_on_off, 16621 NULL, 16622 } 16623 }; 16624 16625 /* Enable/Disable a per queue offloading */ 16626 struct cmd_config_per_queue_tx_offload_result { 16627 cmdline_fixed_string_t port; 16628 portid_t port_id; 16629 cmdline_fixed_string_t txq; 16630 uint16_t queue_id; 16631 cmdline_fixed_string_t tx_offload; 16632 cmdline_fixed_string_t offload; 16633 cmdline_fixed_string_t on_off; 16634 }; 16635 16636 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 16637 TOKEN_STRING_INITIALIZER 16638 (struct cmd_config_per_queue_tx_offload_result, 16639 port, "port"); 16640 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 16641 TOKEN_NUM_INITIALIZER 16642 (struct cmd_config_per_queue_tx_offload_result, 16643 port_id, RTE_UINT16); 16644 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 16645 TOKEN_STRING_INITIALIZER 16646 (struct cmd_config_per_queue_tx_offload_result, 16647 txq, "txq"); 16648 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 16649 TOKEN_NUM_INITIALIZER 16650 (struct cmd_config_per_queue_tx_offload_result, 16651 queue_id, RTE_UINT16); 16652 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 16653 TOKEN_STRING_INITIALIZER 16654 (struct cmd_config_per_queue_tx_offload_result, 16655 tx_offload, "tx_offload"); 16656 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 16657 TOKEN_STRING_INITIALIZER 16658 (struct cmd_config_per_queue_tx_offload_result, 16659 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 16660 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 16661 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 16662 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 16663 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 16664 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 16665 TOKEN_STRING_INITIALIZER 16666 (struct cmd_config_per_queue_tx_offload_result, 16667 on_off, "on#off"); 16668 16669 static void 16670 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 16671 __rte_unused struct cmdline *cl, 16672 __rte_unused void *data) 16673 { 16674 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 16675 struct rte_eth_dev_info dev_info; 16676 portid_t port_id = res->port_id; 16677 uint16_t queue_id = res->queue_id; 16678 struct rte_port *port = &ports[port_id]; 16679 uint64_t single_offload; 16680 int ret; 16681 16682 if (port->port_status != RTE_PORT_STOPPED) { 16683 fprintf(stderr, 16684 "Error: Can't config offload when Port %d is not stopped\n", 16685 port_id); 16686 return; 16687 } 16688 16689 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16690 if (ret != 0) 16691 return; 16692 16693 if (queue_id >= dev_info.nb_tx_queues) { 16694 fprintf(stderr, 16695 "Error: input queue_id should be 0 ... %d\n", 16696 dev_info.nb_tx_queues - 1); 16697 return; 16698 } 16699 16700 single_offload = search_tx_offload(res->offload); 16701 if (single_offload == 0) { 16702 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 16703 return; 16704 } 16705 16706 if (!strcmp(res->on_off, "on")) 16707 port->tx_conf[queue_id].offloads |= single_offload; 16708 else 16709 port->tx_conf[queue_id].offloads &= ~single_offload; 16710 16711 cmd_reconfig_device_queue(port_id, 1, 1); 16712 } 16713 16714 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 16715 .f = cmd_config_per_queue_tx_offload_parsed, 16716 .data = NULL, 16717 .help_str = "port <port_id> txq <queue_id> tx_offload " 16718 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 16719 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 16720 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 16721 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 16722 "mt_lockfree|multi_segs|mbuf_fast_free|security " 16723 "on|off", 16724 .tokens = { 16725 (void *)&cmd_config_per_queue_tx_offload_result_port, 16726 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 16727 (void *)&cmd_config_per_queue_tx_offload_result_txq, 16728 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 16729 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 16730 (void *)&cmd_config_per_queue_tx_offload_result_offload, 16731 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 16732 NULL, 16733 } 16734 }; 16735 16736 /* *** configure tx_metadata for specific port *** */ 16737 struct cmd_config_tx_metadata_specific_result { 16738 cmdline_fixed_string_t port; 16739 cmdline_fixed_string_t keyword; 16740 uint16_t port_id; 16741 cmdline_fixed_string_t item; 16742 uint32_t value; 16743 }; 16744 16745 static void 16746 cmd_config_tx_metadata_specific_parsed(void *parsed_result, 16747 __rte_unused struct cmdline *cl, 16748 __rte_unused void *data) 16749 { 16750 struct cmd_config_tx_metadata_specific_result *res = parsed_result; 16751 16752 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16753 return; 16754 ports[res->port_id].tx_metadata = res->value; 16755 /* Add/remove callback to insert valid metadata in every Tx packet. */ 16756 if (ports[res->port_id].tx_metadata) 16757 add_tx_md_callback(res->port_id); 16758 else 16759 remove_tx_md_callback(res->port_id); 16760 rte_flow_dynf_metadata_register(); 16761 } 16762 16763 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = 16764 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16765 port, "port"); 16766 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = 16767 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16768 keyword, "config"); 16769 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = 16770 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16771 port_id, RTE_UINT16); 16772 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = 16773 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16774 item, "tx_metadata"); 16775 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = 16776 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16777 value, RTE_UINT32); 16778 16779 cmdline_parse_inst_t cmd_config_tx_metadata_specific = { 16780 .f = cmd_config_tx_metadata_specific_parsed, 16781 .data = NULL, 16782 .help_str = "port config <port_id> tx_metadata <value>", 16783 .tokens = { 16784 (void *)&cmd_config_tx_metadata_specific_port, 16785 (void *)&cmd_config_tx_metadata_specific_keyword, 16786 (void *)&cmd_config_tx_metadata_specific_id, 16787 (void *)&cmd_config_tx_metadata_specific_item, 16788 (void *)&cmd_config_tx_metadata_specific_value, 16789 NULL, 16790 }, 16791 }; 16792 16793 /* *** set dynf *** */ 16794 struct cmd_config_tx_dynf_specific_result { 16795 cmdline_fixed_string_t port; 16796 cmdline_fixed_string_t keyword; 16797 uint16_t port_id; 16798 cmdline_fixed_string_t item; 16799 cmdline_fixed_string_t name; 16800 cmdline_fixed_string_t value; 16801 }; 16802 16803 static void 16804 cmd_config_dynf_specific_parsed(void *parsed_result, 16805 __rte_unused struct cmdline *cl, 16806 __rte_unused void *data) 16807 { 16808 struct cmd_config_tx_dynf_specific_result *res = parsed_result; 16809 struct rte_mbuf_dynflag desc_flag; 16810 int flag; 16811 uint64_t old_port_flags; 16812 16813 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16814 return; 16815 flag = rte_mbuf_dynflag_lookup(res->name, NULL); 16816 if (flag <= 0) { 16817 if (strlcpy(desc_flag.name, res->name, 16818 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) { 16819 fprintf(stderr, "Flag name too long\n"); 16820 return; 16821 } 16822 desc_flag.flags = 0; 16823 flag = rte_mbuf_dynflag_register(&desc_flag); 16824 if (flag < 0) { 16825 fprintf(stderr, "Can't register flag\n"); 16826 return; 16827 } 16828 strcpy(dynf_names[flag], desc_flag.name); 16829 } 16830 old_port_flags = ports[res->port_id].mbuf_dynf; 16831 if (!strcmp(res->value, "set")) { 16832 ports[res->port_id].mbuf_dynf |= 1UL << flag; 16833 if (old_port_flags == 0) 16834 add_tx_dynf_callback(res->port_id); 16835 } else { 16836 ports[res->port_id].mbuf_dynf &= ~(1UL << flag); 16837 if (ports[res->port_id].mbuf_dynf == 0) 16838 remove_tx_dynf_callback(res->port_id); 16839 } 16840 } 16841 16842 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port = 16843 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16844 keyword, "port"); 16845 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword = 16846 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16847 keyword, "config"); 16848 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id = 16849 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16850 port_id, RTE_UINT16); 16851 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item = 16852 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16853 item, "dynf"); 16854 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name = 16855 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16856 name, NULL); 16857 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value = 16858 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16859 value, "set#clear"); 16860 16861 cmdline_parse_inst_t cmd_config_tx_dynf_specific = { 16862 .f = cmd_config_dynf_specific_parsed, 16863 .data = NULL, 16864 .help_str = "port config <port id> dynf <name> set|clear", 16865 .tokens = { 16866 (void *)&cmd_config_tx_dynf_specific_port, 16867 (void *)&cmd_config_tx_dynf_specific_keyword, 16868 (void *)&cmd_config_tx_dynf_specific_port_id, 16869 (void *)&cmd_config_tx_dynf_specific_item, 16870 (void *)&cmd_config_tx_dynf_specific_name, 16871 (void *)&cmd_config_tx_dynf_specific_value, 16872 NULL, 16873 }, 16874 }; 16875 16876 /* *** display tx_metadata per port configuration *** */ 16877 struct cmd_show_tx_metadata_result { 16878 cmdline_fixed_string_t cmd_show; 16879 cmdline_fixed_string_t cmd_port; 16880 cmdline_fixed_string_t cmd_keyword; 16881 portid_t cmd_pid; 16882 }; 16883 16884 static void 16885 cmd_show_tx_metadata_parsed(void *parsed_result, 16886 __rte_unused struct cmdline *cl, 16887 __rte_unused void *data) 16888 { 16889 struct cmd_show_tx_metadata_result *res = parsed_result; 16890 16891 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16892 fprintf(stderr, "invalid port id %u\n", res->cmd_pid); 16893 return; 16894 } 16895 if (!strcmp(res->cmd_keyword, "tx_metadata")) { 16896 printf("Port %u tx_metadata: %u\n", res->cmd_pid, 16897 ports[res->cmd_pid].tx_metadata); 16898 } 16899 } 16900 16901 cmdline_parse_token_string_t cmd_show_tx_metadata_show = 16902 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 16903 cmd_show, "show"); 16904 cmdline_parse_token_string_t cmd_show_tx_metadata_port = 16905 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 16906 cmd_port, "port"); 16907 cmdline_parse_token_num_t cmd_show_tx_metadata_pid = 16908 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, 16909 cmd_pid, RTE_UINT16); 16910 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = 16911 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 16912 cmd_keyword, "tx_metadata"); 16913 16914 cmdline_parse_inst_t cmd_show_tx_metadata = { 16915 .f = cmd_show_tx_metadata_parsed, 16916 .data = NULL, 16917 .help_str = "show port <port_id> tx_metadata", 16918 .tokens = { 16919 (void *)&cmd_show_tx_metadata_show, 16920 (void *)&cmd_show_tx_metadata_port, 16921 (void *)&cmd_show_tx_metadata_pid, 16922 (void *)&cmd_show_tx_metadata_keyword, 16923 NULL, 16924 }, 16925 }; 16926 16927 /* *** show fec capability per port configuration *** */ 16928 struct cmd_show_fec_capability_result { 16929 cmdline_fixed_string_t cmd_show; 16930 cmdline_fixed_string_t cmd_port; 16931 cmdline_fixed_string_t cmd_fec; 16932 cmdline_fixed_string_t cmd_keyword; 16933 portid_t cmd_pid; 16934 }; 16935 16936 static void 16937 cmd_show_fec_capability_parsed(void *parsed_result, 16938 __rte_unused struct cmdline *cl, 16939 __rte_unused void *data) 16940 { 16941 struct cmd_show_fec_capability_result *res = parsed_result; 16942 struct rte_eth_fec_capa *speed_fec_capa; 16943 unsigned int num; 16944 int ret; 16945 16946 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16947 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid); 16948 return; 16949 } 16950 16951 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0); 16952 if (ret == -ENOTSUP) { 16953 fprintf(stderr, "Function not implemented\n"); 16954 return; 16955 } else if (ret < 0) { 16956 fprintf(stderr, "Get FEC capability failed: %d\n", ret); 16957 return; 16958 } 16959 16960 num = (unsigned int)ret; 16961 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa)); 16962 if (speed_fec_capa == NULL) { 16963 fprintf(stderr, "Failed to alloc FEC capability buffer\n"); 16964 return; 16965 } 16966 16967 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num); 16968 if (ret < 0) { 16969 fprintf(stderr, "Error getting FEC capability: %d\n", ret); 16970 goto out; 16971 } 16972 16973 show_fec_capability(num, speed_fec_capa); 16974 out: 16975 free(speed_fec_capa); 16976 } 16977 16978 cmdline_parse_token_string_t cmd_show_fec_capability_show = 16979 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16980 cmd_show, "show"); 16981 cmdline_parse_token_string_t cmd_show_fec_capability_port = 16982 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16983 cmd_port, "port"); 16984 cmdline_parse_token_num_t cmd_show_fec_capability_pid = 16985 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result, 16986 cmd_pid, RTE_UINT16); 16987 cmdline_parse_token_string_t cmd_show_fec_capability_fec = 16988 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16989 cmd_fec, "fec"); 16990 cmdline_parse_token_string_t cmd_show_fec_capability_keyword = 16991 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16992 cmd_keyword, "capabilities"); 16993 16994 cmdline_parse_inst_t cmd_show_capability = { 16995 .f = cmd_show_fec_capability_parsed, 16996 .data = NULL, 16997 .help_str = "show port <port_id> fec capabilities", 16998 .tokens = { 16999 (void *)&cmd_show_fec_capability_show, 17000 (void *)&cmd_show_fec_capability_port, 17001 (void *)&cmd_show_fec_capability_pid, 17002 (void *)&cmd_show_fec_capability_fec, 17003 (void *)&cmd_show_fec_capability_keyword, 17004 NULL, 17005 }, 17006 }; 17007 17008 /* *** show fec mode per port configuration *** */ 17009 struct cmd_show_fec_metadata_result { 17010 cmdline_fixed_string_t cmd_show; 17011 cmdline_fixed_string_t cmd_port; 17012 cmdline_fixed_string_t cmd_keyword; 17013 portid_t cmd_pid; 17014 }; 17015 17016 static void 17017 cmd_show_fec_mode_parsed(void *parsed_result, 17018 __rte_unused struct cmdline *cl, 17019 __rte_unused void *data) 17020 { 17021 #define FEC_NAME_SIZE 16 17022 struct cmd_show_fec_metadata_result *res = parsed_result; 17023 uint32_t mode; 17024 char buf[FEC_NAME_SIZE]; 17025 int ret; 17026 17027 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 17028 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid); 17029 return; 17030 } 17031 ret = rte_eth_fec_get(res->cmd_pid, &mode); 17032 if (ret == -ENOTSUP) { 17033 fprintf(stderr, "Function not implemented\n"); 17034 return; 17035 } else if (ret < 0) { 17036 fprintf(stderr, "Get FEC mode failed\n"); 17037 return; 17038 } 17039 17040 switch (mode) { 17041 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC): 17042 strlcpy(buf, "off", sizeof(buf)); 17043 break; 17044 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO): 17045 strlcpy(buf, "auto", sizeof(buf)); 17046 break; 17047 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER): 17048 strlcpy(buf, "baser", sizeof(buf)); 17049 break; 17050 case RTE_ETH_FEC_MODE_CAPA_MASK(RS): 17051 strlcpy(buf, "rs", sizeof(buf)); 17052 break; 17053 default: 17054 return; 17055 } 17056 17057 printf("%s\n", buf); 17058 } 17059 17060 cmdline_parse_token_string_t cmd_show_fec_mode_show = 17061 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 17062 cmd_show, "show"); 17063 cmdline_parse_token_string_t cmd_show_fec_mode_port = 17064 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 17065 cmd_port, "port"); 17066 cmdline_parse_token_num_t cmd_show_fec_mode_pid = 17067 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result, 17068 cmd_pid, RTE_UINT16); 17069 cmdline_parse_token_string_t cmd_show_fec_mode_keyword = 17070 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 17071 cmd_keyword, "fec_mode"); 17072 17073 cmdline_parse_inst_t cmd_show_fec_mode = { 17074 .f = cmd_show_fec_mode_parsed, 17075 .data = NULL, 17076 .help_str = "show port <port_id> fec_mode", 17077 .tokens = { 17078 (void *)&cmd_show_fec_mode_show, 17079 (void *)&cmd_show_fec_mode_port, 17080 (void *)&cmd_show_fec_mode_pid, 17081 (void *)&cmd_show_fec_mode_keyword, 17082 NULL, 17083 }, 17084 }; 17085 17086 /* *** set fec mode per port configuration *** */ 17087 struct cmd_set_port_fec_mode { 17088 cmdline_fixed_string_t set; 17089 cmdline_fixed_string_t port; 17090 portid_t port_id; 17091 cmdline_fixed_string_t fec_mode; 17092 cmdline_fixed_string_t fec_value; 17093 }; 17094 17095 /* Common CLI fields for set fec mode */ 17096 cmdline_parse_token_string_t cmd_set_port_fec_mode_set = 17097 TOKEN_STRING_INITIALIZER 17098 (struct cmd_set_port_fec_mode, 17099 set, "set"); 17100 cmdline_parse_token_string_t cmd_set_port_fec_mode_port = 17101 TOKEN_STRING_INITIALIZER 17102 (struct cmd_set_port_fec_mode, 17103 port, "port"); 17104 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id = 17105 TOKEN_NUM_INITIALIZER 17106 (struct cmd_set_port_fec_mode, 17107 port_id, RTE_UINT16); 17108 cmdline_parse_token_string_t cmd_set_port_fec_mode_str = 17109 TOKEN_STRING_INITIALIZER 17110 (struct cmd_set_port_fec_mode, 17111 fec_mode, "fec_mode"); 17112 cmdline_parse_token_string_t cmd_set_port_fec_mode_value = 17113 TOKEN_STRING_INITIALIZER 17114 (struct cmd_set_port_fec_mode, 17115 fec_value, NULL); 17116 17117 static void 17118 cmd_set_port_fec_mode_parsed( 17119 void *parsed_result, 17120 __rte_unused struct cmdline *cl, 17121 __rte_unused void *data) 17122 { 17123 struct cmd_set_port_fec_mode *res = parsed_result; 17124 uint16_t port_id = res->port_id; 17125 uint32_t fec_capa; 17126 int ret; 17127 17128 ret = parse_fec_mode(res->fec_value, &fec_capa); 17129 if (ret < 0) { 17130 fprintf(stderr, "Unknown fec mode: %s for port %d\n", 17131 res->fec_value, port_id); 17132 return; 17133 } 17134 17135 ret = rte_eth_fec_set(port_id, fec_capa); 17136 if (ret == -ENOTSUP) { 17137 fprintf(stderr, "Function not implemented\n"); 17138 return; 17139 } else if (ret < 0) { 17140 fprintf(stderr, "Set FEC mode failed\n"); 17141 return; 17142 } 17143 } 17144 17145 cmdline_parse_inst_t cmd_set_fec_mode = { 17146 .f = cmd_set_port_fec_mode_parsed, 17147 .data = NULL, 17148 .help_str = "set port <port_id> fec_mode auto|off|rs|baser", 17149 .tokens = { 17150 (void *)&cmd_set_port_fec_mode_set, 17151 (void *)&cmd_set_port_fec_mode_port, 17152 (void *)&cmd_set_port_fec_mode_port_id, 17153 (void *)&cmd_set_port_fec_mode_str, 17154 (void *)&cmd_set_port_fec_mode_value, 17155 NULL, 17156 }, 17157 }; 17158 17159 /* show port supported ptypes */ 17160 17161 /* Common result structure for show port ptypes */ 17162 struct cmd_show_port_supported_ptypes_result { 17163 cmdline_fixed_string_t show; 17164 cmdline_fixed_string_t port; 17165 portid_t port_id; 17166 cmdline_fixed_string_t ptypes; 17167 }; 17168 17169 /* Common CLI fields for show port ptypes */ 17170 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show = 17171 TOKEN_STRING_INITIALIZER 17172 (struct cmd_show_port_supported_ptypes_result, 17173 show, "show"); 17174 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port = 17175 TOKEN_STRING_INITIALIZER 17176 (struct cmd_show_port_supported_ptypes_result, 17177 port, "port"); 17178 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id = 17179 TOKEN_NUM_INITIALIZER 17180 (struct cmd_show_port_supported_ptypes_result, 17181 port_id, RTE_UINT16); 17182 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes = 17183 TOKEN_STRING_INITIALIZER 17184 (struct cmd_show_port_supported_ptypes_result, 17185 ptypes, "ptypes"); 17186 17187 static void 17188 cmd_show_port_supported_ptypes_parsed( 17189 void *parsed_result, 17190 __rte_unused struct cmdline *cl, 17191 __rte_unused void *data) 17192 { 17193 #define RSVD_PTYPE_MASK 0xf0000000 17194 #define MAX_PTYPES_PER_LAYER 16 17195 #define LTYPE_NAMESIZE 32 17196 #define PTYPE_NAMESIZE 256 17197 struct cmd_show_port_supported_ptypes_result *res = parsed_result; 17198 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE]; 17199 uint32_t ptype_mask = RTE_PTYPE_L2_MASK; 17200 uint32_t ptypes[MAX_PTYPES_PER_LAYER]; 17201 uint16_t port_id = res->port_id; 17202 int ret, i; 17203 17204 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0); 17205 if (ret < 0) 17206 return; 17207 17208 while (ptype_mask != RSVD_PTYPE_MASK) { 17209 17210 switch (ptype_mask) { 17211 case RTE_PTYPE_L2_MASK: 17212 strlcpy(ltype, "L2", sizeof(ltype)); 17213 break; 17214 case RTE_PTYPE_L3_MASK: 17215 strlcpy(ltype, "L3", sizeof(ltype)); 17216 break; 17217 case RTE_PTYPE_L4_MASK: 17218 strlcpy(ltype, "L4", sizeof(ltype)); 17219 break; 17220 case RTE_PTYPE_TUNNEL_MASK: 17221 strlcpy(ltype, "Tunnel", sizeof(ltype)); 17222 break; 17223 case RTE_PTYPE_INNER_L2_MASK: 17224 strlcpy(ltype, "Inner L2", sizeof(ltype)); 17225 break; 17226 case RTE_PTYPE_INNER_L3_MASK: 17227 strlcpy(ltype, "Inner L3", sizeof(ltype)); 17228 break; 17229 case RTE_PTYPE_INNER_L4_MASK: 17230 strlcpy(ltype, "Inner L4", sizeof(ltype)); 17231 break; 17232 default: 17233 return; 17234 } 17235 17236 ret = rte_eth_dev_get_supported_ptypes(res->port_id, 17237 ptype_mask, ptypes, 17238 MAX_PTYPES_PER_LAYER); 17239 17240 if (ret > 0) 17241 printf("Supported %s ptypes:\n", ltype); 17242 else 17243 printf("%s ptypes unsupported\n", ltype); 17244 17245 for (i = 0; i < ret; ++i) { 17246 rte_get_ptype_name(ptypes[i], buf, sizeof(buf)); 17247 printf("%s\n", buf); 17248 } 17249 17250 ptype_mask <<= 4; 17251 } 17252 } 17253 17254 cmdline_parse_inst_t cmd_show_port_supported_ptypes = { 17255 .f = cmd_show_port_supported_ptypes_parsed, 17256 .data = NULL, 17257 .help_str = "show port <port_id> ptypes", 17258 .tokens = { 17259 (void *)&cmd_show_port_supported_ptypes_show, 17260 (void *)&cmd_show_port_supported_ptypes_port, 17261 (void *)&cmd_show_port_supported_ptypes_port_id, 17262 (void *)&cmd_show_port_supported_ptypes_ptypes, 17263 NULL, 17264 }, 17265 }; 17266 17267 /* *** display rx/tx descriptor status *** */ 17268 struct cmd_show_rx_tx_desc_status_result { 17269 cmdline_fixed_string_t cmd_show; 17270 cmdline_fixed_string_t cmd_port; 17271 cmdline_fixed_string_t cmd_keyword; 17272 cmdline_fixed_string_t cmd_desc; 17273 cmdline_fixed_string_t cmd_status; 17274 portid_t cmd_pid; 17275 portid_t cmd_qid; 17276 portid_t cmd_did; 17277 }; 17278 17279 static void 17280 cmd_show_rx_tx_desc_status_parsed(void *parsed_result, 17281 __rte_unused struct cmdline *cl, 17282 __rte_unused void *data) 17283 { 17284 struct cmd_show_rx_tx_desc_status_result *res = parsed_result; 17285 int rc; 17286 17287 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 17288 fprintf(stderr, "invalid port id %u\n", res->cmd_pid); 17289 return; 17290 } 17291 17292 if (!strcmp(res->cmd_keyword, "rxq")) { 17293 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid, 17294 res->cmd_did); 17295 if (rc < 0) { 17296 fprintf(stderr, 17297 "Invalid input: queue id = %d, desc id = %d\n", 17298 res->cmd_qid, res->cmd_did); 17299 return; 17300 } 17301 if (rc == RTE_ETH_RX_DESC_AVAIL) 17302 printf("Desc status = AVAILABLE\n"); 17303 else if (rc == RTE_ETH_RX_DESC_DONE) 17304 printf("Desc status = DONE\n"); 17305 else 17306 printf("Desc status = UNAVAILABLE\n"); 17307 } else if (!strcmp(res->cmd_keyword, "txq")) { 17308 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid, 17309 res->cmd_did); 17310 if (rc < 0) { 17311 fprintf(stderr, 17312 "Invalid input: queue id = %d, desc id = %d\n", 17313 res->cmd_qid, res->cmd_did); 17314 return; 17315 } 17316 if (rc == RTE_ETH_TX_DESC_FULL) 17317 printf("Desc status = FULL\n"); 17318 else if (rc == RTE_ETH_TX_DESC_DONE) 17319 printf("Desc status = DONE\n"); 17320 else 17321 printf("Desc status = UNAVAILABLE\n"); 17322 } 17323 } 17324 17325 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show = 17326 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17327 cmd_show, "show"); 17328 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port = 17329 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17330 cmd_port, "port"); 17331 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid = 17332 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17333 cmd_pid, RTE_UINT16); 17334 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword = 17335 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17336 cmd_keyword, "rxq#txq"); 17337 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid = 17338 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17339 cmd_qid, RTE_UINT16); 17340 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc = 17341 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17342 cmd_desc, "desc"); 17343 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did = 17344 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17345 cmd_did, RTE_UINT16); 17346 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status = 17347 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17348 cmd_status, "status"); 17349 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = { 17350 .f = cmd_show_rx_tx_desc_status_parsed, 17351 .data = NULL, 17352 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> " 17353 "status", 17354 .tokens = { 17355 (void *)&cmd_show_rx_tx_desc_status_show, 17356 (void *)&cmd_show_rx_tx_desc_status_port, 17357 (void *)&cmd_show_rx_tx_desc_status_pid, 17358 (void *)&cmd_show_rx_tx_desc_status_keyword, 17359 (void *)&cmd_show_rx_tx_desc_status_qid, 17360 (void *)&cmd_show_rx_tx_desc_status_desc, 17361 (void *)&cmd_show_rx_tx_desc_status_did, 17362 (void *)&cmd_show_rx_tx_desc_status_status, 17363 NULL, 17364 }, 17365 }; 17366 17367 /* *** display rx queue desc used count *** */ 17368 struct cmd_show_rx_queue_desc_used_count_result { 17369 cmdline_fixed_string_t cmd_show; 17370 cmdline_fixed_string_t cmd_port; 17371 cmdline_fixed_string_t cmd_rxq; 17372 cmdline_fixed_string_t cmd_desc; 17373 cmdline_fixed_string_t cmd_used; 17374 cmdline_fixed_string_t cmd_count; 17375 portid_t cmd_pid; 17376 portid_t cmd_qid; 17377 }; 17378 17379 static void 17380 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result, 17381 __rte_unused struct cmdline *cl, 17382 __rte_unused void *data) 17383 { 17384 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result; 17385 int rc; 17386 17387 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 17388 fprintf(stderr, "invalid port id %u\n", res->cmd_pid); 17389 return; 17390 } 17391 17392 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid); 17393 if (rc < 0) { 17394 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid); 17395 return; 17396 } 17397 printf("Used desc count = %d\n", rc); 17398 } 17399 17400 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show = 17401 TOKEN_STRING_INITIALIZER 17402 (struct cmd_show_rx_queue_desc_used_count_result, 17403 cmd_show, "show"); 17404 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port = 17405 TOKEN_STRING_INITIALIZER 17406 (struct cmd_show_rx_queue_desc_used_count_result, 17407 cmd_port, "port"); 17408 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid = 17409 TOKEN_NUM_INITIALIZER 17410 (struct cmd_show_rx_queue_desc_used_count_result, 17411 cmd_pid, RTE_UINT16); 17412 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq = 17413 TOKEN_STRING_INITIALIZER 17414 (struct cmd_show_rx_queue_desc_used_count_result, 17415 cmd_rxq, "rxq"); 17416 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid = 17417 TOKEN_NUM_INITIALIZER 17418 (struct cmd_show_rx_queue_desc_used_count_result, 17419 cmd_qid, RTE_UINT16); 17420 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc = 17421 TOKEN_STRING_INITIALIZER 17422 (struct cmd_show_rx_queue_desc_used_count_result, 17423 cmd_count, "desc"); 17424 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used = 17425 TOKEN_STRING_INITIALIZER 17426 (struct cmd_show_rx_queue_desc_used_count_result, 17427 cmd_count, "used"); 17428 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count = 17429 TOKEN_STRING_INITIALIZER 17430 (struct cmd_show_rx_queue_desc_used_count_result, 17431 cmd_count, "count"); 17432 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = { 17433 .f = cmd_show_rx_queue_desc_used_count_parsed, 17434 .data = NULL, 17435 .help_str = "show port <port_id> rxq <queue_id> desc used count", 17436 .tokens = { 17437 (void *)&cmd_show_rx_queue_desc_used_count_show, 17438 (void *)&cmd_show_rx_queue_desc_used_count_port, 17439 (void *)&cmd_show_rx_queue_desc_used_count_pid, 17440 (void *)&cmd_show_rx_queue_desc_used_count_rxq, 17441 (void *)&cmd_show_rx_queue_desc_used_count_qid, 17442 (void *)&cmd_show_rx_queue_desc_used_count_desc, 17443 (void *)&cmd_show_rx_queue_desc_used_count_used, 17444 (void *)&cmd_show_rx_queue_desc_used_count_count, 17445 NULL, 17446 }, 17447 }; 17448 17449 /* Common result structure for set port ptypes */ 17450 struct cmd_set_port_ptypes_result { 17451 cmdline_fixed_string_t set; 17452 cmdline_fixed_string_t port; 17453 portid_t port_id; 17454 cmdline_fixed_string_t ptype_mask; 17455 uint32_t mask; 17456 }; 17457 17458 /* Common CLI fields for set port ptypes */ 17459 cmdline_parse_token_string_t cmd_set_port_ptypes_set = 17460 TOKEN_STRING_INITIALIZER 17461 (struct cmd_set_port_ptypes_result, 17462 set, "set"); 17463 cmdline_parse_token_string_t cmd_set_port_ptypes_port = 17464 TOKEN_STRING_INITIALIZER 17465 (struct cmd_set_port_ptypes_result, 17466 port, "port"); 17467 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id = 17468 TOKEN_NUM_INITIALIZER 17469 (struct cmd_set_port_ptypes_result, 17470 port_id, RTE_UINT16); 17471 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str = 17472 TOKEN_STRING_INITIALIZER 17473 (struct cmd_set_port_ptypes_result, 17474 ptype_mask, "ptype_mask"); 17475 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 = 17476 TOKEN_NUM_INITIALIZER 17477 (struct cmd_set_port_ptypes_result, 17478 mask, RTE_UINT32); 17479 17480 static void 17481 cmd_set_port_ptypes_parsed( 17482 void *parsed_result, 17483 __rte_unused struct cmdline *cl, 17484 __rte_unused void *data) 17485 { 17486 struct cmd_set_port_ptypes_result *res = parsed_result; 17487 #define PTYPE_NAMESIZE 256 17488 char ptype_name[PTYPE_NAMESIZE]; 17489 uint16_t port_id = res->port_id; 17490 uint32_t ptype_mask = res->mask; 17491 int ret, i; 17492 17493 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK, 17494 NULL, 0); 17495 if (ret <= 0) { 17496 fprintf(stderr, "Port %d doesn't support any ptypes.\n", 17497 port_id); 17498 return; 17499 } 17500 17501 uint32_t ptypes[ret]; 17502 17503 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); 17504 if (ret < 0) { 17505 fprintf(stderr, "Unable to set requested ptypes for Port %d\n", 17506 port_id); 17507 return; 17508 } 17509 17510 printf("Successfully set following ptypes for Port %d\n", port_id); 17511 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) { 17512 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name)); 17513 printf("%s\n", ptype_name); 17514 } 17515 17516 clear_ptypes = false; 17517 } 17518 17519 cmdline_parse_inst_t cmd_set_port_ptypes = { 17520 .f = cmd_set_port_ptypes_parsed, 17521 .data = NULL, 17522 .help_str = "set port <port_id> ptype_mask <mask>", 17523 .tokens = { 17524 (void *)&cmd_set_port_ptypes_set, 17525 (void *)&cmd_set_port_ptypes_port, 17526 (void *)&cmd_set_port_ptypes_port_id, 17527 (void *)&cmd_set_port_ptypes_mask_str, 17528 (void *)&cmd_set_port_ptypes_mask_u32, 17529 NULL, 17530 }, 17531 }; 17532 17533 /* *** display mac addresses added to a port *** */ 17534 struct cmd_showport_macs_result { 17535 cmdline_fixed_string_t cmd_show; 17536 cmdline_fixed_string_t cmd_port; 17537 cmdline_fixed_string_t cmd_keyword; 17538 portid_t cmd_pid; 17539 }; 17540 17541 static void 17542 cmd_showport_macs_parsed(void *parsed_result, 17543 __rte_unused struct cmdline *cl, 17544 __rte_unused void *data) 17545 { 17546 struct cmd_showport_macs_result *res = parsed_result; 17547 17548 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN)) 17549 return; 17550 17551 if (!strcmp(res->cmd_keyword, "macs")) 17552 show_macs(res->cmd_pid); 17553 else if (!strcmp(res->cmd_keyword, "mcast_macs")) 17554 show_mcast_macs(res->cmd_pid); 17555 } 17556 17557 cmdline_parse_token_string_t cmd_showport_macs_show = 17558 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 17559 cmd_show, "show"); 17560 cmdline_parse_token_string_t cmd_showport_macs_port = 17561 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 17562 cmd_port, "port"); 17563 cmdline_parse_token_num_t cmd_showport_macs_pid = 17564 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result, 17565 cmd_pid, RTE_UINT16); 17566 cmdline_parse_token_string_t cmd_showport_macs_keyword = 17567 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 17568 cmd_keyword, "macs#mcast_macs"); 17569 17570 cmdline_parse_inst_t cmd_showport_macs = { 17571 .f = cmd_showport_macs_parsed, 17572 .data = NULL, 17573 .help_str = "show port <port_id> macs|mcast_macs", 17574 .tokens = { 17575 (void *)&cmd_showport_macs_show, 17576 (void *)&cmd_showport_macs_port, 17577 (void *)&cmd_showport_macs_pid, 17578 (void *)&cmd_showport_macs_keyword, 17579 NULL, 17580 }, 17581 }; 17582 17583 /* ******************************************************************************** */ 17584 17585 /* list of instructions */ 17586 cmdline_parse_ctx_t main_ctx[] = { 17587 (cmdline_parse_inst_t *)&cmd_help_brief, 17588 (cmdline_parse_inst_t *)&cmd_help_long, 17589 (cmdline_parse_inst_t *)&cmd_quit, 17590 (cmdline_parse_inst_t *)&cmd_load_from_file, 17591 (cmdline_parse_inst_t *)&cmd_showport, 17592 (cmdline_parse_inst_t *)&cmd_showqueue, 17593 (cmdline_parse_inst_t *)&cmd_showeeprom, 17594 (cmdline_parse_inst_t *)&cmd_showportall, 17595 (cmdline_parse_inst_t *)&cmd_representor_info, 17596 (cmdline_parse_inst_t *)&cmd_showdevice, 17597 (cmdline_parse_inst_t *)&cmd_showcfg, 17598 (cmdline_parse_inst_t *)&cmd_showfwdall, 17599 (cmdline_parse_inst_t *)&cmd_start, 17600 (cmdline_parse_inst_t *)&cmd_start_tx_first, 17601 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 17602 (cmdline_parse_inst_t *)&cmd_set_link_up, 17603 (cmdline_parse_inst_t *)&cmd_set_link_down, 17604 (cmdline_parse_inst_t *)&cmd_reset, 17605 (cmdline_parse_inst_t *)&cmd_set_numbers, 17606 (cmdline_parse_inst_t *)&cmd_set_log, 17607 (cmdline_parse_inst_t *)&cmd_set_rxoffs, 17608 (cmdline_parse_inst_t *)&cmd_set_rxpkts, 17609 (cmdline_parse_inst_t *)&cmd_set_txpkts, 17610 (cmdline_parse_inst_t *)&cmd_set_txsplit, 17611 (cmdline_parse_inst_t *)&cmd_set_txtimes, 17612 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 17613 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 17614 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 17615 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 17616 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 17617 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 17618 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 17619 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 17620 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 17621 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 17622 (cmdline_parse_inst_t *)&cmd_set_link_check, 17623 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 17624 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 17625 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 17626 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 17627 #ifdef RTE_NET_BOND 17628 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 17629 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 17630 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info, 17631 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 17632 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 17633 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 17634 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 17635 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 17636 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 17637 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 17638 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 17639 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 17640 #endif 17641 (cmdline_parse_inst_t *)&cmd_vlan_offload, 17642 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 17643 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 17644 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 17645 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 17646 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 17647 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 17648 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 17649 (cmdline_parse_inst_t *)&cmd_csum_set, 17650 (cmdline_parse_inst_t *)&cmd_csum_show, 17651 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 17652 (cmdline_parse_inst_t *)&cmd_tso_set, 17653 (cmdline_parse_inst_t *)&cmd_tso_show, 17654 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 17655 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 17656 (cmdline_parse_inst_t *)&cmd_gro_enable, 17657 (cmdline_parse_inst_t *)&cmd_gro_flush, 17658 (cmdline_parse_inst_t *)&cmd_gro_show, 17659 (cmdline_parse_inst_t *)&cmd_gso_enable, 17660 (cmdline_parse_inst_t *)&cmd_gso_size, 17661 (cmdline_parse_inst_t *)&cmd_gso_show, 17662 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 17663 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 17664 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 17665 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 17666 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 17667 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 17668 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 17669 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 17670 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 17671 (cmdline_parse_inst_t *)&cmd_link_flow_control_show, 17672 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 17673 (cmdline_parse_inst_t *)&cmd_config_dcb, 17674 (cmdline_parse_inst_t *)&cmd_read_reg, 17675 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 17676 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 17677 (cmdline_parse_inst_t *)&cmd_write_reg, 17678 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 17679 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 17680 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 17681 (cmdline_parse_inst_t *)&cmd_stop, 17682 (cmdline_parse_inst_t *)&cmd_mac_addr, 17683 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 17684 (cmdline_parse_inst_t *)&cmd_set_qmap, 17685 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 17686 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles, 17687 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats, 17688 (cmdline_parse_inst_t *)&cmd_operate_port, 17689 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 17690 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 17691 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 17692 (cmdline_parse_inst_t *)&cmd_operate_detach_device, 17693 (cmdline_parse_inst_t *)&cmd_set_port_setup_on, 17694 (cmdline_parse_inst_t *)&cmd_config_speed_all, 17695 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 17696 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 17697 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 17698 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 17699 (cmdline_parse_inst_t *)&cmd_config_mtu, 17700 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 17701 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size, 17702 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 17703 (cmdline_parse_inst_t *)&cmd_config_rss, 17704 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 17705 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 17706 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 17707 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 17708 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 17709 (cmdline_parse_inst_t *)&cmd_showport_reta, 17710 (cmdline_parse_inst_t *)&cmd_showport_macs, 17711 (cmdline_parse_inst_t *)&cmd_config_burst, 17712 (cmdline_parse_inst_t *)&cmd_config_thresh, 17713 (cmdline_parse_inst_t *)&cmd_config_threshold, 17714 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 17715 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 17716 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 17717 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 17718 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 17719 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 17720 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 17721 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 17722 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs, 17723 (cmdline_parse_inst_t *)&cmd_dump, 17724 (cmdline_parse_inst_t *)&cmd_dump_one, 17725 #ifdef RTE_NET_I40E 17726 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 17727 #endif 17728 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 17729 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 17730 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 17731 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 17732 (cmdline_parse_inst_t *)&cmd_flow, 17733 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 17734 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 17735 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 17736 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 17737 (cmdline_parse_inst_t *)&cmd_create_port_meter, 17738 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 17739 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 17740 (cmdline_parse_inst_t *)&cmd_del_port_meter, 17741 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy, 17742 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 17743 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 17744 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 17745 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 17746 (cmdline_parse_inst_t *)&cmd_mcast_addr, 17747 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 17748 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 17749 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 17750 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 17751 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 17752 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 17753 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 17754 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 17755 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 17756 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 17757 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 17758 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 17759 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 17760 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 17761 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 17762 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 17763 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 17764 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 17765 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 17766 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 17767 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 17768 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 17769 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 17770 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 17771 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 17772 (cmdline_parse_inst_t *)&cmd_set_vxlan, 17773 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl, 17774 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 17775 (cmdline_parse_inst_t *)&cmd_set_nvgre, 17776 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 17777 (cmdline_parse_inst_t *)&cmd_set_l2_encap, 17778 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, 17779 (cmdline_parse_inst_t *)&cmd_set_l2_decap, 17780 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, 17781 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, 17782 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, 17783 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, 17784 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, 17785 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, 17786 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, 17787 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, 17788 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, 17789 (cmdline_parse_inst_t *)&cmd_set_conntrack_common, 17790 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir, 17791 (cmdline_parse_inst_t *)&cmd_ddp_add, 17792 (cmdline_parse_inst_t *)&cmd_ddp_del, 17793 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 17794 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 17795 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 17796 (cmdline_parse_inst_t *)&cmd_clear_input_set, 17797 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 17798 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 17799 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes, 17800 (cmdline_parse_inst_t *)&cmd_set_port_ptypes, 17801 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 17802 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 17803 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 17804 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 17805 17806 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 17807 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 17808 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 17809 (cmdline_parse_inst_t *)&cmd_queue_region, 17810 (cmdline_parse_inst_t *)&cmd_region_flowtype, 17811 (cmdline_parse_inst_t *)&cmd_user_priority_region, 17812 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 17813 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 17814 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 17815 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 17816 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 17817 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 17818 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 17819 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 17820 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 17821 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 17822 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 17823 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 17824 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 17825 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 17826 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 17827 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode, 17828 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 17829 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 17830 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 17831 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 17832 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 17833 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 17834 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, 17835 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, 17836 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, 17837 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 17838 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 17839 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 17840 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 17841 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 17842 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 17843 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 17844 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 17845 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 17846 #ifdef RTE_LIB_BPF 17847 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 17848 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 17849 #endif 17850 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, 17851 (cmdline_parse_inst_t *)&cmd_show_tx_metadata, 17852 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status, 17853 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count, 17854 (cmdline_parse_inst_t *)&cmd_set_raw, 17855 (cmdline_parse_inst_t *)&cmd_show_set_raw, 17856 (cmdline_parse_inst_t *)&cmd_show_set_raw_all, 17857 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific, 17858 (cmdline_parse_inst_t *)&cmd_show_fec_mode, 17859 (cmdline_parse_inst_t *)&cmd_set_fec_mode, 17860 (cmdline_parse_inst_t *)&cmd_show_capability, 17861 NULL, 17862 }; 17863 17864 /* read cmdline commands from file */ 17865 void 17866 cmdline_read_from_file(const char *filename) 17867 { 17868 struct cmdline *cl; 17869 17870 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 17871 if (cl == NULL) { 17872 fprintf(stderr, 17873 "Failed to create file based cmdline context: %s\n", 17874 filename); 17875 return; 17876 } 17877 17878 cmdline_interact(cl); 17879 cmdline_quit(cl); 17880 17881 cmdline_free(cl); 17882 17883 printf("Read CLI commands from %s\n", filename); 17884 } 17885 17886 /* prompt function, called from main on MAIN lcore */ 17887 void 17888 prompt(void) 17889 { 17890 int ret; 17891 /* initialize non-constant commands */ 17892 cmd_set_fwd_mode_init(); 17893 cmd_set_fwd_retry_mode_init(); 17894 17895 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 17896 if (testpmd_cl == NULL) 17897 return; 17898 17899 ret = atexit(prompt_exit); 17900 if (ret != 0) 17901 fprintf(stderr, "Cannot set exit function for cmdline\n"); 17902 17903 cmdline_interact(testpmd_cl); 17904 if (ret != 0) 17905 cmdline_stdin_exit(testpmd_cl); 17906 } 17907 17908 void 17909 prompt_exit(void) 17910 { 17911 if (testpmd_cl != NULL) { 17912 cmdline_quit(testpmd_cl); 17913 cmdline_stdin_exit(testpmd_cl); 17914 } 17915 } 17916 17917 static void 17918 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 17919 { 17920 if (id == (portid_t)RTE_PORT_ALL) { 17921 portid_t pid; 17922 17923 RTE_ETH_FOREACH_DEV(pid) { 17924 /* check if need_reconfig has been set to 1 */ 17925 if (ports[pid].need_reconfig == 0) 17926 ports[pid].need_reconfig = dev; 17927 /* check if need_reconfig_queues has been set to 1 */ 17928 if (ports[pid].need_reconfig_queues == 0) 17929 ports[pid].need_reconfig_queues = queue; 17930 } 17931 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 17932 /* check if need_reconfig has been set to 1 */ 17933 if (ports[id].need_reconfig == 0) 17934 ports[id].need_reconfig = dev; 17935 /* check if need_reconfig_queues has been set to 1 */ 17936 if (ports[id].need_reconfig_queues == 0) 17937 ports[id].need_reconfig_queues = queue; 17938 } 17939 } 17940