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 port_id (module_eeprom|eeprom)\n" 166 " Display the module EEPROM or EEPROM information for port_id.\n\n" 167 168 "show port X rss reta (size) (mask0,mask1,...)\n" 169 " Display the rss redirection table entry indicated" 170 " by masks on port X. size is used to indicate the" 171 " hardware supported reta size\n\n" 172 173 "show port (port_id) rss-hash [key]\n" 174 " Display the RSS hash functions and RSS hash key of port\n\n" 175 176 "clear port (info|stats|xstats|fdir) (port_id|all)\n" 177 " Clear information for port_id, or all.\n\n" 178 179 "show (rxq|txq) info (port_id) (queue_id)\n" 180 " Display information for configured RX/TX queue.\n\n" 181 182 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n" 183 " Display the given configuration.\n\n" 184 185 "read rxd (port_id) (queue_id) (rxd_id)\n" 186 " Display an RX descriptor of a port RX queue.\n\n" 187 188 "read txd (port_id) (queue_id) (txd_id)\n" 189 " Display a TX descriptor of a port TX queue.\n\n" 190 191 "ddp get list (port_id)\n" 192 " Get ddp profile info list\n\n" 193 194 "ddp get info (profile_path)\n" 195 " Get ddp profile information.\n\n" 196 197 "show vf stats (port_id) (vf_id)\n" 198 " Display a VF's statistics.\n\n" 199 200 "clear vf stats (port_id) (vf_id)\n" 201 " Reset a VF's statistics.\n\n" 202 203 "show port (port_id) pctype mapping\n" 204 " Get flow ptype to pctype mapping on a port\n\n" 205 206 "show port meter stats (port_id) (meter_id) (clear)\n" 207 " Get meter stats on a port\n\n" 208 209 "show fwd stats all\n" 210 " Display statistics for all fwd engines.\n\n" 211 212 "clear fwd stats all\n" 213 " Clear statistics for all fwd engines.\n\n" 214 215 "show port (port_id) rx_offload capabilities\n" 216 " List all per queue and per port Rx offloading" 217 " capabilities of a port\n\n" 218 219 "show port (port_id) rx_offload configuration\n" 220 " List port level and all queue level" 221 " Rx offloading configuration\n\n" 222 223 "show port (port_id) tx_offload capabilities\n" 224 " List all per queue and per port" 225 " Tx offloading capabilities of a port\n\n" 226 227 "show port (port_id) tx_offload configuration\n" 228 " List port level and all queue level" 229 " Tx offloading configuration\n\n" 230 231 "show port (port_id) tx_metadata\n" 232 " Show Tx metadata value set" 233 " for a specific port\n\n" 234 235 "show port (port_id) ptypes\n" 236 " Show port supported ptypes" 237 " for a specific port\n\n" 238 239 "show device info (<identifier>|all)" 240 " Show general information about devices probed.\n\n" 241 242 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status" 243 " Show status of rx|tx descriptor.\n\n" 244 245 "show port (port_id) rxq (queue_id) desc used count\n" 246 " Show current number of filled receive" 247 " packet descriptors.\n\n" 248 249 "show port (port_id) macs|mcast_macs" 250 " Display list of mac addresses added to port.\n\n" 251 252 "show port (port_id) fec capabilities" 253 " Show fec capabilities of a port.\n\n" 254 255 "show port (port_id) fec_mode" 256 " Show fec mode of a port.\n\n" 257 258 "show port (port_id) flow_ctrl" 259 " Show flow control info of a port.\n\n" 260 ); 261 } 262 263 if (show_all || !strcmp(res->section, "config")) { 264 cmdline_printf( 265 cl, 266 "\n" 267 "Configuration:\n" 268 "--------------\n" 269 "Configuration changes only become active when" 270 " forwarding is started/restarted.\n\n" 271 272 "set default\n" 273 " Reset forwarding to the default configuration.\n\n" 274 275 "set verbose (level)\n" 276 " Set the debug verbosity level X.\n\n" 277 278 "set log global|(type) (level)\n" 279 " Set the log level.\n\n" 280 281 "set nbport (num)\n" 282 " Set number of ports.\n\n" 283 284 "set nbcore (num)\n" 285 " Set number of cores.\n\n" 286 287 "set coremask (mask)\n" 288 " Set the forwarding cores hexadecimal mask.\n\n" 289 290 "set portmask (mask)\n" 291 " Set the forwarding ports hexadecimal mask.\n\n" 292 293 "set burst (num)\n" 294 " Set number of packets per burst.\n\n" 295 296 "set burst tx delay (microseconds) retry (num)\n" 297 " Set the transmit delay time and number of retries," 298 " effective when retry is enabled.\n\n" 299 300 "set rxoffs (x[,y]*)\n" 301 " Set the offset of each packet segment on" 302 " receiving if split feature is engaged." 303 " Affects only the queues configured with split" 304 " offloads.\n\n" 305 306 "set rxpkts (x[,y]*)\n" 307 " Set the length of each segment to scatter" 308 " packets on receiving if split feature is engaged." 309 " Affects only the queues configured with split" 310 " offloads.\n\n" 311 312 "set txpkts (x[,y]*)\n" 313 " Set the length of each segment of TXONLY" 314 " and optionally CSUM packets.\n\n" 315 316 "set txsplit (off|on|rand)\n" 317 " Set the split policy for the TX packets." 318 " Right now only applicable for CSUM and TXONLY" 319 " modes\n\n" 320 321 "set txtimes (x, y)\n" 322 " Set the scheduling on timestamps" 323 " timings for the TXONLY mode\n\n" 324 325 "set corelist (x[,y]*)\n" 326 " Set the list of forwarding cores.\n\n" 327 328 "set portlist (x[,y]*)\n" 329 " Set the list of forwarding ports.\n\n" 330 331 "set port setup on (iterator|event)\n" 332 " Select how attached port is retrieved for setup.\n\n" 333 334 "set tx loopback (port_id) (on|off)\n" 335 " Enable or disable tx loopback.\n\n" 336 337 "set all queues drop (port_id) (on|off)\n" 338 " Set drop enable bit for all queues.\n\n" 339 340 "set vf split drop (port_id) (vf_id) (on|off)\n" 341 " Set split drop enable bit for a VF from the PF.\n\n" 342 343 "set vf mac antispoof (port_id) (vf_id) (on|off).\n" 344 " Set MAC antispoof for a VF from the PF.\n\n" 345 346 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" 347 " Enable MACsec offload.\n\n" 348 349 "set macsec offload (port_id) off\n" 350 " Disable MACsec offload.\n\n" 351 352 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" 353 " Configure MACsec secure connection (SC).\n\n" 354 355 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" 356 " Configure MACsec secure association (SA).\n\n" 357 358 "set vf broadcast (port_id) (vf_id) (on|off)\n" 359 " Set VF broadcast for a VF from the PF.\n\n" 360 361 "vlan set stripq (on|off) (port_id,queue_id)\n" 362 " Set the VLAN strip for a queue on a port.\n\n" 363 364 "set vf vlan stripq (port_id) (vf_id) (on|off)\n" 365 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" 366 367 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" 368 " Set VLAN insert for a VF from the PF.\n\n" 369 370 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" 371 " Set VLAN antispoof for a VF from the PF.\n\n" 372 373 "set vf vlan tag (port_id) (vf_id) (on|off)\n" 374 " Set VLAN tag for a VF from the PF.\n\n" 375 376 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n" 377 " Set a VF's max bandwidth(Mbps).\n\n" 378 379 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n" 380 " Set all TCs' min bandwidth(%%) on a VF.\n\n" 381 382 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n" 383 " Set a TC's max bandwidth(Mbps) on a VF.\n\n" 384 385 "set tx strict-link-priority (port_id) (tc_bitmap)\n" 386 " Set some TCs' strict link priority mode on a physical port.\n\n" 387 388 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" 389 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n" 390 391 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n" 392 " Set the VLAN strip or filter or qinq strip or extend\n\n" 393 394 "vlan set (inner|outer) tpid (value) (port_id)\n" 395 " Set the VLAN TPID for Packet Filtering on" 396 " a port\n\n" 397 398 "rx_vlan add (vlan_id|all) (port_id)\n" 399 " Add a vlan_id, or all identifiers, to the set" 400 " of VLAN identifiers filtered by port_id.\n\n" 401 402 "rx_vlan rm (vlan_id|all) (port_id)\n" 403 " Remove a vlan_id, or all identifiers, from the set" 404 " of VLAN identifiers filtered by port_id.\n\n" 405 406 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n" 407 " Add a vlan_id, to the set of VLAN identifiers" 408 "filtered for VF(s) from port_id.\n\n" 409 410 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n" 411 " Remove a vlan_id, to the set of VLAN identifiers" 412 "filtered for VF(s) from port_id.\n\n" 413 414 "rx_vxlan_port add (udp_port) (port_id)\n" 415 " Add an UDP port for VXLAN packet filter on a port\n\n" 416 417 "rx_vxlan_port rm (udp_port) (port_id)\n" 418 " Remove an UDP port for VXLAN packet filter on a port\n\n" 419 420 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" 421 " Set hardware insertion of VLAN IDs (single or double VLAN " 422 "depends on the number of VLAN IDs) in packets sent on a port.\n\n" 423 424 "tx_vlan set pvid port_id vlan_id (on|off)\n" 425 " Set port based TX VLAN insertion.\n\n" 426 427 "tx_vlan reset (port_id)\n" 428 " Disable hardware insertion of a VLAN header in" 429 " packets sent on a port.\n\n" 430 431 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n" 432 " Select hardware or software calculation of the" 433 " checksum when transmitting a packet using the" 434 " csum forward engine.\n" 435 " ip|udp|tcp|sctp always concern the inner layer.\n" 436 " outer-ip concerns the outer IP layer in" 437 " outer-udp concerns the outer UDP layer in" 438 " case the packet is recognized as a tunnel packet by" 439 " the forward engine (vxlan, gre and ipip are supported)\n" 440 " Please check the NIC datasheet for HW limits.\n\n" 441 442 "csum parse-tunnel (on|off) (tx_port_id)\n" 443 " If disabled, treat tunnel packets as non-tunneled" 444 " packets (treat inner headers as payload). The port\n" 445 " argument is the port used for TX in csum forward" 446 " engine.\n\n" 447 448 "csum show (port_id)\n" 449 " Display tx checksum offload configuration\n\n" 450 451 "tso set (segsize) (portid)\n" 452 " Enable TCP Segmentation Offload in csum forward" 453 " engine.\n" 454 " Please check the NIC datasheet for HW limits.\n\n" 455 456 "tso show (portid)" 457 " Display the status of TCP Segmentation Offload.\n\n" 458 459 "set port (port_id) gro on|off\n" 460 " Enable or disable Generic Receive Offload in" 461 " csum forwarding engine.\n\n" 462 463 "show port (port_id) gro\n" 464 " Display GRO configuration.\n\n" 465 466 "set gro flush (cycles)\n" 467 " Set the cycle to flush GROed packets from" 468 " reassembly tables.\n\n" 469 470 "set port (port_id) gso (on|off)" 471 " Enable or disable Generic Segmentation Offload in" 472 " csum forwarding engine.\n\n" 473 474 "set gso segsz (length)\n" 475 " Set max packet length for output GSO segments," 476 " including packet header and payload.\n\n" 477 478 "show port (port_id) gso\n" 479 " Show GSO configuration.\n\n" 480 481 "set fwd (%s)\n" 482 " Set packet forwarding mode.\n\n" 483 484 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" 485 " Add a MAC address on port_id.\n\n" 486 487 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n" 488 " Remove a MAC address from port_id.\n\n" 489 490 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n" 491 " Set the default MAC address for port_id.\n\n" 492 493 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n" 494 " Add a MAC address for a VF on the port.\n\n" 495 496 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n" 497 " Set the MAC address for a VF from the PF.\n\n" 498 499 "set eth-peer (port_id) (peer_addr)\n" 500 " set the peer address for certain port.\n\n" 501 502 "set port (port_id) uta (mac_address|all) (on|off)\n" 503 " Add/Remove a or all unicast hash filter(s)" 504 "from port X.\n\n" 505 506 "set promisc (port_id|all) (on|off)\n" 507 " Set the promiscuous mode on port_id, or all.\n\n" 508 509 "set allmulti (port_id|all) (on|off)\n" 510 " Set the allmulti mode on port_id, or all.\n\n" 511 512 "set vf promisc (port_id) (vf_id) (on|off)\n" 513 " Set unicast promiscuous mode for a VF from the PF.\n\n" 514 515 "set vf allmulti (port_id) (vf_id) (on|off)\n" 516 " Set multicast promiscuous mode for a VF from the PF.\n\n" 517 518 "set flow_ctrl rx (on|off) tx (on|off) (high_water)" 519 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" 520 " (on|off) autoneg (on|off) (port_id)\n" 521 "set flow_ctrl rx (on|off) (portid)\n" 522 "set flow_ctrl tx (on|off) (portid)\n" 523 "set flow_ctrl high_water (high_water) (portid)\n" 524 "set flow_ctrl low_water (low_water) (portid)\n" 525 "set flow_ctrl pause_time (pause_time) (portid)\n" 526 "set flow_ctrl send_xon (send_xon) (portid)\n" 527 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n" 528 "set flow_ctrl autoneg (on|off) (port_id)\n" 529 " Set the link flow control parameter on a port.\n\n" 530 531 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)" 532 " (low_water) (pause_time) (priority) (port_id)\n" 533 " Set the priority flow control parameter on a" 534 " port.\n\n" 535 536 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n" 537 " Set statistics mapping (qmapping 0..15) for RX/TX" 538 " queue on port.\n" 539 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2" 540 " on port 0 to mapping 5.\n\n" 541 542 "set xstats-hide-zero on|off\n" 543 " Set the option to hide the zero values" 544 " for xstats display.\n" 545 546 "set record-core-cycles on|off\n" 547 " Set the option to enable measurement of CPU cycles.\n" 548 549 "set record-burst-stats on|off\n" 550 " Set the option to enable display of RX and TX bursts.\n" 551 552 "set port (port_id) vf (vf_id) rx|tx on|off\n" 553 " Enable/Disable a VF receive/tranmit from a port\n\n" 554 555 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" 556 "|MPE) (on|off)\n" 557 " AUPE:accepts untagged VLAN;" 558 "ROPE:accept unicast hash\n\n" 559 " BAM:accepts broadcast packets;" 560 "MPE:accepts all multicast packets\n\n" 561 " Enable/Disable a VF receive mode of a port\n\n" 562 563 "set port (port_id) queue (queue_id) rate (rate_num)\n" 564 " Set rate limit for a queue of a port\n\n" 565 566 "set port (port_id) vf (vf_id) rate (rate_num) " 567 "queue_mask (queue_mask_value)\n" 568 " Set rate limit for queues in VF of a port\n\n" 569 570 "set flush_rx (on|off)\n" 571 " Flush (default) or don't flush RX streams before" 572 " forwarding. Mainly used with PCAP drivers.\n\n" 573 574 "set bypass mode (normal|bypass|isolate) (port_id)\n" 575 " Set the bypass mode for the lowest port on bypass enabled" 576 " NIC.\n\n" 577 578 "set bypass event (timeout|os_on|os_off|power_on|power_off) " 579 "mode (normal|bypass|isolate) (port_id)\n" 580 " Set the event required to initiate specified bypass mode for" 581 " the lowest port on a bypass enabled NIC where:\n" 582 " timeout = enable bypass after watchdog timeout.\n" 583 " os_on = enable bypass when OS/board is powered on.\n" 584 " os_off = enable bypass when OS/board is powered off.\n" 585 " power_on = enable bypass when power supply is turned on.\n" 586 " power_off = enable bypass when power supply is turned off." 587 "\n\n" 588 589 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" 590 " Set the bypass watchdog timeout to 'n' seconds" 591 " where 0 = instant.\n\n" 592 593 "show bypass config (port_id)\n" 594 " Show the bypass configuration for a bypass enabled NIC" 595 " using the lowest port on the NIC.\n\n" 596 597 #ifdef RTE_NET_BOND 598 "create bonded device (mode) (socket)\n" 599 " Create a new bonded device with specific bonding mode and socket.\n\n" 600 601 "add bonding slave (slave_id) (port_id)\n" 602 " Add a slave device to a bonded device.\n\n" 603 604 "remove bonding slave (slave_id) (port_id)\n" 605 " Remove a slave device from a bonded device.\n\n" 606 607 "set bonding mode (value) (port_id)\n" 608 " Set the bonding mode on a bonded device.\n\n" 609 610 "set bonding primary (slave_id) (port_id)\n" 611 " Set the primary slave for a bonded device.\n\n" 612 613 "show bonding config (port_id)\n" 614 " Show the bonding config for port_id.\n\n" 615 616 "set bonding mac_addr (port_id) (address)\n" 617 " Set the MAC address of a bonded device.\n\n" 618 619 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)" 620 " Set Aggregation mode for IEEE802.3AD (mode 4)" 621 622 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n" 623 " Set the transmit balance policy for bonded device running in balance mode.\n\n" 624 625 "set bonding mon_period (port_id) (value)\n" 626 " Set the bonding link status monitoring polling period in ms.\n\n" 627 628 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n" 629 " Enable/disable dedicated queues for LACP control traffic.\n\n" 630 631 #endif 632 "set link-up port (port_id)\n" 633 " Set link up for a port.\n\n" 634 635 "set link-down port (port_id)\n" 636 " Set link down for a port.\n\n" 637 638 "ddp add (port_id) (profile_path[,backup_profile_path])\n" 639 " Load a profile package on a port\n\n" 640 641 "ddp del (port_id) (backup_profile_path)\n" 642 " Delete a profile package from a port\n\n" 643 644 "ptype mapping get (port_id) (valid_only)\n" 645 " Get ptype mapping on a port\n\n" 646 647 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n" 648 " Replace target with the pkt_type in ptype mapping\n\n" 649 650 "ptype mapping reset (port_id)\n" 651 " Reset ptype mapping on a port\n\n" 652 653 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" 654 " Update a ptype mapping item on a port\n\n" 655 656 "set port (port_id) ptype_mask (ptype_mask)\n" 657 " set packet types classification for a specific port\n\n" 658 659 "set port (port_id) queue-region region_id (value) " 660 "queue_start_index (value) queue_num (value)\n" 661 " Set a queue region on a port\n\n" 662 663 "set port (port_id) queue-region region_id (value) " 664 "flowtype (value)\n" 665 " Set a flowtype region index on a port\n\n" 666 667 "set port (port_id) queue-region UP (value) region_id (value)\n" 668 " Set the mapping of User Priority to " 669 "queue region on a port\n\n" 670 671 "set port (port_id) queue-region flush (on|off)\n" 672 " flush all queue region related configuration\n\n" 673 674 "show port meter cap (port_id)\n" 675 " Show port meter capability information\n\n" 676 677 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n" 678 " meter profile add - srtcm rfc 2697\n\n" 679 680 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n" 681 " meter profile add - trtcm rfc 2698\n\n" 682 683 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n" 684 " meter profile add - trtcm rfc 4115\n\n" 685 686 "del port meter profile (port_id) (profile_id)\n" 687 " meter profile delete\n\n" 688 689 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n" 690 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 691 "(dscp_tbl_entry63)]\n" 692 " meter create\n\n" 693 694 "enable port meter (port_id) (mtr_id)\n" 695 " meter enable\n\n" 696 697 "disable port meter (port_id) (mtr_id)\n" 698 " meter disable\n\n" 699 700 "del port meter (port_id) (mtr_id)\n" 701 " meter delete\n\n" 702 703 "add port meter policy (port_id) (policy_id) g_actions (actions)\n" 704 "y_actions (actions) r_actions (actions)\n" 705 " meter policy add\n\n" 706 707 "del port meter policy (port_id) (policy_id)\n" 708 " meter policy delete\n\n" 709 710 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 711 " meter update meter profile\n\n" 712 713 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 714 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 715 " update meter dscp table entries\n\n" 716 717 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 718 "(action0) [(action1) (action2)]\n" 719 " meter update policer action\n\n" 720 721 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 722 " meter update stats\n\n" 723 724 "show port (port_id) queue-region\n" 725 " show all queue region related configuration info\n\n" 726 727 "set port (port_id) fec_mode auto|off|rs|baser\n" 728 " set fec mode for a specific port\n\n" 729 730 , list_pkt_forwarding_modes() 731 ); 732 } 733 734 if (show_all || !strcmp(res->section, "ports")) { 735 736 cmdline_printf( 737 cl, 738 "\n" 739 "Port Operations:\n" 740 "----------------\n\n" 741 742 "port start (port_id|all)\n" 743 " Start all ports or port_id.\n\n" 744 745 "port stop (port_id|all)\n" 746 " Stop all ports or port_id.\n\n" 747 748 "port close (port_id|all)\n" 749 " Close all ports or port_id.\n\n" 750 751 "port reset (port_id|all)\n" 752 " Reset all ports or port_id.\n\n" 753 754 "port attach (ident)\n" 755 " Attach physical or virtual dev by pci address or virtual device name\n\n" 756 757 "port detach (port_id)\n" 758 " Detach physical or virtual dev by port_id\n\n" 759 760 "port config (port_id|all)" 761 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)" 762 " duplex (half|full|auto)\n" 763 " Set speed and duplex for all ports or port_id\n\n" 764 765 "port config (port_id|all) loopback (mode)\n" 766 " Set loopback mode for all ports or port_id\n\n" 767 768 "port config all (rxq|txq|rxd|txd) (value)\n" 769 " Set number for rxq/txq/rxd/txd.\n\n" 770 771 "port config all max-pkt-len (value)\n" 772 " Set the max packet length.\n\n" 773 774 "port config all max-lro-pkt-size (value)\n" 775 " Set the max LRO aggregated packet size.\n\n" 776 777 "port config all drop-en (on|off)\n" 778 " Enable or disable packet drop on all RX queues of all ports when no " 779 "receive buffers available.\n\n" 780 781 "port config all rss (all|default|ip|tcp|udp|sctp|" 782 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|" 783 "level-outer|level-inner|<flowtype_id>)\n" 784 " Set the RSS mode.\n\n" 785 786 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 787 " Set the RSS redirection table.\n\n" 788 789 "port config (port_id) dcb vt (on|off) (traffic_class)" 790 " pfc (on|off)\n" 791 " Set the DCB mode.\n\n" 792 793 "port config all burst (value)\n" 794 " Set the number of packets per burst.\n\n" 795 796 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 797 " (value)\n" 798 " Set the ring prefetch/host/writeback threshold" 799 " for tx/rx queue.\n\n" 800 801 "port config all (txfreet|txrst|rxfreet) (value)\n" 802 " Set free threshold for rx/tx, or set" 803 " tx rs bit threshold.\n\n" 804 "port config mtu X value\n" 805 " Set the MTU of port X to a given value\n\n" 806 807 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n" 808 " Set a rx/tx queue's ring size configuration, the new" 809 " value will take effect after command that (re-)start the port" 810 " or command that setup the specific queue\n\n" 811 812 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 813 " Start/stop a rx/tx queue of port X. Only take effect" 814 " when port X is started\n\n" 815 816 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n" 817 " Switch on/off a deferred start of port X rx/tx queue. Only" 818 " take effect when port X is stopped.\n\n" 819 820 "port (port_id) (rxq|txq) (queue_id) setup\n" 821 " Setup a rx/tx queue of port X.\n\n" 822 823 "port config (port_id) pctype mapping reset\n" 824 " Reset flow type to pctype mapping on a port\n\n" 825 826 "port config (port_id) pctype mapping update" 827 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 828 " Update a flow type to pctype mapping item on a port\n\n" 829 830 "port config (port_id) pctype (pctype_id) hash_inset|" 831 "fdir_inset|fdir_flx_inset get|set|clear field\n" 832 " (field_idx)\n" 833 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n" 834 835 "port config (port_id) pctype (pctype_id) hash_inset|" 836 "fdir_inset|fdir_flx_inset clear all" 837 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n" 838 839 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n" 840 " Add/remove UDP tunnel port for tunneling offload\n\n" 841 842 "port config <port_id> rx_offload vlan_strip|" 843 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 844 "outer_ipv4_cksum|macsec_strip|header_split|" 845 "vlan_filter|vlan_extend|jumbo_frame|scatter|" 846 "buffer_split|timestamp|security|keep_crc on|off\n" 847 " Enable or disable a per port Rx offloading" 848 " on all Rx queues of a port\n\n" 849 850 "port (port_id) rxq (queue_id) rx_offload vlan_strip|" 851 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 852 "outer_ipv4_cksum|macsec_strip|header_split|" 853 "vlan_filter|vlan_extend|jumbo_frame|scatter|" 854 "buffer_split|timestamp|security|keep_crc on|off\n" 855 " Enable or disable a per queue Rx offloading" 856 " only on a specific Rx queue\n\n" 857 858 "port config (port_id) tx_offload vlan_insert|" 859 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 860 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 861 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|" 862 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|" 863 "security on|off\n" 864 " Enable or disable a per port Tx offloading" 865 " on all Tx queues of a port\n\n" 866 867 "port (port_id) txq (queue_id) tx_offload vlan_insert|" 868 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 869 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 870 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert" 871 "|mt_lockfree|multi_segs|mbuf_fast_free|security" 872 " on|off\n" 873 " Enable or disable a per queue Tx offloading" 874 " only on a specific Tx queue\n\n" 875 876 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n" 877 " Load an eBPF program as a callback" 878 " for particular RX/TX queue\n\n" 879 880 "bpf-unload rx|tx (port) (queue)\n" 881 " Unload previously loaded eBPF program" 882 " for particular RX/TX queue\n\n" 883 884 "port config (port_id) tx_metadata (value)\n" 885 " Set Tx metadata value per port. Testpmd will add this value" 886 " to any Tx packet sent from this port\n\n" 887 888 "port config (port_id) dynf (name) set|clear\n" 889 " Register a dynf and Set/clear this flag on Tx. " 890 "Testpmd will set this value to any Tx packet " 891 "sent from this port\n\n" 892 893 "port cleanup (port_id) txq (queue_id) (free_cnt)\n" 894 " Cleanup txq mbufs for a specific Tx queue\n\n" 895 ); 896 } 897 898 if (show_all || !strcmp(res->section, "registers")) { 899 900 cmdline_printf( 901 cl, 902 "\n" 903 "Registers:\n" 904 "----------\n\n" 905 906 "read reg (port_id) (address)\n" 907 " Display value of a port register.\n\n" 908 909 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 910 " Display a port register bit field.\n\n" 911 912 "read regbit (port_id) (address) (bit_x)\n" 913 " Display a single port register bit.\n\n" 914 915 "write reg (port_id) (address) (value)\n" 916 " Set value of a port register.\n\n" 917 918 "write regfield (port_id) (address) (bit_x) (bit_y)" 919 " (value)\n" 920 " Set bit field of a port register.\n\n" 921 922 "write regbit (port_id) (address) (bit_x) (value)\n" 923 " Set single bit value of a port register.\n\n" 924 ); 925 } 926 if (show_all || !strcmp(res->section, "filters")) { 927 928 cmdline_printf( 929 cl, 930 "\n" 931 "filters:\n" 932 "--------\n\n" 933 934 #ifdef RTE_NET_I40E 935 "flow_director_filter (port_id) mode raw (add|del|update)" 936 " flow (flow_id) (drop|fwd) queue (queue_id)" 937 " fd_id (fd_id_value) packet (packet file name)\n" 938 " Add/Del a raw type flow director filter.\n\n" 939 #endif 940 941 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 942 " src_mask (ipv4_src) (ipv6_src) (src_port)" 943 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 944 " Set flow director IP mask.\n\n" 945 946 "flow_director_mask (port_id) mode MAC-VLAN" 947 " vlan (vlan_value)\n" 948 " Set flow director MAC-VLAN mask.\n\n" 949 950 "flow_director_mask (port_id) mode Tunnel" 951 " vlan (vlan_value) mac (mac_value)" 952 " tunnel-type (tunnel_type_value)" 953 " tunnel-id (tunnel_id_value)\n" 954 " Set flow director Tunnel mask.\n\n" 955 956 "flow_director_flex_payload (port_id)" 957 " (raw|l2|l3|l4) (config)\n" 958 " Configure flex payload selection.\n\n" 959 960 "flow validate {port_id}" 961 " [group {group_id}] [priority {level}]" 962 " [ingress] [egress]" 963 " pattern {item} [/ {item} [...]] / end" 964 " actions {action} [/ {action} [...]] / end\n" 965 " Check whether a flow rule can be created.\n\n" 966 967 "flow create {port_id}" 968 " [group {group_id}] [priority {level}]" 969 " [ingress] [egress]" 970 " pattern {item} [/ {item} [...]] / end" 971 " actions {action} [/ {action} [...]] / end\n" 972 " Create a flow rule.\n\n" 973 974 "flow destroy {port_id} rule {rule_id} [...]\n" 975 " Destroy specific flow rules.\n\n" 976 977 "flow flush {port_id}\n" 978 " Destroy all flow rules.\n\n" 979 980 "flow query {port_id} {rule_id} {action}\n" 981 " Query an existing flow rule.\n\n" 982 983 "flow list {port_id} [group {group_id}] [...]\n" 984 " List existing flow rules sorted by priority," 985 " filtered by group identifiers.\n\n" 986 987 "flow isolate {port_id} {boolean}\n" 988 " Restrict ingress traffic to the defined" 989 " flow rules\n\n" 990 991 "flow aged {port_id} [destroy]\n" 992 " List and destroy aged flows" 993 " flow rules\n\n" 994 995 "flow indirect_action {port_id} create" 996 " [action_id {indirect_action_id}]" 997 " [ingress] [egress]" 998 " action {action} / end\n" 999 " Create indirect action.\n\n" 1000 1001 "flow indirect_action {port_id} update" 1002 " {indirect_action_id} action {action} / end\n" 1003 " Update indirect action.\n\n" 1004 1005 "flow indirect_action {port_id} destroy" 1006 " action_id {indirect_action_id} [...]\n" 1007 " Destroy specific indirect actions.\n\n" 1008 1009 "flow indirect_action {port_id} query" 1010 " {indirect_action_id}\n" 1011 " Query an existing indirect action.\n\n" 1012 1013 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" 1014 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" 1015 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n" 1016 " Configure the VXLAN encapsulation for flows.\n\n" 1017 1018 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)" 1019 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)" 1020 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)" 1021 " eth-dst (eth-dst)\n" 1022 " Configure the VXLAN encapsulation for flows.\n\n" 1023 1024 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src" 1025 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)" 1026 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)" 1027 " eth-dst (eth-dst)\n" 1028 " Configure the VXLAN encapsulation for flows.\n\n" 1029 1030 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src" 1031 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst" 1032 " (eth-dst)\n" 1033 " Configure the NVGRE encapsulation for flows.\n\n" 1034 1035 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)" 1036 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)" 1037 " eth-src (eth-src) eth-dst (eth-dst)\n" 1038 " Configure the NVGRE encapsulation for flows.\n\n" 1039 1040 "set raw_encap {flow items}\n" 1041 " Configure the encapsulation with raw data.\n\n" 1042 1043 "set raw_decap {flow items}\n" 1044 " Configure the decapsulation with raw data.\n\n" 1045 1046 ); 1047 } 1048 1049 if (show_all || !strcmp(res->section, "traffic_management")) { 1050 cmdline_printf( 1051 cl, 1052 "\n" 1053 "Traffic Management:\n" 1054 "--------------\n" 1055 "show port tm cap (port_id)\n" 1056 " Display the port TM capability.\n\n" 1057 1058 "show port tm level cap (port_id) (level_id)\n" 1059 " Display the port TM hierarchical level capability.\n\n" 1060 1061 "show port tm node cap (port_id) (node_id)\n" 1062 " Display the port TM node capability.\n\n" 1063 1064 "show port tm node type (port_id) (node_id)\n" 1065 " Display the port TM node type.\n\n" 1066 1067 "show port tm node stats (port_id) (node_id) (clear)\n" 1068 " Display the port TM node stats.\n\n" 1069 1070 "add port tm node shaper profile (port_id) (shaper_profile_id)" 1071 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)" 1072 " (packet_length_adjust) (packet_mode)\n" 1073 " Add port tm node private shaper profile.\n\n" 1074 1075 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 1076 " Delete port tm node private shaper profile.\n\n" 1077 1078 "add port tm node shared shaper (port_id) (shared_shaper_id)" 1079 " (shaper_profile_id)\n" 1080 " Add/update port tm node shared shaper.\n\n" 1081 1082 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 1083 " Delete port tm node shared shaper.\n\n" 1084 1085 "set port tm node shaper profile (port_id) (node_id)" 1086 " (shaper_profile_id)\n" 1087 " Set port tm node shaper profile.\n\n" 1088 1089 "add port tm node wred profile (port_id) (wred_profile_id)" 1090 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 1091 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 1092 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 1093 " Add port tm node wred profile.\n\n" 1094 1095 "del port tm node wred profile (port_id) (wred_profile_id)\n" 1096 " Delete port tm node wred profile.\n\n" 1097 1098 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 1099 " (priority) (weight) (level_id) (shaper_profile_id)" 1100 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1101 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1102 " Add port tm nonleaf node.\n\n" 1103 1104 "add port tm nonleaf node pktmode (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 with pkt mode enabled.\n\n" 1109 1110 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 1111 " (priority) (weight) (level_id) (shaper_profile_id)" 1112 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 1113 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1114 " Add port tm leaf node.\n\n" 1115 1116 "del port tm node (port_id) (node_id)\n" 1117 " Delete port tm node.\n\n" 1118 1119 "set port tm node parent (port_id) (node_id) (parent_node_id)" 1120 " (priority) (weight)\n" 1121 " Set port tm node parent.\n\n" 1122 1123 "suspend port tm node (port_id) (node_id)" 1124 " Suspend tm node.\n\n" 1125 1126 "resume port tm node (port_id) (node_id)" 1127 " Resume tm node.\n\n" 1128 1129 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 1130 " Commit tm hierarchy.\n\n" 1131 1132 "set port tm mark ip_ecn (port) (green) (yellow)" 1133 " (red)\n" 1134 " Enables/Disables the traffic management marking" 1135 " for IP ECN (Explicit Congestion Notification)" 1136 " packets on a given port\n\n" 1137 1138 "set port tm mark ip_dscp (port) (green) (yellow)" 1139 " (red)\n" 1140 " Enables/Disables the traffic management marking" 1141 " on the port for IP dscp packets\n\n" 1142 1143 "set port tm mark vlan_dei (port) (green) (yellow)" 1144 " (red)\n" 1145 " Enables/Disables the traffic management marking" 1146 " on the port for VLAN packets with DEI enabled\n\n" 1147 ); 1148 } 1149 1150 if (show_all || !strcmp(res->section, "devices")) { 1151 cmdline_printf( 1152 cl, 1153 "\n" 1154 "Device Operations:\n" 1155 "--------------\n" 1156 "device detach (identifier)\n" 1157 " Detach device by identifier.\n\n" 1158 ); 1159 } 1160 1161 } 1162 1163 cmdline_parse_token_string_t cmd_help_long_help = 1164 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1165 1166 cmdline_parse_token_string_t cmd_help_long_section = 1167 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1168 "all#control#display#config#" 1169 "ports#registers#filters#traffic_management#devices"); 1170 1171 cmdline_parse_inst_t cmd_help_long = { 1172 .f = cmd_help_long_parsed, 1173 .data = NULL, 1174 .help_str = "help all|control|display|config|ports|register|" 1175 "filters|traffic_management|devices: " 1176 "Show help", 1177 .tokens = { 1178 (void *)&cmd_help_long_help, 1179 (void *)&cmd_help_long_section, 1180 NULL, 1181 }, 1182 }; 1183 1184 1185 /* *** start/stop/close all ports *** */ 1186 struct cmd_operate_port_result { 1187 cmdline_fixed_string_t keyword; 1188 cmdline_fixed_string_t name; 1189 cmdline_fixed_string_t value; 1190 }; 1191 1192 static void cmd_operate_port_parsed(void *parsed_result, 1193 __rte_unused struct cmdline *cl, 1194 __rte_unused void *data) 1195 { 1196 struct cmd_operate_port_result *res = parsed_result; 1197 1198 if (!strcmp(res->name, "start")) 1199 start_port(RTE_PORT_ALL); 1200 else if (!strcmp(res->name, "stop")) 1201 stop_port(RTE_PORT_ALL); 1202 else if (!strcmp(res->name, "close")) 1203 close_port(RTE_PORT_ALL); 1204 else if (!strcmp(res->name, "reset")) 1205 reset_port(RTE_PORT_ALL); 1206 else 1207 fprintf(stderr, "Unknown parameter\n"); 1208 } 1209 1210 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1211 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1212 "port"); 1213 cmdline_parse_token_string_t cmd_operate_port_all_port = 1214 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1215 "start#stop#close#reset"); 1216 cmdline_parse_token_string_t cmd_operate_port_all_all = 1217 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1218 1219 cmdline_parse_inst_t cmd_operate_port = { 1220 .f = cmd_operate_port_parsed, 1221 .data = NULL, 1222 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports", 1223 .tokens = { 1224 (void *)&cmd_operate_port_all_cmd, 1225 (void *)&cmd_operate_port_all_port, 1226 (void *)&cmd_operate_port_all_all, 1227 NULL, 1228 }, 1229 }; 1230 1231 /* *** start/stop/close specific port *** */ 1232 struct cmd_operate_specific_port_result { 1233 cmdline_fixed_string_t keyword; 1234 cmdline_fixed_string_t name; 1235 uint8_t value; 1236 }; 1237 1238 static void cmd_operate_specific_port_parsed(void *parsed_result, 1239 __rte_unused struct cmdline *cl, 1240 __rte_unused void *data) 1241 { 1242 struct cmd_operate_specific_port_result *res = parsed_result; 1243 1244 if (!strcmp(res->name, "start")) 1245 start_port(res->value); 1246 else if (!strcmp(res->name, "stop")) 1247 stop_port(res->value); 1248 else if (!strcmp(res->name, "close")) 1249 close_port(res->value); 1250 else if (!strcmp(res->name, "reset")) 1251 reset_port(res->value); 1252 else 1253 fprintf(stderr, "Unknown parameter\n"); 1254 } 1255 1256 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1257 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1258 keyword, "port"); 1259 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1260 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1261 name, "start#stop#close#reset"); 1262 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1263 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1264 value, RTE_UINT8); 1265 1266 cmdline_parse_inst_t cmd_operate_specific_port = { 1267 .f = cmd_operate_specific_port_parsed, 1268 .data = NULL, 1269 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id", 1270 .tokens = { 1271 (void *)&cmd_operate_specific_port_cmd, 1272 (void *)&cmd_operate_specific_port_port, 1273 (void *)&cmd_operate_specific_port_id, 1274 NULL, 1275 }, 1276 }; 1277 1278 /* *** enable port setup (after attach) via iterator or event *** */ 1279 struct cmd_set_port_setup_on_result { 1280 cmdline_fixed_string_t set; 1281 cmdline_fixed_string_t port; 1282 cmdline_fixed_string_t setup; 1283 cmdline_fixed_string_t on; 1284 cmdline_fixed_string_t mode; 1285 }; 1286 1287 static void cmd_set_port_setup_on_parsed(void *parsed_result, 1288 __rte_unused struct cmdline *cl, 1289 __rte_unused void *data) 1290 { 1291 struct cmd_set_port_setup_on_result *res = parsed_result; 1292 1293 if (strcmp(res->mode, "event") == 0) 1294 setup_on_probe_event = true; 1295 else if (strcmp(res->mode, "iterator") == 0) 1296 setup_on_probe_event = false; 1297 else 1298 fprintf(stderr, "Unknown mode\n"); 1299 } 1300 1301 cmdline_parse_token_string_t cmd_set_port_setup_on_set = 1302 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1303 set, "set"); 1304 cmdline_parse_token_string_t cmd_set_port_setup_on_port = 1305 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1306 port, "port"); 1307 cmdline_parse_token_string_t cmd_set_port_setup_on_setup = 1308 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1309 setup, "setup"); 1310 cmdline_parse_token_string_t cmd_set_port_setup_on_on = 1311 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1312 on, "on"); 1313 cmdline_parse_token_string_t cmd_set_port_setup_on_mode = 1314 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1315 mode, "iterator#event"); 1316 1317 cmdline_parse_inst_t cmd_set_port_setup_on = { 1318 .f = cmd_set_port_setup_on_parsed, 1319 .data = NULL, 1320 .help_str = "set port setup on iterator|event", 1321 .tokens = { 1322 (void *)&cmd_set_port_setup_on_set, 1323 (void *)&cmd_set_port_setup_on_port, 1324 (void *)&cmd_set_port_setup_on_setup, 1325 (void *)&cmd_set_port_setup_on_on, 1326 (void *)&cmd_set_port_setup_on_mode, 1327 NULL, 1328 }, 1329 }; 1330 1331 /* *** attach a specified port *** */ 1332 struct cmd_operate_attach_port_result { 1333 cmdline_fixed_string_t port; 1334 cmdline_fixed_string_t keyword; 1335 cmdline_multi_string_t identifier; 1336 }; 1337 1338 static void cmd_operate_attach_port_parsed(void *parsed_result, 1339 __rte_unused struct cmdline *cl, 1340 __rte_unused void *data) 1341 { 1342 struct cmd_operate_attach_port_result *res = parsed_result; 1343 1344 if (!strcmp(res->keyword, "attach")) 1345 attach_port(res->identifier); 1346 else 1347 fprintf(stderr, "Unknown parameter\n"); 1348 } 1349 1350 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1351 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1352 port, "port"); 1353 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1354 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1355 keyword, "attach"); 1356 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1357 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1358 identifier, TOKEN_STRING_MULTI); 1359 1360 cmdline_parse_inst_t cmd_operate_attach_port = { 1361 .f = cmd_operate_attach_port_parsed, 1362 .data = NULL, 1363 .help_str = "port attach <identifier>: " 1364 "(identifier: pci address or virtual dev name)", 1365 .tokens = { 1366 (void *)&cmd_operate_attach_port_port, 1367 (void *)&cmd_operate_attach_port_keyword, 1368 (void *)&cmd_operate_attach_port_identifier, 1369 NULL, 1370 }, 1371 }; 1372 1373 /* *** detach a specified port *** */ 1374 struct cmd_operate_detach_port_result { 1375 cmdline_fixed_string_t port; 1376 cmdline_fixed_string_t keyword; 1377 portid_t port_id; 1378 }; 1379 1380 static void cmd_operate_detach_port_parsed(void *parsed_result, 1381 __rte_unused struct cmdline *cl, 1382 __rte_unused void *data) 1383 { 1384 struct cmd_operate_detach_port_result *res = parsed_result; 1385 1386 if (!strcmp(res->keyword, "detach")) { 1387 RTE_ETH_VALID_PORTID_OR_RET(res->port_id); 1388 detach_port_device(res->port_id); 1389 } else { 1390 fprintf(stderr, "Unknown parameter\n"); 1391 } 1392 } 1393 1394 cmdline_parse_token_string_t cmd_operate_detach_port_port = 1395 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1396 port, "port"); 1397 cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1398 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1399 keyword, "detach"); 1400 cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1401 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1402 port_id, RTE_UINT16); 1403 1404 cmdline_parse_inst_t cmd_operate_detach_port = { 1405 .f = cmd_operate_detach_port_parsed, 1406 .data = NULL, 1407 .help_str = "port detach <port_id>", 1408 .tokens = { 1409 (void *)&cmd_operate_detach_port_port, 1410 (void *)&cmd_operate_detach_port_keyword, 1411 (void *)&cmd_operate_detach_port_port_id, 1412 NULL, 1413 }, 1414 }; 1415 1416 /* *** detach device by identifier *** */ 1417 struct cmd_operate_detach_device_result { 1418 cmdline_fixed_string_t device; 1419 cmdline_fixed_string_t keyword; 1420 cmdline_fixed_string_t identifier; 1421 }; 1422 1423 static void cmd_operate_detach_device_parsed(void *parsed_result, 1424 __rte_unused struct cmdline *cl, 1425 __rte_unused void *data) 1426 { 1427 struct cmd_operate_detach_device_result *res = parsed_result; 1428 1429 if (!strcmp(res->keyword, "detach")) 1430 detach_devargs(res->identifier); 1431 else 1432 fprintf(stderr, "Unknown parameter\n"); 1433 } 1434 1435 cmdline_parse_token_string_t cmd_operate_detach_device_device = 1436 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1437 device, "device"); 1438 cmdline_parse_token_string_t cmd_operate_detach_device_keyword = 1439 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1440 keyword, "detach"); 1441 cmdline_parse_token_string_t cmd_operate_detach_device_identifier = 1442 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1443 identifier, NULL); 1444 1445 cmdline_parse_inst_t cmd_operate_detach_device = { 1446 .f = cmd_operate_detach_device_parsed, 1447 .data = NULL, 1448 .help_str = "device detach <identifier>:" 1449 "(identifier: pci address or virtual dev name)", 1450 .tokens = { 1451 (void *)&cmd_operate_detach_device_device, 1452 (void *)&cmd_operate_detach_device_keyword, 1453 (void *)&cmd_operate_detach_device_identifier, 1454 NULL, 1455 }, 1456 }; 1457 /* *** configure speed for all ports *** */ 1458 struct cmd_config_speed_all { 1459 cmdline_fixed_string_t port; 1460 cmdline_fixed_string_t keyword; 1461 cmdline_fixed_string_t all; 1462 cmdline_fixed_string_t item1; 1463 cmdline_fixed_string_t item2; 1464 cmdline_fixed_string_t value1; 1465 cmdline_fixed_string_t value2; 1466 }; 1467 1468 static int 1469 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1470 { 1471 1472 int duplex; 1473 1474 if (!strcmp(duplexstr, "half")) { 1475 duplex = ETH_LINK_HALF_DUPLEX; 1476 } else if (!strcmp(duplexstr, "full")) { 1477 duplex = ETH_LINK_FULL_DUPLEX; 1478 } else if (!strcmp(duplexstr, "auto")) { 1479 duplex = ETH_LINK_FULL_DUPLEX; 1480 } else { 1481 fprintf(stderr, "Unknown duplex parameter\n"); 1482 return -1; 1483 } 1484 1485 if (!strcmp(speedstr, "10")) { 1486 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1487 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M; 1488 } else if (!strcmp(speedstr, "100")) { 1489 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1490 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M; 1491 } else { 1492 if (duplex != ETH_LINK_FULL_DUPLEX) { 1493 fprintf(stderr, "Invalid speed/duplex parameters\n"); 1494 return -1; 1495 } 1496 if (!strcmp(speedstr, "1000")) { 1497 *speed = ETH_LINK_SPEED_1G; 1498 } else if (!strcmp(speedstr, "10000")) { 1499 *speed = ETH_LINK_SPEED_10G; 1500 } else if (!strcmp(speedstr, "25000")) { 1501 *speed = ETH_LINK_SPEED_25G; 1502 } else if (!strcmp(speedstr, "40000")) { 1503 *speed = ETH_LINK_SPEED_40G; 1504 } else if (!strcmp(speedstr, "50000")) { 1505 *speed = ETH_LINK_SPEED_50G; 1506 } else if (!strcmp(speedstr, "100000")) { 1507 *speed = ETH_LINK_SPEED_100G; 1508 } else if (!strcmp(speedstr, "200000")) { 1509 *speed = ETH_LINK_SPEED_200G; 1510 } else if (!strcmp(speedstr, "auto")) { 1511 *speed = ETH_LINK_SPEED_AUTONEG; 1512 } else { 1513 fprintf(stderr, "Unknown speed parameter\n"); 1514 return -1; 1515 } 1516 } 1517 1518 if (*speed != ETH_LINK_SPEED_AUTONEG) 1519 *speed |= ETH_LINK_SPEED_FIXED; 1520 1521 return 0; 1522 } 1523 1524 static void 1525 cmd_config_speed_all_parsed(void *parsed_result, 1526 __rte_unused struct cmdline *cl, 1527 __rte_unused void *data) 1528 { 1529 struct cmd_config_speed_all *res = parsed_result; 1530 uint32_t link_speed; 1531 portid_t pid; 1532 1533 if (!all_ports_stopped()) { 1534 fprintf(stderr, "Please stop all ports first\n"); 1535 return; 1536 } 1537 1538 if (parse_and_check_speed_duplex(res->value1, res->value2, 1539 &link_speed) < 0) 1540 return; 1541 1542 RTE_ETH_FOREACH_DEV(pid) { 1543 ports[pid].dev_conf.link_speeds = link_speed; 1544 } 1545 1546 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1547 } 1548 1549 cmdline_parse_token_string_t cmd_config_speed_all_port = 1550 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1551 cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1552 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1553 "config"); 1554 cmdline_parse_token_string_t cmd_config_speed_all_all = 1555 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1556 cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1557 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1558 cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1559 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1560 "10#100#1000#10000#25000#40000#50000#100000#200000#auto"); 1561 cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1562 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1563 cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1564 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1565 "half#full#auto"); 1566 1567 cmdline_parse_inst_t cmd_config_speed_all = { 1568 .f = cmd_config_speed_all_parsed, 1569 .data = NULL, 1570 .help_str = "port config all speed " 1571 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex " 1572 "half|full|auto", 1573 .tokens = { 1574 (void *)&cmd_config_speed_all_port, 1575 (void *)&cmd_config_speed_all_keyword, 1576 (void *)&cmd_config_speed_all_all, 1577 (void *)&cmd_config_speed_all_item1, 1578 (void *)&cmd_config_speed_all_value1, 1579 (void *)&cmd_config_speed_all_item2, 1580 (void *)&cmd_config_speed_all_value2, 1581 NULL, 1582 }, 1583 }; 1584 1585 /* *** configure speed for specific port *** */ 1586 struct cmd_config_speed_specific { 1587 cmdline_fixed_string_t port; 1588 cmdline_fixed_string_t keyword; 1589 portid_t id; 1590 cmdline_fixed_string_t item1; 1591 cmdline_fixed_string_t item2; 1592 cmdline_fixed_string_t value1; 1593 cmdline_fixed_string_t value2; 1594 }; 1595 1596 static void 1597 cmd_config_speed_specific_parsed(void *parsed_result, 1598 __rte_unused struct cmdline *cl, 1599 __rte_unused void *data) 1600 { 1601 struct cmd_config_speed_specific *res = parsed_result; 1602 uint32_t link_speed; 1603 1604 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1605 return; 1606 1607 if (!port_is_stopped(res->id)) { 1608 fprintf(stderr, "Please stop port %d first\n", res->id); 1609 return; 1610 } 1611 1612 if (parse_and_check_speed_duplex(res->value1, res->value2, 1613 &link_speed) < 0) 1614 return; 1615 1616 ports[res->id].dev_conf.link_speeds = link_speed; 1617 1618 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1619 } 1620 1621 1622 cmdline_parse_token_string_t cmd_config_speed_specific_port = 1623 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1624 "port"); 1625 cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1626 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1627 "config"); 1628 cmdline_parse_token_num_t cmd_config_speed_specific_id = 1629 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16); 1630 cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1631 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1632 "speed"); 1633 cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1634 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1635 "10#100#1000#10000#25000#40000#50000#100000#200000#auto"); 1636 cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1637 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1638 "duplex"); 1639 cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1640 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1641 "half#full#auto"); 1642 1643 cmdline_parse_inst_t cmd_config_speed_specific = { 1644 .f = cmd_config_speed_specific_parsed, 1645 .data = NULL, 1646 .help_str = "port config <port_id> speed " 1647 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex " 1648 "half|full|auto", 1649 .tokens = { 1650 (void *)&cmd_config_speed_specific_port, 1651 (void *)&cmd_config_speed_specific_keyword, 1652 (void *)&cmd_config_speed_specific_id, 1653 (void *)&cmd_config_speed_specific_item1, 1654 (void *)&cmd_config_speed_specific_value1, 1655 (void *)&cmd_config_speed_specific_item2, 1656 (void *)&cmd_config_speed_specific_value2, 1657 NULL, 1658 }, 1659 }; 1660 1661 /* *** configure loopback for all ports *** */ 1662 struct cmd_config_loopback_all { 1663 cmdline_fixed_string_t port; 1664 cmdline_fixed_string_t keyword; 1665 cmdline_fixed_string_t all; 1666 cmdline_fixed_string_t item; 1667 uint32_t mode; 1668 }; 1669 1670 static void 1671 cmd_config_loopback_all_parsed(void *parsed_result, 1672 __rte_unused struct cmdline *cl, 1673 __rte_unused void *data) 1674 { 1675 struct cmd_config_loopback_all *res = parsed_result; 1676 portid_t pid; 1677 1678 if (!all_ports_stopped()) { 1679 fprintf(stderr, "Please stop all ports first\n"); 1680 return; 1681 } 1682 1683 RTE_ETH_FOREACH_DEV(pid) { 1684 ports[pid].dev_conf.lpbk_mode = res->mode; 1685 } 1686 1687 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1688 } 1689 1690 cmdline_parse_token_string_t cmd_config_loopback_all_port = 1691 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port"); 1692 cmdline_parse_token_string_t cmd_config_loopback_all_keyword = 1693 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword, 1694 "config"); 1695 cmdline_parse_token_string_t cmd_config_loopback_all_all = 1696 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all"); 1697 cmdline_parse_token_string_t cmd_config_loopback_all_item = 1698 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item, 1699 "loopback"); 1700 cmdline_parse_token_num_t cmd_config_loopback_all_mode = 1701 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32); 1702 1703 cmdline_parse_inst_t cmd_config_loopback_all = { 1704 .f = cmd_config_loopback_all_parsed, 1705 .data = NULL, 1706 .help_str = "port config all loopback <mode>", 1707 .tokens = { 1708 (void *)&cmd_config_loopback_all_port, 1709 (void *)&cmd_config_loopback_all_keyword, 1710 (void *)&cmd_config_loopback_all_all, 1711 (void *)&cmd_config_loopback_all_item, 1712 (void *)&cmd_config_loopback_all_mode, 1713 NULL, 1714 }, 1715 }; 1716 1717 /* *** configure loopback for specific port *** */ 1718 struct cmd_config_loopback_specific { 1719 cmdline_fixed_string_t port; 1720 cmdline_fixed_string_t keyword; 1721 uint16_t port_id; 1722 cmdline_fixed_string_t item; 1723 uint32_t mode; 1724 }; 1725 1726 static void 1727 cmd_config_loopback_specific_parsed(void *parsed_result, 1728 __rte_unused struct cmdline *cl, 1729 __rte_unused void *data) 1730 { 1731 struct cmd_config_loopback_specific *res = parsed_result; 1732 1733 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 1734 return; 1735 1736 if (!port_is_stopped(res->port_id)) { 1737 fprintf(stderr, "Please stop port %u first\n", res->port_id); 1738 return; 1739 } 1740 1741 ports[res->port_id].dev_conf.lpbk_mode = res->mode; 1742 1743 cmd_reconfig_device_queue(res->port_id, 1, 1); 1744 } 1745 1746 1747 cmdline_parse_token_string_t cmd_config_loopback_specific_port = 1748 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port, 1749 "port"); 1750 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword = 1751 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword, 1752 "config"); 1753 cmdline_parse_token_num_t cmd_config_loopback_specific_id = 1754 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id, 1755 RTE_UINT16); 1756 cmdline_parse_token_string_t cmd_config_loopback_specific_item = 1757 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item, 1758 "loopback"); 1759 cmdline_parse_token_num_t cmd_config_loopback_specific_mode = 1760 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode, 1761 RTE_UINT32); 1762 1763 cmdline_parse_inst_t cmd_config_loopback_specific = { 1764 .f = cmd_config_loopback_specific_parsed, 1765 .data = NULL, 1766 .help_str = "port config <port_id> loopback <mode>", 1767 .tokens = { 1768 (void *)&cmd_config_loopback_specific_port, 1769 (void *)&cmd_config_loopback_specific_keyword, 1770 (void *)&cmd_config_loopback_specific_id, 1771 (void *)&cmd_config_loopback_specific_item, 1772 (void *)&cmd_config_loopback_specific_mode, 1773 NULL, 1774 }, 1775 }; 1776 1777 /* *** configure txq/rxq, txd/rxd *** */ 1778 struct cmd_config_rx_tx { 1779 cmdline_fixed_string_t port; 1780 cmdline_fixed_string_t keyword; 1781 cmdline_fixed_string_t all; 1782 cmdline_fixed_string_t name; 1783 uint16_t value; 1784 }; 1785 1786 static void 1787 cmd_config_rx_tx_parsed(void *parsed_result, 1788 __rte_unused struct cmdline *cl, 1789 __rte_unused void *data) 1790 { 1791 struct cmd_config_rx_tx *res = parsed_result; 1792 1793 if (!all_ports_stopped()) { 1794 fprintf(stderr, "Please stop all ports first\n"); 1795 return; 1796 } 1797 if (!strcmp(res->name, "rxq")) { 1798 if (!res->value && !nb_txq) { 1799 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n"); 1800 return; 1801 } 1802 if (check_nb_rxq(res->value) != 0) 1803 return; 1804 nb_rxq = res->value; 1805 } 1806 else if (!strcmp(res->name, "txq")) { 1807 if (!res->value && !nb_rxq) { 1808 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n"); 1809 return; 1810 } 1811 if (check_nb_txq(res->value) != 0) 1812 return; 1813 nb_txq = res->value; 1814 } 1815 else if (!strcmp(res->name, "rxd")) { 1816 if (check_nb_rxd(res->value) != 0) 1817 return; 1818 nb_rxd = res->value; 1819 } else if (!strcmp(res->name, "txd")) { 1820 if (check_nb_txd(res->value) != 0) 1821 return; 1822 1823 nb_txd = res->value; 1824 } else { 1825 fprintf(stderr, "Unknown parameter\n"); 1826 return; 1827 } 1828 1829 fwd_config_setup(); 1830 1831 init_port_config(); 1832 1833 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1834 } 1835 1836 cmdline_parse_token_string_t cmd_config_rx_tx_port = 1837 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1838 cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1839 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1840 cmdline_parse_token_string_t cmd_config_rx_tx_all = 1841 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1842 cmdline_parse_token_string_t cmd_config_rx_tx_name = 1843 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1844 "rxq#txq#rxd#txd"); 1845 cmdline_parse_token_num_t cmd_config_rx_tx_value = 1846 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16); 1847 1848 cmdline_parse_inst_t cmd_config_rx_tx = { 1849 .f = cmd_config_rx_tx_parsed, 1850 .data = NULL, 1851 .help_str = "port config all rxq|txq|rxd|txd <value>", 1852 .tokens = { 1853 (void *)&cmd_config_rx_tx_port, 1854 (void *)&cmd_config_rx_tx_keyword, 1855 (void *)&cmd_config_rx_tx_all, 1856 (void *)&cmd_config_rx_tx_name, 1857 (void *)&cmd_config_rx_tx_value, 1858 NULL, 1859 }, 1860 }; 1861 1862 /* *** config max packet length *** */ 1863 struct cmd_config_max_pkt_len_result { 1864 cmdline_fixed_string_t port; 1865 cmdline_fixed_string_t keyword; 1866 cmdline_fixed_string_t all; 1867 cmdline_fixed_string_t name; 1868 uint32_t value; 1869 }; 1870 1871 static void 1872 cmd_config_max_pkt_len_parsed(void *parsed_result, 1873 __rte_unused struct cmdline *cl, 1874 __rte_unused void *data) 1875 { 1876 struct cmd_config_max_pkt_len_result *res = parsed_result; 1877 uint32_t max_rx_pkt_len_backup = 0; 1878 portid_t pid; 1879 int ret; 1880 1881 if (!all_ports_stopped()) { 1882 fprintf(stderr, "Please stop all ports first\n"); 1883 return; 1884 } 1885 1886 RTE_ETH_FOREACH_DEV(pid) { 1887 struct rte_port *port = &ports[pid]; 1888 1889 if (!strcmp(res->name, "max-pkt-len")) { 1890 if (res->value < RTE_ETHER_MIN_LEN) { 1891 fprintf(stderr, 1892 "max-pkt-len can not be less than %d\n", 1893 RTE_ETHER_MIN_LEN); 1894 return; 1895 } 1896 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len) 1897 return; 1898 1899 ret = eth_dev_info_get_print_err(pid, &port->dev_info); 1900 if (ret != 0) { 1901 fprintf(stderr, 1902 "rte_eth_dev_info_get() failed for port %u\n", 1903 pid); 1904 return; 1905 } 1906 1907 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len; 1908 1909 port->dev_conf.rxmode.max_rx_pkt_len = res->value; 1910 if (update_jumbo_frame_offload(pid) != 0) 1911 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup; 1912 } else { 1913 fprintf(stderr, "Unknown parameter\n"); 1914 return; 1915 } 1916 } 1917 1918 init_port_config(); 1919 1920 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1921 } 1922 1923 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 1924 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 1925 "port"); 1926 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 1927 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 1928 "config"); 1929 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 1930 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 1931 "all"); 1932 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 1933 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 1934 "max-pkt-len"); 1935 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 1936 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 1937 RTE_UINT32); 1938 1939 cmdline_parse_inst_t cmd_config_max_pkt_len = { 1940 .f = cmd_config_max_pkt_len_parsed, 1941 .data = NULL, 1942 .help_str = "port config all max-pkt-len <value>", 1943 .tokens = { 1944 (void *)&cmd_config_max_pkt_len_port, 1945 (void *)&cmd_config_max_pkt_len_keyword, 1946 (void *)&cmd_config_max_pkt_len_all, 1947 (void *)&cmd_config_max_pkt_len_name, 1948 (void *)&cmd_config_max_pkt_len_value, 1949 NULL, 1950 }, 1951 }; 1952 1953 /* *** config max LRO aggregated packet size *** */ 1954 struct cmd_config_max_lro_pkt_size_result { 1955 cmdline_fixed_string_t port; 1956 cmdline_fixed_string_t keyword; 1957 cmdline_fixed_string_t all; 1958 cmdline_fixed_string_t name; 1959 uint32_t value; 1960 }; 1961 1962 static void 1963 cmd_config_max_lro_pkt_size_parsed(void *parsed_result, 1964 __rte_unused struct cmdline *cl, 1965 __rte_unused void *data) 1966 { 1967 struct cmd_config_max_lro_pkt_size_result *res = parsed_result; 1968 portid_t pid; 1969 1970 if (!all_ports_stopped()) { 1971 fprintf(stderr, "Please stop all ports first\n"); 1972 return; 1973 } 1974 1975 RTE_ETH_FOREACH_DEV(pid) { 1976 struct rte_port *port = &ports[pid]; 1977 1978 if (!strcmp(res->name, "max-lro-pkt-size")) { 1979 if (res->value == 1980 port->dev_conf.rxmode.max_lro_pkt_size) 1981 return; 1982 1983 port->dev_conf.rxmode.max_lro_pkt_size = res->value; 1984 } else { 1985 fprintf(stderr, "Unknown parameter\n"); 1986 return; 1987 } 1988 } 1989 1990 init_port_config(); 1991 1992 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1993 } 1994 1995 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port = 1996 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 1997 port, "port"); 1998 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword = 1999 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2000 keyword, "config"); 2001 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all = 2002 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2003 all, "all"); 2004 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name = 2005 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2006 name, "max-lro-pkt-size"); 2007 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value = 2008 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2009 value, RTE_UINT32); 2010 2011 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = { 2012 .f = cmd_config_max_lro_pkt_size_parsed, 2013 .data = NULL, 2014 .help_str = "port config all max-lro-pkt-size <value>", 2015 .tokens = { 2016 (void *)&cmd_config_max_lro_pkt_size_port, 2017 (void *)&cmd_config_max_lro_pkt_size_keyword, 2018 (void *)&cmd_config_max_lro_pkt_size_all, 2019 (void *)&cmd_config_max_lro_pkt_size_name, 2020 (void *)&cmd_config_max_lro_pkt_size_value, 2021 NULL, 2022 }, 2023 }; 2024 2025 /* *** configure port MTU *** */ 2026 struct cmd_config_mtu_result { 2027 cmdline_fixed_string_t port; 2028 cmdline_fixed_string_t keyword; 2029 cmdline_fixed_string_t mtu; 2030 portid_t port_id; 2031 uint16_t value; 2032 }; 2033 2034 static void 2035 cmd_config_mtu_parsed(void *parsed_result, 2036 __rte_unused struct cmdline *cl, 2037 __rte_unused void *data) 2038 { 2039 struct cmd_config_mtu_result *res = parsed_result; 2040 2041 if (res->value < RTE_ETHER_MIN_LEN) { 2042 fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN); 2043 return; 2044 } 2045 port_mtu_set(res->port_id, res->value); 2046 } 2047 2048 cmdline_parse_token_string_t cmd_config_mtu_port = 2049 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 2050 "port"); 2051 cmdline_parse_token_string_t cmd_config_mtu_keyword = 2052 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2053 "config"); 2054 cmdline_parse_token_string_t cmd_config_mtu_mtu = 2055 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2056 "mtu"); 2057 cmdline_parse_token_num_t cmd_config_mtu_port_id = 2058 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, 2059 RTE_UINT16); 2060 cmdline_parse_token_num_t cmd_config_mtu_value = 2061 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, 2062 RTE_UINT16); 2063 2064 cmdline_parse_inst_t cmd_config_mtu = { 2065 .f = cmd_config_mtu_parsed, 2066 .data = NULL, 2067 .help_str = "port config mtu <port_id> <value>", 2068 .tokens = { 2069 (void *)&cmd_config_mtu_port, 2070 (void *)&cmd_config_mtu_keyword, 2071 (void *)&cmd_config_mtu_mtu, 2072 (void *)&cmd_config_mtu_port_id, 2073 (void *)&cmd_config_mtu_value, 2074 NULL, 2075 }, 2076 }; 2077 2078 /* *** configure rx mode *** */ 2079 struct cmd_config_rx_mode_flag { 2080 cmdline_fixed_string_t port; 2081 cmdline_fixed_string_t keyword; 2082 cmdline_fixed_string_t all; 2083 cmdline_fixed_string_t name; 2084 cmdline_fixed_string_t value; 2085 }; 2086 2087 static void 2088 cmd_config_rx_mode_flag_parsed(void *parsed_result, 2089 __rte_unused struct cmdline *cl, 2090 __rte_unused void *data) 2091 { 2092 struct cmd_config_rx_mode_flag *res = parsed_result; 2093 2094 if (!all_ports_stopped()) { 2095 fprintf(stderr, "Please stop all ports first\n"); 2096 return; 2097 } 2098 2099 if (!strcmp(res->name, "drop-en")) { 2100 if (!strcmp(res->value, "on")) 2101 rx_drop_en = 1; 2102 else if (!strcmp(res->value, "off")) 2103 rx_drop_en = 0; 2104 else { 2105 fprintf(stderr, "Unknown parameter\n"); 2106 return; 2107 } 2108 } else { 2109 fprintf(stderr, "Unknown parameter\n"); 2110 return; 2111 } 2112 2113 init_port_config(); 2114 2115 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2116 } 2117 2118 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 2119 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 2120 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 2121 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 2122 "config"); 2123 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 2124 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 2125 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 2126 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 2127 "drop-en"); 2128 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 2129 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 2130 "on#off"); 2131 2132 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 2133 .f = cmd_config_rx_mode_flag_parsed, 2134 .data = NULL, 2135 .help_str = "port config all drop-en on|off", 2136 .tokens = { 2137 (void *)&cmd_config_rx_mode_flag_port, 2138 (void *)&cmd_config_rx_mode_flag_keyword, 2139 (void *)&cmd_config_rx_mode_flag_all, 2140 (void *)&cmd_config_rx_mode_flag_name, 2141 (void *)&cmd_config_rx_mode_flag_value, 2142 NULL, 2143 }, 2144 }; 2145 2146 /* *** configure rss *** */ 2147 struct cmd_config_rss { 2148 cmdline_fixed_string_t port; 2149 cmdline_fixed_string_t keyword; 2150 cmdline_fixed_string_t all; 2151 cmdline_fixed_string_t name; 2152 cmdline_fixed_string_t value; 2153 }; 2154 2155 static void 2156 cmd_config_rss_parsed(void *parsed_result, 2157 __rte_unused struct cmdline *cl, 2158 __rte_unused void *data) 2159 { 2160 struct cmd_config_rss *res = parsed_result; 2161 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2162 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2163 int use_default = 0; 2164 int all_updated = 1; 2165 int diag; 2166 uint16_t i; 2167 int ret; 2168 2169 if (!strcmp(res->value, "all")) 2170 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP | 2171 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP | 2172 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP | 2173 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU | 2174 ETH_RSS_ECPRI; 2175 else if (!strcmp(res->value, "eth")) 2176 rss_conf.rss_hf = ETH_RSS_ETH; 2177 else if (!strcmp(res->value, "vlan")) 2178 rss_conf.rss_hf = ETH_RSS_VLAN; 2179 else if (!strcmp(res->value, "ip")) 2180 rss_conf.rss_hf = ETH_RSS_IP; 2181 else if (!strcmp(res->value, "udp")) 2182 rss_conf.rss_hf = ETH_RSS_UDP; 2183 else if (!strcmp(res->value, "tcp")) 2184 rss_conf.rss_hf = ETH_RSS_TCP; 2185 else if (!strcmp(res->value, "sctp")) 2186 rss_conf.rss_hf = ETH_RSS_SCTP; 2187 else if (!strcmp(res->value, "ether")) 2188 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 2189 else if (!strcmp(res->value, "port")) 2190 rss_conf.rss_hf = ETH_RSS_PORT; 2191 else if (!strcmp(res->value, "vxlan")) 2192 rss_conf.rss_hf = ETH_RSS_VXLAN; 2193 else if (!strcmp(res->value, "geneve")) 2194 rss_conf.rss_hf = ETH_RSS_GENEVE; 2195 else if (!strcmp(res->value, "nvgre")) 2196 rss_conf.rss_hf = ETH_RSS_NVGRE; 2197 else if (!strcmp(res->value, "l3-pre32")) 2198 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32; 2199 else if (!strcmp(res->value, "l3-pre40")) 2200 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40; 2201 else if (!strcmp(res->value, "l3-pre48")) 2202 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48; 2203 else if (!strcmp(res->value, "l3-pre56")) 2204 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56; 2205 else if (!strcmp(res->value, "l3-pre64")) 2206 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64; 2207 else if (!strcmp(res->value, "l3-pre96")) 2208 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96; 2209 else if (!strcmp(res->value, "l3-src-only")) 2210 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY; 2211 else if (!strcmp(res->value, "l3-dst-only")) 2212 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY; 2213 else if (!strcmp(res->value, "l4-src-only")) 2214 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY; 2215 else if (!strcmp(res->value, "l4-dst-only")) 2216 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY; 2217 else if (!strcmp(res->value, "l2-src-only")) 2218 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY; 2219 else if (!strcmp(res->value, "l2-dst-only")) 2220 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY; 2221 else if (!strcmp(res->value, "l2tpv3")) 2222 rss_conf.rss_hf = ETH_RSS_L2TPV3; 2223 else if (!strcmp(res->value, "esp")) 2224 rss_conf.rss_hf = ETH_RSS_ESP; 2225 else if (!strcmp(res->value, "ah")) 2226 rss_conf.rss_hf = ETH_RSS_AH; 2227 else if (!strcmp(res->value, "pfcp")) 2228 rss_conf.rss_hf = ETH_RSS_PFCP; 2229 else if (!strcmp(res->value, "pppoe")) 2230 rss_conf.rss_hf = ETH_RSS_PPPOE; 2231 else if (!strcmp(res->value, "gtpu")) 2232 rss_conf.rss_hf = ETH_RSS_GTPU; 2233 else if (!strcmp(res->value, "ecpri")) 2234 rss_conf.rss_hf = ETH_RSS_ECPRI; 2235 else if (!strcmp(res->value, "mpls")) 2236 rss_conf.rss_hf = ETH_RSS_MPLS; 2237 else if (!strcmp(res->value, "ipv4-chksum")) 2238 rss_conf.rss_hf = ETH_RSS_IPV4_CHKSUM; 2239 else if (!strcmp(res->value, "none")) 2240 rss_conf.rss_hf = 0; 2241 else if (!strcmp(res->value, "level-default")) { 2242 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2243 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT); 2244 } else if (!strcmp(res->value, "level-outer")) { 2245 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2246 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST); 2247 } else if (!strcmp(res->value, "level-inner")) { 2248 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2249 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST); 2250 } else if (!strcmp(res->value, "default")) 2251 use_default = 1; 2252 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 2253 atoi(res->value) < 64) 2254 rss_conf.rss_hf = 1ULL << atoi(res->value); 2255 else { 2256 fprintf(stderr, "Unknown parameter\n"); 2257 return; 2258 } 2259 rss_conf.rss_key = NULL; 2260 /* Update global configuration for RSS types. */ 2261 RTE_ETH_FOREACH_DEV(i) { 2262 struct rte_eth_rss_conf local_rss_conf; 2263 2264 ret = eth_dev_info_get_print_err(i, &dev_info); 2265 if (ret != 0) 2266 return; 2267 2268 if (use_default) 2269 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2270 2271 local_rss_conf = rss_conf; 2272 local_rss_conf.rss_hf = rss_conf.rss_hf & 2273 dev_info.flow_type_rss_offloads; 2274 if (local_rss_conf.rss_hf != rss_conf.rss_hf) { 2275 printf("Port %u modified RSS hash function based on hardware support," 2276 "requested:%#"PRIx64" configured:%#"PRIx64"\n", 2277 i, rss_conf.rss_hf, local_rss_conf.rss_hf); 2278 } 2279 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf); 2280 if (diag < 0) { 2281 all_updated = 0; 2282 fprintf(stderr, 2283 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n", 2284 i, -diag, strerror(-diag)); 2285 } 2286 } 2287 if (all_updated && !use_default) { 2288 rss_hf = rss_conf.rss_hf; 2289 printf("rss_hf %#"PRIx64"\n", rss_hf); 2290 } 2291 } 2292 2293 cmdline_parse_token_string_t cmd_config_rss_port = 2294 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2295 cmdline_parse_token_string_t cmd_config_rss_keyword = 2296 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2297 cmdline_parse_token_string_t cmd_config_rss_all = 2298 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2299 cmdline_parse_token_string_t cmd_config_rss_name = 2300 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2301 cmdline_parse_token_string_t cmd_config_rss_value = 2302 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2303 2304 cmdline_parse_inst_t cmd_config_rss = { 2305 .f = cmd_config_rss_parsed, 2306 .data = NULL, 2307 .help_str = "port config all rss " 2308 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|" 2309 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|" 2310 "level-outer|level-inner|ipv4-chksum|<flowtype_id>", 2311 .tokens = { 2312 (void *)&cmd_config_rss_port, 2313 (void *)&cmd_config_rss_keyword, 2314 (void *)&cmd_config_rss_all, 2315 (void *)&cmd_config_rss_name, 2316 (void *)&cmd_config_rss_value, 2317 NULL, 2318 }, 2319 }; 2320 2321 /* *** configure rss hash key *** */ 2322 struct cmd_config_rss_hash_key { 2323 cmdline_fixed_string_t port; 2324 cmdline_fixed_string_t config; 2325 portid_t port_id; 2326 cmdline_fixed_string_t rss_hash_key; 2327 cmdline_fixed_string_t rss_type; 2328 cmdline_fixed_string_t key; 2329 }; 2330 2331 static uint8_t 2332 hexa_digit_to_value(char hexa_digit) 2333 { 2334 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2335 return (uint8_t) (hexa_digit - '0'); 2336 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2337 return (uint8_t) ((hexa_digit - 'a') + 10); 2338 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2339 return (uint8_t) ((hexa_digit - 'A') + 10); 2340 /* Invalid hexa digit */ 2341 return 0xFF; 2342 } 2343 2344 static uint8_t 2345 parse_and_check_key_hexa_digit(char *key, int idx) 2346 { 2347 uint8_t hexa_v; 2348 2349 hexa_v = hexa_digit_to_value(key[idx]); 2350 if (hexa_v == 0xFF) 2351 fprintf(stderr, 2352 "invalid key: character %c at position %d is not a valid hexa digit\n", 2353 key[idx], idx); 2354 return hexa_v; 2355 } 2356 2357 static void 2358 cmd_config_rss_hash_key_parsed(void *parsed_result, 2359 __rte_unused struct cmdline *cl, 2360 __rte_unused void *data) 2361 { 2362 struct cmd_config_rss_hash_key *res = parsed_result; 2363 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2364 uint8_t xdgt0; 2365 uint8_t xdgt1; 2366 int i; 2367 struct rte_eth_dev_info dev_info; 2368 uint8_t hash_key_size; 2369 uint32_t key_len; 2370 int ret; 2371 2372 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2373 if (ret != 0) 2374 return; 2375 2376 if (dev_info.hash_key_size > 0 && 2377 dev_info.hash_key_size <= sizeof(hash_key)) 2378 hash_key_size = dev_info.hash_key_size; 2379 else { 2380 fprintf(stderr, 2381 "dev_info did not provide a valid hash key size\n"); 2382 return; 2383 } 2384 /* Check the length of the RSS hash key */ 2385 key_len = strlen(res->key); 2386 if (key_len != (hash_key_size * 2)) { 2387 fprintf(stderr, 2388 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n", 2389 (int)key_len, hash_key_size * 2); 2390 return; 2391 } 2392 /* Translate RSS hash key into binary representation */ 2393 for (i = 0; i < hash_key_size; i++) { 2394 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2395 if (xdgt0 == 0xFF) 2396 return; 2397 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2398 if (xdgt1 == 0xFF) 2399 return; 2400 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2401 } 2402 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2403 hash_key_size); 2404 } 2405 2406 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2407 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2408 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2409 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2410 "config"); 2411 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2412 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, 2413 RTE_UINT16); 2414 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2415 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2416 rss_hash_key, "rss-hash-key"); 2417 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2418 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2419 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2420 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2421 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2422 "ipv6-tcp-ex#ipv6-udp-ex#" 2423 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#" 2424 "l2-src-only#l2-dst-only#s-vlan#c-vlan#" 2425 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls"); 2426 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2427 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2428 2429 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2430 .f = cmd_config_rss_hash_key_parsed, 2431 .data = NULL, 2432 .help_str = "port config <port_id> rss-hash-key " 2433 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2434 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2435 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|" 2436 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|" 2437 "l2-src-only|l2-dst-only|s-vlan|c-vlan|" 2438 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls " 2439 "<string of hex digits (variable length, NIC dependent)>", 2440 .tokens = { 2441 (void *)&cmd_config_rss_hash_key_port, 2442 (void *)&cmd_config_rss_hash_key_config, 2443 (void *)&cmd_config_rss_hash_key_port_id, 2444 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2445 (void *)&cmd_config_rss_hash_key_rss_type, 2446 (void *)&cmd_config_rss_hash_key_value, 2447 NULL, 2448 }, 2449 }; 2450 2451 /* *** cleanup txq mbufs *** */ 2452 struct cmd_cleanup_txq_mbufs_result { 2453 cmdline_fixed_string_t port; 2454 cmdline_fixed_string_t keyword; 2455 cmdline_fixed_string_t name; 2456 uint16_t port_id; 2457 uint16_t queue_id; 2458 uint32_t free_cnt; 2459 }; 2460 2461 static void 2462 cmd_cleanup_txq_mbufs_parsed(void *parsed_result, 2463 __rte_unused struct cmdline *cl, 2464 __rte_unused void *data) 2465 { 2466 struct cmd_cleanup_txq_mbufs_result *res = parsed_result; 2467 uint16_t port_id = res->port_id; 2468 uint16_t queue_id = res->queue_id; 2469 uint32_t free_cnt = res->free_cnt; 2470 struct rte_eth_txq_info qinfo; 2471 int ret; 2472 2473 if (test_done == 0) { 2474 fprintf(stderr, "Please stop forwarding first\n"); 2475 return; 2476 } 2477 2478 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) { 2479 fprintf(stderr, "Failed to get port %u Tx queue %u info\n", 2480 port_id, queue_id); 2481 return; 2482 } 2483 2484 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) { 2485 fprintf(stderr, "Tx queue %u not started\n", queue_id); 2486 return; 2487 } 2488 2489 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt); 2490 if (ret < 0) { 2491 fprintf(stderr, 2492 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n", 2493 port_id, queue_id, strerror(-ret), ret); 2494 return; 2495 } 2496 2497 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n", 2498 port_id, queue_id, ret); 2499 } 2500 2501 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port = 2502 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port, 2503 "port"); 2504 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup = 2505 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword, 2506 "cleanup"); 2507 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id = 2508 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id, 2509 RTE_UINT16); 2510 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq = 2511 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name, 2512 "txq"); 2513 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id = 2514 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id, 2515 RTE_UINT16); 2516 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt = 2517 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt, 2518 RTE_UINT32); 2519 2520 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = { 2521 .f = cmd_cleanup_txq_mbufs_parsed, 2522 .data = NULL, 2523 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>", 2524 .tokens = { 2525 (void *)&cmd_cleanup_txq_mbufs_port, 2526 (void *)&cmd_cleanup_txq_mbufs_cleanup, 2527 (void *)&cmd_cleanup_txq_mbufs_port_id, 2528 (void *)&cmd_cleanup_txq_mbufs_txq, 2529 (void *)&cmd_cleanup_txq_mbufs_queue_id, 2530 (void *)&cmd_cleanup_txq_mbufs_free_cnt, 2531 NULL, 2532 }, 2533 }; 2534 2535 /* *** configure port rxq/txq ring size *** */ 2536 struct cmd_config_rxtx_ring_size { 2537 cmdline_fixed_string_t port; 2538 cmdline_fixed_string_t config; 2539 portid_t portid; 2540 cmdline_fixed_string_t rxtxq; 2541 uint16_t qid; 2542 cmdline_fixed_string_t rsize; 2543 uint16_t size; 2544 }; 2545 2546 static void 2547 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2548 __rte_unused struct cmdline *cl, 2549 __rte_unused void *data) 2550 { 2551 struct cmd_config_rxtx_ring_size *res = parsed_result; 2552 struct rte_port *port; 2553 uint8_t isrx; 2554 2555 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2556 return; 2557 2558 if (res->portid == (portid_t)RTE_PORT_ALL) { 2559 fprintf(stderr, "Invalid port id\n"); 2560 return; 2561 } 2562 2563 port = &ports[res->portid]; 2564 2565 if (!strcmp(res->rxtxq, "rxq")) 2566 isrx = 1; 2567 else if (!strcmp(res->rxtxq, "txq")) 2568 isrx = 0; 2569 else { 2570 fprintf(stderr, "Unknown parameter\n"); 2571 return; 2572 } 2573 2574 if (isrx && rx_queue_id_is_invalid(res->qid)) 2575 return; 2576 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2577 return; 2578 2579 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2580 fprintf(stderr, 2581 "Invalid rx ring_size, must > rx_free_thresh: %d\n", 2582 rx_free_thresh); 2583 return; 2584 } 2585 2586 if (isrx) 2587 port->nb_rx_desc[res->qid] = res->size; 2588 else 2589 port->nb_tx_desc[res->qid] = res->size; 2590 2591 cmd_reconfig_device_queue(res->portid, 0, 1); 2592 } 2593 2594 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2595 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2596 port, "port"); 2597 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2598 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2599 config, "config"); 2600 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2601 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2602 portid, RTE_UINT16); 2603 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2604 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2605 rxtxq, "rxq#txq"); 2606 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2607 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2608 qid, RTE_UINT16); 2609 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2610 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2611 rsize, "ring_size"); 2612 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2613 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2614 size, RTE_UINT16); 2615 2616 cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2617 .f = cmd_config_rxtx_ring_size_parsed, 2618 .data = NULL, 2619 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2620 .tokens = { 2621 (void *)&cmd_config_rxtx_ring_size_port, 2622 (void *)&cmd_config_rxtx_ring_size_config, 2623 (void *)&cmd_config_rxtx_ring_size_portid, 2624 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2625 (void *)&cmd_config_rxtx_ring_size_qid, 2626 (void *)&cmd_config_rxtx_ring_size_rsize, 2627 (void *)&cmd_config_rxtx_ring_size_size, 2628 NULL, 2629 }, 2630 }; 2631 2632 /* *** configure port rxq/txq start/stop *** */ 2633 struct cmd_config_rxtx_queue { 2634 cmdline_fixed_string_t port; 2635 portid_t portid; 2636 cmdline_fixed_string_t rxtxq; 2637 uint16_t qid; 2638 cmdline_fixed_string_t opname; 2639 }; 2640 2641 static void 2642 cmd_config_rxtx_queue_parsed(void *parsed_result, 2643 __rte_unused struct cmdline *cl, 2644 __rte_unused void *data) 2645 { 2646 struct cmd_config_rxtx_queue *res = parsed_result; 2647 uint8_t isrx; 2648 uint8_t isstart; 2649 int ret = 0; 2650 2651 if (test_done == 0) { 2652 fprintf(stderr, "Please stop forwarding first\n"); 2653 return; 2654 } 2655 2656 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2657 return; 2658 2659 if (port_is_started(res->portid) != 1) { 2660 fprintf(stderr, "Please start port %u first\n", res->portid); 2661 return; 2662 } 2663 2664 if (!strcmp(res->rxtxq, "rxq")) 2665 isrx = 1; 2666 else if (!strcmp(res->rxtxq, "txq")) 2667 isrx = 0; 2668 else { 2669 fprintf(stderr, "Unknown parameter\n"); 2670 return; 2671 } 2672 2673 if (isrx && rx_queue_id_is_invalid(res->qid)) 2674 return; 2675 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2676 return; 2677 2678 if (!strcmp(res->opname, "start")) 2679 isstart = 1; 2680 else if (!strcmp(res->opname, "stop")) 2681 isstart = 0; 2682 else { 2683 fprintf(stderr, "Unknown parameter\n"); 2684 return; 2685 } 2686 2687 if (isstart && isrx) 2688 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2689 else if (!isstart && isrx) 2690 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2691 else if (isstart && !isrx) 2692 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2693 else 2694 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2695 2696 if (ret == -ENOTSUP) 2697 fprintf(stderr, "Function not supported in PMD driver\n"); 2698 } 2699 2700 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2701 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2702 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2703 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16); 2704 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2705 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2706 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2707 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16); 2708 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2709 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2710 "start#stop"); 2711 2712 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2713 .f = cmd_config_rxtx_queue_parsed, 2714 .data = NULL, 2715 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2716 .tokens = { 2717 (void *)&cmd_config_rxtx_queue_port, 2718 (void *)&cmd_config_rxtx_queue_portid, 2719 (void *)&cmd_config_rxtx_queue_rxtxq, 2720 (void *)&cmd_config_rxtx_queue_qid, 2721 (void *)&cmd_config_rxtx_queue_opname, 2722 NULL, 2723 }, 2724 }; 2725 2726 /* *** configure port rxq/txq deferred start on/off *** */ 2727 struct cmd_config_deferred_start_rxtx_queue { 2728 cmdline_fixed_string_t port; 2729 portid_t port_id; 2730 cmdline_fixed_string_t rxtxq; 2731 uint16_t qid; 2732 cmdline_fixed_string_t opname; 2733 cmdline_fixed_string_t state; 2734 }; 2735 2736 static void 2737 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, 2738 __rte_unused struct cmdline *cl, 2739 __rte_unused void *data) 2740 { 2741 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; 2742 struct rte_port *port; 2743 uint8_t isrx; 2744 uint8_t ison; 2745 uint8_t needreconfig = 0; 2746 2747 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 2748 return; 2749 2750 if (port_is_started(res->port_id) != 0) { 2751 fprintf(stderr, "Please stop port %u first\n", res->port_id); 2752 return; 2753 } 2754 2755 port = &ports[res->port_id]; 2756 2757 isrx = !strcmp(res->rxtxq, "rxq"); 2758 2759 if (isrx && rx_queue_id_is_invalid(res->qid)) 2760 return; 2761 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2762 return; 2763 2764 ison = !strcmp(res->state, "on"); 2765 2766 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) { 2767 port->rx_conf[res->qid].rx_deferred_start = ison; 2768 needreconfig = 1; 2769 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) { 2770 port->tx_conf[res->qid].tx_deferred_start = ison; 2771 needreconfig = 1; 2772 } 2773 2774 if (needreconfig) 2775 cmd_reconfig_device_queue(res->port_id, 0, 1); 2776 } 2777 2778 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = 2779 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2780 port, "port"); 2781 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = 2782 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2783 port_id, RTE_UINT16); 2784 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = 2785 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2786 rxtxq, "rxq#txq"); 2787 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = 2788 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2789 qid, RTE_UINT16); 2790 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = 2791 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2792 opname, "deferred_start"); 2793 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = 2794 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2795 state, "on#off"); 2796 2797 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { 2798 .f = cmd_config_deferred_start_rxtx_queue_parsed, 2799 .data = NULL, 2800 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", 2801 .tokens = { 2802 (void *)&cmd_config_deferred_start_rxtx_queue_port, 2803 (void *)&cmd_config_deferred_start_rxtx_queue_port_id, 2804 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, 2805 (void *)&cmd_config_deferred_start_rxtx_queue_qid, 2806 (void *)&cmd_config_deferred_start_rxtx_queue_opname, 2807 (void *)&cmd_config_deferred_start_rxtx_queue_state, 2808 NULL, 2809 }, 2810 }; 2811 2812 /* *** configure port rxq/txq setup *** */ 2813 struct cmd_setup_rxtx_queue { 2814 cmdline_fixed_string_t port; 2815 portid_t portid; 2816 cmdline_fixed_string_t rxtxq; 2817 uint16_t qid; 2818 cmdline_fixed_string_t setup; 2819 }; 2820 2821 /* Common CLI fields for queue setup */ 2822 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2823 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2824 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2825 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16); 2826 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2827 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2828 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2829 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16); 2830 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2831 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2832 2833 static void 2834 cmd_setup_rxtx_queue_parsed( 2835 void *parsed_result, 2836 __rte_unused struct cmdline *cl, 2837 __rte_unused void *data) 2838 { 2839 struct cmd_setup_rxtx_queue *res = parsed_result; 2840 struct rte_port *port; 2841 struct rte_mempool *mp; 2842 unsigned int socket_id; 2843 uint8_t isrx = 0; 2844 int ret; 2845 2846 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2847 return; 2848 2849 if (res->portid == (portid_t)RTE_PORT_ALL) { 2850 fprintf(stderr, "Invalid port id\n"); 2851 return; 2852 } 2853 2854 if (!strcmp(res->rxtxq, "rxq")) 2855 isrx = 1; 2856 else if (!strcmp(res->rxtxq, "txq")) 2857 isrx = 0; 2858 else { 2859 fprintf(stderr, "Unknown parameter\n"); 2860 return; 2861 } 2862 2863 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2864 fprintf(stderr, "Invalid rx queue\n"); 2865 return; 2866 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2867 fprintf(stderr, "Invalid tx queue\n"); 2868 return; 2869 } 2870 2871 port = &ports[res->portid]; 2872 if (isrx) { 2873 socket_id = rxring_numa[res->portid]; 2874 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2875 socket_id = port->socket_id; 2876 2877 mp = mbuf_pool_find(socket_id, 0); 2878 if (mp == NULL) { 2879 fprintf(stderr, 2880 "Failed to setup RX queue: No mempool allocation on the socket %d\n", 2881 rxring_numa[res->portid]); 2882 return; 2883 } 2884 ret = rx_queue_setup(res->portid, 2885 res->qid, 2886 port->nb_rx_desc[res->qid], 2887 socket_id, 2888 &port->rx_conf[res->qid], 2889 mp); 2890 if (ret) 2891 fprintf(stderr, "Failed to setup RX queue\n"); 2892 } else { 2893 socket_id = txring_numa[res->portid]; 2894 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2895 socket_id = port->socket_id; 2896 2897 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) { 2898 fprintf(stderr, 2899 "Failed to setup TX queue: not enough descriptors\n"); 2900 return; 2901 } 2902 ret = rte_eth_tx_queue_setup(res->portid, 2903 res->qid, 2904 port->nb_tx_desc[res->qid], 2905 socket_id, 2906 &port->tx_conf[res->qid]); 2907 if (ret) 2908 fprintf(stderr, "Failed to setup TX queue\n"); 2909 } 2910 } 2911 2912 cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2913 .f = cmd_setup_rxtx_queue_parsed, 2914 .data = NULL, 2915 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2916 .tokens = { 2917 (void *)&cmd_setup_rxtx_queue_port, 2918 (void *)&cmd_setup_rxtx_queue_portid, 2919 (void *)&cmd_setup_rxtx_queue_rxtxq, 2920 (void *)&cmd_setup_rxtx_queue_qid, 2921 (void *)&cmd_setup_rxtx_queue_setup, 2922 NULL, 2923 }, 2924 }; 2925 2926 2927 /* *** Configure RSS RETA *** */ 2928 struct cmd_config_rss_reta { 2929 cmdline_fixed_string_t port; 2930 cmdline_fixed_string_t keyword; 2931 portid_t port_id; 2932 cmdline_fixed_string_t name; 2933 cmdline_fixed_string_t list_name; 2934 cmdline_fixed_string_t list_of_items; 2935 }; 2936 2937 static int 2938 parse_reta_config(const char *str, 2939 struct rte_eth_rss_reta_entry64 *reta_conf, 2940 uint16_t nb_entries) 2941 { 2942 int i; 2943 unsigned size; 2944 uint16_t hash_index, idx, shift; 2945 uint16_t nb_queue; 2946 char s[256]; 2947 const char *p, *p0 = str; 2948 char *end; 2949 enum fieldnames { 2950 FLD_HASH_INDEX = 0, 2951 FLD_QUEUE, 2952 _NUM_FLD 2953 }; 2954 unsigned long int_fld[_NUM_FLD]; 2955 char *str_fld[_NUM_FLD]; 2956 2957 while ((p = strchr(p0,'(')) != NULL) { 2958 ++p; 2959 if((p0 = strchr(p,')')) == NULL) 2960 return -1; 2961 2962 size = p0 - p; 2963 if(size >= sizeof(s)) 2964 return -1; 2965 2966 snprintf(s, sizeof(s), "%.*s", size, p); 2967 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2968 return -1; 2969 for (i = 0; i < _NUM_FLD; i++) { 2970 errno = 0; 2971 int_fld[i] = strtoul(str_fld[i], &end, 0); 2972 if (errno != 0 || end == str_fld[i] || 2973 int_fld[i] > 65535) 2974 return -1; 2975 } 2976 2977 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2978 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2979 2980 if (hash_index >= nb_entries) { 2981 fprintf(stderr, "Invalid RETA hash index=%d\n", 2982 hash_index); 2983 return -1; 2984 } 2985 2986 idx = hash_index / RTE_RETA_GROUP_SIZE; 2987 shift = hash_index % RTE_RETA_GROUP_SIZE; 2988 reta_conf[idx].mask |= (1ULL << shift); 2989 reta_conf[idx].reta[shift] = nb_queue; 2990 } 2991 2992 return 0; 2993 } 2994 2995 static void 2996 cmd_set_rss_reta_parsed(void *parsed_result, 2997 __rte_unused struct cmdline *cl, 2998 __rte_unused void *data) 2999 { 3000 int ret; 3001 struct rte_eth_dev_info dev_info; 3002 struct rte_eth_rss_reta_entry64 reta_conf[8]; 3003 struct cmd_config_rss_reta *res = parsed_result; 3004 3005 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 3006 if (ret != 0) 3007 return; 3008 3009 if (dev_info.reta_size == 0) { 3010 fprintf(stderr, 3011 "Redirection table size is 0 which is invalid for RSS\n"); 3012 return; 3013 } else 3014 printf("The reta size of port %d is %u\n", 3015 res->port_id, dev_info.reta_size); 3016 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 3017 fprintf(stderr, 3018 "Currently do not support more than %u entries of redirection table\n", 3019 ETH_RSS_RETA_SIZE_512); 3020 return; 3021 } 3022 3023 memset(reta_conf, 0, sizeof(reta_conf)); 3024 if (!strcmp(res->list_name, "reta")) { 3025 if (parse_reta_config(res->list_of_items, reta_conf, 3026 dev_info.reta_size)) { 3027 fprintf(stderr, 3028 "Invalid RSS Redirection Table config entered\n"); 3029 return; 3030 } 3031 ret = rte_eth_dev_rss_reta_update(res->port_id, 3032 reta_conf, dev_info.reta_size); 3033 if (ret != 0) 3034 fprintf(stderr, 3035 "Bad redirection table parameter, return code = %d\n", 3036 ret); 3037 } 3038 } 3039 3040 cmdline_parse_token_string_t cmd_config_rss_reta_port = 3041 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 3042 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 3043 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 3044 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 3045 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16); 3046 cmdline_parse_token_string_t cmd_config_rss_reta_name = 3047 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 3048 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 3049 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 3050 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 3051 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 3052 NULL); 3053 cmdline_parse_inst_t cmd_config_rss_reta = { 3054 .f = cmd_set_rss_reta_parsed, 3055 .data = NULL, 3056 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 3057 .tokens = { 3058 (void *)&cmd_config_rss_reta_port, 3059 (void *)&cmd_config_rss_reta_keyword, 3060 (void *)&cmd_config_rss_reta_port_id, 3061 (void *)&cmd_config_rss_reta_name, 3062 (void *)&cmd_config_rss_reta_list_name, 3063 (void *)&cmd_config_rss_reta_list_of_items, 3064 NULL, 3065 }, 3066 }; 3067 3068 /* *** SHOW PORT RETA INFO *** */ 3069 struct cmd_showport_reta { 3070 cmdline_fixed_string_t show; 3071 cmdline_fixed_string_t port; 3072 portid_t port_id; 3073 cmdline_fixed_string_t rss; 3074 cmdline_fixed_string_t reta; 3075 uint16_t size; 3076 cmdline_fixed_string_t list_of_items; 3077 }; 3078 3079 static int 3080 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 3081 uint16_t nb_entries, 3082 char *str) 3083 { 3084 uint32_t size; 3085 const char *p, *p0 = str; 3086 char s[256]; 3087 char *end; 3088 char *str_fld[8]; 3089 uint16_t i; 3090 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 3091 RTE_RETA_GROUP_SIZE; 3092 int ret; 3093 3094 p = strchr(p0, '('); 3095 if (p == NULL) 3096 return -1; 3097 p++; 3098 p0 = strchr(p, ')'); 3099 if (p0 == NULL) 3100 return -1; 3101 size = p0 - p; 3102 if (size >= sizeof(s)) { 3103 fprintf(stderr, 3104 "The string size exceeds the internal buffer size\n"); 3105 return -1; 3106 } 3107 snprintf(s, sizeof(s), "%.*s", size, p); 3108 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 3109 if (ret <= 0 || ret != num) { 3110 fprintf(stderr, 3111 "The bits of masks do not match the number of reta entries: %u\n", 3112 num); 3113 return -1; 3114 } 3115 for (i = 0; i < ret; i++) 3116 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 3117 3118 return 0; 3119 } 3120 3121 static void 3122 cmd_showport_reta_parsed(void *parsed_result, 3123 __rte_unused struct cmdline *cl, 3124 __rte_unused void *data) 3125 { 3126 struct cmd_showport_reta *res = parsed_result; 3127 struct rte_eth_rss_reta_entry64 reta_conf[8]; 3128 struct rte_eth_dev_info dev_info; 3129 uint16_t max_reta_size; 3130 int ret; 3131 3132 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 3133 if (ret != 0) 3134 return; 3135 3136 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 3137 if (res->size == 0 || res->size > max_reta_size) { 3138 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n", 3139 res->size, max_reta_size); 3140 return; 3141 } 3142 3143 memset(reta_conf, 0, sizeof(reta_conf)); 3144 if (showport_parse_reta_config(reta_conf, res->size, 3145 res->list_of_items) < 0) { 3146 fprintf(stderr, "Invalid string: %s for reta masks\n", 3147 res->list_of_items); 3148 return; 3149 } 3150 port_rss_reta_info(res->port_id, reta_conf, res->size); 3151 } 3152 3153 cmdline_parse_token_string_t cmd_showport_reta_show = 3154 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 3155 cmdline_parse_token_string_t cmd_showport_reta_port = 3156 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 3157 cmdline_parse_token_num_t cmd_showport_reta_port_id = 3158 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16); 3159 cmdline_parse_token_string_t cmd_showport_reta_rss = 3160 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 3161 cmdline_parse_token_string_t cmd_showport_reta_reta = 3162 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 3163 cmdline_parse_token_num_t cmd_showport_reta_size = 3164 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16); 3165 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 3166 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 3167 list_of_items, NULL); 3168 3169 cmdline_parse_inst_t cmd_showport_reta = { 3170 .f = cmd_showport_reta_parsed, 3171 .data = NULL, 3172 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 3173 .tokens = { 3174 (void *)&cmd_showport_reta_show, 3175 (void *)&cmd_showport_reta_port, 3176 (void *)&cmd_showport_reta_port_id, 3177 (void *)&cmd_showport_reta_rss, 3178 (void *)&cmd_showport_reta_reta, 3179 (void *)&cmd_showport_reta_size, 3180 (void *)&cmd_showport_reta_list_of_items, 3181 NULL, 3182 }, 3183 }; 3184 3185 /* *** Show RSS hash configuration *** */ 3186 struct cmd_showport_rss_hash { 3187 cmdline_fixed_string_t show; 3188 cmdline_fixed_string_t port; 3189 portid_t port_id; 3190 cmdline_fixed_string_t rss_hash; 3191 cmdline_fixed_string_t rss_type; 3192 cmdline_fixed_string_t key; /* optional argument */ 3193 }; 3194 3195 static void cmd_showport_rss_hash_parsed(void *parsed_result, 3196 __rte_unused struct cmdline *cl, 3197 void *show_rss_key) 3198 { 3199 struct cmd_showport_rss_hash *res = parsed_result; 3200 3201 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); 3202 } 3203 3204 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 3205 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 3206 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 3207 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 3208 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 3209 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, 3210 RTE_UINT16); 3211 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 3212 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 3213 "rss-hash"); 3214 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 3215 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 3216 3217 cmdline_parse_inst_t cmd_showport_rss_hash = { 3218 .f = cmd_showport_rss_hash_parsed, 3219 .data = NULL, 3220 .help_str = "show port <port_id> rss-hash", 3221 .tokens = { 3222 (void *)&cmd_showport_rss_hash_show, 3223 (void *)&cmd_showport_rss_hash_port, 3224 (void *)&cmd_showport_rss_hash_port_id, 3225 (void *)&cmd_showport_rss_hash_rss_hash, 3226 NULL, 3227 }, 3228 }; 3229 3230 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 3231 .f = cmd_showport_rss_hash_parsed, 3232 .data = (void *)1, 3233 .help_str = "show port <port_id> rss-hash key", 3234 .tokens = { 3235 (void *)&cmd_showport_rss_hash_show, 3236 (void *)&cmd_showport_rss_hash_port, 3237 (void *)&cmd_showport_rss_hash_port_id, 3238 (void *)&cmd_showport_rss_hash_rss_hash, 3239 (void *)&cmd_showport_rss_hash_rss_key, 3240 NULL, 3241 }, 3242 }; 3243 3244 /* *** Configure DCB *** */ 3245 struct cmd_config_dcb { 3246 cmdline_fixed_string_t port; 3247 cmdline_fixed_string_t config; 3248 portid_t port_id; 3249 cmdline_fixed_string_t dcb; 3250 cmdline_fixed_string_t vt; 3251 cmdline_fixed_string_t vt_en; 3252 uint8_t num_tcs; 3253 cmdline_fixed_string_t pfc; 3254 cmdline_fixed_string_t pfc_en; 3255 }; 3256 3257 static void 3258 cmd_config_dcb_parsed(void *parsed_result, 3259 __rte_unused struct cmdline *cl, 3260 __rte_unused void *data) 3261 { 3262 struct cmd_config_dcb *res = parsed_result; 3263 struct rte_eth_dcb_info dcb_info; 3264 portid_t port_id = res->port_id; 3265 struct rte_port *port; 3266 uint8_t pfc_en; 3267 int ret; 3268 3269 port = &ports[port_id]; 3270 /** Check if the port is not started **/ 3271 if (port->port_status != RTE_PORT_STOPPED) { 3272 fprintf(stderr, "Please stop port %d first\n", port_id); 3273 return; 3274 } 3275 3276 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 3277 fprintf(stderr, 3278 "The invalid number of traffic class, only 4 or 8 allowed.\n"); 3279 return; 3280 } 3281 3282 if (nb_fwd_lcores < res->num_tcs) { 3283 fprintf(stderr, 3284 "nb_cores shouldn't be less than number of TCs.\n"); 3285 return; 3286 } 3287 3288 /* Check whether the port supports the report of DCB info. */ 3289 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info); 3290 if (ret == -ENOTSUP) { 3291 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n"); 3292 return; 3293 } 3294 3295 if (!strncmp(res->pfc_en, "on", 2)) 3296 pfc_en = 1; 3297 else 3298 pfc_en = 0; 3299 3300 /* DCB in VT mode */ 3301 if (!strncmp(res->vt_en, "on", 2)) 3302 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 3303 (enum rte_eth_nb_tcs)res->num_tcs, 3304 pfc_en); 3305 else 3306 ret = init_port_dcb_config(port_id, DCB_ENABLED, 3307 (enum rte_eth_nb_tcs)res->num_tcs, 3308 pfc_en); 3309 if (ret != 0) { 3310 fprintf(stderr, "Cannot initialize network ports.\n"); 3311 return; 3312 } 3313 3314 fwd_config_setup(); 3315 3316 cmd_reconfig_device_queue(port_id, 1, 1); 3317 } 3318 3319 cmdline_parse_token_string_t cmd_config_dcb_port = 3320 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 3321 cmdline_parse_token_string_t cmd_config_dcb_config = 3322 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 3323 cmdline_parse_token_num_t cmd_config_dcb_port_id = 3324 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16); 3325 cmdline_parse_token_string_t cmd_config_dcb_dcb = 3326 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 3327 cmdline_parse_token_string_t cmd_config_dcb_vt = 3328 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 3329 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 3330 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 3331 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 3332 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8); 3333 cmdline_parse_token_string_t cmd_config_dcb_pfc= 3334 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 3335 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 3336 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 3337 3338 cmdline_parse_inst_t cmd_config_dcb = { 3339 .f = cmd_config_dcb_parsed, 3340 .data = NULL, 3341 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 3342 .tokens = { 3343 (void *)&cmd_config_dcb_port, 3344 (void *)&cmd_config_dcb_config, 3345 (void *)&cmd_config_dcb_port_id, 3346 (void *)&cmd_config_dcb_dcb, 3347 (void *)&cmd_config_dcb_vt, 3348 (void *)&cmd_config_dcb_vt_en, 3349 (void *)&cmd_config_dcb_num_tcs, 3350 (void *)&cmd_config_dcb_pfc, 3351 (void *)&cmd_config_dcb_pfc_en, 3352 NULL, 3353 }, 3354 }; 3355 3356 /* *** configure number of packets per burst *** */ 3357 struct cmd_config_burst { 3358 cmdline_fixed_string_t port; 3359 cmdline_fixed_string_t keyword; 3360 cmdline_fixed_string_t all; 3361 cmdline_fixed_string_t name; 3362 uint16_t value; 3363 }; 3364 3365 static void 3366 cmd_config_burst_parsed(void *parsed_result, 3367 __rte_unused struct cmdline *cl, 3368 __rte_unused void *data) 3369 { 3370 struct cmd_config_burst *res = parsed_result; 3371 struct rte_eth_dev_info dev_info; 3372 uint16_t rec_nb_pkts; 3373 int ret; 3374 3375 if (!all_ports_stopped()) { 3376 fprintf(stderr, "Please stop all ports first\n"); 3377 return; 3378 } 3379 3380 if (!strcmp(res->name, "burst")) { 3381 if (res->value == 0) { 3382 /* If user gives a value of zero, query the PMD for 3383 * its recommended Rx burst size. Testpmd uses a single 3384 * size for all ports, so assume all ports are the same 3385 * NIC model and use the values from Port 0. 3386 */ 3387 ret = eth_dev_info_get_print_err(0, &dev_info); 3388 if (ret != 0) 3389 return; 3390 3391 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 3392 3393 if (rec_nb_pkts == 0) { 3394 printf("PMD does not recommend a burst size.\n" 3395 "User provided value must be between" 3396 " 1 and %d\n", MAX_PKT_BURST); 3397 return; 3398 } else if (rec_nb_pkts > MAX_PKT_BURST) { 3399 printf("PMD recommended burst size of %d" 3400 " exceeds maximum value of %d\n", 3401 rec_nb_pkts, MAX_PKT_BURST); 3402 return; 3403 } 3404 printf("Using PMD-provided burst value of %d\n", 3405 rec_nb_pkts); 3406 nb_pkt_per_burst = rec_nb_pkts; 3407 } else if (res->value > MAX_PKT_BURST) { 3408 fprintf(stderr, "burst must be >= 1 && <= %d\n", 3409 MAX_PKT_BURST); 3410 return; 3411 } else 3412 nb_pkt_per_burst = res->value; 3413 } else { 3414 fprintf(stderr, "Unknown parameter\n"); 3415 return; 3416 } 3417 3418 init_port_config(); 3419 3420 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3421 } 3422 3423 cmdline_parse_token_string_t cmd_config_burst_port = 3424 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3425 cmdline_parse_token_string_t cmd_config_burst_keyword = 3426 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3427 cmdline_parse_token_string_t cmd_config_burst_all = 3428 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3429 cmdline_parse_token_string_t cmd_config_burst_name = 3430 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3431 cmdline_parse_token_num_t cmd_config_burst_value = 3432 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16); 3433 3434 cmdline_parse_inst_t cmd_config_burst = { 3435 .f = cmd_config_burst_parsed, 3436 .data = NULL, 3437 .help_str = "port config all burst <value>", 3438 .tokens = { 3439 (void *)&cmd_config_burst_port, 3440 (void *)&cmd_config_burst_keyword, 3441 (void *)&cmd_config_burst_all, 3442 (void *)&cmd_config_burst_name, 3443 (void *)&cmd_config_burst_value, 3444 NULL, 3445 }, 3446 }; 3447 3448 /* *** configure rx/tx queues *** */ 3449 struct cmd_config_thresh { 3450 cmdline_fixed_string_t port; 3451 cmdline_fixed_string_t keyword; 3452 cmdline_fixed_string_t all; 3453 cmdline_fixed_string_t name; 3454 uint8_t value; 3455 }; 3456 3457 static void 3458 cmd_config_thresh_parsed(void *parsed_result, 3459 __rte_unused struct cmdline *cl, 3460 __rte_unused void *data) 3461 { 3462 struct cmd_config_thresh *res = parsed_result; 3463 3464 if (!all_ports_stopped()) { 3465 fprintf(stderr, "Please stop all ports first\n"); 3466 return; 3467 } 3468 3469 if (!strcmp(res->name, "txpt")) 3470 tx_pthresh = res->value; 3471 else if(!strcmp(res->name, "txht")) 3472 tx_hthresh = res->value; 3473 else if(!strcmp(res->name, "txwt")) 3474 tx_wthresh = res->value; 3475 else if(!strcmp(res->name, "rxpt")) 3476 rx_pthresh = res->value; 3477 else if(!strcmp(res->name, "rxht")) 3478 rx_hthresh = res->value; 3479 else if(!strcmp(res->name, "rxwt")) 3480 rx_wthresh = res->value; 3481 else { 3482 fprintf(stderr, "Unknown parameter\n"); 3483 return; 3484 } 3485 3486 init_port_config(); 3487 3488 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3489 } 3490 3491 cmdline_parse_token_string_t cmd_config_thresh_port = 3492 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3493 cmdline_parse_token_string_t cmd_config_thresh_keyword = 3494 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3495 cmdline_parse_token_string_t cmd_config_thresh_all = 3496 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3497 cmdline_parse_token_string_t cmd_config_thresh_name = 3498 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3499 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3500 cmdline_parse_token_num_t cmd_config_thresh_value = 3501 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8); 3502 3503 cmdline_parse_inst_t cmd_config_thresh = { 3504 .f = cmd_config_thresh_parsed, 3505 .data = NULL, 3506 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3507 .tokens = { 3508 (void *)&cmd_config_thresh_port, 3509 (void *)&cmd_config_thresh_keyword, 3510 (void *)&cmd_config_thresh_all, 3511 (void *)&cmd_config_thresh_name, 3512 (void *)&cmd_config_thresh_value, 3513 NULL, 3514 }, 3515 }; 3516 3517 /* *** configure free/rs threshold *** */ 3518 struct cmd_config_threshold { 3519 cmdline_fixed_string_t port; 3520 cmdline_fixed_string_t keyword; 3521 cmdline_fixed_string_t all; 3522 cmdline_fixed_string_t name; 3523 uint16_t value; 3524 }; 3525 3526 static void 3527 cmd_config_threshold_parsed(void *parsed_result, 3528 __rte_unused struct cmdline *cl, 3529 __rte_unused void *data) 3530 { 3531 struct cmd_config_threshold *res = parsed_result; 3532 3533 if (!all_ports_stopped()) { 3534 fprintf(stderr, "Please stop all ports first\n"); 3535 return; 3536 } 3537 3538 if (!strcmp(res->name, "txfreet")) 3539 tx_free_thresh = res->value; 3540 else if (!strcmp(res->name, "txrst")) 3541 tx_rs_thresh = res->value; 3542 else if (!strcmp(res->name, "rxfreet")) 3543 rx_free_thresh = res->value; 3544 else { 3545 fprintf(stderr, "Unknown parameter\n"); 3546 return; 3547 } 3548 3549 init_port_config(); 3550 3551 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3552 } 3553 3554 cmdline_parse_token_string_t cmd_config_threshold_port = 3555 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3556 cmdline_parse_token_string_t cmd_config_threshold_keyword = 3557 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3558 "config"); 3559 cmdline_parse_token_string_t cmd_config_threshold_all = 3560 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3561 cmdline_parse_token_string_t cmd_config_threshold_name = 3562 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3563 "txfreet#txrst#rxfreet"); 3564 cmdline_parse_token_num_t cmd_config_threshold_value = 3565 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16); 3566 3567 cmdline_parse_inst_t cmd_config_threshold = { 3568 .f = cmd_config_threshold_parsed, 3569 .data = NULL, 3570 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3571 .tokens = { 3572 (void *)&cmd_config_threshold_port, 3573 (void *)&cmd_config_threshold_keyword, 3574 (void *)&cmd_config_threshold_all, 3575 (void *)&cmd_config_threshold_name, 3576 (void *)&cmd_config_threshold_value, 3577 NULL, 3578 }, 3579 }; 3580 3581 /* *** stop *** */ 3582 struct cmd_stop_result { 3583 cmdline_fixed_string_t stop; 3584 }; 3585 3586 static void cmd_stop_parsed(__rte_unused void *parsed_result, 3587 __rte_unused struct cmdline *cl, 3588 __rte_unused void *data) 3589 { 3590 stop_packet_forwarding(); 3591 } 3592 3593 cmdline_parse_token_string_t cmd_stop_stop = 3594 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3595 3596 cmdline_parse_inst_t cmd_stop = { 3597 .f = cmd_stop_parsed, 3598 .data = NULL, 3599 .help_str = "stop: Stop packet forwarding", 3600 .tokens = { 3601 (void *)&cmd_stop_stop, 3602 NULL, 3603 }, 3604 }; 3605 3606 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3607 3608 unsigned int 3609 parse_item_list(const char *str, const char *item_name, unsigned int max_items, 3610 unsigned int *parsed_items, int check_unique_values) 3611 { 3612 unsigned int nb_item; 3613 unsigned int value; 3614 unsigned int i; 3615 unsigned int j; 3616 int value_ok; 3617 char c; 3618 3619 /* 3620 * First parse all items in the list and store their value. 3621 */ 3622 value = 0; 3623 nb_item = 0; 3624 value_ok = 0; 3625 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3626 c = str[i]; 3627 if ((c >= '0') && (c <= '9')) { 3628 value = (unsigned int) (value * 10 + (c - '0')); 3629 value_ok = 1; 3630 continue; 3631 } 3632 if (c != ',') { 3633 fprintf(stderr, "character %c is not a decimal digit\n", c); 3634 return 0; 3635 } 3636 if (! value_ok) { 3637 fprintf(stderr, "No valid value before comma\n"); 3638 return 0; 3639 } 3640 if (nb_item < max_items) { 3641 parsed_items[nb_item] = value; 3642 value_ok = 0; 3643 value = 0; 3644 } 3645 nb_item++; 3646 } 3647 if (nb_item >= max_items) { 3648 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n", 3649 item_name, nb_item + 1, max_items); 3650 return 0; 3651 } 3652 parsed_items[nb_item++] = value; 3653 if (! check_unique_values) 3654 return nb_item; 3655 3656 /* 3657 * Then, check that all values in the list are differents. 3658 * No optimization here... 3659 */ 3660 for (i = 0; i < nb_item; i++) { 3661 for (j = i + 1; j < nb_item; j++) { 3662 if (parsed_items[j] == parsed_items[i]) { 3663 fprintf(stderr, 3664 "duplicated %s %u at index %u and %u\n", 3665 item_name, parsed_items[i], i, j); 3666 return 0; 3667 } 3668 } 3669 } 3670 return nb_item; 3671 } 3672 3673 struct cmd_set_list_result { 3674 cmdline_fixed_string_t cmd_keyword; 3675 cmdline_fixed_string_t list_name; 3676 cmdline_fixed_string_t list_of_items; 3677 }; 3678 3679 static void cmd_set_list_parsed(void *parsed_result, 3680 __rte_unused struct cmdline *cl, 3681 __rte_unused void *data) 3682 { 3683 struct cmd_set_list_result *res; 3684 union { 3685 unsigned int lcorelist[RTE_MAX_LCORE]; 3686 unsigned int portlist[RTE_MAX_ETHPORTS]; 3687 } parsed_items; 3688 unsigned int nb_item; 3689 3690 if (test_done == 0) { 3691 fprintf(stderr, "Please stop forwarding first\n"); 3692 return; 3693 } 3694 3695 res = parsed_result; 3696 if (!strcmp(res->list_name, "corelist")) { 3697 nb_item = parse_item_list(res->list_of_items, "core", 3698 RTE_MAX_LCORE, 3699 parsed_items.lcorelist, 1); 3700 if (nb_item > 0) { 3701 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3702 fwd_config_setup(); 3703 } 3704 return; 3705 } 3706 if (!strcmp(res->list_name, "portlist")) { 3707 nb_item = parse_item_list(res->list_of_items, "port", 3708 RTE_MAX_ETHPORTS, 3709 parsed_items.portlist, 1); 3710 if (nb_item > 0) { 3711 set_fwd_ports_list(parsed_items.portlist, nb_item); 3712 fwd_config_setup(); 3713 } 3714 } 3715 } 3716 3717 cmdline_parse_token_string_t cmd_set_list_keyword = 3718 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3719 "set"); 3720 cmdline_parse_token_string_t cmd_set_list_name = 3721 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3722 "corelist#portlist"); 3723 cmdline_parse_token_string_t cmd_set_list_of_items = 3724 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3725 NULL); 3726 3727 cmdline_parse_inst_t cmd_set_fwd_list = { 3728 .f = cmd_set_list_parsed, 3729 .data = NULL, 3730 .help_str = "set corelist|portlist <list0[,list1]*>", 3731 .tokens = { 3732 (void *)&cmd_set_list_keyword, 3733 (void *)&cmd_set_list_name, 3734 (void *)&cmd_set_list_of_items, 3735 NULL, 3736 }, 3737 }; 3738 3739 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3740 3741 struct cmd_setmask_result { 3742 cmdline_fixed_string_t set; 3743 cmdline_fixed_string_t mask; 3744 uint64_t hexavalue; 3745 }; 3746 3747 static void cmd_set_mask_parsed(void *parsed_result, 3748 __rte_unused struct cmdline *cl, 3749 __rte_unused void *data) 3750 { 3751 struct cmd_setmask_result *res = parsed_result; 3752 3753 if (test_done == 0) { 3754 fprintf(stderr, "Please stop forwarding first\n"); 3755 return; 3756 } 3757 if (!strcmp(res->mask, "coremask")) { 3758 set_fwd_lcores_mask(res->hexavalue); 3759 fwd_config_setup(); 3760 } else if (!strcmp(res->mask, "portmask")) { 3761 set_fwd_ports_mask(res->hexavalue); 3762 fwd_config_setup(); 3763 } 3764 } 3765 3766 cmdline_parse_token_string_t cmd_setmask_set = 3767 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3768 cmdline_parse_token_string_t cmd_setmask_mask = 3769 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3770 "coremask#portmask"); 3771 cmdline_parse_token_num_t cmd_setmask_value = 3772 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64); 3773 3774 cmdline_parse_inst_t cmd_set_fwd_mask = { 3775 .f = cmd_set_mask_parsed, 3776 .data = NULL, 3777 .help_str = "set coremask|portmask <hexadecimal value>", 3778 .tokens = { 3779 (void *)&cmd_setmask_set, 3780 (void *)&cmd_setmask_mask, 3781 (void *)&cmd_setmask_value, 3782 NULL, 3783 }, 3784 }; 3785 3786 /* 3787 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3788 */ 3789 struct cmd_set_result { 3790 cmdline_fixed_string_t set; 3791 cmdline_fixed_string_t what; 3792 uint16_t value; 3793 }; 3794 3795 static void cmd_set_parsed(void *parsed_result, 3796 __rte_unused struct cmdline *cl, 3797 __rte_unused void *data) 3798 { 3799 struct cmd_set_result *res = parsed_result; 3800 if (!strcmp(res->what, "nbport")) { 3801 set_fwd_ports_number(res->value); 3802 fwd_config_setup(); 3803 } else if (!strcmp(res->what, "nbcore")) { 3804 set_fwd_lcores_number(res->value); 3805 fwd_config_setup(); 3806 } else if (!strcmp(res->what, "burst")) 3807 set_nb_pkt_per_burst(res->value); 3808 else if (!strcmp(res->what, "verbose")) 3809 set_verbose_level(res->value); 3810 } 3811 3812 cmdline_parse_token_string_t cmd_set_set = 3813 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3814 cmdline_parse_token_string_t cmd_set_what = 3815 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3816 "nbport#nbcore#burst#verbose"); 3817 cmdline_parse_token_num_t cmd_set_value = 3818 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16); 3819 3820 cmdline_parse_inst_t cmd_set_numbers = { 3821 .f = cmd_set_parsed, 3822 .data = NULL, 3823 .help_str = "set nbport|nbcore|burst|verbose <value>", 3824 .tokens = { 3825 (void *)&cmd_set_set, 3826 (void *)&cmd_set_what, 3827 (void *)&cmd_set_value, 3828 NULL, 3829 }, 3830 }; 3831 3832 /* *** SET LOG LEVEL CONFIGURATION *** */ 3833 3834 struct cmd_set_log_result { 3835 cmdline_fixed_string_t set; 3836 cmdline_fixed_string_t log; 3837 cmdline_fixed_string_t type; 3838 uint32_t level; 3839 }; 3840 3841 static void 3842 cmd_set_log_parsed(void *parsed_result, 3843 __rte_unused struct cmdline *cl, 3844 __rte_unused void *data) 3845 { 3846 struct cmd_set_log_result *res; 3847 int ret; 3848 3849 res = parsed_result; 3850 if (!strcmp(res->type, "global")) 3851 rte_log_set_global_level(res->level); 3852 else { 3853 ret = rte_log_set_level_regexp(res->type, res->level); 3854 if (ret < 0) 3855 fprintf(stderr, "Unable to set log level\n"); 3856 } 3857 } 3858 3859 cmdline_parse_token_string_t cmd_set_log_set = 3860 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3861 cmdline_parse_token_string_t cmd_set_log_log = 3862 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3863 cmdline_parse_token_string_t cmd_set_log_type = 3864 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3865 cmdline_parse_token_num_t cmd_set_log_level = 3866 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32); 3867 3868 cmdline_parse_inst_t cmd_set_log = { 3869 .f = cmd_set_log_parsed, 3870 .data = NULL, 3871 .help_str = "set log global|<type> <level>", 3872 .tokens = { 3873 (void *)&cmd_set_log_set, 3874 (void *)&cmd_set_log_log, 3875 (void *)&cmd_set_log_type, 3876 (void *)&cmd_set_log_level, 3877 NULL, 3878 }, 3879 }; 3880 3881 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */ 3882 3883 struct cmd_set_rxoffs_result { 3884 cmdline_fixed_string_t cmd_keyword; 3885 cmdline_fixed_string_t rxoffs; 3886 cmdline_fixed_string_t seg_offsets; 3887 }; 3888 3889 static void 3890 cmd_set_rxoffs_parsed(void *parsed_result, 3891 __rte_unused struct cmdline *cl, 3892 __rte_unused void *data) 3893 { 3894 struct cmd_set_rxoffs_result *res; 3895 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT]; 3896 unsigned int nb_segs; 3897 3898 res = parsed_result; 3899 nb_segs = parse_item_list(res->seg_offsets, "segment offsets", 3900 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0); 3901 if (nb_segs > 0) 3902 set_rx_pkt_offsets(seg_offsets, nb_segs); 3903 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1); 3904 } 3905 3906 cmdline_parse_token_string_t cmd_set_rxoffs_keyword = 3907 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3908 cmd_keyword, "set"); 3909 cmdline_parse_token_string_t cmd_set_rxoffs_name = 3910 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3911 rxoffs, "rxoffs"); 3912 cmdline_parse_token_string_t cmd_set_rxoffs_offsets = 3913 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3914 seg_offsets, NULL); 3915 3916 cmdline_parse_inst_t cmd_set_rxoffs = { 3917 .f = cmd_set_rxoffs_parsed, 3918 .data = NULL, 3919 .help_str = "set rxoffs <len0[,len1]*>", 3920 .tokens = { 3921 (void *)&cmd_set_rxoffs_keyword, 3922 (void *)&cmd_set_rxoffs_name, 3923 (void *)&cmd_set_rxoffs_offsets, 3924 NULL, 3925 }, 3926 }; 3927 3928 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */ 3929 3930 struct cmd_set_rxpkts_result { 3931 cmdline_fixed_string_t cmd_keyword; 3932 cmdline_fixed_string_t rxpkts; 3933 cmdline_fixed_string_t seg_lengths; 3934 }; 3935 3936 static void 3937 cmd_set_rxpkts_parsed(void *parsed_result, 3938 __rte_unused struct cmdline *cl, 3939 __rte_unused void *data) 3940 { 3941 struct cmd_set_rxpkts_result *res; 3942 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT]; 3943 unsigned int nb_segs; 3944 3945 res = parsed_result; 3946 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3947 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0); 3948 if (nb_segs > 0) 3949 set_rx_pkt_segments(seg_lengths, nb_segs); 3950 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1); 3951 } 3952 3953 cmdline_parse_token_string_t cmd_set_rxpkts_keyword = 3954 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3955 cmd_keyword, "set"); 3956 cmdline_parse_token_string_t cmd_set_rxpkts_name = 3957 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3958 rxpkts, "rxpkts"); 3959 cmdline_parse_token_string_t cmd_set_rxpkts_lengths = 3960 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3961 seg_lengths, NULL); 3962 3963 cmdline_parse_inst_t cmd_set_rxpkts = { 3964 .f = cmd_set_rxpkts_parsed, 3965 .data = NULL, 3966 .help_str = "set rxpkts <len0[,len1]*>", 3967 .tokens = { 3968 (void *)&cmd_set_rxpkts_keyword, 3969 (void *)&cmd_set_rxpkts_name, 3970 (void *)&cmd_set_rxpkts_lengths, 3971 NULL, 3972 }, 3973 }; 3974 3975 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3976 3977 struct cmd_set_txpkts_result { 3978 cmdline_fixed_string_t cmd_keyword; 3979 cmdline_fixed_string_t txpkts; 3980 cmdline_fixed_string_t seg_lengths; 3981 }; 3982 3983 static void 3984 cmd_set_txpkts_parsed(void *parsed_result, 3985 __rte_unused struct cmdline *cl, 3986 __rte_unused void *data) 3987 { 3988 struct cmd_set_txpkts_result *res; 3989 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3990 unsigned int nb_segs; 3991 3992 res = parsed_result; 3993 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3994 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3995 if (nb_segs > 0) 3996 set_tx_pkt_segments(seg_lengths, nb_segs); 3997 } 3998 3999 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 4000 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 4001 cmd_keyword, "set"); 4002 cmdline_parse_token_string_t cmd_set_txpkts_name = 4003 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 4004 txpkts, "txpkts"); 4005 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 4006 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 4007 seg_lengths, NULL); 4008 4009 cmdline_parse_inst_t cmd_set_txpkts = { 4010 .f = cmd_set_txpkts_parsed, 4011 .data = NULL, 4012 .help_str = "set txpkts <len0[,len1]*>", 4013 .tokens = { 4014 (void *)&cmd_set_txpkts_keyword, 4015 (void *)&cmd_set_txpkts_name, 4016 (void *)&cmd_set_txpkts_lengths, 4017 NULL, 4018 }, 4019 }; 4020 4021 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 4022 4023 struct cmd_set_txsplit_result { 4024 cmdline_fixed_string_t cmd_keyword; 4025 cmdline_fixed_string_t txsplit; 4026 cmdline_fixed_string_t mode; 4027 }; 4028 4029 static void 4030 cmd_set_txsplit_parsed(void *parsed_result, 4031 __rte_unused struct cmdline *cl, 4032 __rte_unused void *data) 4033 { 4034 struct cmd_set_txsplit_result *res; 4035 4036 res = parsed_result; 4037 set_tx_pkt_split(res->mode); 4038 } 4039 4040 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 4041 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 4042 cmd_keyword, "set"); 4043 cmdline_parse_token_string_t cmd_set_txsplit_name = 4044 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 4045 txsplit, "txsplit"); 4046 cmdline_parse_token_string_t cmd_set_txsplit_mode = 4047 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 4048 mode, NULL); 4049 4050 cmdline_parse_inst_t cmd_set_txsplit = { 4051 .f = cmd_set_txsplit_parsed, 4052 .data = NULL, 4053 .help_str = "set txsplit on|off|rand", 4054 .tokens = { 4055 (void *)&cmd_set_txsplit_keyword, 4056 (void *)&cmd_set_txsplit_name, 4057 (void *)&cmd_set_txsplit_mode, 4058 NULL, 4059 }, 4060 }; 4061 4062 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */ 4063 4064 struct cmd_set_txtimes_result { 4065 cmdline_fixed_string_t cmd_keyword; 4066 cmdline_fixed_string_t txtimes; 4067 cmdline_fixed_string_t tx_times; 4068 }; 4069 4070 static void 4071 cmd_set_txtimes_parsed(void *parsed_result, 4072 __rte_unused struct cmdline *cl, 4073 __rte_unused void *data) 4074 { 4075 struct cmd_set_txtimes_result *res; 4076 unsigned int tx_times[2] = {0, 0}; 4077 unsigned int n_times; 4078 4079 res = parsed_result; 4080 n_times = parse_item_list(res->tx_times, "tx times", 4081 2, tx_times, 0); 4082 if (n_times == 2) 4083 set_tx_pkt_times(tx_times); 4084 } 4085 4086 cmdline_parse_token_string_t cmd_set_txtimes_keyword = 4087 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 4088 cmd_keyword, "set"); 4089 cmdline_parse_token_string_t cmd_set_txtimes_name = 4090 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 4091 txtimes, "txtimes"); 4092 cmdline_parse_token_string_t cmd_set_txtimes_value = 4093 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 4094 tx_times, NULL); 4095 4096 cmdline_parse_inst_t cmd_set_txtimes = { 4097 .f = cmd_set_txtimes_parsed, 4098 .data = NULL, 4099 .help_str = "set txtimes <inter_burst>,<intra_burst>", 4100 .tokens = { 4101 (void *)&cmd_set_txtimes_keyword, 4102 (void *)&cmd_set_txtimes_name, 4103 (void *)&cmd_set_txtimes_value, 4104 NULL, 4105 }, 4106 }; 4107 4108 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 4109 struct cmd_rx_vlan_filter_all_result { 4110 cmdline_fixed_string_t rx_vlan; 4111 cmdline_fixed_string_t what; 4112 cmdline_fixed_string_t all; 4113 portid_t port_id; 4114 }; 4115 4116 static void 4117 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 4118 __rte_unused struct cmdline *cl, 4119 __rte_unused void *data) 4120 { 4121 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 4122 4123 if (!strcmp(res->what, "add")) 4124 rx_vlan_all_filter_set(res->port_id, 1); 4125 else 4126 rx_vlan_all_filter_set(res->port_id, 0); 4127 } 4128 4129 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 4130 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4131 rx_vlan, "rx_vlan"); 4132 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 4133 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4134 what, "add#rm"); 4135 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 4136 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4137 all, "all"); 4138 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 4139 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4140 port_id, RTE_UINT16); 4141 4142 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 4143 .f = cmd_rx_vlan_filter_all_parsed, 4144 .data = NULL, 4145 .help_str = "rx_vlan add|rm all <port_id>: " 4146 "Add/Remove all identifiers to/from the set of VLAN " 4147 "identifiers filtered by a port", 4148 .tokens = { 4149 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 4150 (void *)&cmd_rx_vlan_filter_all_what, 4151 (void *)&cmd_rx_vlan_filter_all_all, 4152 (void *)&cmd_rx_vlan_filter_all_portid, 4153 NULL, 4154 }, 4155 }; 4156 4157 /* *** VLAN OFFLOAD SET ON A PORT *** */ 4158 struct cmd_vlan_offload_result { 4159 cmdline_fixed_string_t vlan; 4160 cmdline_fixed_string_t set; 4161 cmdline_fixed_string_t vlan_type; 4162 cmdline_fixed_string_t what; 4163 cmdline_fixed_string_t on; 4164 cmdline_fixed_string_t port_id; 4165 }; 4166 4167 static void 4168 cmd_vlan_offload_parsed(void *parsed_result, 4169 __rte_unused struct cmdline *cl, 4170 __rte_unused void *data) 4171 { 4172 int on; 4173 struct cmd_vlan_offload_result *res = parsed_result; 4174 char *str; 4175 int i, len = 0; 4176 portid_t port_id = 0; 4177 unsigned int tmp; 4178 4179 str = res->port_id; 4180 len = strnlen(str, STR_TOKEN_SIZE); 4181 i = 0; 4182 /* Get port_id first */ 4183 while(i < len){ 4184 if(str[i] == ',') 4185 break; 4186 4187 i++; 4188 } 4189 str[i]='\0'; 4190 tmp = strtoul(str, NULL, 0); 4191 /* If port_id greater that what portid_t can represent, return */ 4192 if(tmp >= RTE_MAX_ETHPORTS) 4193 return; 4194 port_id = (portid_t)tmp; 4195 4196 if (!strcmp(res->on, "on")) 4197 on = 1; 4198 else 4199 on = 0; 4200 4201 if (!strcmp(res->what, "strip")) 4202 rx_vlan_strip_set(port_id, on); 4203 else if(!strcmp(res->what, "stripq")){ 4204 uint16_t queue_id = 0; 4205 4206 /* No queue_id, return */ 4207 if(i + 1 >= len) { 4208 fprintf(stderr, "must specify (port,queue_id)\n"); 4209 return; 4210 } 4211 tmp = strtoul(str + i + 1, NULL, 0); 4212 /* If queue_id greater that what 16-bits can represent, return */ 4213 if(tmp > 0xffff) 4214 return; 4215 4216 queue_id = (uint16_t)tmp; 4217 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 4218 } 4219 else if (!strcmp(res->what, "filter")) 4220 rx_vlan_filter_set(port_id, on); 4221 else if (!strcmp(res->what, "qinq_strip")) 4222 rx_vlan_qinq_strip_set(port_id, on); 4223 else 4224 vlan_extend_set(port_id, on); 4225 4226 return; 4227 } 4228 4229 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 4230 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4231 vlan, "vlan"); 4232 cmdline_parse_token_string_t cmd_vlan_offload_set = 4233 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4234 set, "set"); 4235 cmdline_parse_token_string_t cmd_vlan_offload_what = 4236 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4237 what, "strip#filter#qinq_strip#extend#stripq"); 4238 cmdline_parse_token_string_t cmd_vlan_offload_on = 4239 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4240 on, "on#off"); 4241 cmdline_parse_token_string_t cmd_vlan_offload_portid = 4242 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4243 port_id, NULL); 4244 4245 cmdline_parse_inst_t cmd_vlan_offload = { 4246 .f = cmd_vlan_offload_parsed, 4247 .data = NULL, 4248 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off " 4249 "<port_id[,queue_id]>: " 4250 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides", 4251 .tokens = { 4252 (void *)&cmd_vlan_offload_vlan, 4253 (void *)&cmd_vlan_offload_set, 4254 (void *)&cmd_vlan_offload_what, 4255 (void *)&cmd_vlan_offload_on, 4256 (void *)&cmd_vlan_offload_portid, 4257 NULL, 4258 }, 4259 }; 4260 4261 /* *** VLAN TPID SET ON A PORT *** */ 4262 struct cmd_vlan_tpid_result { 4263 cmdline_fixed_string_t vlan; 4264 cmdline_fixed_string_t set; 4265 cmdline_fixed_string_t vlan_type; 4266 cmdline_fixed_string_t what; 4267 uint16_t tp_id; 4268 portid_t port_id; 4269 }; 4270 4271 static void 4272 cmd_vlan_tpid_parsed(void *parsed_result, 4273 __rte_unused struct cmdline *cl, 4274 __rte_unused void *data) 4275 { 4276 struct cmd_vlan_tpid_result *res = parsed_result; 4277 enum rte_vlan_type vlan_type; 4278 4279 if (!strcmp(res->vlan_type, "inner")) 4280 vlan_type = ETH_VLAN_TYPE_INNER; 4281 else if (!strcmp(res->vlan_type, "outer")) 4282 vlan_type = ETH_VLAN_TYPE_OUTER; 4283 else { 4284 fprintf(stderr, "Unknown vlan type\n"); 4285 return; 4286 } 4287 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 4288 } 4289 4290 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 4291 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4292 vlan, "vlan"); 4293 cmdline_parse_token_string_t cmd_vlan_tpid_set = 4294 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4295 set, "set"); 4296 cmdline_parse_token_string_t cmd_vlan_type = 4297 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4298 vlan_type, "inner#outer"); 4299 cmdline_parse_token_string_t cmd_vlan_tpid_what = 4300 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4301 what, "tpid"); 4302 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 4303 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4304 tp_id, RTE_UINT16); 4305 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 4306 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4307 port_id, RTE_UINT16); 4308 4309 cmdline_parse_inst_t cmd_vlan_tpid = { 4310 .f = cmd_vlan_tpid_parsed, 4311 .data = NULL, 4312 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 4313 "Set the VLAN Ether type", 4314 .tokens = { 4315 (void *)&cmd_vlan_tpid_vlan, 4316 (void *)&cmd_vlan_tpid_set, 4317 (void *)&cmd_vlan_type, 4318 (void *)&cmd_vlan_tpid_what, 4319 (void *)&cmd_vlan_tpid_tpid, 4320 (void *)&cmd_vlan_tpid_portid, 4321 NULL, 4322 }, 4323 }; 4324 4325 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 4326 struct cmd_rx_vlan_filter_result { 4327 cmdline_fixed_string_t rx_vlan; 4328 cmdline_fixed_string_t what; 4329 uint16_t vlan_id; 4330 portid_t port_id; 4331 }; 4332 4333 static void 4334 cmd_rx_vlan_filter_parsed(void *parsed_result, 4335 __rte_unused struct cmdline *cl, 4336 __rte_unused void *data) 4337 { 4338 struct cmd_rx_vlan_filter_result *res = parsed_result; 4339 4340 if (!strcmp(res->what, "add")) 4341 rx_vft_set(res->port_id, res->vlan_id, 1); 4342 else 4343 rx_vft_set(res->port_id, res->vlan_id, 0); 4344 } 4345 4346 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 4347 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4348 rx_vlan, "rx_vlan"); 4349 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 4350 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4351 what, "add#rm"); 4352 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 4353 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4354 vlan_id, RTE_UINT16); 4355 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 4356 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4357 port_id, RTE_UINT16); 4358 4359 cmdline_parse_inst_t cmd_rx_vlan_filter = { 4360 .f = cmd_rx_vlan_filter_parsed, 4361 .data = NULL, 4362 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 4363 "Add/Remove a VLAN identifier to/from the set of VLAN " 4364 "identifiers filtered by a port", 4365 .tokens = { 4366 (void *)&cmd_rx_vlan_filter_rx_vlan, 4367 (void *)&cmd_rx_vlan_filter_what, 4368 (void *)&cmd_rx_vlan_filter_vlanid, 4369 (void *)&cmd_rx_vlan_filter_portid, 4370 NULL, 4371 }, 4372 }; 4373 4374 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4375 struct cmd_tx_vlan_set_result { 4376 cmdline_fixed_string_t tx_vlan; 4377 cmdline_fixed_string_t set; 4378 portid_t port_id; 4379 uint16_t vlan_id; 4380 }; 4381 4382 static void 4383 cmd_tx_vlan_set_parsed(void *parsed_result, 4384 __rte_unused struct cmdline *cl, 4385 __rte_unused void *data) 4386 { 4387 struct cmd_tx_vlan_set_result *res = parsed_result; 4388 4389 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4390 return; 4391 4392 if (!port_is_stopped(res->port_id)) { 4393 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4394 return; 4395 } 4396 4397 tx_vlan_set(res->port_id, res->vlan_id); 4398 4399 cmd_reconfig_device_queue(res->port_id, 1, 1); 4400 } 4401 4402 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 4403 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4404 tx_vlan, "tx_vlan"); 4405 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 4406 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4407 set, "set"); 4408 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 4409 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4410 port_id, RTE_UINT16); 4411 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 4412 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4413 vlan_id, RTE_UINT16); 4414 4415 cmdline_parse_inst_t cmd_tx_vlan_set = { 4416 .f = cmd_tx_vlan_set_parsed, 4417 .data = NULL, 4418 .help_str = "tx_vlan set <port_id> <vlan_id>: " 4419 "Enable hardware insertion of a single VLAN header " 4420 "with a given TAG Identifier in packets sent on a port", 4421 .tokens = { 4422 (void *)&cmd_tx_vlan_set_tx_vlan, 4423 (void *)&cmd_tx_vlan_set_set, 4424 (void *)&cmd_tx_vlan_set_portid, 4425 (void *)&cmd_tx_vlan_set_vlanid, 4426 NULL, 4427 }, 4428 }; 4429 4430 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 4431 struct cmd_tx_vlan_set_qinq_result { 4432 cmdline_fixed_string_t tx_vlan; 4433 cmdline_fixed_string_t set; 4434 portid_t port_id; 4435 uint16_t vlan_id; 4436 uint16_t vlan_id_outer; 4437 }; 4438 4439 static void 4440 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 4441 __rte_unused struct cmdline *cl, 4442 __rte_unused void *data) 4443 { 4444 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 4445 4446 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4447 return; 4448 4449 if (!port_is_stopped(res->port_id)) { 4450 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4451 return; 4452 } 4453 4454 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 4455 4456 cmd_reconfig_device_queue(res->port_id, 1, 1); 4457 } 4458 4459 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 4460 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4461 tx_vlan, "tx_vlan"); 4462 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 4463 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4464 set, "set"); 4465 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 4466 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4467 port_id, RTE_UINT16); 4468 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 4469 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4470 vlan_id, RTE_UINT16); 4471 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 4472 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4473 vlan_id_outer, RTE_UINT16); 4474 4475 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 4476 .f = cmd_tx_vlan_set_qinq_parsed, 4477 .data = NULL, 4478 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 4479 "Enable hardware insertion of double VLAN header " 4480 "with given TAG Identifiers in packets sent on a port", 4481 .tokens = { 4482 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 4483 (void *)&cmd_tx_vlan_set_qinq_set, 4484 (void *)&cmd_tx_vlan_set_qinq_portid, 4485 (void *)&cmd_tx_vlan_set_qinq_vlanid, 4486 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 4487 NULL, 4488 }, 4489 }; 4490 4491 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 4492 struct cmd_tx_vlan_set_pvid_result { 4493 cmdline_fixed_string_t tx_vlan; 4494 cmdline_fixed_string_t set; 4495 cmdline_fixed_string_t pvid; 4496 portid_t port_id; 4497 uint16_t vlan_id; 4498 cmdline_fixed_string_t mode; 4499 }; 4500 4501 static void 4502 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 4503 __rte_unused struct cmdline *cl, 4504 __rte_unused void *data) 4505 { 4506 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 4507 4508 if (strcmp(res->mode, "on") == 0) 4509 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 4510 else 4511 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 4512 } 4513 4514 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 4515 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4516 tx_vlan, "tx_vlan"); 4517 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 4518 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4519 set, "set"); 4520 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 4521 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4522 pvid, "pvid"); 4523 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 4524 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4525 port_id, RTE_UINT16); 4526 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 4527 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4528 vlan_id, RTE_UINT16); 4529 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 4530 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4531 mode, "on#off"); 4532 4533 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 4534 .f = cmd_tx_vlan_set_pvid_parsed, 4535 .data = NULL, 4536 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 4537 .tokens = { 4538 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 4539 (void *)&cmd_tx_vlan_set_pvid_set, 4540 (void *)&cmd_tx_vlan_set_pvid_pvid, 4541 (void *)&cmd_tx_vlan_set_pvid_port_id, 4542 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 4543 (void *)&cmd_tx_vlan_set_pvid_mode, 4544 NULL, 4545 }, 4546 }; 4547 4548 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4549 struct cmd_tx_vlan_reset_result { 4550 cmdline_fixed_string_t tx_vlan; 4551 cmdline_fixed_string_t reset; 4552 portid_t port_id; 4553 }; 4554 4555 static void 4556 cmd_tx_vlan_reset_parsed(void *parsed_result, 4557 __rte_unused struct cmdline *cl, 4558 __rte_unused void *data) 4559 { 4560 struct cmd_tx_vlan_reset_result *res = parsed_result; 4561 4562 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4563 return; 4564 4565 if (!port_is_stopped(res->port_id)) { 4566 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4567 return; 4568 } 4569 4570 tx_vlan_reset(res->port_id); 4571 4572 cmd_reconfig_device_queue(res->port_id, 1, 1); 4573 } 4574 4575 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4576 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4577 tx_vlan, "tx_vlan"); 4578 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4579 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4580 reset, "reset"); 4581 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4582 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4583 port_id, RTE_UINT16); 4584 4585 cmdline_parse_inst_t cmd_tx_vlan_reset = { 4586 .f = cmd_tx_vlan_reset_parsed, 4587 .data = NULL, 4588 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4589 "VLAN header in packets sent on a port", 4590 .tokens = { 4591 (void *)&cmd_tx_vlan_reset_tx_vlan, 4592 (void *)&cmd_tx_vlan_reset_reset, 4593 (void *)&cmd_tx_vlan_reset_portid, 4594 NULL, 4595 }, 4596 }; 4597 4598 4599 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4600 struct cmd_csum_result { 4601 cmdline_fixed_string_t csum; 4602 cmdline_fixed_string_t mode; 4603 cmdline_fixed_string_t proto; 4604 cmdline_fixed_string_t hwsw; 4605 portid_t port_id; 4606 }; 4607 4608 static void 4609 csum_show(int port_id) 4610 { 4611 struct rte_eth_dev_info dev_info; 4612 uint64_t tx_offloads; 4613 int ret; 4614 4615 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4616 printf("Parse tunnel is %s\n", 4617 (ports[port_id].parse_tunnel) ? "on" : "off"); 4618 printf("IP checksum offload is %s\n", 4619 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4620 printf("UDP checksum offload is %s\n", 4621 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4622 printf("TCP checksum offload is %s\n", 4623 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4624 printf("SCTP checksum offload is %s\n", 4625 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4626 printf("Outer-Ip checksum offload is %s\n", 4627 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4628 printf("Outer-Udp checksum offload is %s\n", 4629 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); 4630 4631 /* display warnings if configuration is not supported by the NIC */ 4632 ret = eth_dev_info_get_print_err(port_id, &dev_info); 4633 if (ret != 0) 4634 return; 4635 4636 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 4637 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4638 fprintf(stderr, 4639 "Warning: hardware IP checksum enabled but not supported by port %d\n", 4640 port_id); 4641 } 4642 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 4643 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 4644 fprintf(stderr, 4645 "Warning: hardware UDP checksum enabled but not supported by port %d\n", 4646 port_id); 4647 } 4648 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 4649 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 4650 fprintf(stderr, 4651 "Warning: hardware TCP checksum enabled but not supported by port %d\n", 4652 port_id); 4653 } 4654 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 4655 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4656 fprintf(stderr, 4657 "Warning: hardware SCTP checksum enabled but not supported by port %d\n", 4658 port_id); 4659 } 4660 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4661 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4662 fprintf(stderr, 4663 "Warning: hardware outer IP checksum enabled but not supported by port %d\n", 4664 port_id); 4665 } 4666 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) && 4667 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) 4668 == 0) { 4669 fprintf(stderr, 4670 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n", 4671 port_id); 4672 } 4673 } 4674 4675 static void 4676 cmd_config_queue_tx_offloads(struct rte_port *port) 4677 { 4678 int k; 4679 4680 /* Apply queue tx offloads configuration */ 4681 for (k = 0; k < port->dev_info.max_tx_queues; k++) 4682 port->tx_conf[k].offloads = 4683 port->dev_conf.txmode.offloads; 4684 } 4685 4686 static void 4687 cmd_csum_parsed(void *parsed_result, 4688 __rte_unused struct cmdline *cl, 4689 __rte_unused void *data) 4690 { 4691 struct cmd_csum_result *res = parsed_result; 4692 int hw = 0; 4693 uint64_t csum_offloads = 0; 4694 struct rte_eth_dev_info dev_info; 4695 int ret; 4696 4697 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4698 fprintf(stderr, "invalid port %d\n", res->port_id); 4699 return; 4700 } 4701 if (!port_is_stopped(res->port_id)) { 4702 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4703 return; 4704 } 4705 4706 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4707 if (ret != 0) 4708 return; 4709 4710 if (!strcmp(res->mode, "set")) { 4711 4712 if (!strcmp(res->hwsw, "hw")) 4713 hw = 1; 4714 4715 if (!strcmp(res->proto, "ip")) { 4716 if (hw == 0 || (dev_info.tx_offload_capa & 4717 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 4718 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 4719 } else { 4720 fprintf(stderr, 4721 "IP checksum offload is not supported by port %u\n", 4722 res->port_id); 4723 } 4724 } else if (!strcmp(res->proto, "udp")) { 4725 if (hw == 0 || (dev_info.tx_offload_capa & 4726 DEV_TX_OFFLOAD_UDP_CKSUM)) { 4727 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 4728 } else { 4729 fprintf(stderr, 4730 "UDP checksum offload is not supported by port %u\n", 4731 res->port_id); 4732 } 4733 } else if (!strcmp(res->proto, "tcp")) { 4734 if (hw == 0 || (dev_info.tx_offload_capa & 4735 DEV_TX_OFFLOAD_TCP_CKSUM)) { 4736 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 4737 } else { 4738 fprintf(stderr, 4739 "TCP checksum offload is not supported by port %u\n", 4740 res->port_id); 4741 } 4742 } else if (!strcmp(res->proto, "sctp")) { 4743 if (hw == 0 || (dev_info.tx_offload_capa & 4744 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 4745 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 4746 } else { 4747 fprintf(stderr, 4748 "SCTP checksum offload is not supported by port %u\n", 4749 res->port_id); 4750 } 4751 } else if (!strcmp(res->proto, "outer-ip")) { 4752 if (hw == 0 || (dev_info.tx_offload_capa & 4753 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4754 csum_offloads |= 4755 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4756 } else { 4757 fprintf(stderr, 4758 "Outer IP checksum offload is not supported by port %u\n", 4759 res->port_id); 4760 } 4761 } else if (!strcmp(res->proto, "outer-udp")) { 4762 if (hw == 0 || (dev_info.tx_offload_capa & 4763 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) { 4764 csum_offloads |= 4765 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; 4766 } else { 4767 fprintf(stderr, 4768 "Outer UDP checksum offload is not supported by port %u\n", 4769 res->port_id); 4770 } 4771 } 4772 4773 if (hw) { 4774 ports[res->port_id].dev_conf.txmode.offloads |= 4775 csum_offloads; 4776 } else { 4777 ports[res->port_id].dev_conf.txmode.offloads &= 4778 (~csum_offloads); 4779 } 4780 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4781 } 4782 csum_show(res->port_id); 4783 4784 cmd_reconfig_device_queue(res->port_id, 1, 1); 4785 } 4786 4787 cmdline_parse_token_string_t cmd_csum_csum = 4788 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4789 csum, "csum"); 4790 cmdline_parse_token_string_t cmd_csum_mode = 4791 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4792 mode, "set"); 4793 cmdline_parse_token_string_t cmd_csum_proto = 4794 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4795 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); 4796 cmdline_parse_token_string_t cmd_csum_hwsw = 4797 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4798 hwsw, "hw#sw"); 4799 cmdline_parse_token_num_t cmd_csum_portid = 4800 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4801 port_id, RTE_UINT16); 4802 4803 cmdline_parse_inst_t cmd_csum_set = { 4804 .f = cmd_csum_parsed, 4805 .data = NULL, 4806 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: " 4807 "Enable/Disable hardware calculation of L3/L4 checksum when " 4808 "using csum forward engine", 4809 .tokens = { 4810 (void *)&cmd_csum_csum, 4811 (void *)&cmd_csum_mode, 4812 (void *)&cmd_csum_proto, 4813 (void *)&cmd_csum_hwsw, 4814 (void *)&cmd_csum_portid, 4815 NULL, 4816 }, 4817 }; 4818 4819 cmdline_parse_token_string_t cmd_csum_mode_show = 4820 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4821 mode, "show"); 4822 4823 cmdline_parse_inst_t cmd_csum_show = { 4824 .f = cmd_csum_parsed, 4825 .data = NULL, 4826 .help_str = "csum show <port_id>: Show checksum offload configuration", 4827 .tokens = { 4828 (void *)&cmd_csum_csum, 4829 (void *)&cmd_csum_mode_show, 4830 (void *)&cmd_csum_portid, 4831 NULL, 4832 }, 4833 }; 4834 4835 /* Enable/disable tunnel parsing */ 4836 struct cmd_csum_tunnel_result { 4837 cmdline_fixed_string_t csum; 4838 cmdline_fixed_string_t parse; 4839 cmdline_fixed_string_t onoff; 4840 portid_t port_id; 4841 }; 4842 4843 static void 4844 cmd_csum_tunnel_parsed(void *parsed_result, 4845 __rte_unused struct cmdline *cl, 4846 __rte_unused void *data) 4847 { 4848 struct cmd_csum_tunnel_result *res = parsed_result; 4849 4850 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4851 return; 4852 4853 if (!strcmp(res->onoff, "on")) 4854 ports[res->port_id].parse_tunnel = 1; 4855 else 4856 ports[res->port_id].parse_tunnel = 0; 4857 4858 csum_show(res->port_id); 4859 } 4860 4861 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4862 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4863 csum, "csum"); 4864 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4865 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4866 parse, "parse-tunnel"); 4867 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4868 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4869 onoff, "on#off"); 4870 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4871 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4872 port_id, RTE_UINT16); 4873 4874 cmdline_parse_inst_t cmd_csum_tunnel = { 4875 .f = cmd_csum_tunnel_parsed, 4876 .data = NULL, 4877 .help_str = "csum parse-tunnel on|off <port_id>: " 4878 "Enable/Disable parsing of tunnels for csum engine", 4879 .tokens = { 4880 (void *)&cmd_csum_tunnel_csum, 4881 (void *)&cmd_csum_tunnel_parse, 4882 (void *)&cmd_csum_tunnel_onoff, 4883 (void *)&cmd_csum_tunnel_portid, 4884 NULL, 4885 }, 4886 }; 4887 4888 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4889 struct cmd_tso_set_result { 4890 cmdline_fixed_string_t tso; 4891 cmdline_fixed_string_t mode; 4892 uint16_t tso_segsz; 4893 portid_t port_id; 4894 }; 4895 4896 static void 4897 cmd_tso_set_parsed(void *parsed_result, 4898 __rte_unused struct cmdline *cl, 4899 __rte_unused void *data) 4900 { 4901 struct cmd_tso_set_result *res = parsed_result; 4902 struct rte_eth_dev_info dev_info; 4903 int ret; 4904 4905 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4906 return; 4907 if (!port_is_stopped(res->port_id)) { 4908 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4909 return; 4910 } 4911 4912 if (!strcmp(res->mode, "set")) 4913 ports[res->port_id].tso_segsz = res->tso_segsz; 4914 4915 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4916 if (ret != 0) 4917 return; 4918 4919 if ((ports[res->port_id].tso_segsz != 0) && 4920 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4921 fprintf(stderr, "Error: TSO is not supported by port %d\n", 4922 res->port_id); 4923 return; 4924 } 4925 4926 if (ports[res->port_id].tso_segsz == 0) { 4927 ports[res->port_id].dev_conf.txmode.offloads &= 4928 ~DEV_TX_OFFLOAD_TCP_TSO; 4929 printf("TSO for non-tunneled packets is disabled\n"); 4930 } else { 4931 ports[res->port_id].dev_conf.txmode.offloads |= 4932 DEV_TX_OFFLOAD_TCP_TSO; 4933 printf("TSO segment size for non-tunneled packets is %d\n", 4934 ports[res->port_id].tso_segsz); 4935 } 4936 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4937 4938 /* display warnings if configuration is not supported by the NIC */ 4939 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4940 if (ret != 0) 4941 return; 4942 4943 if ((ports[res->port_id].tso_segsz != 0) && 4944 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4945 fprintf(stderr, 4946 "Warning: TSO enabled but not supported by port %d\n", 4947 res->port_id); 4948 } 4949 4950 cmd_reconfig_device_queue(res->port_id, 1, 1); 4951 } 4952 4953 cmdline_parse_token_string_t cmd_tso_set_tso = 4954 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4955 tso, "tso"); 4956 cmdline_parse_token_string_t cmd_tso_set_mode = 4957 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4958 mode, "set"); 4959 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4960 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4961 tso_segsz, RTE_UINT16); 4962 cmdline_parse_token_num_t cmd_tso_set_portid = 4963 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4964 port_id, RTE_UINT16); 4965 4966 cmdline_parse_inst_t cmd_tso_set = { 4967 .f = cmd_tso_set_parsed, 4968 .data = NULL, 4969 .help_str = "tso set <tso_segsz> <port_id>: " 4970 "Set TSO segment size of non-tunneled packets for csum engine " 4971 "(0 to disable)", 4972 .tokens = { 4973 (void *)&cmd_tso_set_tso, 4974 (void *)&cmd_tso_set_mode, 4975 (void *)&cmd_tso_set_tso_segsz, 4976 (void *)&cmd_tso_set_portid, 4977 NULL, 4978 }, 4979 }; 4980 4981 cmdline_parse_token_string_t cmd_tso_show_mode = 4982 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4983 mode, "show"); 4984 4985 4986 cmdline_parse_inst_t cmd_tso_show = { 4987 .f = cmd_tso_set_parsed, 4988 .data = NULL, 4989 .help_str = "tso show <port_id>: " 4990 "Show TSO segment size of non-tunneled packets for csum engine", 4991 .tokens = { 4992 (void *)&cmd_tso_set_tso, 4993 (void *)&cmd_tso_show_mode, 4994 (void *)&cmd_tso_set_portid, 4995 NULL, 4996 }, 4997 }; 4998 4999 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 5000 struct cmd_tunnel_tso_set_result { 5001 cmdline_fixed_string_t tso; 5002 cmdline_fixed_string_t mode; 5003 uint16_t tso_segsz; 5004 portid_t port_id; 5005 }; 5006 5007 static struct rte_eth_dev_info 5008 check_tunnel_tso_nic_support(portid_t port_id) 5009 { 5010 struct rte_eth_dev_info dev_info; 5011 5012 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0) 5013 return dev_info; 5014 5015 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 5016 fprintf(stderr, 5017 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n", 5018 port_id); 5019 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 5020 fprintf(stderr, 5021 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n", 5022 port_id); 5023 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 5024 fprintf(stderr, 5025 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n", 5026 port_id); 5027 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 5028 fprintf(stderr, 5029 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n", 5030 port_id); 5031 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO)) 5032 fprintf(stderr, 5033 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n", 5034 port_id); 5035 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO)) 5036 fprintf(stderr, 5037 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n", 5038 port_id); 5039 return dev_info; 5040 } 5041 5042 static void 5043 cmd_tunnel_tso_set_parsed(void *parsed_result, 5044 __rte_unused struct cmdline *cl, 5045 __rte_unused void *data) 5046 { 5047 struct cmd_tunnel_tso_set_result *res = parsed_result; 5048 struct rte_eth_dev_info dev_info; 5049 5050 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 5051 return; 5052 if (!port_is_stopped(res->port_id)) { 5053 fprintf(stderr, "Please stop port %d first\n", res->port_id); 5054 return; 5055 } 5056 5057 if (!strcmp(res->mode, "set")) 5058 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 5059 5060 dev_info = check_tunnel_tso_nic_support(res->port_id); 5061 if (ports[res->port_id].tunnel_tso_segsz == 0) { 5062 ports[res->port_id].dev_conf.txmode.offloads &= 5063 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 5064 DEV_TX_OFFLOAD_GRE_TNL_TSO | 5065 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 5066 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 5067 DEV_TX_OFFLOAD_IP_TNL_TSO | 5068 DEV_TX_OFFLOAD_UDP_TNL_TSO); 5069 printf("TSO for tunneled packets is disabled\n"); 5070 } else { 5071 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 5072 DEV_TX_OFFLOAD_GRE_TNL_TSO | 5073 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 5074 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 5075 DEV_TX_OFFLOAD_IP_TNL_TSO | 5076 DEV_TX_OFFLOAD_UDP_TNL_TSO); 5077 5078 ports[res->port_id].dev_conf.txmode.offloads |= 5079 (tso_offloads & dev_info.tx_offload_capa); 5080 printf("TSO segment size for tunneled packets is %d\n", 5081 ports[res->port_id].tunnel_tso_segsz); 5082 5083 /* Below conditions are needed to make it work: 5084 * (1) tunnel TSO is supported by the NIC; 5085 * (2) "csum parse_tunnel" must be set so that tunneled pkts 5086 * are recognized; 5087 * (3) for tunneled pkts with outer L3 of IPv4, 5088 * "csum set outer-ip" must be set to hw, because after tso, 5089 * total_len of outer IP header is changed, and the checksum 5090 * of outer IP header calculated by sw should be wrong; that 5091 * is not necessary for IPv6 tunneled pkts because there's no 5092 * checksum in IP header anymore. 5093 */ 5094 5095 if (!ports[res->port_id].parse_tunnel) 5096 fprintf(stderr, 5097 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n"); 5098 if (!(ports[res->port_id].dev_conf.txmode.offloads & 5099 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 5100 fprintf(stderr, 5101 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n"); 5102 } 5103 5104 cmd_config_queue_tx_offloads(&ports[res->port_id]); 5105 cmd_reconfig_device_queue(res->port_id, 1, 1); 5106 } 5107 5108 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 5109 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5110 tso, "tunnel_tso"); 5111 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 5112 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5113 mode, "set"); 5114 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 5115 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 5116 tso_segsz, RTE_UINT16); 5117 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 5118 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 5119 port_id, RTE_UINT16); 5120 5121 cmdline_parse_inst_t cmd_tunnel_tso_set = { 5122 .f = cmd_tunnel_tso_set_parsed, 5123 .data = NULL, 5124 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 5125 "Set TSO segment size of tunneled packets for csum engine " 5126 "(0 to disable)", 5127 .tokens = { 5128 (void *)&cmd_tunnel_tso_set_tso, 5129 (void *)&cmd_tunnel_tso_set_mode, 5130 (void *)&cmd_tunnel_tso_set_tso_segsz, 5131 (void *)&cmd_tunnel_tso_set_portid, 5132 NULL, 5133 }, 5134 }; 5135 5136 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 5137 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5138 mode, "show"); 5139 5140 5141 cmdline_parse_inst_t cmd_tunnel_tso_show = { 5142 .f = cmd_tunnel_tso_set_parsed, 5143 .data = NULL, 5144 .help_str = "tunnel_tso show <port_id> " 5145 "Show TSO segment size of tunneled packets for csum engine", 5146 .tokens = { 5147 (void *)&cmd_tunnel_tso_set_tso, 5148 (void *)&cmd_tunnel_tso_show_mode, 5149 (void *)&cmd_tunnel_tso_set_portid, 5150 NULL, 5151 }, 5152 }; 5153 5154 /* *** SET GRO FOR A PORT *** */ 5155 struct cmd_gro_enable_result { 5156 cmdline_fixed_string_t cmd_set; 5157 cmdline_fixed_string_t cmd_port; 5158 cmdline_fixed_string_t cmd_keyword; 5159 cmdline_fixed_string_t cmd_onoff; 5160 portid_t cmd_pid; 5161 }; 5162 5163 static void 5164 cmd_gro_enable_parsed(void *parsed_result, 5165 __rte_unused struct cmdline *cl, 5166 __rte_unused void *data) 5167 { 5168 struct cmd_gro_enable_result *res; 5169 5170 res = parsed_result; 5171 if (!strcmp(res->cmd_keyword, "gro")) 5172 setup_gro(res->cmd_onoff, res->cmd_pid); 5173 } 5174 5175 cmdline_parse_token_string_t cmd_gro_enable_set = 5176 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5177 cmd_set, "set"); 5178 cmdline_parse_token_string_t cmd_gro_enable_port = 5179 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5180 cmd_keyword, "port"); 5181 cmdline_parse_token_num_t cmd_gro_enable_pid = 5182 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 5183 cmd_pid, RTE_UINT16); 5184 cmdline_parse_token_string_t cmd_gro_enable_keyword = 5185 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5186 cmd_keyword, "gro"); 5187 cmdline_parse_token_string_t cmd_gro_enable_onoff = 5188 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5189 cmd_onoff, "on#off"); 5190 5191 cmdline_parse_inst_t cmd_gro_enable = { 5192 .f = cmd_gro_enable_parsed, 5193 .data = NULL, 5194 .help_str = "set port <port_id> gro on|off", 5195 .tokens = { 5196 (void *)&cmd_gro_enable_set, 5197 (void *)&cmd_gro_enable_port, 5198 (void *)&cmd_gro_enable_pid, 5199 (void *)&cmd_gro_enable_keyword, 5200 (void *)&cmd_gro_enable_onoff, 5201 NULL, 5202 }, 5203 }; 5204 5205 /* *** DISPLAY GRO CONFIGURATION *** */ 5206 struct cmd_gro_show_result { 5207 cmdline_fixed_string_t cmd_show; 5208 cmdline_fixed_string_t cmd_port; 5209 cmdline_fixed_string_t cmd_keyword; 5210 portid_t cmd_pid; 5211 }; 5212 5213 static void 5214 cmd_gro_show_parsed(void *parsed_result, 5215 __rte_unused struct cmdline *cl, 5216 __rte_unused void *data) 5217 { 5218 struct cmd_gro_show_result *res; 5219 5220 res = parsed_result; 5221 if (!strcmp(res->cmd_keyword, "gro")) 5222 show_gro(res->cmd_pid); 5223 } 5224 5225 cmdline_parse_token_string_t cmd_gro_show_show = 5226 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5227 cmd_show, "show"); 5228 cmdline_parse_token_string_t cmd_gro_show_port = 5229 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5230 cmd_port, "port"); 5231 cmdline_parse_token_num_t cmd_gro_show_pid = 5232 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 5233 cmd_pid, RTE_UINT16); 5234 cmdline_parse_token_string_t cmd_gro_show_keyword = 5235 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5236 cmd_keyword, "gro"); 5237 5238 cmdline_parse_inst_t cmd_gro_show = { 5239 .f = cmd_gro_show_parsed, 5240 .data = NULL, 5241 .help_str = "show port <port_id> gro", 5242 .tokens = { 5243 (void *)&cmd_gro_show_show, 5244 (void *)&cmd_gro_show_port, 5245 (void *)&cmd_gro_show_pid, 5246 (void *)&cmd_gro_show_keyword, 5247 NULL, 5248 }, 5249 }; 5250 5251 /* *** SET FLUSH CYCLES FOR GRO *** */ 5252 struct cmd_gro_flush_result { 5253 cmdline_fixed_string_t cmd_set; 5254 cmdline_fixed_string_t cmd_keyword; 5255 cmdline_fixed_string_t cmd_flush; 5256 uint8_t cmd_cycles; 5257 }; 5258 5259 static void 5260 cmd_gro_flush_parsed(void *parsed_result, 5261 __rte_unused struct cmdline *cl, 5262 __rte_unused void *data) 5263 { 5264 struct cmd_gro_flush_result *res; 5265 5266 res = parsed_result; 5267 if ((!strcmp(res->cmd_keyword, "gro")) && 5268 (!strcmp(res->cmd_flush, "flush"))) 5269 setup_gro_flush_cycles(res->cmd_cycles); 5270 } 5271 5272 cmdline_parse_token_string_t cmd_gro_flush_set = 5273 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5274 cmd_set, "set"); 5275 cmdline_parse_token_string_t cmd_gro_flush_keyword = 5276 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5277 cmd_keyword, "gro"); 5278 cmdline_parse_token_string_t cmd_gro_flush_flush = 5279 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5280 cmd_flush, "flush"); 5281 cmdline_parse_token_num_t cmd_gro_flush_cycles = 5282 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 5283 cmd_cycles, RTE_UINT8); 5284 5285 cmdline_parse_inst_t cmd_gro_flush = { 5286 .f = cmd_gro_flush_parsed, 5287 .data = NULL, 5288 .help_str = "set gro flush <cycles>", 5289 .tokens = { 5290 (void *)&cmd_gro_flush_set, 5291 (void *)&cmd_gro_flush_keyword, 5292 (void *)&cmd_gro_flush_flush, 5293 (void *)&cmd_gro_flush_cycles, 5294 NULL, 5295 }, 5296 }; 5297 5298 /* *** ENABLE/DISABLE GSO *** */ 5299 struct cmd_gso_enable_result { 5300 cmdline_fixed_string_t cmd_set; 5301 cmdline_fixed_string_t cmd_port; 5302 cmdline_fixed_string_t cmd_keyword; 5303 cmdline_fixed_string_t cmd_mode; 5304 portid_t cmd_pid; 5305 }; 5306 5307 static void 5308 cmd_gso_enable_parsed(void *parsed_result, 5309 __rte_unused struct cmdline *cl, 5310 __rte_unused void *data) 5311 { 5312 struct cmd_gso_enable_result *res; 5313 5314 res = parsed_result; 5315 if (!strcmp(res->cmd_keyword, "gso")) 5316 setup_gso(res->cmd_mode, res->cmd_pid); 5317 } 5318 5319 cmdline_parse_token_string_t cmd_gso_enable_set = 5320 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5321 cmd_set, "set"); 5322 cmdline_parse_token_string_t cmd_gso_enable_port = 5323 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5324 cmd_port, "port"); 5325 cmdline_parse_token_string_t cmd_gso_enable_keyword = 5326 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5327 cmd_keyword, "gso"); 5328 cmdline_parse_token_string_t cmd_gso_enable_mode = 5329 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5330 cmd_mode, "on#off"); 5331 cmdline_parse_token_num_t cmd_gso_enable_pid = 5332 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 5333 cmd_pid, RTE_UINT16); 5334 5335 cmdline_parse_inst_t cmd_gso_enable = { 5336 .f = cmd_gso_enable_parsed, 5337 .data = NULL, 5338 .help_str = "set port <port_id> gso on|off", 5339 .tokens = { 5340 (void *)&cmd_gso_enable_set, 5341 (void *)&cmd_gso_enable_port, 5342 (void *)&cmd_gso_enable_pid, 5343 (void *)&cmd_gso_enable_keyword, 5344 (void *)&cmd_gso_enable_mode, 5345 NULL, 5346 }, 5347 }; 5348 5349 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 5350 struct cmd_gso_size_result { 5351 cmdline_fixed_string_t cmd_set; 5352 cmdline_fixed_string_t cmd_keyword; 5353 cmdline_fixed_string_t cmd_segsz; 5354 uint16_t cmd_size; 5355 }; 5356 5357 static void 5358 cmd_gso_size_parsed(void *parsed_result, 5359 __rte_unused struct cmdline *cl, 5360 __rte_unused void *data) 5361 { 5362 struct cmd_gso_size_result *res = parsed_result; 5363 5364 if (test_done == 0) { 5365 fprintf(stderr, 5366 "Before setting GSO segsz, please first stop forwarding\n"); 5367 return; 5368 } 5369 5370 if (!strcmp(res->cmd_keyword, "gso") && 5371 !strcmp(res->cmd_segsz, "segsz")) { 5372 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 5373 fprintf(stderr, 5374 "gso_size should be larger than %zu. Please input a legal value\n", 5375 RTE_GSO_SEG_SIZE_MIN); 5376 else 5377 gso_max_segment_size = res->cmd_size; 5378 } 5379 } 5380 5381 cmdline_parse_token_string_t cmd_gso_size_set = 5382 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5383 cmd_set, "set"); 5384 cmdline_parse_token_string_t cmd_gso_size_keyword = 5385 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5386 cmd_keyword, "gso"); 5387 cmdline_parse_token_string_t cmd_gso_size_segsz = 5388 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5389 cmd_segsz, "segsz"); 5390 cmdline_parse_token_num_t cmd_gso_size_size = 5391 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 5392 cmd_size, RTE_UINT16); 5393 5394 cmdline_parse_inst_t cmd_gso_size = { 5395 .f = cmd_gso_size_parsed, 5396 .data = NULL, 5397 .help_str = "set gso segsz <length>", 5398 .tokens = { 5399 (void *)&cmd_gso_size_set, 5400 (void *)&cmd_gso_size_keyword, 5401 (void *)&cmd_gso_size_segsz, 5402 (void *)&cmd_gso_size_size, 5403 NULL, 5404 }, 5405 }; 5406 5407 /* *** SHOW GSO CONFIGURATION *** */ 5408 struct cmd_gso_show_result { 5409 cmdline_fixed_string_t cmd_show; 5410 cmdline_fixed_string_t cmd_port; 5411 cmdline_fixed_string_t cmd_keyword; 5412 portid_t cmd_pid; 5413 }; 5414 5415 static void 5416 cmd_gso_show_parsed(void *parsed_result, 5417 __rte_unused struct cmdline *cl, 5418 __rte_unused void *data) 5419 { 5420 struct cmd_gso_show_result *res = parsed_result; 5421 5422 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 5423 fprintf(stderr, "invalid port id %u\n", res->cmd_pid); 5424 return; 5425 } 5426 if (!strcmp(res->cmd_keyword, "gso")) { 5427 if (gso_ports[res->cmd_pid].enable) { 5428 printf("Max GSO'd packet size: %uB\n" 5429 "Supported GSO types: TCP/IPv4, " 5430 "UDP/IPv4, VxLAN with inner " 5431 "TCP/IPv4 packet, GRE with inner " 5432 "TCP/IPv4 packet\n", 5433 gso_max_segment_size); 5434 } else 5435 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 5436 } 5437 } 5438 5439 cmdline_parse_token_string_t cmd_gso_show_show = 5440 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5441 cmd_show, "show"); 5442 cmdline_parse_token_string_t cmd_gso_show_port = 5443 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5444 cmd_port, "port"); 5445 cmdline_parse_token_string_t cmd_gso_show_keyword = 5446 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5447 cmd_keyword, "gso"); 5448 cmdline_parse_token_num_t cmd_gso_show_pid = 5449 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 5450 cmd_pid, RTE_UINT16); 5451 5452 cmdline_parse_inst_t cmd_gso_show = { 5453 .f = cmd_gso_show_parsed, 5454 .data = NULL, 5455 .help_str = "show port <port_id> gso", 5456 .tokens = { 5457 (void *)&cmd_gso_show_show, 5458 (void *)&cmd_gso_show_port, 5459 (void *)&cmd_gso_show_pid, 5460 (void *)&cmd_gso_show_keyword, 5461 NULL, 5462 }, 5463 }; 5464 5465 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 5466 struct cmd_set_flush_rx { 5467 cmdline_fixed_string_t set; 5468 cmdline_fixed_string_t flush_rx; 5469 cmdline_fixed_string_t mode; 5470 }; 5471 5472 static void 5473 cmd_set_flush_rx_parsed(void *parsed_result, 5474 __rte_unused struct cmdline *cl, 5475 __rte_unused void *data) 5476 { 5477 struct cmd_set_flush_rx *res = parsed_result; 5478 5479 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) { 5480 printf("multi-process doesn't support to flush Rx queues.\n"); 5481 return; 5482 } 5483 5484 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5485 } 5486 5487 cmdline_parse_token_string_t cmd_setflushrx_set = 5488 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5489 set, "set"); 5490 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 5491 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5492 flush_rx, "flush_rx"); 5493 cmdline_parse_token_string_t cmd_setflushrx_mode = 5494 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5495 mode, "on#off"); 5496 5497 5498 cmdline_parse_inst_t cmd_set_flush_rx = { 5499 .f = cmd_set_flush_rx_parsed, 5500 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 5501 .data = NULL, 5502 .tokens = { 5503 (void *)&cmd_setflushrx_set, 5504 (void *)&cmd_setflushrx_flush_rx, 5505 (void *)&cmd_setflushrx_mode, 5506 NULL, 5507 }, 5508 }; 5509 5510 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 5511 struct cmd_set_link_check { 5512 cmdline_fixed_string_t set; 5513 cmdline_fixed_string_t link_check; 5514 cmdline_fixed_string_t mode; 5515 }; 5516 5517 static void 5518 cmd_set_link_check_parsed(void *parsed_result, 5519 __rte_unused struct cmdline *cl, 5520 __rte_unused void *data) 5521 { 5522 struct cmd_set_link_check *res = parsed_result; 5523 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5524 } 5525 5526 cmdline_parse_token_string_t cmd_setlinkcheck_set = 5527 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5528 set, "set"); 5529 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 5530 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5531 link_check, "link_check"); 5532 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 5533 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5534 mode, "on#off"); 5535 5536 5537 cmdline_parse_inst_t cmd_set_link_check = { 5538 .f = cmd_set_link_check_parsed, 5539 .help_str = "set link_check on|off: Enable/Disable link status check " 5540 "when starting/stopping a port", 5541 .data = NULL, 5542 .tokens = { 5543 (void *)&cmd_setlinkcheck_set, 5544 (void *)&cmd_setlinkcheck_link_check, 5545 (void *)&cmd_setlinkcheck_mode, 5546 NULL, 5547 }, 5548 }; 5549 5550 /* *** SET NIC BYPASS MODE *** */ 5551 struct cmd_set_bypass_mode_result { 5552 cmdline_fixed_string_t set; 5553 cmdline_fixed_string_t bypass; 5554 cmdline_fixed_string_t mode; 5555 cmdline_fixed_string_t value; 5556 portid_t port_id; 5557 }; 5558 5559 static void 5560 cmd_set_bypass_mode_parsed(void *parsed_result, 5561 __rte_unused struct cmdline *cl, 5562 __rte_unused void *data) 5563 { 5564 struct cmd_set_bypass_mode_result *res = parsed_result; 5565 portid_t port_id = res->port_id; 5566 int32_t rc = -EINVAL; 5567 5568 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5569 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5570 5571 if (!strcmp(res->value, "bypass")) 5572 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5573 else if (!strcmp(res->value, "isolate")) 5574 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5575 else 5576 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5577 5578 /* Set the bypass mode for the relevant port. */ 5579 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 5580 #endif 5581 if (rc != 0) 5582 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n", 5583 port_id); 5584 } 5585 5586 cmdline_parse_token_string_t cmd_setbypass_mode_set = 5587 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5588 set, "set"); 5589 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 5590 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5591 bypass, "bypass"); 5592 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 5593 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5594 mode, "mode"); 5595 cmdline_parse_token_string_t cmd_setbypass_mode_value = 5596 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5597 value, "normal#bypass#isolate"); 5598 cmdline_parse_token_num_t cmd_setbypass_mode_port = 5599 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 5600 port_id, RTE_UINT16); 5601 5602 cmdline_parse_inst_t cmd_set_bypass_mode = { 5603 .f = cmd_set_bypass_mode_parsed, 5604 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 5605 "Set the NIC bypass mode for port_id", 5606 .data = NULL, 5607 .tokens = { 5608 (void *)&cmd_setbypass_mode_set, 5609 (void *)&cmd_setbypass_mode_bypass, 5610 (void *)&cmd_setbypass_mode_mode, 5611 (void *)&cmd_setbypass_mode_value, 5612 (void *)&cmd_setbypass_mode_port, 5613 NULL, 5614 }, 5615 }; 5616 5617 /* *** SET NIC BYPASS EVENT *** */ 5618 struct cmd_set_bypass_event_result { 5619 cmdline_fixed_string_t set; 5620 cmdline_fixed_string_t bypass; 5621 cmdline_fixed_string_t event; 5622 cmdline_fixed_string_t event_value; 5623 cmdline_fixed_string_t mode; 5624 cmdline_fixed_string_t mode_value; 5625 portid_t port_id; 5626 }; 5627 5628 static void 5629 cmd_set_bypass_event_parsed(void *parsed_result, 5630 __rte_unused struct cmdline *cl, 5631 __rte_unused void *data) 5632 { 5633 int32_t rc = -EINVAL; 5634 struct cmd_set_bypass_event_result *res = parsed_result; 5635 portid_t port_id = res->port_id; 5636 5637 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5638 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5639 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5640 5641 if (!strcmp(res->event_value, "timeout")) 5642 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 5643 else if (!strcmp(res->event_value, "os_on")) 5644 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 5645 else if (!strcmp(res->event_value, "os_off")) 5646 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 5647 else if (!strcmp(res->event_value, "power_on")) 5648 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 5649 else if (!strcmp(res->event_value, "power_off")) 5650 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 5651 else 5652 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5653 5654 if (!strcmp(res->mode_value, "bypass")) 5655 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5656 else if (!strcmp(res->mode_value, "isolate")) 5657 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5658 else 5659 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5660 5661 /* Set the watchdog timeout. */ 5662 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 5663 5664 rc = -EINVAL; 5665 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 5666 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 5667 bypass_timeout); 5668 } 5669 if (rc != 0) { 5670 fprintf(stderr, 5671 "Failed to set timeout value %u for port %d, errto code: %d.\n", 5672 bypass_timeout, port_id, rc); 5673 } 5674 } 5675 5676 /* Set the bypass event to transition to bypass mode. */ 5677 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 5678 bypass_mode); 5679 #endif 5680 5681 if (rc != 0) 5682 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n", 5683 port_id); 5684 } 5685 5686 cmdline_parse_token_string_t cmd_setbypass_event_set = 5687 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5688 set, "set"); 5689 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 5690 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5691 bypass, "bypass"); 5692 cmdline_parse_token_string_t cmd_setbypass_event_event = 5693 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5694 event, "event"); 5695 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 5696 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5697 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 5698 cmdline_parse_token_string_t cmd_setbypass_event_mode = 5699 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5700 mode, "mode"); 5701 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 5702 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5703 mode_value, "normal#bypass#isolate"); 5704 cmdline_parse_token_num_t cmd_setbypass_event_port = 5705 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 5706 port_id, RTE_UINT16); 5707 5708 cmdline_parse_inst_t cmd_set_bypass_event = { 5709 .f = cmd_set_bypass_event_parsed, 5710 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 5711 "power_off mode normal|bypass|isolate <port_id>: " 5712 "Set the NIC bypass event mode for port_id", 5713 .data = NULL, 5714 .tokens = { 5715 (void *)&cmd_setbypass_event_set, 5716 (void *)&cmd_setbypass_event_bypass, 5717 (void *)&cmd_setbypass_event_event, 5718 (void *)&cmd_setbypass_event_event_value, 5719 (void *)&cmd_setbypass_event_mode, 5720 (void *)&cmd_setbypass_event_mode_value, 5721 (void *)&cmd_setbypass_event_port, 5722 NULL, 5723 }, 5724 }; 5725 5726 5727 /* *** SET NIC BYPASS TIMEOUT *** */ 5728 struct cmd_set_bypass_timeout_result { 5729 cmdline_fixed_string_t set; 5730 cmdline_fixed_string_t bypass; 5731 cmdline_fixed_string_t timeout; 5732 cmdline_fixed_string_t value; 5733 }; 5734 5735 static void 5736 cmd_set_bypass_timeout_parsed(void *parsed_result, 5737 __rte_unused struct cmdline *cl, 5738 __rte_unused void *data) 5739 { 5740 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 5741 5742 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5743 if (!strcmp(res->value, "1.5")) 5744 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 5745 else if (!strcmp(res->value, "2")) 5746 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 5747 else if (!strcmp(res->value, "3")) 5748 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 5749 else if (!strcmp(res->value, "4")) 5750 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 5751 else if (!strcmp(res->value, "8")) 5752 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 5753 else if (!strcmp(res->value, "16")) 5754 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 5755 else if (!strcmp(res->value, "32")) 5756 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 5757 else 5758 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5759 #endif 5760 } 5761 5762 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 5763 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5764 set, "set"); 5765 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 5766 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5767 bypass, "bypass"); 5768 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 5769 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5770 timeout, "timeout"); 5771 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 5772 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5773 value, "0#1.5#2#3#4#8#16#32"); 5774 5775 cmdline_parse_inst_t cmd_set_bypass_timeout = { 5776 .f = cmd_set_bypass_timeout_parsed, 5777 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 5778 "Set the NIC bypass watchdog timeout in seconds", 5779 .data = NULL, 5780 .tokens = { 5781 (void *)&cmd_setbypass_timeout_set, 5782 (void *)&cmd_setbypass_timeout_bypass, 5783 (void *)&cmd_setbypass_timeout_timeout, 5784 (void *)&cmd_setbypass_timeout_value, 5785 NULL, 5786 }, 5787 }; 5788 5789 /* *** SHOW NIC BYPASS MODE *** */ 5790 struct cmd_show_bypass_config_result { 5791 cmdline_fixed_string_t show; 5792 cmdline_fixed_string_t bypass; 5793 cmdline_fixed_string_t config; 5794 portid_t port_id; 5795 }; 5796 5797 static void 5798 cmd_show_bypass_config_parsed(void *parsed_result, 5799 __rte_unused struct cmdline *cl, 5800 __rte_unused void *data) 5801 { 5802 struct cmd_show_bypass_config_result *res = parsed_result; 5803 portid_t port_id = res->port_id; 5804 int rc = -EINVAL; 5805 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5806 uint32_t event_mode; 5807 uint32_t bypass_mode; 5808 uint32_t timeout = bypass_timeout; 5809 unsigned int i; 5810 5811 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 5812 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 5813 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 5814 {"UNKNOWN", "normal", "bypass", "isolate"}; 5815 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 5816 "NONE", 5817 "OS/board on", 5818 "power supply on", 5819 "OS/board off", 5820 "power supply off", 5821 "timeout"}; 5822 5823 /* Display the bypass mode.*/ 5824 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 5825 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n", 5826 port_id); 5827 return; 5828 } 5829 else { 5830 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 5831 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5832 5833 printf("\tbypass mode = %s\n", modes[bypass_mode]); 5834 } 5835 5836 /* Display the bypass timeout.*/ 5837 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 5838 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5839 5840 printf("\tbypass timeout = %s\n", timeouts[timeout]); 5841 5842 /* Display the bypass events and associated modes. */ 5843 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) { 5844 5845 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 5846 fprintf(stderr, 5847 "\tFailed to get bypass mode for event = %s\n", 5848 events[i]); 5849 } else { 5850 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 5851 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5852 5853 printf("\tbypass event: %-16s = %s\n", events[i], 5854 modes[event_mode]); 5855 } 5856 } 5857 #endif 5858 if (rc != 0) 5859 fprintf(stderr, 5860 "\tFailed to get bypass configuration for port = %d\n", 5861 port_id); 5862 } 5863 5864 cmdline_parse_token_string_t cmd_showbypass_config_show = 5865 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5866 show, "show"); 5867 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 5868 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5869 bypass, "bypass"); 5870 cmdline_parse_token_string_t cmd_showbypass_config_config = 5871 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5872 config, "config"); 5873 cmdline_parse_token_num_t cmd_showbypass_config_port = 5874 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 5875 port_id, RTE_UINT16); 5876 5877 cmdline_parse_inst_t cmd_show_bypass_config = { 5878 .f = cmd_show_bypass_config_parsed, 5879 .help_str = "show bypass config <port_id>: " 5880 "Show the NIC bypass config for port_id", 5881 .data = NULL, 5882 .tokens = { 5883 (void *)&cmd_showbypass_config_show, 5884 (void *)&cmd_showbypass_config_bypass, 5885 (void *)&cmd_showbypass_config_config, 5886 (void *)&cmd_showbypass_config_port, 5887 NULL, 5888 }, 5889 }; 5890 5891 #ifdef RTE_NET_BOND 5892 /* *** SET BONDING MODE *** */ 5893 struct cmd_set_bonding_mode_result { 5894 cmdline_fixed_string_t set; 5895 cmdline_fixed_string_t bonding; 5896 cmdline_fixed_string_t mode; 5897 uint8_t value; 5898 portid_t port_id; 5899 }; 5900 5901 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5902 __rte_unused struct cmdline *cl, 5903 __rte_unused void *data) 5904 { 5905 struct cmd_set_bonding_mode_result *res = parsed_result; 5906 portid_t port_id = res->port_id; 5907 5908 /* Set the bonding mode for the relevant port. */ 5909 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5910 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n", 5911 port_id); 5912 } 5913 5914 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5915 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5916 set, "set"); 5917 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5918 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5919 bonding, "bonding"); 5920 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5921 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5922 mode, "mode"); 5923 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5924 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5925 value, RTE_UINT8); 5926 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5927 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5928 port_id, RTE_UINT16); 5929 5930 cmdline_parse_inst_t cmd_set_bonding_mode = { 5931 .f = cmd_set_bonding_mode_parsed, 5932 .help_str = "set bonding mode <mode_value> <port_id>: " 5933 "Set the bonding mode for port_id", 5934 .data = NULL, 5935 .tokens = { 5936 (void *) &cmd_setbonding_mode_set, 5937 (void *) &cmd_setbonding_mode_bonding, 5938 (void *) &cmd_setbonding_mode_mode, 5939 (void *) &cmd_setbonding_mode_value, 5940 (void *) &cmd_setbonding_mode_port, 5941 NULL 5942 } 5943 }; 5944 5945 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5946 struct cmd_set_bonding_lacp_dedicated_queues_result { 5947 cmdline_fixed_string_t set; 5948 cmdline_fixed_string_t bonding; 5949 cmdline_fixed_string_t lacp; 5950 cmdline_fixed_string_t dedicated_queues; 5951 portid_t port_id; 5952 cmdline_fixed_string_t mode; 5953 }; 5954 5955 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5956 __rte_unused struct cmdline *cl, 5957 __rte_unused void *data) 5958 { 5959 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5960 portid_t port_id = res->port_id; 5961 struct rte_port *port; 5962 5963 port = &ports[port_id]; 5964 5965 /** Check if the port is not started **/ 5966 if (port->port_status != RTE_PORT_STOPPED) { 5967 fprintf(stderr, "Please stop port %d first\n", port_id); 5968 return; 5969 } 5970 5971 if (!strcmp(res->mode, "enable")) { 5972 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5973 printf("Dedicate queues for LACP control packets" 5974 " enabled\n"); 5975 else 5976 printf("Enabling dedicate queues for LACP control " 5977 "packets on port %d failed\n", port_id); 5978 } else if (!strcmp(res->mode, "disable")) { 5979 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5980 printf("Dedicated queues for LACP control packets " 5981 "disabled\n"); 5982 else 5983 printf("Disabling dedicated queues for LACP control " 5984 "traffic on port %d failed\n", port_id); 5985 } 5986 } 5987 5988 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 5989 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5990 set, "set"); 5991 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 5992 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5993 bonding, "bonding"); 5994 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 5995 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5996 lacp, "lacp"); 5997 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 5998 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5999 dedicated_queues, "dedicated_queues"); 6000 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 6001 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 6002 port_id, RTE_UINT16); 6003 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 6004 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 6005 mode, "enable#disable"); 6006 6007 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 6008 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 6009 .help_str = "set bonding lacp dedicated_queues <port_id> " 6010 "enable|disable: " 6011 "Enable/disable dedicated queues for LACP control traffic for port_id", 6012 .data = NULL, 6013 .tokens = { 6014 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 6015 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 6016 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 6017 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 6018 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 6019 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 6020 NULL 6021 } 6022 }; 6023 6024 /* *** SET BALANCE XMIT POLICY *** */ 6025 struct cmd_set_bonding_balance_xmit_policy_result { 6026 cmdline_fixed_string_t set; 6027 cmdline_fixed_string_t bonding; 6028 cmdline_fixed_string_t balance_xmit_policy; 6029 portid_t port_id; 6030 cmdline_fixed_string_t policy; 6031 }; 6032 6033 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 6034 __rte_unused struct cmdline *cl, 6035 __rte_unused void *data) 6036 { 6037 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 6038 portid_t port_id = res->port_id; 6039 uint8_t policy; 6040 6041 if (!strcmp(res->policy, "l2")) { 6042 policy = BALANCE_XMIT_POLICY_LAYER2; 6043 } else if (!strcmp(res->policy, "l23")) { 6044 policy = BALANCE_XMIT_POLICY_LAYER23; 6045 } else if (!strcmp(res->policy, "l34")) { 6046 policy = BALANCE_XMIT_POLICY_LAYER34; 6047 } else { 6048 fprintf(stderr, "\t Invalid xmit policy selection"); 6049 return; 6050 } 6051 6052 /* Set the bonding mode for the relevant port. */ 6053 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 6054 fprintf(stderr, 6055 "\t Failed to set bonding balance xmit policy for port = %d.\n", 6056 port_id); 6057 } 6058 } 6059 6060 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 6061 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6062 set, "set"); 6063 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 6064 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6065 bonding, "bonding"); 6066 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 6067 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6068 balance_xmit_policy, "balance_xmit_policy"); 6069 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 6070 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6071 port_id, RTE_UINT16); 6072 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 6073 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6074 policy, "l2#l23#l34"); 6075 6076 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 6077 .f = cmd_set_bonding_balance_xmit_policy_parsed, 6078 .help_str = "set bonding balance_xmit_policy <port_id> " 6079 "l2|l23|l34: " 6080 "Set the bonding balance_xmit_policy for port_id", 6081 .data = NULL, 6082 .tokens = { 6083 (void *)&cmd_setbonding_balance_xmit_policy_set, 6084 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 6085 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 6086 (void *)&cmd_setbonding_balance_xmit_policy_port, 6087 (void *)&cmd_setbonding_balance_xmit_policy_policy, 6088 NULL 6089 } 6090 }; 6091 6092 /* *** SHOW NIC BONDING CONFIGURATION *** */ 6093 struct cmd_show_bonding_config_result { 6094 cmdline_fixed_string_t show; 6095 cmdline_fixed_string_t bonding; 6096 cmdline_fixed_string_t config; 6097 portid_t port_id; 6098 }; 6099 6100 static void cmd_show_bonding_config_parsed(void *parsed_result, 6101 __rte_unused struct cmdline *cl, 6102 __rte_unused void *data) 6103 { 6104 struct cmd_show_bonding_config_result *res = parsed_result; 6105 int bonding_mode, agg_mode; 6106 portid_t slaves[RTE_MAX_ETHPORTS]; 6107 int num_slaves, num_active_slaves; 6108 int primary_id; 6109 int i; 6110 portid_t port_id = res->port_id; 6111 6112 /* Display the bonding mode.*/ 6113 bonding_mode = rte_eth_bond_mode_get(port_id); 6114 if (bonding_mode < 0) { 6115 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n", 6116 port_id); 6117 return; 6118 } else 6119 printf("\tBonding mode: %d\n", bonding_mode); 6120 6121 if (bonding_mode == BONDING_MODE_BALANCE) { 6122 int balance_xmit_policy; 6123 6124 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 6125 if (balance_xmit_policy < 0) { 6126 fprintf(stderr, 6127 "\tFailed to get balance xmit policy for port = %d\n", 6128 port_id); 6129 return; 6130 } else { 6131 printf("\tBalance Xmit Policy: "); 6132 6133 switch (balance_xmit_policy) { 6134 case BALANCE_XMIT_POLICY_LAYER2: 6135 printf("BALANCE_XMIT_POLICY_LAYER2"); 6136 break; 6137 case BALANCE_XMIT_POLICY_LAYER23: 6138 printf("BALANCE_XMIT_POLICY_LAYER23"); 6139 break; 6140 case BALANCE_XMIT_POLICY_LAYER34: 6141 printf("BALANCE_XMIT_POLICY_LAYER34"); 6142 break; 6143 } 6144 printf("\n"); 6145 } 6146 } 6147 6148 if (bonding_mode == BONDING_MODE_8023AD) { 6149 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 6150 printf("\tIEEE802.3AD Aggregator Mode: "); 6151 switch (agg_mode) { 6152 case AGG_BANDWIDTH: 6153 printf("bandwidth"); 6154 break; 6155 case AGG_STABLE: 6156 printf("stable"); 6157 break; 6158 case AGG_COUNT: 6159 printf("count"); 6160 break; 6161 } 6162 printf("\n"); 6163 } 6164 6165 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 6166 6167 if (num_slaves < 0) { 6168 fprintf(stderr, "\tFailed to get slave list for port = %d\n", 6169 port_id); 6170 return; 6171 } 6172 if (num_slaves > 0) { 6173 printf("\tSlaves (%d): [", num_slaves); 6174 for (i = 0; i < num_slaves - 1; i++) 6175 printf("%d ", slaves[i]); 6176 6177 printf("%d]\n", slaves[num_slaves - 1]); 6178 } else { 6179 printf("\tSlaves: []\n"); 6180 6181 } 6182 6183 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 6184 RTE_MAX_ETHPORTS); 6185 6186 if (num_active_slaves < 0) { 6187 fprintf(stderr, 6188 "\tFailed to get active slave list for port = %d\n", 6189 port_id); 6190 return; 6191 } 6192 if (num_active_slaves > 0) { 6193 printf("\tActive Slaves (%d): [", num_active_slaves); 6194 for (i = 0; i < num_active_slaves - 1; i++) 6195 printf("%d ", slaves[i]); 6196 6197 printf("%d]\n", slaves[num_active_slaves - 1]); 6198 6199 } else { 6200 printf("\tActive Slaves: []\n"); 6201 6202 } 6203 6204 primary_id = rte_eth_bond_primary_get(port_id); 6205 if (primary_id < 0) { 6206 fprintf(stderr, "\tFailed to get primary slave for port = %d\n", 6207 port_id); 6208 return; 6209 } else 6210 printf("\tPrimary: [%d]\n", primary_id); 6211 6212 } 6213 6214 cmdline_parse_token_string_t cmd_showbonding_config_show = 6215 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6216 show, "show"); 6217 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 6218 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6219 bonding, "bonding"); 6220 cmdline_parse_token_string_t cmd_showbonding_config_config = 6221 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6222 config, "config"); 6223 cmdline_parse_token_num_t cmd_showbonding_config_port = 6224 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 6225 port_id, RTE_UINT16); 6226 6227 cmdline_parse_inst_t cmd_show_bonding_config = { 6228 .f = cmd_show_bonding_config_parsed, 6229 .help_str = "show bonding config <port_id>: " 6230 "Show the bonding config for port_id", 6231 .data = NULL, 6232 .tokens = { 6233 (void *)&cmd_showbonding_config_show, 6234 (void *)&cmd_showbonding_config_bonding, 6235 (void *)&cmd_showbonding_config_config, 6236 (void *)&cmd_showbonding_config_port, 6237 NULL 6238 } 6239 }; 6240 6241 /* *** SET BONDING PRIMARY *** */ 6242 struct cmd_set_bonding_primary_result { 6243 cmdline_fixed_string_t set; 6244 cmdline_fixed_string_t bonding; 6245 cmdline_fixed_string_t primary; 6246 portid_t slave_id; 6247 portid_t port_id; 6248 }; 6249 6250 static void cmd_set_bonding_primary_parsed(void *parsed_result, 6251 __rte_unused struct cmdline *cl, 6252 __rte_unused void *data) 6253 { 6254 struct cmd_set_bonding_primary_result *res = parsed_result; 6255 portid_t master_port_id = res->port_id; 6256 portid_t slave_port_id = res->slave_id; 6257 6258 /* Set the primary slave for a bonded device. */ 6259 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 6260 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n", 6261 master_port_id); 6262 return; 6263 } 6264 init_port_config(); 6265 } 6266 6267 cmdline_parse_token_string_t cmd_setbonding_primary_set = 6268 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6269 set, "set"); 6270 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 6271 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6272 bonding, "bonding"); 6273 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 6274 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6275 primary, "primary"); 6276 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 6277 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6278 slave_id, RTE_UINT16); 6279 cmdline_parse_token_num_t cmd_setbonding_primary_port = 6280 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6281 port_id, RTE_UINT16); 6282 6283 cmdline_parse_inst_t cmd_set_bonding_primary = { 6284 .f = cmd_set_bonding_primary_parsed, 6285 .help_str = "set bonding primary <slave_id> <port_id>: " 6286 "Set the primary slave for port_id", 6287 .data = NULL, 6288 .tokens = { 6289 (void *)&cmd_setbonding_primary_set, 6290 (void *)&cmd_setbonding_primary_bonding, 6291 (void *)&cmd_setbonding_primary_primary, 6292 (void *)&cmd_setbonding_primary_slave, 6293 (void *)&cmd_setbonding_primary_port, 6294 NULL 6295 } 6296 }; 6297 6298 /* *** ADD SLAVE *** */ 6299 struct cmd_add_bonding_slave_result { 6300 cmdline_fixed_string_t add; 6301 cmdline_fixed_string_t bonding; 6302 cmdline_fixed_string_t slave; 6303 portid_t slave_id; 6304 portid_t port_id; 6305 }; 6306 6307 static void cmd_add_bonding_slave_parsed(void *parsed_result, 6308 __rte_unused struct cmdline *cl, 6309 __rte_unused void *data) 6310 { 6311 struct cmd_add_bonding_slave_result *res = parsed_result; 6312 portid_t master_port_id = res->port_id; 6313 portid_t slave_port_id = res->slave_id; 6314 6315 /* add the slave for a bonded device. */ 6316 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 6317 fprintf(stderr, 6318 "\t Failed to add slave %d to master port = %d.\n", 6319 slave_port_id, master_port_id); 6320 return; 6321 } 6322 init_port_config(); 6323 set_port_slave_flag(slave_port_id); 6324 } 6325 6326 cmdline_parse_token_string_t cmd_addbonding_slave_add = 6327 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6328 add, "add"); 6329 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 6330 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6331 bonding, "bonding"); 6332 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 6333 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6334 slave, "slave"); 6335 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 6336 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6337 slave_id, RTE_UINT16); 6338 cmdline_parse_token_num_t cmd_addbonding_slave_port = 6339 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6340 port_id, RTE_UINT16); 6341 6342 cmdline_parse_inst_t cmd_add_bonding_slave = { 6343 .f = cmd_add_bonding_slave_parsed, 6344 .help_str = "add bonding slave <slave_id> <port_id>: " 6345 "Add a slave device to a bonded device", 6346 .data = NULL, 6347 .tokens = { 6348 (void *)&cmd_addbonding_slave_add, 6349 (void *)&cmd_addbonding_slave_bonding, 6350 (void *)&cmd_addbonding_slave_slave, 6351 (void *)&cmd_addbonding_slave_slaveid, 6352 (void *)&cmd_addbonding_slave_port, 6353 NULL 6354 } 6355 }; 6356 6357 /* *** REMOVE SLAVE *** */ 6358 struct cmd_remove_bonding_slave_result { 6359 cmdline_fixed_string_t remove; 6360 cmdline_fixed_string_t bonding; 6361 cmdline_fixed_string_t slave; 6362 portid_t slave_id; 6363 portid_t port_id; 6364 }; 6365 6366 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 6367 __rte_unused struct cmdline *cl, 6368 __rte_unused void *data) 6369 { 6370 struct cmd_remove_bonding_slave_result *res = parsed_result; 6371 portid_t master_port_id = res->port_id; 6372 portid_t slave_port_id = res->slave_id; 6373 6374 /* remove the slave from a bonded device. */ 6375 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 6376 fprintf(stderr, 6377 "\t Failed to remove slave %d from master port = %d.\n", 6378 slave_port_id, master_port_id); 6379 return; 6380 } 6381 init_port_config(); 6382 clear_port_slave_flag(slave_port_id); 6383 } 6384 6385 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 6386 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6387 remove, "remove"); 6388 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 6389 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6390 bonding, "bonding"); 6391 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 6392 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6393 slave, "slave"); 6394 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 6395 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6396 slave_id, RTE_UINT16); 6397 cmdline_parse_token_num_t cmd_removebonding_slave_port = 6398 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6399 port_id, RTE_UINT16); 6400 6401 cmdline_parse_inst_t cmd_remove_bonding_slave = { 6402 .f = cmd_remove_bonding_slave_parsed, 6403 .help_str = "remove bonding slave <slave_id> <port_id>: " 6404 "Remove a slave device from a bonded device", 6405 .data = NULL, 6406 .tokens = { 6407 (void *)&cmd_removebonding_slave_remove, 6408 (void *)&cmd_removebonding_slave_bonding, 6409 (void *)&cmd_removebonding_slave_slave, 6410 (void *)&cmd_removebonding_slave_slaveid, 6411 (void *)&cmd_removebonding_slave_port, 6412 NULL 6413 } 6414 }; 6415 6416 /* *** CREATE BONDED DEVICE *** */ 6417 struct cmd_create_bonded_device_result { 6418 cmdline_fixed_string_t create; 6419 cmdline_fixed_string_t bonded; 6420 cmdline_fixed_string_t device; 6421 uint8_t mode; 6422 uint8_t socket; 6423 }; 6424 6425 static int bond_dev_num = 0; 6426 6427 static void cmd_create_bonded_device_parsed(void *parsed_result, 6428 __rte_unused struct cmdline *cl, 6429 __rte_unused void *data) 6430 { 6431 struct cmd_create_bonded_device_result *res = parsed_result; 6432 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 6433 int port_id; 6434 int ret; 6435 6436 if (test_done == 0) { 6437 fprintf(stderr, "Please stop forwarding first\n"); 6438 return; 6439 } 6440 6441 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 6442 bond_dev_num++); 6443 6444 /* Create a new bonded device. */ 6445 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 6446 if (port_id < 0) { 6447 fprintf(stderr, "\t Failed to create bonded device.\n"); 6448 return; 6449 } else { 6450 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 6451 port_id); 6452 6453 /* Update number of ports */ 6454 nb_ports = rte_eth_dev_count_avail(); 6455 reconfig(port_id, res->socket); 6456 ret = rte_eth_promiscuous_enable(port_id); 6457 if (ret != 0) 6458 fprintf(stderr, 6459 "Failed to enable promiscuous mode for port %u: %s - ignore\n", 6460 port_id, rte_strerror(-ret)); 6461 6462 ports[port_id].need_setup = 0; 6463 ports[port_id].port_status = RTE_PORT_STOPPED; 6464 } 6465 6466 } 6467 6468 cmdline_parse_token_string_t cmd_createbonded_device_create = 6469 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6470 create, "create"); 6471 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 6472 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6473 bonded, "bonded"); 6474 cmdline_parse_token_string_t cmd_createbonded_device_device = 6475 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6476 device, "device"); 6477 cmdline_parse_token_num_t cmd_createbonded_device_mode = 6478 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6479 mode, RTE_UINT8); 6480 cmdline_parse_token_num_t cmd_createbonded_device_socket = 6481 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6482 socket, RTE_UINT8); 6483 6484 cmdline_parse_inst_t cmd_create_bonded_device = { 6485 .f = cmd_create_bonded_device_parsed, 6486 .help_str = "create bonded device <mode> <socket>: " 6487 "Create a new bonded device with specific bonding mode and socket", 6488 .data = NULL, 6489 .tokens = { 6490 (void *)&cmd_createbonded_device_create, 6491 (void *)&cmd_createbonded_device_bonded, 6492 (void *)&cmd_createbonded_device_device, 6493 (void *)&cmd_createbonded_device_mode, 6494 (void *)&cmd_createbonded_device_socket, 6495 NULL 6496 } 6497 }; 6498 6499 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 6500 struct cmd_set_bond_mac_addr_result { 6501 cmdline_fixed_string_t set; 6502 cmdline_fixed_string_t bonding; 6503 cmdline_fixed_string_t mac_addr; 6504 uint16_t port_num; 6505 struct rte_ether_addr address; 6506 }; 6507 6508 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 6509 __rte_unused struct cmdline *cl, 6510 __rte_unused void *data) 6511 { 6512 struct cmd_set_bond_mac_addr_result *res = parsed_result; 6513 int ret; 6514 6515 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 6516 return; 6517 6518 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 6519 6520 /* check the return value and print it if is < 0 */ 6521 if (ret < 0) 6522 fprintf(stderr, "set_bond_mac_addr error: (%s)\n", 6523 strerror(-ret)); 6524 } 6525 6526 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 6527 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 6528 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 6529 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 6530 "bonding"); 6531 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 6532 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 6533 "mac_addr"); 6534 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 6535 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 6536 port_num, RTE_UINT16); 6537 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 6538 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 6539 6540 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 6541 .f = cmd_set_bond_mac_addr_parsed, 6542 .data = (void *) 0, 6543 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 6544 .tokens = { 6545 (void *)&cmd_set_bond_mac_addr_set, 6546 (void *)&cmd_set_bond_mac_addr_bonding, 6547 (void *)&cmd_set_bond_mac_addr_mac, 6548 (void *)&cmd_set_bond_mac_addr_portnum, 6549 (void *)&cmd_set_bond_mac_addr_addr, 6550 NULL 6551 } 6552 }; 6553 6554 6555 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 6556 struct cmd_set_bond_mon_period_result { 6557 cmdline_fixed_string_t set; 6558 cmdline_fixed_string_t bonding; 6559 cmdline_fixed_string_t mon_period; 6560 uint16_t port_num; 6561 uint32_t period_ms; 6562 }; 6563 6564 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 6565 __rte_unused struct cmdline *cl, 6566 __rte_unused void *data) 6567 { 6568 struct cmd_set_bond_mon_period_result *res = parsed_result; 6569 int ret; 6570 6571 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 6572 6573 /* check the return value and print it if is < 0 */ 6574 if (ret < 0) 6575 fprintf(stderr, "set_bond_mac_addr error: (%s)\n", 6576 strerror(-ret)); 6577 } 6578 6579 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 6580 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6581 set, "set"); 6582 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 6583 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6584 bonding, "bonding"); 6585 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 6586 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6587 mon_period, "mon_period"); 6588 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 6589 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6590 port_num, RTE_UINT16); 6591 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 6592 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6593 period_ms, RTE_UINT32); 6594 6595 cmdline_parse_inst_t cmd_set_bond_mon_period = { 6596 .f = cmd_set_bond_mon_period_parsed, 6597 .data = (void *) 0, 6598 .help_str = "set bonding mon_period <port_id> <period_ms>", 6599 .tokens = { 6600 (void *)&cmd_set_bond_mon_period_set, 6601 (void *)&cmd_set_bond_mon_period_bonding, 6602 (void *)&cmd_set_bond_mon_period_mon_period, 6603 (void *)&cmd_set_bond_mon_period_portnum, 6604 (void *)&cmd_set_bond_mon_period_period_ms, 6605 NULL 6606 } 6607 }; 6608 6609 6610 6611 struct cmd_set_bonding_agg_mode_policy_result { 6612 cmdline_fixed_string_t set; 6613 cmdline_fixed_string_t bonding; 6614 cmdline_fixed_string_t agg_mode; 6615 uint16_t port_num; 6616 cmdline_fixed_string_t policy; 6617 }; 6618 6619 6620 static void 6621 cmd_set_bonding_agg_mode(void *parsed_result, 6622 __rte_unused struct cmdline *cl, 6623 __rte_unused void *data) 6624 { 6625 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 6626 uint8_t policy = AGG_BANDWIDTH; 6627 6628 if (!strcmp(res->policy, "bandwidth")) 6629 policy = AGG_BANDWIDTH; 6630 else if (!strcmp(res->policy, "stable")) 6631 policy = AGG_STABLE; 6632 else if (!strcmp(res->policy, "count")) 6633 policy = AGG_COUNT; 6634 6635 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 6636 } 6637 6638 6639 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 6640 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6641 set, "set"); 6642 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 6643 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6644 bonding, "bonding"); 6645 6646 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 6647 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6648 agg_mode, "agg_mode"); 6649 6650 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 6651 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6652 port_num, RTE_UINT16); 6653 6654 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 6655 TOKEN_STRING_INITIALIZER( 6656 struct cmd_set_bonding_balance_xmit_policy_result, 6657 policy, "stable#bandwidth#count"); 6658 6659 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 6660 .f = cmd_set_bonding_agg_mode, 6661 .data = (void *) 0, 6662 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 6663 .tokens = { 6664 (void *)&cmd_set_bonding_agg_mode_set, 6665 (void *)&cmd_set_bonding_agg_mode_bonding, 6666 (void *)&cmd_set_bonding_agg_mode_agg_mode, 6667 (void *)&cmd_set_bonding_agg_mode_portnum, 6668 (void *)&cmd_set_bonding_agg_mode_policy_string, 6669 NULL 6670 } 6671 }; 6672 6673 6674 #endif /* RTE_NET_BOND */ 6675 6676 /* *** SET FORWARDING MODE *** */ 6677 struct cmd_set_fwd_mode_result { 6678 cmdline_fixed_string_t set; 6679 cmdline_fixed_string_t fwd; 6680 cmdline_fixed_string_t mode; 6681 }; 6682 6683 static void cmd_set_fwd_mode_parsed(void *parsed_result, 6684 __rte_unused struct cmdline *cl, 6685 __rte_unused void *data) 6686 { 6687 struct cmd_set_fwd_mode_result *res = parsed_result; 6688 6689 retry_enabled = 0; 6690 set_pkt_forwarding_mode(res->mode); 6691 } 6692 6693 cmdline_parse_token_string_t cmd_setfwd_set = 6694 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 6695 cmdline_parse_token_string_t cmd_setfwd_fwd = 6696 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 6697 cmdline_parse_token_string_t cmd_setfwd_mode = 6698 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 6699 "" /* defined at init */); 6700 6701 cmdline_parse_inst_t cmd_set_fwd_mode = { 6702 .f = cmd_set_fwd_mode_parsed, 6703 .data = NULL, 6704 .help_str = NULL, /* defined at init */ 6705 .tokens = { 6706 (void *)&cmd_setfwd_set, 6707 (void *)&cmd_setfwd_fwd, 6708 (void *)&cmd_setfwd_mode, 6709 NULL, 6710 }, 6711 }; 6712 6713 static void cmd_set_fwd_mode_init(void) 6714 { 6715 char *modes, *c; 6716 static char token[128]; 6717 static char help[256]; 6718 cmdline_parse_token_string_t *token_struct; 6719 6720 modes = list_pkt_forwarding_modes(); 6721 snprintf(help, sizeof(help), "set fwd %s: " 6722 "Set packet forwarding mode", modes); 6723 cmd_set_fwd_mode.help_str = help; 6724 6725 /* string token separator is # */ 6726 for (c = token; *modes != '\0'; modes++) 6727 if (*modes == '|') 6728 *c++ = '#'; 6729 else 6730 *c++ = *modes; 6731 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 6732 token_struct->string_data.str = token; 6733 } 6734 6735 /* *** SET RETRY FORWARDING MODE *** */ 6736 struct cmd_set_fwd_retry_mode_result { 6737 cmdline_fixed_string_t set; 6738 cmdline_fixed_string_t fwd; 6739 cmdline_fixed_string_t mode; 6740 cmdline_fixed_string_t retry; 6741 }; 6742 6743 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 6744 __rte_unused struct cmdline *cl, 6745 __rte_unused void *data) 6746 { 6747 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 6748 6749 retry_enabled = 1; 6750 set_pkt_forwarding_mode(res->mode); 6751 } 6752 6753 cmdline_parse_token_string_t cmd_setfwd_retry_set = 6754 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6755 set, "set"); 6756 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 6757 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6758 fwd, "fwd"); 6759 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 6760 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6761 mode, 6762 "" /* defined at init */); 6763 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 6764 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6765 retry, "retry"); 6766 6767 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 6768 .f = cmd_set_fwd_retry_mode_parsed, 6769 .data = NULL, 6770 .help_str = NULL, /* defined at init */ 6771 .tokens = { 6772 (void *)&cmd_setfwd_retry_set, 6773 (void *)&cmd_setfwd_retry_fwd, 6774 (void *)&cmd_setfwd_retry_mode, 6775 (void *)&cmd_setfwd_retry_retry, 6776 NULL, 6777 }, 6778 }; 6779 6780 static void cmd_set_fwd_retry_mode_init(void) 6781 { 6782 char *modes, *c; 6783 static char token[128]; 6784 static char help[256]; 6785 cmdline_parse_token_string_t *token_struct; 6786 6787 modes = list_pkt_forwarding_retry_modes(); 6788 snprintf(help, sizeof(help), "set fwd %s retry: " 6789 "Set packet forwarding mode with retry", modes); 6790 cmd_set_fwd_retry_mode.help_str = help; 6791 6792 /* string token separator is # */ 6793 for (c = token; *modes != '\0'; modes++) 6794 if (*modes == '|') 6795 *c++ = '#'; 6796 else 6797 *c++ = *modes; 6798 token_struct = (cmdline_parse_token_string_t *) 6799 cmd_set_fwd_retry_mode.tokens[2]; 6800 token_struct->string_data.str = token; 6801 } 6802 6803 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 6804 struct cmd_set_burst_tx_retry_result { 6805 cmdline_fixed_string_t set; 6806 cmdline_fixed_string_t burst; 6807 cmdline_fixed_string_t tx; 6808 cmdline_fixed_string_t delay; 6809 uint32_t time; 6810 cmdline_fixed_string_t retry; 6811 uint32_t retry_num; 6812 }; 6813 6814 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 6815 __rte_unused struct cmdline *cl, 6816 __rte_unused void *data) 6817 { 6818 struct cmd_set_burst_tx_retry_result *res = parsed_result; 6819 6820 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 6821 && !strcmp(res->tx, "tx")) { 6822 if (!strcmp(res->delay, "delay")) 6823 burst_tx_delay_time = res->time; 6824 if (!strcmp(res->retry, "retry")) 6825 burst_tx_retry_num = res->retry_num; 6826 } 6827 6828 } 6829 6830 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 6831 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 6832 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 6833 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 6834 "burst"); 6835 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 6836 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 6837 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 6838 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 6839 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 6840 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, 6841 RTE_UINT32); 6842 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 6843 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 6844 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 6845 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, 6846 RTE_UINT32); 6847 6848 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 6849 .f = cmd_set_burst_tx_retry_parsed, 6850 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 6851 .tokens = { 6852 (void *)&cmd_set_burst_tx_retry_set, 6853 (void *)&cmd_set_burst_tx_retry_burst, 6854 (void *)&cmd_set_burst_tx_retry_tx, 6855 (void *)&cmd_set_burst_tx_retry_delay, 6856 (void *)&cmd_set_burst_tx_retry_time, 6857 (void *)&cmd_set_burst_tx_retry_retry, 6858 (void *)&cmd_set_burst_tx_retry_retry_num, 6859 NULL, 6860 }, 6861 }; 6862 6863 /* *** SET PROMISC MODE *** */ 6864 struct cmd_set_promisc_mode_result { 6865 cmdline_fixed_string_t set; 6866 cmdline_fixed_string_t promisc; 6867 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6868 uint16_t port_num; /* valid if "allports" argument == 0 */ 6869 cmdline_fixed_string_t mode; 6870 }; 6871 6872 static void cmd_set_promisc_mode_parsed(void *parsed_result, 6873 __rte_unused struct cmdline *cl, 6874 void *allports) 6875 { 6876 struct cmd_set_promisc_mode_result *res = parsed_result; 6877 int enable; 6878 portid_t i; 6879 6880 if (!strcmp(res->mode, "on")) 6881 enable = 1; 6882 else 6883 enable = 0; 6884 6885 /* all ports */ 6886 if (allports) { 6887 RTE_ETH_FOREACH_DEV(i) 6888 eth_set_promisc_mode(i, enable); 6889 } else { 6890 eth_set_promisc_mode(res->port_num, enable); 6891 } 6892 } 6893 6894 cmdline_parse_token_string_t cmd_setpromisc_set = 6895 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 6896 cmdline_parse_token_string_t cmd_setpromisc_promisc = 6897 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 6898 "promisc"); 6899 cmdline_parse_token_string_t cmd_setpromisc_portall = 6900 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 6901 "all"); 6902 cmdline_parse_token_num_t cmd_setpromisc_portnum = 6903 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 6904 RTE_UINT16); 6905 cmdline_parse_token_string_t cmd_setpromisc_mode = 6906 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 6907 "on#off"); 6908 6909 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 6910 .f = cmd_set_promisc_mode_parsed, 6911 .data = (void *)1, 6912 .help_str = "set promisc all on|off: Set promisc mode for all ports", 6913 .tokens = { 6914 (void *)&cmd_setpromisc_set, 6915 (void *)&cmd_setpromisc_promisc, 6916 (void *)&cmd_setpromisc_portall, 6917 (void *)&cmd_setpromisc_mode, 6918 NULL, 6919 }, 6920 }; 6921 6922 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 6923 .f = cmd_set_promisc_mode_parsed, 6924 .data = (void *)0, 6925 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 6926 .tokens = { 6927 (void *)&cmd_setpromisc_set, 6928 (void *)&cmd_setpromisc_promisc, 6929 (void *)&cmd_setpromisc_portnum, 6930 (void *)&cmd_setpromisc_mode, 6931 NULL, 6932 }, 6933 }; 6934 6935 /* *** SET ALLMULTI MODE *** */ 6936 struct cmd_set_allmulti_mode_result { 6937 cmdline_fixed_string_t set; 6938 cmdline_fixed_string_t allmulti; 6939 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6940 uint16_t port_num; /* valid if "allports" argument == 0 */ 6941 cmdline_fixed_string_t mode; 6942 }; 6943 6944 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 6945 __rte_unused struct cmdline *cl, 6946 void *allports) 6947 { 6948 struct cmd_set_allmulti_mode_result *res = parsed_result; 6949 int enable; 6950 portid_t i; 6951 6952 if (!strcmp(res->mode, "on")) 6953 enable = 1; 6954 else 6955 enable = 0; 6956 6957 /* all ports */ 6958 if (allports) { 6959 RTE_ETH_FOREACH_DEV(i) { 6960 eth_set_allmulticast_mode(i, enable); 6961 } 6962 } 6963 else { 6964 eth_set_allmulticast_mode(res->port_num, enable); 6965 } 6966 } 6967 6968 cmdline_parse_token_string_t cmd_setallmulti_set = 6969 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 6970 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 6971 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 6972 "allmulti"); 6973 cmdline_parse_token_string_t cmd_setallmulti_portall = 6974 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 6975 "all"); 6976 cmdline_parse_token_num_t cmd_setallmulti_portnum = 6977 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 6978 RTE_UINT16); 6979 cmdline_parse_token_string_t cmd_setallmulti_mode = 6980 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 6981 "on#off"); 6982 6983 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 6984 .f = cmd_set_allmulti_mode_parsed, 6985 .data = (void *)1, 6986 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 6987 .tokens = { 6988 (void *)&cmd_setallmulti_set, 6989 (void *)&cmd_setallmulti_allmulti, 6990 (void *)&cmd_setallmulti_portall, 6991 (void *)&cmd_setallmulti_mode, 6992 NULL, 6993 }, 6994 }; 6995 6996 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 6997 .f = cmd_set_allmulti_mode_parsed, 6998 .data = (void *)0, 6999 .help_str = "set allmulti <port_id> on|off: " 7000 "Set allmulti mode on port_id", 7001 .tokens = { 7002 (void *)&cmd_setallmulti_set, 7003 (void *)&cmd_setallmulti_allmulti, 7004 (void *)&cmd_setallmulti_portnum, 7005 (void *)&cmd_setallmulti_mode, 7006 NULL, 7007 }, 7008 }; 7009 7010 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */ 7011 struct cmd_link_flow_ctrl_show { 7012 cmdline_fixed_string_t show; 7013 cmdline_fixed_string_t port; 7014 portid_t port_id; 7015 cmdline_fixed_string_t flow_ctrl; 7016 }; 7017 7018 cmdline_parse_token_string_t cmd_lfc_show_show = 7019 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, 7020 show, "show"); 7021 cmdline_parse_token_string_t cmd_lfc_show_port = 7022 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, 7023 port, "port"); 7024 cmdline_parse_token_num_t cmd_lfc_show_portid = 7025 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show, 7026 port_id, RTE_UINT16); 7027 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl = 7028 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, 7029 flow_ctrl, "flow_ctrl"); 7030 7031 static void 7032 cmd_link_flow_ctrl_show_parsed(void *parsed_result, 7033 __rte_unused struct cmdline *cl, 7034 __rte_unused void *data) 7035 { 7036 struct cmd_link_flow_ctrl_show *res = parsed_result; 7037 static const char *info_border = "*********************"; 7038 struct rte_eth_fc_conf fc_conf; 7039 bool rx_fc_en = false; 7040 bool tx_fc_en = false; 7041 int ret; 7042 7043 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 7044 if (ret != 0) { 7045 fprintf(stderr, 7046 "Failed to get current flow ctrl information: err = %d\n", 7047 ret); 7048 return; 7049 } 7050 7051 if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL) 7052 rx_fc_en = true; 7053 if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL) 7054 tx_fc_en = true; 7055 7056 printf("\n%s Flow control infos for port %-2d %s\n", 7057 info_border, res->port_id, info_border); 7058 printf("FC mode:\n"); 7059 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off"); 7060 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off"); 7061 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off"); 7062 printf("Pause time: 0x%x\n", fc_conf.pause_time); 7063 printf("High waterline: 0x%x\n", fc_conf.high_water); 7064 printf("Low waterline: 0x%x\n", fc_conf.low_water); 7065 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off"); 7066 printf("Forward MAC control frames: %s\n", 7067 fc_conf.mac_ctrl_frame_fwd ? "on" : "off"); 7068 printf("\n%s************** End ***********%s\n", 7069 info_border, info_border); 7070 } 7071 7072 cmdline_parse_inst_t cmd_link_flow_control_show = { 7073 .f = cmd_link_flow_ctrl_show_parsed, 7074 .data = NULL, 7075 .help_str = "show port <port_id> flow_ctrl", 7076 .tokens = { 7077 (void *)&cmd_lfc_show_show, 7078 (void *)&cmd_lfc_show_port, 7079 (void *)&cmd_lfc_show_portid, 7080 (void *)&cmd_lfc_show_flow_ctrl, 7081 NULL, 7082 }, 7083 }; 7084 7085 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 7086 struct cmd_link_flow_ctrl_set_result { 7087 cmdline_fixed_string_t set; 7088 cmdline_fixed_string_t flow_ctrl; 7089 cmdline_fixed_string_t rx; 7090 cmdline_fixed_string_t rx_lfc_mode; 7091 cmdline_fixed_string_t tx; 7092 cmdline_fixed_string_t tx_lfc_mode; 7093 cmdline_fixed_string_t mac_ctrl_frame_fwd; 7094 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 7095 cmdline_fixed_string_t autoneg_str; 7096 cmdline_fixed_string_t autoneg; 7097 cmdline_fixed_string_t hw_str; 7098 uint32_t high_water; 7099 cmdline_fixed_string_t lw_str; 7100 uint32_t low_water; 7101 cmdline_fixed_string_t pt_str; 7102 uint16_t pause_time; 7103 cmdline_fixed_string_t xon_str; 7104 uint16_t send_xon; 7105 portid_t port_id; 7106 }; 7107 7108 cmdline_parse_token_string_t cmd_lfc_set_set = 7109 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7110 set, "set"); 7111 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 7112 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7113 flow_ctrl, "flow_ctrl"); 7114 cmdline_parse_token_string_t cmd_lfc_set_rx = 7115 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7116 rx, "rx"); 7117 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 7118 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7119 rx_lfc_mode, "on#off"); 7120 cmdline_parse_token_string_t cmd_lfc_set_tx = 7121 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7122 tx, "tx"); 7123 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 7124 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7125 tx_lfc_mode, "on#off"); 7126 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 7127 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7128 hw_str, "high_water"); 7129 cmdline_parse_token_num_t cmd_lfc_set_high_water = 7130 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7131 high_water, RTE_UINT32); 7132 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 7133 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7134 lw_str, "low_water"); 7135 cmdline_parse_token_num_t cmd_lfc_set_low_water = 7136 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7137 low_water, RTE_UINT32); 7138 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 7139 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7140 pt_str, "pause_time"); 7141 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 7142 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7143 pause_time, RTE_UINT16); 7144 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 7145 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7146 xon_str, "send_xon"); 7147 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 7148 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7149 send_xon, RTE_UINT16); 7150 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 7151 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7152 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 7153 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 7154 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7155 mac_ctrl_frame_fwd_mode, "on#off"); 7156 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 7157 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7158 autoneg_str, "autoneg"); 7159 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 7160 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7161 autoneg, "on#off"); 7162 cmdline_parse_token_num_t cmd_lfc_set_portid = 7163 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7164 port_id, RTE_UINT16); 7165 7166 /* forward declaration */ 7167 static void 7168 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 7169 void *data); 7170 7171 cmdline_parse_inst_t cmd_link_flow_control_set = { 7172 .f = cmd_link_flow_ctrl_set_parsed, 7173 .data = NULL, 7174 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 7175 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 7176 "autoneg on|off <port_id>: Configure the Ethernet flow control", 7177 .tokens = { 7178 (void *)&cmd_lfc_set_set, 7179 (void *)&cmd_lfc_set_flow_ctrl, 7180 (void *)&cmd_lfc_set_rx, 7181 (void *)&cmd_lfc_set_rx_mode, 7182 (void *)&cmd_lfc_set_tx, 7183 (void *)&cmd_lfc_set_tx_mode, 7184 (void *)&cmd_lfc_set_high_water, 7185 (void *)&cmd_lfc_set_low_water, 7186 (void *)&cmd_lfc_set_pause_time, 7187 (void *)&cmd_lfc_set_send_xon, 7188 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 7189 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 7190 (void *)&cmd_lfc_set_autoneg_str, 7191 (void *)&cmd_lfc_set_autoneg, 7192 (void *)&cmd_lfc_set_portid, 7193 NULL, 7194 }, 7195 }; 7196 7197 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 7198 .f = cmd_link_flow_ctrl_set_parsed, 7199 .data = (void *)&cmd_link_flow_control_set_rx, 7200 .help_str = "set flow_ctrl rx on|off <port_id>: " 7201 "Change rx flow control parameter", 7202 .tokens = { 7203 (void *)&cmd_lfc_set_set, 7204 (void *)&cmd_lfc_set_flow_ctrl, 7205 (void *)&cmd_lfc_set_rx, 7206 (void *)&cmd_lfc_set_rx_mode, 7207 (void *)&cmd_lfc_set_portid, 7208 NULL, 7209 }, 7210 }; 7211 7212 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 7213 .f = cmd_link_flow_ctrl_set_parsed, 7214 .data = (void *)&cmd_link_flow_control_set_tx, 7215 .help_str = "set flow_ctrl tx on|off <port_id>: " 7216 "Change tx flow control parameter", 7217 .tokens = { 7218 (void *)&cmd_lfc_set_set, 7219 (void *)&cmd_lfc_set_flow_ctrl, 7220 (void *)&cmd_lfc_set_tx, 7221 (void *)&cmd_lfc_set_tx_mode, 7222 (void *)&cmd_lfc_set_portid, 7223 NULL, 7224 }, 7225 }; 7226 7227 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 7228 .f = cmd_link_flow_ctrl_set_parsed, 7229 .data = (void *)&cmd_link_flow_control_set_hw, 7230 .help_str = "set flow_ctrl high_water <value> <port_id>: " 7231 "Change high water flow control parameter", 7232 .tokens = { 7233 (void *)&cmd_lfc_set_set, 7234 (void *)&cmd_lfc_set_flow_ctrl, 7235 (void *)&cmd_lfc_set_high_water_str, 7236 (void *)&cmd_lfc_set_high_water, 7237 (void *)&cmd_lfc_set_portid, 7238 NULL, 7239 }, 7240 }; 7241 7242 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 7243 .f = cmd_link_flow_ctrl_set_parsed, 7244 .data = (void *)&cmd_link_flow_control_set_lw, 7245 .help_str = "set flow_ctrl low_water <value> <port_id>: " 7246 "Change low water flow control parameter", 7247 .tokens = { 7248 (void *)&cmd_lfc_set_set, 7249 (void *)&cmd_lfc_set_flow_ctrl, 7250 (void *)&cmd_lfc_set_low_water_str, 7251 (void *)&cmd_lfc_set_low_water, 7252 (void *)&cmd_lfc_set_portid, 7253 NULL, 7254 }, 7255 }; 7256 7257 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 7258 .f = cmd_link_flow_ctrl_set_parsed, 7259 .data = (void *)&cmd_link_flow_control_set_pt, 7260 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 7261 "Change pause time flow control parameter", 7262 .tokens = { 7263 (void *)&cmd_lfc_set_set, 7264 (void *)&cmd_lfc_set_flow_ctrl, 7265 (void *)&cmd_lfc_set_pause_time_str, 7266 (void *)&cmd_lfc_set_pause_time, 7267 (void *)&cmd_lfc_set_portid, 7268 NULL, 7269 }, 7270 }; 7271 7272 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 7273 .f = cmd_link_flow_ctrl_set_parsed, 7274 .data = (void *)&cmd_link_flow_control_set_xon, 7275 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 7276 "Change send_xon flow control parameter", 7277 .tokens = { 7278 (void *)&cmd_lfc_set_set, 7279 (void *)&cmd_lfc_set_flow_ctrl, 7280 (void *)&cmd_lfc_set_send_xon_str, 7281 (void *)&cmd_lfc_set_send_xon, 7282 (void *)&cmd_lfc_set_portid, 7283 NULL, 7284 }, 7285 }; 7286 7287 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 7288 .f = cmd_link_flow_ctrl_set_parsed, 7289 .data = (void *)&cmd_link_flow_control_set_macfwd, 7290 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 7291 "Change mac ctrl fwd flow control parameter", 7292 .tokens = { 7293 (void *)&cmd_lfc_set_set, 7294 (void *)&cmd_lfc_set_flow_ctrl, 7295 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 7296 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 7297 (void *)&cmd_lfc_set_portid, 7298 NULL, 7299 }, 7300 }; 7301 7302 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 7303 .f = cmd_link_flow_ctrl_set_parsed, 7304 .data = (void *)&cmd_link_flow_control_set_autoneg, 7305 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 7306 "Change autoneg flow control parameter", 7307 .tokens = { 7308 (void *)&cmd_lfc_set_set, 7309 (void *)&cmd_lfc_set_flow_ctrl, 7310 (void *)&cmd_lfc_set_autoneg_str, 7311 (void *)&cmd_lfc_set_autoneg, 7312 (void *)&cmd_lfc_set_portid, 7313 NULL, 7314 }, 7315 }; 7316 7317 static void 7318 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 7319 __rte_unused struct cmdline *cl, 7320 void *data) 7321 { 7322 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 7323 cmdline_parse_inst_t *cmd = data; 7324 struct rte_eth_fc_conf fc_conf; 7325 int rx_fc_en = 0; 7326 int tx_fc_en = 0; 7327 int ret; 7328 7329 /* 7330 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 7331 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 7332 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 7333 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 7334 */ 7335 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 7336 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 7337 }; 7338 7339 /* Partial command line, retrieve current configuration */ 7340 if (cmd) { 7341 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 7342 if (ret != 0) { 7343 fprintf(stderr, 7344 "cannot get current flow ctrl parameters, return code = %d\n", 7345 ret); 7346 return; 7347 } 7348 7349 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 7350 (fc_conf.mode == RTE_FC_FULL)) 7351 rx_fc_en = 1; 7352 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 7353 (fc_conf.mode == RTE_FC_FULL)) 7354 tx_fc_en = 1; 7355 } 7356 7357 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 7358 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 7359 7360 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 7361 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 7362 7363 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 7364 7365 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 7366 fc_conf.high_water = res->high_water; 7367 7368 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 7369 fc_conf.low_water = res->low_water; 7370 7371 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 7372 fc_conf.pause_time = res->pause_time; 7373 7374 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 7375 fc_conf.send_xon = res->send_xon; 7376 7377 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 7378 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 7379 fc_conf.mac_ctrl_frame_fwd = 1; 7380 else 7381 fc_conf.mac_ctrl_frame_fwd = 0; 7382 } 7383 7384 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 7385 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 7386 7387 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 7388 if (ret != 0) 7389 fprintf(stderr, 7390 "bad flow control parameter, return code = %d\n", 7391 ret); 7392 } 7393 7394 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 7395 struct cmd_priority_flow_ctrl_set_result { 7396 cmdline_fixed_string_t set; 7397 cmdline_fixed_string_t pfc_ctrl; 7398 cmdline_fixed_string_t rx; 7399 cmdline_fixed_string_t rx_pfc_mode; 7400 cmdline_fixed_string_t tx; 7401 cmdline_fixed_string_t tx_pfc_mode; 7402 uint32_t high_water; 7403 uint32_t low_water; 7404 uint16_t pause_time; 7405 uint8_t priority; 7406 portid_t port_id; 7407 }; 7408 7409 static void 7410 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 7411 __rte_unused struct cmdline *cl, 7412 __rte_unused void *data) 7413 { 7414 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 7415 struct rte_eth_pfc_conf pfc_conf; 7416 int rx_fc_enable, tx_fc_enable; 7417 int ret; 7418 7419 /* 7420 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 7421 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 7422 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 7423 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 7424 */ 7425 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 7426 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 7427 }; 7428 7429 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf)); 7430 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 7431 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 7432 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 7433 pfc_conf.fc.high_water = res->high_water; 7434 pfc_conf.fc.low_water = res->low_water; 7435 pfc_conf.fc.pause_time = res->pause_time; 7436 pfc_conf.priority = res->priority; 7437 7438 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 7439 if (ret != 0) 7440 fprintf(stderr, 7441 "bad priority flow control parameter, return code = %d\n", 7442 ret); 7443 } 7444 7445 cmdline_parse_token_string_t cmd_pfc_set_set = 7446 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7447 set, "set"); 7448 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 7449 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7450 pfc_ctrl, "pfc_ctrl"); 7451 cmdline_parse_token_string_t cmd_pfc_set_rx = 7452 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7453 rx, "rx"); 7454 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 7455 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7456 rx_pfc_mode, "on#off"); 7457 cmdline_parse_token_string_t cmd_pfc_set_tx = 7458 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7459 tx, "tx"); 7460 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 7461 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7462 tx_pfc_mode, "on#off"); 7463 cmdline_parse_token_num_t cmd_pfc_set_high_water = 7464 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7465 high_water, RTE_UINT32); 7466 cmdline_parse_token_num_t cmd_pfc_set_low_water = 7467 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7468 low_water, RTE_UINT32); 7469 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 7470 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7471 pause_time, RTE_UINT16); 7472 cmdline_parse_token_num_t cmd_pfc_set_priority = 7473 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7474 priority, RTE_UINT8); 7475 cmdline_parse_token_num_t cmd_pfc_set_portid = 7476 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7477 port_id, RTE_UINT16); 7478 7479 cmdline_parse_inst_t cmd_priority_flow_control_set = { 7480 .f = cmd_priority_flow_ctrl_set_parsed, 7481 .data = NULL, 7482 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 7483 "<pause_time> <priority> <port_id>: " 7484 "Configure the Ethernet priority flow control", 7485 .tokens = { 7486 (void *)&cmd_pfc_set_set, 7487 (void *)&cmd_pfc_set_flow_ctrl, 7488 (void *)&cmd_pfc_set_rx, 7489 (void *)&cmd_pfc_set_rx_mode, 7490 (void *)&cmd_pfc_set_tx, 7491 (void *)&cmd_pfc_set_tx_mode, 7492 (void *)&cmd_pfc_set_high_water, 7493 (void *)&cmd_pfc_set_low_water, 7494 (void *)&cmd_pfc_set_pause_time, 7495 (void *)&cmd_pfc_set_priority, 7496 (void *)&cmd_pfc_set_portid, 7497 NULL, 7498 }, 7499 }; 7500 7501 /* *** RESET CONFIGURATION *** */ 7502 struct cmd_reset_result { 7503 cmdline_fixed_string_t reset; 7504 cmdline_fixed_string_t def; 7505 }; 7506 7507 static void cmd_reset_parsed(__rte_unused void *parsed_result, 7508 struct cmdline *cl, 7509 __rte_unused void *data) 7510 { 7511 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 7512 set_def_fwd_config(); 7513 } 7514 7515 cmdline_parse_token_string_t cmd_reset_set = 7516 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 7517 cmdline_parse_token_string_t cmd_reset_def = 7518 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 7519 "default"); 7520 7521 cmdline_parse_inst_t cmd_reset = { 7522 .f = cmd_reset_parsed, 7523 .data = NULL, 7524 .help_str = "set default: Reset default forwarding configuration", 7525 .tokens = { 7526 (void *)&cmd_reset_set, 7527 (void *)&cmd_reset_def, 7528 NULL, 7529 }, 7530 }; 7531 7532 /* *** START FORWARDING *** */ 7533 struct cmd_start_result { 7534 cmdline_fixed_string_t start; 7535 }; 7536 7537 cmdline_parse_token_string_t cmd_start_start = 7538 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 7539 7540 static void cmd_start_parsed(__rte_unused void *parsed_result, 7541 __rte_unused struct cmdline *cl, 7542 __rte_unused void *data) 7543 { 7544 start_packet_forwarding(0); 7545 } 7546 7547 cmdline_parse_inst_t cmd_start = { 7548 .f = cmd_start_parsed, 7549 .data = NULL, 7550 .help_str = "start: Start packet forwarding", 7551 .tokens = { 7552 (void *)&cmd_start_start, 7553 NULL, 7554 }, 7555 }; 7556 7557 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 7558 struct cmd_start_tx_first_result { 7559 cmdline_fixed_string_t start; 7560 cmdline_fixed_string_t tx_first; 7561 }; 7562 7563 static void 7564 cmd_start_tx_first_parsed(__rte_unused void *parsed_result, 7565 __rte_unused struct cmdline *cl, 7566 __rte_unused void *data) 7567 { 7568 start_packet_forwarding(1); 7569 } 7570 7571 cmdline_parse_token_string_t cmd_start_tx_first_start = 7572 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 7573 "start"); 7574 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 7575 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 7576 tx_first, "tx_first"); 7577 7578 cmdline_parse_inst_t cmd_start_tx_first = { 7579 .f = cmd_start_tx_first_parsed, 7580 .data = NULL, 7581 .help_str = "start tx_first: Start packet forwarding, " 7582 "after sending 1 burst of packets", 7583 .tokens = { 7584 (void *)&cmd_start_tx_first_start, 7585 (void *)&cmd_start_tx_first_tx_first, 7586 NULL, 7587 }, 7588 }; 7589 7590 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 7591 struct cmd_start_tx_first_n_result { 7592 cmdline_fixed_string_t start; 7593 cmdline_fixed_string_t tx_first; 7594 uint32_t tx_num; 7595 }; 7596 7597 static void 7598 cmd_start_tx_first_n_parsed(void *parsed_result, 7599 __rte_unused struct cmdline *cl, 7600 __rte_unused void *data) 7601 { 7602 struct cmd_start_tx_first_n_result *res = parsed_result; 7603 7604 start_packet_forwarding(res->tx_num); 7605 } 7606 7607 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 7608 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7609 start, "start"); 7610 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 7611 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7612 tx_first, "tx_first"); 7613 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 7614 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 7615 tx_num, RTE_UINT32); 7616 7617 cmdline_parse_inst_t cmd_start_tx_first_n = { 7618 .f = cmd_start_tx_first_n_parsed, 7619 .data = NULL, 7620 .help_str = "start tx_first <num>: " 7621 "packet forwarding, after sending <num> bursts of packets", 7622 .tokens = { 7623 (void *)&cmd_start_tx_first_n_start, 7624 (void *)&cmd_start_tx_first_n_tx_first, 7625 (void *)&cmd_start_tx_first_n_tx_num, 7626 NULL, 7627 }, 7628 }; 7629 7630 /* *** SET LINK UP *** */ 7631 struct cmd_set_link_up_result { 7632 cmdline_fixed_string_t set; 7633 cmdline_fixed_string_t link_up; 7634 cmdline_fixed_string_t port; 7635 portid_t port_id; 7636 }; 7637 7638 cmdline_parse_token_string_t cmd_set_link_up_set = 7639 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 7640 cmdline_parse_token_string_t cmd_set_link_up_link_up = 7641 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 7642 "link-up"); 7643 cmdline_parse_token_string_t cmd_set_link_up_port = 7644 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 7645 cmdline_parse_token_num_t cmd_set_link_up_port_id = 7646 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, 7647 RTE_UINT16); 7648 7649 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result, 7650 __rte_unused struct cmdline *cl, 7651 __rte_unused void *data) 7652 { 7653 struct cmd_set_link_up_result *res = parsed_result; 7654 dev_set_link_up(res->port_id); 7655 } 7656 7657 cmdline_parse_inst_t cmd_set_link_up = { 7658 .f = cmd_set_link_up_parsed, 7659 .data = NULL, 7660 .help_str = "set link-up port <port id>", 7661 .tokens = { 7662 (void *)&cmd_set_link_up_set, 7663 (void *)&cmd_set_link_up_link_up, 7664 (void *)&cmd_set_link_up_port, 7665 (void *)&cmd_set_link_up_port_id, 7666 NULL, 7667 }, 7668 }; 7669 7670 /* *** SET LINK DOWN *** */ 7671 struct cmd_set_link_down_result { 7672 cmdline_fixed_string_t set; 7673 cmdline_fixed_string_t link_down; 7674 cmdline_fixed_string_t port; 7675 portid_t port_id; 7676 }; 7677 7678 cmdline_parse_token_string_t cmd_set_link_down_set = 7679 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 7680 cmdline_parse_token_string_t cmd_set_link_down_link_down = 7681 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 7682 "link-down"); 7683 cmdline_parse_token_string_t cmd_set_link_down_port = 7684 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 7685 cmdline_parse_token_num_t cmd_set_link_down_port_id = 7686 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, 7687 RTE_UINT16); 7688 7689 static void cmd_set_link_down_parsed( 7690 __rte_unused void *parsed_result, 7691 __rte_unused struct cmdline *cl, 7692 __rte_unused void *data) 7693 { 7694 struct cmd_set_link_down_result *res = parsed_result; 7695 dev_set_link_down(res->port_id); 7696 } 7697 7698 cmdline_parse_inst_t cmd_set_link_down = { 7699 .f = cmd_set_link_down_parsed, 7700 .data = NULL, 7701 .help_str = "set link-down port <port id>", 7702 .tokens = { 7703 (void *)&cmd_set_link_down_set, 7704 (void *)&cmd_set_link_down_link_down, 7705 (void *)&cmd_set_link_down_port, 7706 (void *)&cmd_set_link_down_port_id, 7707 NULL, 7708 }, 7709 }; 7710 7711 /* *** SHOW CFG *** */ 7712 struct cmd_showcfg_result { 7713 cmdline_fixed_string_t show; 7714 cmdline_fixed_string_t cfg; 7715 cmdline_fixed_string_t what; 7716 }; 7717 7718 static void cmd_showcfg_parsed(void *parsed_result, 7719 __rte_unused struct cmdline *cl, 7720 __rte_unused void *data) 7721 { 7722 struct cmd_showcfg_result *res = parsed_result; 7723 if (!strcmp(res->what, "rxtx")) 7724 rxtx_config_display(); 7725 else if (!strcmp(res->what, "cores")) 7726 fwd_lcores_config_display(); 7727 else if (!strcmp(res->what, "fwd")) 7728 pkt_fwd_config_display(&cur_fwd_config); 7729 else if (!strcmp(res->what, "rxoffs")) 7730 show_rx_pkt_offsets(); 7731 else if (!strcmp(res->what, "rxpkts")) 7732 show_rx_pkt_segments(); 7733 else if (!strcmp(res->what, "txpkts")) 7734 show_tx_pkt_segments(); 7735 else if (!strcmp(res->what, "txtimes")) 7736 show_tx_pkt_times(); 7737 } 7738 7739 cmdline_parse_token_string_t cmd_showcfg_show = 7740 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 7741 cmdline_parse_token_string_t cmd_showcfg_port = 7742 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7743 cmdline_parse_token_string_t cmd_showcfg_what = 7744 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7745 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes"); 7746 7747 cmdline_parse_inst_t cmd_showcfg = { 7748 .f = cmd_showcfg_parsed, 7749 .data = NULL, 7750 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes", 7751 .tokens = { 7752 (void *)&cmd_showcfg_show, 7753 (void *)&cmd_showcfg_port, 7754 (void *)&cmd_showcfg_what, 7755 NULL, 7756 }, 7757 }; 7758 7759 /* *** SHOW ALL PORT INFO *** */ 7760 struct cmd_showportall_result { 7761 cmdline_fixed_string_t show; 7762 cmdline_fixed_string_t port; 7763 cmdline_fixed_string_t what; 7764 cmdline_fixed_string_t all; 7765 }; 7766 7767 static void cmd_showportall_parsed(void *parsed_result, 7768 __rte_unused struct cmdline *cl, 7769 __rte_unused void *data) 7770 { 7771 portid_t i; 7772 7773 struct cmd_showportall_result *res = parsed_result; 7774 if (!strcmp(res->show, "clear")) { 7775 if (!strcmp(res->what, "stats")) 7776 RTE_ETH_FOREACH_DEV(i) 7777 nic_stats_clear(i); 7778 else if (!strcmp(res->what, "xstats")) 7779 RTE_ETH_FOREACH_DEV(i) 7780 nic_xstats_clear(i); 7781 } else if (!strcmp(res->what, "info")) 7782 RTE_ETH_FOREACH_DEV(i) 7783 port_infos_display(i); 7784 else if (!strcmp(res->what, "summary")) { 7785 port_summary_header_display(); 7786 RTE_ETH_FOREACH_DEV(i) 7787 port_summary_display(i); 7788 } 7789 else if (!strcmp(res->what, "stats")) 7790 RTE_ETH_FOREACH_DEV(i) 7791 nic_stats_display(i); 7792 else if (!strcmp(res->what, "xstats")) 7793 RTE_ETH_FOREACH_DEV(i) 7794 nic_xstats_display(i); 7795 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) 7796 else if (!strcmp(res->what, "fdir")) 7797 RTE_ETH_FOREACH_DEV(i) 7798 fdir_get_infos(i); 7799 #endif 7800 else if (!strcmp(res->what, "dcb_tc")) 7801 RTE_ETH_FOREACH_DEV(i) 7802 port_dcb_info_display(i); 7803 } 7804 7805 cmdline_parse_token_string_t cmd_showportall_show = 7806 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7807 "show#clear"); 7808 cmdline_parse_token_string_t cmd_showportall_port = 7809 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7810 cmdline_parse_token_string_t cmd_showportall_what = 7811 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7812 "info#summary#stats#xstats#fdir#dcb_tc"); 7813 cmdline_parse_token_string_t cmd_showportall_all = 7814 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 7815 cmdline_parse_inst_t cmd_showportall = { 7816 .f = cmd_showportall_parsed, 7817 .data = NULL, 7818 .help_str = "show|clear port " 7819 "info|summary|stats|xstats|fdir|dcb_tc all", 7820 .tokens = { 7821 (void *)&cmd_showportall_show, 7822 (void *)&cmd_showportall_port, 7823 (void *)&cmd_showportall_what, 7824 (void *)&cmd_showportall_all, 7825 NULL, 7826 }, 7827 }; 7828 7829 /* *** SHOW PORT INFO *** */ 7830 struct cmd_showport_result { 7831 cmdline_fixed_string_t show; 7832 cmdline_fixed_string_t port; 7833 cmdline_fixed_string_t what; 7834 uint16_t portnum; 7835 }; 7836 7837 static void cmd_showport_parsed(void *parsed_result, 7838 __rte_unused struct cmdline *cl, 7839 __rte_unused void *data) 7840 { 7841 struct cmd_showport_result *res = parsed_result; 7842 if (!strcmp(res->show, "clear")) { 7843 if (!strcmp(res->what, "stats")) 7844 nic_stats_clear(res->portnum); 7845 else if (!strcmp(res->what, "xstats")) 7846 nic_xstats_clear(res->portnum); 7847 } else if (!strcmp(res->what, "info")) 7848 port_infos_display(res->portnum); 7849 else if (!strcmp(res->what, "summary")) { 7850 port_summary_header_display(); 7851 port_summary_display(res->portnum); 7852 } 7853 else if (!strcmp(res->what, "stats")) 7854 nic_stats_display(res->portnum); 7855 else if (!strcmp(res->what, "xstats")) 7856 nic_xstats_display(res->portnum); 7857 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) 7858 else if (!strcmp(res->what, "fdir")) 7859 fdir_get_infos(res->portnum); 7860 #endif 7861 else if (!strcmp(res->what, "dcb_tc")) 7862 port_dcb_info_display(res->portnum); 7863 } 7864 7865 cmdline_parse_token_string_t cmd_showport_show = 7866 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 7867 "show#clear"); 7868 cmdline_parse_token_string_t cmd_showport_port = 7869 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 7870 cmdline_parse_token_string_t cmd_showport_what = 7871 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 7872 "info#summary#stats#xstats#fdir#dcb_tc"); 7873 cmdline_parse_token_num_t cmd_showport_portnum = 7874 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16); 7875 7876 cmdline_parse_inst_t cmd_showport = { 7877 .f = cmd_showport_parsed, 7878 .data = NULL, 7879 .help_str = "show|clear port " 7880 "info|summary|stats|xstats|fdir|dcb_tc " 7881 "<port_id>", 7882 .tokens = { 7883 (void *)&cmd_showport_show, 7884 (void *)&cmd_showport_port, 7885 (void *)&cmd_showport_what, 7886 (void *)&cmd_showport_portnum, 7887 NULL, 7888 }, 7889 }; 7890 7891 /* *** SHOW DEVICE INFO *** */ 7892 struct cmd_showdevice_result { 7893 cmdline_fixed_string_t show; 7894 cmdline_fixed_string_t device; 7895 cmdline_fixed_string_t what; 7896 cmdline_fixed_string_t identifier; 7897 }; 7898 7899 static void cmd_showdevice_parsed(void *parsed_result, 7900 __rte_unused struct cmdline *cl, 7901 __rte_unused void *data) 7902 { 7903 struct cmd_showdevice_result *res = parsed_result; 7904 if (!strcmp(res->what, "info")) { 7905 if (!strcmp(res->identifier, "all")) 7906 device_infos_display(NULL); 7907 else 7908 device_infos_display(res->identifier); 7909 } 7910 } 7911 7912 cmdline_parse_token_string_t cmd_showdevice_show = 7913 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show, 7914 "show"); 7915 cmdline_parse_token_string_t cmd_showdevice_device = 7916 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device"); 7917 cmdline_parse_token_string_t cmd_showdevice_what = 7918 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what, 7919 "info"); 7920 cmdline_parse_token_string_t cmd_showdevice_identifier = 7921 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, 7922 identifier, NULL); 7923 7924 cmdline_parse_inst_t cmd_showdevice = { 7925 .f = cmd_showdevice_parsed, 7926 .data = NULL, 7927 .help_str = "show device info <identifier>|all", 7928 .tokens = { 7929 (void *)&cmd_showdevice_show, 7930 (void *)&cmd_showdevice_device, 7931 (void *)&cmd_showdevice_what, 7932 (void *)&cmd_showdevice_identifier, 7933 NULL, 7934 }, 7935 }; 7936 7937 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */ 7938 struct cmd_showeeprom_result { 7939 cmdline_fixed_string_t show; 7940 cmdline_fixed_string_t port; 7941 uint16_t portnum; 7942 cmdline_fixed_string_t type; 7943 }; 7944 7945 static void cmd_showeeprom_parsed(void *parsed_result, 7946 __rte_unused struct cmdline *cl, 7947 __rte_unused void *data) 7948 { 7949 struct cmd_showeeprom_result *res = parsed_result; 7950 7951 if (!strcmp(res->type, "eeprom")) 7952 port_eeprom_display(res->portnum); 7953 else if (!strcmp(res->type, "module_eeprom")) 7954 port_module_eeprom_display(res->portnum); 7955 else 7956 fprintf(stderr, "Unknown argument\n"); 7957 } 7958 7959 cmdline_parse_token_string_t cmd_showeeprom_show = 7960 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show"); 7961 cmdline_parse_token_string_t cmd_showeeprom_port = 7962 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port"); 7963 cmdline_parse_token_num_t cmd_showeeprom_portnum = 7964 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, 7965 RTE_UINT16); 7966 cmdline_parse_token_string_t cmd_showeeprom_type = 7967 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom"); 7968 7969 cmdline_parse_inst_t cmd_showeeprom = { 7970 .f = cmd_showeeprom_parsed, 7971 .data = NULL, 7972 .help_str = "show port <port_id> module_eeprom|eeprom", 7973 .tokens = { 7974 (void *)&cmd_showeeprom_show, 7975 (void *)&cmd_showeeprom_port, 7976 (void *)&cmd_showeeprom_portnum, 7977 (void *)&cmd_showeeprom_type, 7978 NULL, 7979 }, 7980 }; 7981 7982 /* *** SHOW QUEUE INFO *** */ 7983 struct cmd_showqueue_result { 7984 cmdline_fixed_string_t show; 7985 cmdline_fixed_string_t type; 7986 cmdline_fixed_string_t what; 7987 uint16_t portnum; 7988 uint16_t queuenum; 7989 }; 7990 7991 static void 7992 cmd_showqueue_parsed(void *parsed_result, 7993 __rte_unused struct cmdline *cl, 7994 __rte_unused void *data) 7995 { 7996 struct cmd_showqueue_result *res = parsed_result; 7997 7998 if (!strcmp(res->type, "rxq")) 7999 rx_queue_infos_display(res->portnum, res->queuenum); 8000 else if (!strcmp(res->type, "txq")) 8001 tx_queue_infos_display(res->portnum, res->queuenum); 8002 } 8003 8004 cmdline_parse_token_string_t cmd_showqueue_show = 8005 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 8006 cmdline_parse_token_string_t cmd_showqueue_type = 8007 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 8008 cmdline_parse_token_string_t cmd_showqueue_what = 8009 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 8010 cmdline_parse_token_num_t cmd_showqueue_portnum = 8011 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, 8012 RTE_UINT16); 8013 cmdline_parse_token_num_t cmd_showqueue_queuenum = 8014 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, 8015 RTE_UINT16); 8016 8017 cmdline_parse_inst_t cmd_showqueue = { 8018 .f = cmd_showqueue_parsed, 8019 .data = NULL, 8020 .help_str = "show rxq|txq info <port_id> <queue_id>", 8021 .tokens = { 8022 (void *)&cmd_showqueue_show, 8023 (void *)&cmd_showqueue_type, 8024 (void *)&cmd_showqueue_what, 8025 (void *)&cmd_showqueue_portnum, 8026 (void *)&cmd_showqueue_queuenum, 8027 NULL, 8028 }, 8029 }; 8030 8031 /* show/clear fwd engine statistics */ 8032 struct fwd_result { 8033 cmdline_fixed_string_t action; 8034 cmdline_fixed_string_t fwd; 8035 cmdline_fixed_string_t stats; 8036 cmdline_fixed_string_t all; 8037 }; 8038 8039 cmdline_parse_token_string_t cmd_fwd_action = 8040 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear"); 8041 cmdline_parse_token_string_t cmd_fwd_fwd = 8042 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd"); 8043 cmdline_parse_token_string_t cmd_fwd_stats = 8044 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats"); 8045 cmdline_parse_token_string_t cmd_fwd_all = 8046 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all"); 8047 8048 static void 8049 cmd_showfwdall_parsed(void *parsed_result, 8050 __rte_unused struct cmdline *cl, 8051 __rte_unused void *data) 8052 { 8053 struct fwd_result *res = parsed_result; 8054 8055 if (!strcmp(res->action, "show")) 8056 fwd_stats_display(); 8057 else 8058 fwd_stats_reset(); 8059 } 8060 8061 static cmdline_parse_inst_t cmd_showfwdall = { 8062 .f = cmd_showfwdall_parsed, 8063 .data = NULL, 8064 .help_str = "show|clear fwd stats all", 8065 .tokens = { 8066 (void *)&cmd_fwd_action, 8067 (void *)&cmd_fwd_fwd, 8068 (void *)&cmd_fwd_stats, 8069 (void *)&cmd_fwd_all, 8070 NULL, 8071 }, 8072 }; 8073 8074 /* *** READ PORT REGISTER *** */ 8075 struct cmd_read_reg_result { 8076 cmdline_fixed_string_t read; 8077 cmdline_fixed_string_t reg; 8078 portid_t port_id; 8079 uint32_t reg_off; 8080 }; 8081 8082 static void 8083 cmd_read_reg_parsed(void *parsed_result, 8084 __rte_unused struct cmdline *cl, 8085 __rte_unused void *data) 8086 { 8087 struct cmd_read_reg_result *res = parsed_result; 8088 port_reg_display(res->port_id, res->reg_off); 8089 } 8090 8091 cmdline_parse_token_string_t cmd_read_reg_read = 8092 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 8093 cmdline_parse_token_string_t cmd_read_reg_reg = 8094 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 8095 cmdline_parse_token_num_t cmd_read_reg_port_id = 8096 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16); 8097 cmdline_parse_token_num_t cmd_read_reg_reg_off = 8098 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32); 8099 8100 cmdline_parse_inst_t cmd_read_reg = { 8101 .f = cmd_read_reg_parsed, 8102 .data = NULL, 8103 .help_str = "read reg <port_id> <reg_off>", 8104 .tokens = { 8105 (void *)&cmd_read_reg_read, 8106 (void *)&cmd_read_reg_reg, 8107 (void *)&cmd_read_reg_port_id, 8108 (void *)&cmd_read_reg_reg_off, 8109 NULL, 8110 }, 8111 }; 8112 8113 /* *** READ PORT REGISTER BIT FIELD *** */ 8114 struct cmd_read_reg_bit_field_result { 8115 cmdline_fixed_string_t read; 8116 cmdline_fixed_string_t regfield; 8117 portid_t port_id; 8118 uint32_t reg_off; 8119 uint8_t bit1_pos; 8120 uint8_t bit2_pos; 8121 }; 8122 8123 static void 8124 cmd_read_reg_bit_field_parsed(void *parsed_result, 8125 __rte_unused struct cmdline *cl, 8126 __rte_unused void *data) 8127 { 8128 struct cmd_read_reg_bit_field_result *res = parsed_result; 8129 port_reg_bit_field_display(res->port_id, res->reg_off, 8130 res->bit1_pos, res->bit2_pos); 8131 } 8132 8133 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 8134 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 8135 "read"); 8136 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 8137 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 8138 regfield, "regfield"); 8139 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 8140 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 8141 RTE_UINT16); 8142 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 8143 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 8144 RTE_UINT32); 8145 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 8146 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 8147 RTE_UINT8); 8148 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 8149 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 8150 RTE_UINT8); 8151 8152 cmdline_parse_inst_t cmd_read_reg_bit_field = { 8153 .f = cmd_read_reg_bit_field_parsed, 8154 .data = NULL, 8155 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 8156 "Read register bit field between bit_x and bit_y included", 8157 .tokens = { 8158 (void *)&cmd_read_reg_bit_field_read, 8159 (void *)&cmd_read_reg_bit_field_regfield, 8160 (void *)&cmd_read_reg_bit_field_port_id, 8161 (void *)&cmd_read_reg_bit_field_reg_off, 8162 (void *)&cmd_read_reg_bit_field_bit1_pos, 8163 (void *)&cmd_read_reg_bit_field_bit2_pos, 8164 NULL, 8165 }, 8166 }; 8167 8168 /* *** READ PORT REGISTER BIT *** */ 8169 struct cmd_read_reg_bit_result { 8170 cmdline_fixed_string_t read; 8171 cmdline_fixed_string_t regbit; 8172 portid_t port_id; 8173 uint32_t reg_off; 8174 uint8_t bit_pos; 8175 }; 8176 8177 static void 8178 cmd_read_reg_bit_parsed(void *parsed_result, 8179 __rte_unused struct cmdline *cl, 8180 __rte_unused void *data) 8181 { 8182 struct cmd_read_reg_bit_result *res = parsed_result; 8183 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 8184 } 8185 8186 cmdline_parse_token_string_t cmd_read_reg_bit_read = 8187 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 8188 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 8189 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 8190 regbit, "regbit"); 8191 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 8192 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, 8193 RTE_UINT16); 8194 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 8195 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, 8196 RTE_UINT32); 8197 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 8198 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, 8199 RTE_UINT8); 8200 8201 cmdline_parse_inst_t cmd_read_reg_bit = { 8202 .f = cmd_read_reg_bit_parsed, 8203 .data = NULL, 8204 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 8205 .tokens = { 8206 (void *)&cmd_read_reg_bit_read, 8207 (void *)&cmd_read_reg_bit_regbit, 8208 (void *)&cmd_read_reg_bit_port_id, 8209 (void *)&cmd_read_reg_bit_reg_off, 8210 (void *)&cmd_read_reg_bit_bit_pos, 8211 NULL, 8212 }, 8213 }; 8214 8215 /* *** WRITE PORT REGISTER *** */ 8216 struct cmd_write_reg_result { 8217 cmdline_fixed_string_t write; 8218 cmdline_fixed_string_t reg; 8219 portid_t port_id; 8220 uint32_t reg_off; 8221 uint32_t value; 8222 }; 8223 8224 static void 8225 cmd_write_reg_parsed(void *parsed_result, 8226 __rte_unused struct cmdline *cl, 8227 __rte_unused void *data) 8228 { 8229 struct cmd_write_reg_result *res = parsed_result; 8230 port_reg_set(res->port_id, res->reg_off, res->value); 8231 } 8232 8233 cmdline_parse_token_string_t cmd_write_reg_write = 8234 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 8235 cmdline_parse_token_string_t cmd_write_reg_reg = 8236 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 8237 cmdline_parse_token_num_t cmd_write_reg_port_id = 8238 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16); 8239 cmdline_parse_token_num_t cmd_write_reg_reg_off = 8240 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32); 8241 cmdline_parse_token_num_t cmd_write_reg_value = 8242 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32); 8243 8244 cmdline_parse_inst_t cmd_write_reg = { 8245 .f = cmd_write_reg_parsed, 8246 .data = NULL, 8247 .help_str = "write reg <port_id> <reg_off> <reg_value>", 8248 .tokens = { 8249 (void *)&cmd_write_reg_write, 8250 (void *)&cmd_write_reg_reg, 8251 (void *)&cmd_write_reg_port_id, 8252 (void *)&cmd_write_reg_reg_off, 8253 (void *)&cmd_write_reg_value, 8254 NULL, 8255 }, 8256 }; 8257 8258 /* *** WRITE PORT REGISTER BIT FIELD *** */ 8259 struct cmd_write_reg_bit_field_result { 8260 cmdline_fixed_string_t write; 8261 cmdline_fixed_string_t regfield; 8262 portid_t port_id; 8263 uint32_t reg_off; 8264 uint8_t bit1_pos; 8265 uint8_t bit2_pos; 8266 uint32_t value; 8267 }; 8268 8269 static void 8270 cmd_write_reg_bit_field_parsed(void *parsed_result, 8271 __rte_unused struct cmdline *cl, 8272 __rte_unused void *data) 8273 { 8274 struct cmd_write_reg_bit_field_result *res = parsed_result; 8275 port_reg_bit_field_set(res->port_id, res->reg_off, 8276 res->bit1_pos, res->bit2_pos, res->value); 8277 } 8278 8279 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 8280 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 8281 "write"); 8282 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 8283 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 8284 regfield, "regfield"); 8285 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 8286 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 8287 RTE_UINT16); 8288 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 8289 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 8290 RTE_UINT32); 8291 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 8292 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 8293 RTE_UINT8); 8294 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 8295 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 8296 RTE_UINT8); 8297 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 8298 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 8299 RTE_UINT32); 8300 8301 cmdline_parse_inst_t cmd_write_reg_bit_field = { 8302 .f = cmd_write_reg_bit_field_parsed, 8303 .data = NULL, 8304 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 8305 "<reg_value>: " 8306 "Set register bit field between bit_x and bit_y included", 8307 .tokens = { 8308 (void *)&cmd_write_reg_bit_field_write, 8309 (void *)&cmd_write_reg_bit_field_regfield, 8310 (void *)&cmd_write_reg_bit_field_port_id, 8311 (void *)&cmd_write_reg_bit_field_reg_off, 8312 (void *)&cmd_write_reg_bit_field_bit1_pos, 8313 (void *)&cmd_write_reg_bit_field_bit2_pos, 8314 (void *)&cmd_write_reg_bit_field_value, 8315 NULL, 8316 }, 8317 }; 8318 8319 /* *** WRITE PORT REGISTER BIT *** */ 8320 struct cmd_write_reg_bit_result { 8321 cmdline_fixed_string_t write; 8322 cmdline_fixed_string_t regbit; 8323 portid_t port_id; 8324 uint32_t reg_off; 8325 uint8_t bit_pos; 8326 uint8_t value; 8327 }; 8328 8329 static void 8330 cmd_write_reg_bit_parsed(void *parsed_result, 8331 __rte_unused struct cmdline *cl, 8332 __rte_unused void *data) 8333 { 8334 struct cmd_write_reg_bit_result *res = parsed_result; 8335 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 8336 } 8337 8338 cmdline_parse_token_string_t cmd_write_reg_bit_write = 8339 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 8340 "write"); 8341 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 8342 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 8343 regbit, "regbit"); 8344 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 8345 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, 8346 RTE_UINT16); 8347 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 8348 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, 8349 RTE_UINT32); 8350 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 8351 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, 8352 RTE_UINT8); 8353 cmdline_parse_token_num_t cmd_write_reg_bit_value = 8354 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, 8355 RTE_UINT8); 8356 8357 cmdline_parse_inst_t cmd_write_reg_bit = { 8358 .f = cmd_write_reg_bit_parsed, 8359 .data = NULL, 8360 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 8361 "0 <= bit_x <= 31", 8362 .tokens = { 8363 (void *)&cmd_write_reg_bit_write, 8364 (void *)&cmd_write_reg_bit_regbit, 8365 (void *)&cmd_write_reg_bit_port_id, 8366 (void *)&cmd_write_reg_bit_reg_off, 8367 (void *)&cmd_write_reg_bit_bit_pos, 8368 (void *)&cmd_write_reg_bit_value, 8369 NULL, 8370 }, 8371 }; 8372 8373 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 8374 struct cmd_read_rxd_txd_result { 8375 cmdline_fixed_string_t read; 8376 cmdline_fixed_string_t rxd_txd; 8377 portid_t port_id; 8378 uint16_t queue_id; 8379 uint16_t desc_id; 8380 }; 8381 8382 static void 8383 cmd_read_rxd_txd_parsed(void *parsed_result, 8384 __rte_unused struct cmdline *cl, 8385 __rte_unused void *data) 8386 { 8387 struct cmd_read_rxd_txd_result *res = parsed_result; 8388 8389 if (!strcmp(res->rxd_txd, "rxd")) 8390 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 8391 else if (!strcmp(res->rxd_txd, "txd")) 8392 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 8393 } 8394 8395 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 8396 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 8397 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 8398 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 8399 "rxd#txd"); 8400 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 8401 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, 8402 RTE_UINT16); 8403 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 8404 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, 8405 RTE_UINT16); 8406 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 8407 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, 8408 RTE_UINT16); 8409 8410 cmdline_parse_inst_t cmd_read_rxd_txd = { 8411 .f = cmd_read_rxd_txd_parsed, 8412 .data = NULL, 8413 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 8414 .tokens = { 8415 (void *)&cmd_read_rxd_txd_read, 8416 (void *)&cmd_read_rxd_txd_rxd_txd, 8417 (void *)&cmd_read_rxd_txd_port_id, 8418 (void *)&cmd_read_rxd_txd_queue_id, 8419 (void *)&cmd_read_rxd_txd_desc_id, 8420 NULL, 8421 }, 8422 }; 8423 8424 /* *** QUIT *** */ 8425 struct cmd_quit_result { 8426 cmdline_fixed_string_t quit; 8427 }; 8428 8429 static void cmd_quit_parsed(__rte_unused void *parsed_result, 8430 struct cmdline *cl, 8431 __rte_unused void *data) 8432 { 8433 cmdline_quit(cl); 8434 } 8435 8436 cmdline_parse_token_string_t cmd_quit_quit = 8437 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 8438 8439 cmdline_parse_inst_t cmd_quit = { 8440 .f = cmd_quit_parsed, 8441 .data = NULL, 8442 .help_str = "quit: Exit application", 8443 .tokens = { 8444 (void *)&cmd_quit_quit, 8445 NULL, 8446 }, 8447 }; 8448 8449 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 8450 struct cmd_mac_addr_result { 8451 cmdline_fixed_string_t mac_addr_cmd; 8452 cmdline_fixed_string_t what; 8453 uint16_t port_num; 8454 struct rte_ether_addr address; 8455 }; 8456 8457 static void cmd_mac_addr_parsed(void *parsed_result, 8458 __rte_unused struct cmdline *cl, 8459 __rte_unused void *data) 8460 { 8461 struct cmd_mac_addr_result *res = parsed_result; 8462 int ret; 8463 8464 if (strcmp(res->what, "add") == 0) 8465 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 8466 else if (strcmp(res->what, "set") == 0) 8467 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 8468 &res->address); 8469 else 8470 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 8471 8472 /* check the return value and print it if is < 0 */ 8473 if(ret < 0) 8474 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret)); 8475 8476 } 8477 8478 cmdline_parse_token_string_t cmd_mac_addr_cmd = 8479 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 8480 "mac_addr"); 8481 cmdline_parse_token_string_t cmd_mac_addr_what = 8482 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 8483 "add#remove#set"); 8484 cmdline_parse_token_num_t cmd_mac_addr_portnum = 8485 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 8486 RTE_UINT16); 8487 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 8488 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 8489 8490 cmdline_parse_inst_t cmd_mac_addr = { 8491 .f = cmd_mac_addr_parsed, 8492 .data = (void *)0, 8493 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 8494 "Add/Remove/Set MAC address on port_id", 8495 .tokens = { 8496 (void *)&cmd_mac_addr_cmd, 8497 (void *)&cmd_mac_addr_what, 8498 (void *)&cmd_mac_addr_portnum, 8499 (void *)&cmd_mac_addr_addr, 8500 NULL, 8501 }, 8502 }; 8503 8504 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 8505 struct cmd_eth_peer_result { 8506 cmdline_fixed_string_t set; 8507 cmdline_fixed_string_t eth_peer; 8508 portid_t port_id; 8509 cmdline_fixed_string_t peer_addr; 8510 }; 8511 8512 static void cmd_set_eth_peer_parsed(void *parsed_result, 8513 __rte_unused struct cmdline *cl, 8514 __rte_unused void *data) 8515 { 8516 struct cmd_eth_peer_result *res = parsed_result; 8517 8518 if (test_done == 0) { 8519 fprintf(stderr, "Please stop forwarding first\n"); 8520 return; 8521 } 8522 if (!strcmp(res->eth_peer, "eth-peer")) { 8523 set_fwd_eth_peer(res->port_id, res->peer_addr); 8524 fwd_config_setup(); 8525 } 8526 } 8527 cmdline_parse_token_string_t cmd_eth_peer_set = 8528 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 8529 cmdline_parse_token_string_t cmd_eth_peer = 8530 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 8531 cmdline_parse_token_num_t cmd_eth_peer_port_id = 8532 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, 8533 RTE_UINT16); 8534 cmdline_parse_token_string_t cmd_eth_peer_addr = 8535 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 8536 8537 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 8538 .f = cmd_set_eth_peer_parsed, 8539 .data = NULL, 8540 .help_str = "set eth-peer <port_id> <peer_mac>", 8541 .tokens = { 8542 (void *)&cmd_eth_peer_set, 8543 (void *)&cmd_eth_peer, 8544 (void *)&cmd_eth_peer_port_id, 8545 (void *)&cmd_eth_peer_addr, 8546 NULL, 8547 }, 8548 }; 8549 8550 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 8551 struct cmd_set_qmap_result { 8552 cmdline_fixed_string_t set; 8553 cmdline_fixed_string_t qmap; 8554 cmdline_fixed_string_t what; 8555 portid_t port_id; 8556 uint16_t queue_id; 8557 uint8_t map_value; 8558 }; 8559 8560 static void 8561 cmd_set_qmap_parsed(void *parsed_result, 8562 __rte_unused struct cmdline *cl, 8563 __rte_unused void *data) 8564 { 8565 struct cmd_set_qmap_result *res = parsed_result; 8566 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 8567 8568 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 8569 } 8570 8571 cmdline_parse_token_string_t cmd_setqmap_set = 8572 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8573 set, "set"); 8574 cmdline_parse_token_string_t cmd_setqmap_qmap = 8575 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8576 qmap, "stat_qmap"); 8577 cmdline_parse_token_string_t cmd_setqmap_what = 8578 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8579 what, "tx#rx"); 8580 cmdline_parse_token_num_t cmd_setqmap_portid = 8581 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8582 port_id, RTE_UINT16); 8583 cmdline_parse_token_num_t cmd_setqmap_queueid = 8584 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8585 queue_id, RTE_UINT16); 8586 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 8587 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8588 map_value, RTE_UINT8); 8589 8590 cmdline_parse_inst_t cmd_set_qmap = { 8591 .f = cmd_set_qmap_parsed, 8592 .data = NULL, 8593 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 8594 "Set statistics mapping value on tx|rx queue_id of port_id", 8595 .tokens = { 8596 (void *)&cmd_setqmap_set, 8597 (void *)&cmd_setqmap_qmap, 8598 (void *)&cmd_setqmap_what, 8599 (void *)&cmd_setqmap_portid, 8600 (void *)&cmd_setqmap_queueid, 8601 (void *)&cmd_setqmap_mapvalue, 8602 NULL, 8603 }, 8604 }; 8605 8606 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 8607 struct cmd_set_xstats_hide_zero_result { 8608 cmdline_fixed_string_t keyword; 8609 cmdline_fixed_string_t name; 8610 cmdline_fixed_string_t on_off; 8611 }; 8612 8613 static void 8614 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 8615 __rte_unused struct cmdline *cl, 8616 __rte_unused void *data) 8617 { 8618 struct cmd_set_xstats_hide_zero_result *res; 8619 uint16_t on_off = 0; 8620 8621 res = parsed_result; 8622 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8623 set_xstats_hide_zero(on_off); 8624 } 8625 8626 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 8627 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8628 keyword, "set"); 8629 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 8630 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8631 name, "xstats-hide-zero"); 8632 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 8633 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8634 on_off, "on#off"); 8635 8636 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 8637 .f = cmd_set_xstats_hide_zero_parsed, 8638 .data = NULL, 8639 .help_str = "set xstats-hide-zero on|off", 8640 .tokens = { 8641 (void *)&cmd_set_xstats_hide_zero_keyword, 8642 (void *)&cmd_set_xstats_hide_zero_name, 8643 (void *)&cmd_set_xstats_hide_zero_on_off, 8644 NULL, 8645 }, 8646 }; 8647 8648 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */ 8649 struct cmd_set_record_core_cycles_result { 8650 cmdline_fixed_string_t keyword; 8651 cmdline_fixed_string_t name; 8652 cmdline_fixed_string_t on_off; 8653 }; 8654 8655 static void 8656 cmd_set_record_core_cycles_parsed(void *parsed_result, 8657 __rte_unused struct cmdline *cl, 8658 __rte_unused void *data) 8659 { 8660 struct cmd_set_record_core_cycles_result *res; 8661 uint16_t on_off = 0; 8662 8663 res = parsed_result; 8664 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8665 set_record_core_cycles(on_off); 8666 } 8667 8668 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword = 8669 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8670 keyword, "set"); 8671 cmdline_parse_token_string_t cmd_set_record_core_cycles_name = 8672 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8673 name, "record-core-cycles"); 8674 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off = 8675 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8676 on_off, "on#off"); 8677 8678 cmdline_parse_inst_t cmd_set_record_core_cycles = { 8679 .f = cmd_set_record_core_cycles_parsed, 8680 .data = NULL, 8681 .help_str = "set record-core-cycles on|off", 8682 .tokens = { 8683 (void *)&cmd_set_record_core_cycles_keyword, 8684 (void *)&cmd_set_record_core_cycles_name, 8685 (void *)&cmd_set_record_core_cycles_on_off, 8686 NULL, 8687 }, 8688 }; 8689 8690 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */ 8691 struct cmd_set_record_burst_stats_result { 8692 cmdline_fixed_string_t keyword; 8693 cmdline_fixed_string_t name; 8694 cmdline_fixed_string_t on_off; 8695 }; 8696 8697 static void 8698 cmd_set_record_burst_stats_parsed(void *parsed_result, 8699 __rte_unused struct cmdline *cl, 8700 __rte_unused void *data) 8701 { 8702 struct cmd_set_record_burst_stats_result *res; 8703 uint16_t on_off = 0; 8704 8705 res = parsed_result; 8706 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8707 set_record_burst_stats(on_off); 8708 } 8709 8710 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword = 8711 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8712 keyword, "set"); 8713 cmdline_parse_token_string_t cmd_set_record_burst_stats_name = 8714 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8715 name, "record-burst-stats"); 8716 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off = 8717 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8718 on_off, "on#off"); 8719 8720 cmdline_parse_inst_t cmd_set_record_burst_stats = { 8721 .f = cmd_set_record_burst_stats_parsed, 8722 .data = NULL, 8723 .help_str = "set record-burst-stats on|off", 8724 .tokens = { 8725 (void *)&cmd_set_record_burst_stats_keyword, 8726 (void *)&cmd_set_record_burst_stats_name, 8727 (void *)&cmd_set_record_burst_stats_on_off, 8728 NULL, 8729 }, 8730 }; 8731 8732 /* *** CONFIGURE UNICAST HASH TABLE *** */ 8733 struct cmd_set_uc_hash_table { 8734 cmdline_fixed_string_t set; 8735 cmdline_fixed_string_t port; 8736 portid_t port_id; 8737 cmdline_fixed_string_t what; 8738 struct rte_ether_addr address; 8739 cmdline_fixed_string_t mode; 8740 }; 8741 8742 static void 8743 cmd_set_uc_hash_parsed(void *parsed_result, 8744 __rte_unused struct cmdline *cl, 8745 __rte_unused void *data) 8746 { 8747 int ret=0; 8748 struct cmd_set_uc_hash_table *res = parsed_result; 8749 8750 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8751 8752 if (strcmp(res->what, "uta") == 0) 8753 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 8754 &res->address,(uint8_t)is_on); 8755 if (ret < 0) 8756 fprintf(stderr, 8757 "bad unicast hash table parameter, return code = %d\n", 8758 ret); 8759 8760 } 8761 8762 cmdline_parse_token_string_t cmd_set_uc_hash_set = 8763 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8764 set, "set"); 8765 cmdline_parse_token_string_t cmd_set_uc_hash_port = 8766 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8767 port, "port"); 8768 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 8769 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 8770 port_id, RTE_UINT16); 8771 cmdline_parse_token_string_t cmd_set_uc_hash_what = 8772 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8773 what, "uta"); 8774 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 8775 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 8776 address); 8777 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 8778 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8779 mode, "on#off"); 8780 8781 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 8782 .f = cmd_set_uc_hash_parsed, 8783 .data = NULL, 8784 .help_str = "set port <port_id> uta <mac_addr> on|off)", 8785 .tokens = { 8786 (void *)&cmd_set_uc_hash_set, 8787 (void *)&cmd_set_uc_hash_port, 8788 (void *)&cmd_set_uc_hash_portid, 8789 (void *)&cmd_set_uc_hash_what, 8790 (void *)&cmd_set_uc_hash_mac, 8791 (void *)&cmd_set_uc_hash_mode, 8792 NULL, 8793 }, 8794 }; 8795 8796 struct cmd_set_uc_all_hash_table { 8797 cmdline_fixed_string_t set; 8798 cmdline_fixed_string_t port; 8799 portid_t port_id; 8800 cmdline_fixed_string_t what; 8801 cmdline_fixed_string_t value; 8802 cmdline_fixed_string_t mode; 8803 }; 8804 8805 static void 8806 cmd_set_uc_all_hash_parsed(void *parsed_result, 8807 __rte_unused struct cmdline *cl, 8808 __rte_unused void *data) 8809 { 8810 int ret=0; 8811 struct cmd_set_uc_all_hash_table *res = parsed_result; 8812 8813 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8814 8815 if ((strcmp(res->what, "uta") == 0) && 8816 (strcmp(res->value, "all") == 0)) 8817 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 8818 if (ret < 0) 8819 fprintf(stderr, 8820 "bad unicast hash table parameter, return code = %d\n", 8821 ret); 8822 } 8823 8824 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 8825 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8826 set, "set"); 8827 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 8828 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8829 port, "port"); 8830 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 8831 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 8832 port_id, RTE_UINT16); 8833 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 8834 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8835 what, "uta"); 8836 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 8837 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8838 value,"all"); 8839 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 8840 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8841 mode, "on#off"); 8842 8843 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 8844 .f = cmd_set_uc_all_hash_parsed, 8845 .data = NULL, 8846 .help_str = "set port <port_id> uta all on|off", 8847 .tokens = { 8848 (void *)&cmd_set_uc_all_hash_set, 8849 (void *)&cmd_set_uc_all_hash_port, 8850 (void *)&cmd_set_uc_all_hash_portid, 8851 (void *)&cmd_set_uc_all_hash_what, 8852 (void *)&cmd_set_uc_all_hash_value, 8853 (void *)&cmd_set_uc_all_hash_mode, 8854 NULL, 8855 }, 8856 }; 8857 8858 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 8859 struct cmd_set_vf_traffic { 8860 cmdline_fixed_string_t set; 8861 cmdline_fixed_string_t port; 8862 portid_t port_id; 8863 cmdline_fixed_string_t vf; 8864 uint8_t vf_id; 8865 cmdline_fixed_string_t what; 8866 cmdline_fixed_string_t mode; 8867 }; 8868 8869 static void 8870 cmd_set_vf_traffic_parsed(void *parsed_result, 8871 __rte_unused struct cmdline *cl, 8872 __rte_unused void *data) 8873 { 8874 struct cmd_set_vf_traffic *res = parsed_result; 8875 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 8876 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8877 8878 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 8879 } 8880 8881 cmdline_parse_token_string_t cmd_setvf_traffic_set = 8882 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8883 set, "set"); 8884 cmdline_parse_token_string_t cmd_setvf_traffic_port = 8885 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8886 port, "port"); 8887 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 8888 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8889 port_id, RTE_UINT16); 8890 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 8891 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8892 vf, "vf"); 8893 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 8894 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8895 vf_id, RTE_UINT8); 8896 cmdline_parse_token_string_t cmd_setvf_traffic_what = 8897 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8898 what, "tx#rx"); 8899 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 8900 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8901 mode, "on#off"); 8902 8903 cmdline_parse_inst_t cmd_set_vf_traffic = { 8904 .f = cmd_set_vf_traffic_parsed, 8905 .data = NULL, 8906 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 8907 .tokens = { 8908 (void *)&cmd_setvf_traffic_set, 8909 (void *)&cmd_setvf_traffic_port, 8910 (void *)&cmd_setvf_traffic_portid, 8911 (void *)&cmd_setvf_traffic_vf, 8912 (void *)&cmd_setvf_traffic_vfid, 8913 (void *)&cmd_setvf_traffic_what, 8914 (void *)&cmd_setvf_traffic_mode, 8915 NULL, 8916 }, 8917 }; 8918 8919 /* *** CONFIGURE VF RECEIVE MODE *** */ 8920 struct cmd_set_vf_rxmode { 8921 cmdline_fixed_string_t set; 8922 cmdline_fixed_string_t port; 8923 portid_t port_id; 8924 cmdline_fixed_string_t vf; 8925 uint8_t vf_id; 8926 cmdline_fixed_string_t what; 8927 cmdline_fixed_string_t mode; 8928 cmdline_fixed_string_t on; 8929 }; 8930 8931 static void 8932 cmd_set_vf_rxmode_parsed(void *parsed_result, 8933 __rte_unused struct cmdline *cl, 8934 __rte_unused void *data) 8935 { 8936 int ret = -ENOTSUP; 8937 uint16_t vf_rxmode = 0; 8938 struct cmd_set_vf_rxmode *res = parsed_result; 8939 8940 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 8941 if (!strcmp(res->what,"rxmode")) { 8942 if (!strcmp(res->mode, "AUPE")) 8943 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG; 8944 else if (!strcmp(res->mode, "ROPE")) 8945 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC; 8946 else if (!strcmp(res->mode, "BAM")) 8947 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST; 8948 else if (!strncmp(res->mode, "MPE",3)) 8949 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST; 8950 } 8951 8952 RTE_SET_USED(is_on); 8953 8954 #ifdef RTE_NET_IXGBE 8955 if (ret == -ENOTSUP) 8956 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 8957 vf_rxmode, (uint8_t)is_on); 8958 #endif 8959 #ifdef RTE_NET_BNXT 8960 if (ret == -ENOTSUP) 8961 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 8962 vf_rxmode, (uint8_t)is_on); 8963 #endif 8964 if (ret < 0) 8965 fprintf(stderr, 8966 "bad VF receive mode parameter, return code = %d\n", 8967 ret); 8968 } 8969 8970 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 8971 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8972 set, "set"); 8973 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 8974 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8975 port, "port"); 8976 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 8977 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8978 port_id, RTE_UINT16); 8979 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 8980 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8981 vf, "vf"); 8982 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 8983 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8984 vf_id, RTE_UINT8); 8985 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 8986 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8987 what, "rxmode"); 8988 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 8989 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8990 mode, "AUPE#ROPE#BAM#MPE"); 8991 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 8992 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8993 on, "on#off"); 8994 8995 cmdline_parse_inst_t cmd_set_vf_rxmode = { 8996 .f = cmd_set_vf_rxmode_parsed, 8997 .data = NULL, 8998 .help_str = "set port <port_id> vf <vf_id> rxmode " 8999 "AUPE|ROPE|BAM|MPE on|off", 9000 .tokens = { 9001 (void *)&cmd_set_vf_rxmode_set, 9002 (void *)&cmd_set_vf_rxmode_port, 9003 (void *)&cmd_set_vf_rxmode_portid, 9004 (void *)&cmd_set_vf_rxmode_vf, 9005 (void *)&cmd_set_vf_rxmode_vfid, 9006 (void *)&cmd_set_vf_rxmode_what, 9007 (void *)&cmd_set_vf_rxmode_mode, 9008 (void *)&cmd_set_vf_rxmode_on, 9009 NULL, 9010 }, 9011 }; 9012 9013 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 9014 struct cmd_vf_mac_addr_result { 9015 cmdline_fixed_string_t mac_addr_cmd; 9016 cmdline_fixed_string_t what; 9017 cmdline_fixed_string_t port; 9018 uint16_t port_num; 9019 cmdline_fixed_string_t vf; 9020 uint8_t vf_num; 9021 struct rte_ether_addr address; 9022 }; 9023 9024 static void cmd_vf_mac_addr_parsed(void *parsed_result, 9025 __rte_unused struct cmdline *cl, 9026 __rte_unused void *data) 9027 { 9028 struct cmd_vf_mac_addr_result *res = parsed_result; 9029 int ret = -ENOTSUP; 9030 9031 if (strcmp(res->what, "add") != 0) 9032 return; 9033 9034 #ifdef RTE_NET_I40E 9035 if (ret == -ENOTSUP) 9036 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 9037 &res->address); 9038 #endif 9039 #ifdef RTE_NET_BNXT 9040 if (ret == -ENOTSUP) 9041 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 9042 res->vf_num); 9043 #endif 9044 9045 if(ret < 0) 9046 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 9047 9048 } 9049 9050 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 9051 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 9052 mac_addr_cmd,"mac_addr"); 9053 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 9054 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 9055 what,"add"); 9056 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 9057 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 9058 port,"port"); 9059 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 9060 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 9061 port_num, RTE_UINT16); 9062 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 9063 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 9064 vf,"vf"); 9065 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 9066 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 9067 vf_num, RTE_UINT8); 9068 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 9069 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 9070 address); 9071 9072 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 9073 .f = cmd_vf_mac_addr_parsed, 9074 .data = (void *)0, 9075 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 9076 "Add MAC address filtering for a VF on port_id", 9077 .tokens = { 9078 (void *)&cmd_vf_mac_addr_cmd, 9079 (void *)&cmd_vf_mac_addr_what, 9080 (void *)&cmd_vf_mac_addr_port, 9081 (void *)&cmd_vf_mac_addr_portnum, 9082 (void *)&cmd_vf_mac_addr_vf, 9083 (void *)&cmd_vf_mac_addr_vfnum, 9084 (void *)&cmd_vf_mac_addr_addr, 9085 NULL, 9086 }, 9087 }; 9088 9089 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 9090 struct cmd_vf_rx_vlan_filter { 9091 cmdline_fixed_string_t rx_vlan; 9092 cmdline_fixed_string_t what; 9093 uint16_t vlan_id; 9094 cmdline_fixed_string_t port; 9095 portid_t port_id; 9096 cmdline_fixed_string_t vf; 9097 uint64_t vf_mask; 9098 }; 9099 9100 static void 9101 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 9102 __rte_unused struct cmdline *cl, 9103 __rte_unused void *data) 9104 { 9105 struct cmd_vf_rx_vlan_filter *res = parsed_result; 9106 int ret = -ENOTSUP; 9107 9108 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 9109 9110 #ifdef RTE_NET_IXGBE 9111 if (ret == -ENOTSUP) 9112 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 9113 res->vlan_id, res->vf_mask, is_add); 9114 #endif 9115 #ifdef RTE_NET_I40E 9116 if (ret == -ENOTSUP) 9117 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 9118 res->vlan_id, res->vf_mask, is_add); 9119 #endif 9120 #ifdef RTE_NET_BNXT 9121 if (ret == -ENOTSUP) 9122 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 9123 res->vlan_id, res->vf_mask, is_add); 9124 #endif 9125 9126 switch (ret) { 9127 case 0: 9128 break; 9129 case -EINVAL: 9130 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n", 9131 res->vlan_id, res->vf_mask); 9132 break; 9133 case -ENODEV: 9134 fprintf(stderr, "invalid port_id %d\n", res->port_id); 9135 break; 9136 case -ENOTSUP: 9137 fprintf(stderr, "function not implemented or supported\n"); 9138 break; 9139 default: 9140 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 9141 } 9142 } 9143 9144 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 9145 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9146 rx_vlan, "rx_vlan"); 9147 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 9148 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9149 what, "add#rm"); 9150 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 9151 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9152 vlan_id, RTE_UINT16); 9153 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 9154 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9155 port, "port"); 9156 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 9157 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9158 port_id, RTE_UINT16); 9159 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 9160 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9161 vf, "vf"); 9162 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 9163 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9164 vf_mask, RTE_UINT64); 9165 9166 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 9167 .f = cmd_vf_rx_vlan_filter_parsed, 9168 .data = NULL, 9169 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 9170 "(vf_mask = hexadecimal VF mask)", 9171 .tokens = { 9172 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 9173 (void *)&cmd_vf_rx_vlan_filter_what, 9174 (void *)&cmd_vf_rx_vlan_filter_vlanid, 9175 (void *)&cmd_vf_rx_vlan_filter_port, 9176 (void *)&cmd_vf_rx_vlan_filter_portid, 9177 (void *)&cmd_vf_rx_vlan_filter_vf, 9178 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 9179 NULL, 9180 }, 9181 }; 9182 9183 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 9184 struct cmd_queue_rate_limit_result { 9185 cmdline_fixed_string_t set; 9186 cmdline_fixed_string_t port; 9187 uint16_t port_num; 9188 cmdline_fixed_string_t queue; 9189 uint8_t queue_num; 9190 cmdline_fixed_string_t rate; 9191 uint16_t rate_num; 9192 }; 9193 9194 static void cmd_queue_rate_limit_parsed(void *parsed_result, 9195 __rte_unused struct cmdline *cl, 9196 __rte_unused void *data) 9197 { 9198 struct cmd_queue_rate_limit_result *res = parsed_result; 9199 int ret = 0; 9200 9201 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 9202 && (strcmp(res->queue, "queue") == 0) 9203 && (strcmp(res->rate, "rate") == 0)) 9204 ret = set_queue_rate_limit(res->port_num, res->queue_num, 9205 res->rate_num); 9206 if (ret < 0) 9207 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n", 9208 strerror(-ret)); 9209 9210 } 9211 9212 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 9213 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9214 set, "set"); 9215 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 9216 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9217 port, "port"); 9218 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 9219 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9220 port_num, RTE_UINT16); 9221 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 9222 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9223 queue, "queue"); 9224 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 9225 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9226 queue_num, RTE_UINT8); 9227 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 9228 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9229 rate, "rate"); 9230 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 9231 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9232 rate_num, RTE_UINT16); 9233 9234 cmdline_parse_inst_t cmd_queue_rate_limit = { 9235 .f = cmd_queue_rate_limit_parsed, 9236 .data = (void *)0, 9237 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 9238 "Set rate limit for a queue on port_id", 9239 .tokens = { 9240 (void *)&cmd_queue_rate_limit_set, 9241 (void *)&cmd_queue_rate_limit_port, 9242 (void *)&cmd_queue_rate_limit_portnum, 9243 (void *)&cmd_queue_rate_limit_queue, 9244 (void *)&cmd_queue_rate_limit_queuenum, 9245 (void *)&cmd_queue_rate_limit_rate, 9246 (void *)&cmd_queue_rate_limit_ratenum, 9247 NULL, 9248 }, 9249 }; 9250 9251 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 9252 struct cmd_vf_rate_limit_result { 9253 cmdline_fixed_string_t set; 9254 cmdline_fixed_string_t port; 9255 uint16_t port_num; 9256 cmdline_fixed_string_t vf; 9257 uint8_t vf_num; 9258 cmdline_fixed_string_t rate; 9259 uint16_t rate_num; 9260 cmdline_fixed_string_t q_msk; 9261 uint64_t q_msk_val; 9262 }; 9263 9264 static void cmd_vf_rate_limit_parsed(void *parsed_result, 9265 __rte_unused struct cmdline *cl, 9266 __rte_unused void *data) 9267 { 9268 struct cmd_vf_rate_limit_result *res = parsed_result; 9269 int ret = 0; 9270 9271 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 9272 && (strcmp(res->vf, "vf") == 0) 9273 && (strcmp(res->rate, "rate") == 0) 9274 && (strcmp(res->q_msk, "queue_mask") == 0)) 9275 ret = set_vf_rate_limit(res->port_num, res->vf_num, 9276 res->rate_num, res->q_msk_val); 9277 if (ret < 0) 9278 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n", 9279 strerror(-ret)); 9280 9281 } 9282 9283 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 9284 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9285 set, "set"); 9286 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 9287 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9288 port, "port"); 9289 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 9290 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9291 port_num, RTE_UINT16); 9292 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 9293 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9294 vf, "vf"); 9295 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 9296 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9297 vf_num, RTE_UINT8); 9298 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 9299 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9300 rate, "rate"); 9301 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 9302 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9303 rate_num, RTE_UINT16); 9304 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 9305 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9306 q_msk, "queue_mask"); 9307 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 9308 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9309 q_msk_val, RTE_UINT64); 9310 9311 cmdline_parse_inst_t cmd_vf_rate_limit = { 9312 .f = cmd_vf_rate_limit_parsed, 9313 .data = (void *)0, 9314 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 9315 "queue_mask <queue_mask_value>: " 9316 "Set rate limit for queues of VF on port_id", 9317 .tokens = { 9318 (void *)&cmd_vf_rate_limit_set, 9319 (void *)&cmd_vf_rate_limit_port, 9320 (void *)&cmd_vf_rate_limit_portnum, 9321 (void *)&cmd_vf_rate_limit_vf, 9322 (void *)&cmd_vf_rate_limit_vfnum, 9323 (void *)&cmd_vf_rate_limit_rate, 9324 (void *)&cmd_vf_rate_limit_ratenum, 9325 (void *)&cmd_vf_rate_limit_q_msk, 9326 (void *)&cmd_vf_rate_limit_q_msk_val, 9327 NULL, 9328 }, 9329 }; 9330 9331 /* *** CONFIGURE TUNNEL UDP PORT *** */ 9332 struct cmd_tunnel_udp_config { 9333 cmdline_fixed_string_t rx_vxlan_port; 9334 cmdline_fixed_string_t what; 9335 uint16_t udp_port; 9336 portid_t port_id; 9337 }; 9338 9339 static void 9340 cmd_tunnel_udp_config_parsed(void *parsed_result, 9341 __rte_unused struct cmdline *cl, 9342 __rte_unused void *data) 9343 { 9344 struct cmd_tunnel_udp_config *res = parsed_result; 9345 struct rte_eth_udp_tunnel tunnel_udp; 9346 int ret; 9347 9348 tunnel_udp.udp_port = res->udp_port; 9349 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9350 9351 if (!strcmp(res->what, "add")) 9352 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9353 &tunnel_udp); 9354 else 9355 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9356 &tunnel_udp); 9357 9358 if (ret < 0) 9359 fprintf(stderr, "udp tunneling add error: (%s)\n", 9360 strerror(-ret)); 9361 } 9362 9363 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port = 9364 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9365 rx_vxlan_port, "rx_vxlan_port"); 9366 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 9367 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9368 what, "add#rm"); 9369 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 9370 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9371 udp_port, RTE_UINT16); 9372 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 9373 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9374 port_id, RTE_UINT16); 9375 9376 cmdline_parse_inst_t cmd_tunnel_udp_config = { 9377 .f = cmd_tunnel_udp_config_parsed, 9378 .data = (void *)0, 9379 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 9380 "Add/Remove a tunneling UDP port filter", 9381 .tokens = { 9382 (void *)&cmd_tunnel_udp_config_rx_vxlan_port, 9383 (void *)&cmd_tunnel_udp_config_what, 9384 (void *)&cmd_tunnel_udp_config_udp_port, 9385 (void *)&cmd_tunnel_udp_config_port_id, 9386 NULL, 9387 }, 9388 }; 9389 9390 struct cmd_config_tunnel_udp_port { 9391 cmdline_fixed_string_t port; 9392 cmdline_fixed_string_t config; 9393 portid_t port_id; 9394 cmdline_fixed_string_t udp_tunnel_port; 9395 cmdline_fixed_string_t action; 9396 cmdline_fixed_string_t tunnel_type; 9397 uint16_t udp_port; 9398 }; 9399 9400 static void 9401 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 9402 __rte_unused struct cmdline *cl, 9403 __rte_unused void *data) 9404 { 9405 struct cmd_config_tunnel_udp_port *res = parsed_result; 9406 struct rte_eth_udp_tunnel tunnel_udp; 9407 int ret = 0; 9408 9409 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9410 return; 9411 9412 tunnel_udp.udp_port = res->udp_port; 9413 9414 if (!strcmp(res->tunnel_type, "vxlan")) { 9415 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9416 } else if (!strcmp(res->tunnel_type, "geneve")) { 9417 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 9418 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) { 9419 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 9420 } else if (!strcmp(res->tunnel_type, "ecpri")) { 9421 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI; 9422 } else { 9423 fprintf(stderr, "Invalid tunnel type\n"); 9424 return; 9425 } 9426 9427 if (!strcmp(res->action, "add")) 9428 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9429 &tunnel_udp); 9430 else 9431 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9432 &tunnel_udp); 9433 9434 if (ret < 0) 9435 fprintf(stderr, "udp tunneling port add error: (%s)\n", 9436 strerror(-ret)); 9437 } 9438 9439 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 9440 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 9441 "port"); 9442 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 9443 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 9444 "config"); 9445 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 9446 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 9447 RTE_UINT16); 9448 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 9449 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 9450 udp_tunnel_port, 9451 "udp_tunnel_port"); 9452 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 9453 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 9454 "add#rm"); 9455 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 9456 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 9457 "vxlan#geneve#vxlan-gpe#ecpri"); 9458 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 9459 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 9460 RTE_UINT16); 9461 9462 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 9463 .f = cmd_cfg_tunnel_udp_port_parsed, 9464 .data = NULL, 9465 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|" 9466 "geneve|vxlan-gpe|ecpri <udp_port>", 9467 .tokens = { 9468 (void *)&cmd_config_tunnel_udp_port_port, 9469 (void *)&cmd_config_tunnel_udp_port_config, 9470 (void *)&cmd_config_tunnel_udp_port_port_id, 9471 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 9472 (void *)&cmd_config_tunnel_udp_port_action, 9473 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 9474 (void *)&cmd_config_tunnel_udp_port_value, 9475 NULL, 9476 }, 9477 }; 9478 9479 /* ******************************************************************************** */ 9480 9481 struct cmd_dump_result { 9482 cmdline_fixed_string_t dump; 9483 }; 9484 9485 static void 9486 dump_struct_sizes(void) 9487 { 9488 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9489 DUMP_SIZE(struct rte_mbuf); 9490 DUMP_SIZE(struct rte_mempool); 9491 DUMP_SIZE(struct rte_ring); 9492 #undef DUMP_SIZE 9493 } 9494 9495 9496 /* Dump the socket memory statistics on console */ 9497 static void 9498 dump_socket_mem(FILE *f) 9499 { 9500 struct rte_malloc_socket_stats socket_stats; 9501 unsigned int i; 9502 size_t total = 0; 9503 size_t alloc = 0; 9504 size_t free = 0; 9505 unsigned int n_alloc = 0; 9506 unsigned int n_free = 0; 9507 static size_t last_allocs; 9508 static size_t last_total; 9509 9510 9511 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) { 9512 if (rte_malloc_get_socket_stats(i, &socket_stats) || 9513 !socket_stats.heap_totalsz_bytes) 9514 continue; 9515 total += socket_stats.heap_totalsz_bytes; 9516 alloc += socket_stats.heap_allocsz_bytes; 9517 free += socket_stats.heap_freesz_bytes; 9518 n_alloc += socket_stats.alloc_count; 9519 n_free += socket_stats.free_count; 9520 fprintf(f, 9521 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 9522 i, 9523 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024), 9524 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024), 9525 (double)socket_stats.heap_allocsz_bytes * 100 / 9526 (double)socket_stats.heap_totalsz_bytes, 9527 (double)socket_stats.heap_freesz_bytes / (1024 * 1024), 9528 socket_stats.alloc_count, 9529 socket_stats.free_count); 9530 } 9531 fprintf(f, 9532 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 9533 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024), 9534 total ? ((double)alloc * 100 / (double)total) : 0, 9535 (double)free / (1024 * 1024), 9536 n_alloc, n_free); 9537 if (last_allocs) 9538 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n", 9539 ((double)total - (double)last_total) / (1024 * 1024), 9540 (double)(alloc - (double)last_allocs) / 1024 / 1024); 9541 last_allocs = alloc; 9542 last_total = total; 9543 } 9544 9545 static void cmd_dump_parsed(void *parsed_result, 9546 __rte_unused struct cmdline *cl, 9547 __rte_unused void *data) 9548 { 9549 struct cmd_dump_result *res = parsed_result; 9550 9551 if (!strcmp(res->dump, "dump_physmem")) 9552 rte_dump_physmem_layout(stdout); 9553 else if (!strcmp(res->dump, "dump_socket_mem")) 9554 dump_socket_mem(stdout); 9555 else if (!strcmp(res->dump, "dump_memzone")) 9556 rte_memzone_dump(stdout); 9557 else if (!strcmp(res->dump, "dump_struct_sizes")) 9558 dump_struct_sizes(); 9559 else if (!strcmp(res->dump, "dump_ring")) 9560 rte_ring_list_dump(stdout); 9561 else if (!strcmp(res->dump, "dump_mempool")) 9562 rte_mempool_list_dump(stdout); 9563 else if (!strcmp(res->dump, "dump_devargs")) 9564 rte_devargs_dump(stdout); 9565 else if (!strcmp(res->dump, "dump_log_types")) 9566 rte_log_dump(stdout); 9567 } 9568 9569 cmdline_parse_token_string_t cmd_dump_dump = 9570 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9571 "dump_physmem#" 9572 "dump_memzone#" 9573 "dump_socket_mem#" 9574 "dump_struct_sizes#" 9575 "dump_ring#" 9576 "dump_mempool#" 9577 "dump_devargs#" 9578 "dump_log_types"); 9579 9580 cmdline_parse_inst_t cmd_dump = { 9581 .f = cmd_dump_parsed, /* function to call */ 9582 .data = NULL, /* 2nd arg of func */ 9583 .help_str = "Dump status", 9584 .tokens = { /* token list, NULL terminated */ 9585 (void *)&cmd_dump_dump, 9586 NULL, 9587 }, 9588 }; 9589 9590 /* ******************************************************************************** */ 9591 9592 struct cmd_dump_one_result { 9593 cmdline_fixed_string_t dump; 9594 cmdline_fixed_string_t name; 9595 }; 9596 9597 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9598 __rte_unused void *data) 9599 { 9600 struct cmd_dump_one_result *res = parsed_result; 9601 9602 if (!strcmp(res->dump, "dump_ring")) { 9603 struct rte_ring *r; 9604 r = rte_ring_lookup(res->name); 9605 if (r == NULL) { 9606 cmdline_printf(cl, "Cannot find ring\n"); 9607 return; 9608 } 9609 rte_ring_dump(stdout, r); 9610 } else if (!strcmp(res->dump, "dump_mempool")) { 9611 struct rte_mempool *mp; 9612 mp = rte_mempool_lookup(res->name); 9613 if (mp == NULL) { 9614 cmdline_printf(cl, "Cannot find mempool\n"); 9615 return; 9616 } 9617 rte_mempool_dump(stdout, mp); 9618 } 9619 } 9620 9621 cmdline_parse_token_string_t cmd_dump_one_dump = 9622 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9623 "dump_ring#dump_mempool"); 9624 9625 cmdline_parse_token_string_t cmd_dump_one_name = 9626 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9627 9628 cmdline_parse_inst_t cmd_dump_one = { 9629 .f = cmd_dump_one_parsed, /* function to call */ 9630 .data = NULL, /* 2nd arg of func */ 9631 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9632 .tokens = { /* token list, NULL terminated */ 9633 (void *)&cmd_dump_one_dump, 9634 (void *)&cmd_dump_one_name, 9635 NULL, 9636 }, 9637 }; 9638 9639 /* *** queue region set *** */ 9640 struct cmd_queue_region_result { 9641 cmdline_fixed_string_t set; 9642 cmdline_fixed_string_t port; 9643 portid_t port_id; 9644 cmdline_fixed_string_t cmd; 9645 cmdline_fixed_string_t region; 9646 uint8_t region_id; 9647 cmdline_fixed_string_t queue_start_index; 9648 uint8_t queue_id; 9649 cmdline_fixed_string_t queue_num; 9650 uint8_t queue_num_value; 9651 }; 9652 9653 static void 9654 cmd_queue_region_parsed(void *parsed_result, 9655 __rte_unused struct cmdline *cl, 9656 __rte_unused void *data) 9657 { 9658 struct cmd_queue_region_result *res = parsed_result; 9659 int ret = -ENOTSUP; 9660 #ifdef RTE_NET_I40E 9661 struct rte_pmd_i40e_queue_region_conf region_conf; 9662 enum rte_pmd_i40e_queue_region_op op_type; 9663 #endif 9664 9665 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9666 return; 9667 9668 #ifdef RTE_NET_I40E 9669 memset(®ion_conf, 0, sizeof(region_conf)); 9670 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 9671 region_conf.region_id = res->region_id; 9672 region_conf.queue_num = res->queue_num_value; 9673 region_conf.queue_start_index = res->queue_id; 9674 9675 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9676 op_type, ®ion_conf); 9677 #endif 9678 9679 switch (ret) { 9680 case 0: 9681 break; 9682 case -ENOTSUP: 9683 fprintf(stderr, "function not implemented or supported\n"); 9684 break; 9685 default: 9686 fprintf(stderr, "queue region config error: (%s)\n", 9687 strerror(-ret)); 9688 } 9689 } 9690 9691 cmdline_parse_token_string_t cmd_queue_region_set = 9692 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9693 set, "set"); 9694 cmdline_parse_token_string_t cmd_queue_region_port = 9695 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 9696 cmdline_parse_token_num_t cmd_queue_region_port_id = 9697 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9698 port_id, RTE_UINT16); 9699 cmdline_parse_token_string_t cmd_queue_region_cmd = 9700 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9701 cmd, "queue-region"); 9702 cmdline_parse_token_string_t cmd_queue_region_id = 9703 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9704 region, "region_id"); 9705 cmdline_parse_token_num_t cmd_queue_region_index = 9706 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9707 region_id, RTE_UINT8); 9708 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 9709 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9710 queue_start_index, "queue_start_index"); 9711 cmdline_parse_token_num_t cmd_queue_region_queue_id = 9712 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9713 queue_id, RTE_UINT8); 9714 cmdline_parse_token_string_t cmd_queue_region_queue_num = 9715 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9716 queue_num, "queue_num"); 9717 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 9718 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9719 queue_num_value, RTE_UINT8); 9720 9721 cmdline_parse_inst_t cmd_queue_region = { 9722 .f = cmd_queue_region_parsed, 9723 .data = NULL, 9724 .help_str = "set port <port_id> queue-region region_id <value> " 9725 "queue_start_index <value> queue_num <value>: Set a queue region", 9726 .tokens = { 9727 (void *)&cmd_queue_region_set, 9728 (void *)&cmd_queue_region_port, 9729 (void *)&cmd_queue_region_port_id, 9730 (void *)&cmd_queue_region_cmd, 9731 (void *)&cmd_queue_region_id, 9732 (void *)&cmd_queue_region_index, 9733 (void *)&cmd_queue_region_queue_start_index, 9734 (void *)&cmd_queue_region_queue_id, 9735 (void *)&cmd_queue_region_queue_num, 9736 (void *)&cmd_queue_region_queue_num_value, 9737 NULL, 9738 }, 9739 }; 9740 9741 /* *** queue region and flowtype set *** */ 9742 struct cmd_region_flowtype_result { 9743 cmdline_fixed_string_t set; 9744 cmdline_fixed_string_t port; 9745 portid_t port_id; 9746 cmdline_fixed_string_t cmd; 9747 cmdline_fixed_string_t region; 9748 uint8_t region_id; 9749 cmdline_fixed_string_t flowtype; 9750 uint8_t flowtype_id; 9751 }; 9752 9753 static void 9754 cmd_region_flowtype_parsed(void *parsed_result, 9755 __rte_unused struct cmdline *cl, 9756 __rte_unused void *data) 9757 { 9758 struct cmd_region_flowtype_result *res = parsed_result; 9759 int ret = -ENOTSUP; 9760 #ifdef RTE_NET_I40E 9761 struct rte_pmd_i40e_queue_region_conf region_conf; 9762 enum rte_pmd_i40e_queue_region_op op_type; 9763 #endif 9764 9765 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9766 return; 9767 9768 #ifdef RTE_NET_I40E 9769 memset(®ion_conf, 0, sizeof(region_conf)); 9770 9771 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 9772 region_conf.region_id = res->region_id; 9773 region_conf.hw_flowtype = res->flowtype_id; 9774 9775 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9776 op_type, ®ion_conf); 9777 #endif 9778 9779 switch (ret) { 9780 case 0: 9781 break; 9782 case -ENOTSUP: 9783 fprintf(stderr, "function not implemented or supported\n"); 9784 break; 9785 default: 9786 fprintf(stderr, "region flowtype config error: (%s)\n", 9787 strerror(-ret)); 9788 } 9789 } 9790 9791 cmdline_parse_token_string_t cmd_region_flowtype_set = 9792 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9793 set, "set"); 9794 cmdline_parse_token_string_t cmd_region_flowtype_port = 9795 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9796 port, "port"); 9797 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 9798 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9799 port_id, RTE_UINT16); 9800 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 9801 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9802 cmd, "queue-region"); 9803 cmdline_parse_token_string_t cmd_region_flowtype_index = 9804 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9805 region, "region_id"); 9806 cmdline_parse_token_num_t cmd_region_flowtype_id = 9807 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9808 region_id, RTE_UINT8); 9809 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 9810 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9811 flowtype, "flowtype"); 9812 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 9813 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9814 flowtype_id, RTE_UINT8); 9815 cmdline_parse_inst_t cmd_region_flowtype = { 9816 .f = cmd_region_flowtype_parsed, 9817 .data = NULL, 9818 .help_str = "set port <port_id> queue-region region_id <value> " 9819 "flowtype <value>: Set a flowtype region index", 9820 .tokens = { 9821 (void *)&cmd_region_flowtype_set, 9822 (void *)&cmd_region_flowtype_port, 9823 (void *)&cmd_region_flowtype_port_index, 9824 (void *)&cmd_region_flowtype_cmd, 9825 (void *)&cmd_region_flowtype_index, 9826 (void *)&cmd_region_flowtype_id, 9827 (void *)&cmd_region_flowtype_flow_index, 9828 (void *)&cmd_region_flowtype_flow_id, 9829 NULL, 9830 }, 9831 }; 9832 9833 /* *** User Priority (UP) to queue region (region_id) set *** */ 9834 struct cmd_user_priority_region_result { 9835 cmdline_fixed_string_t set; 9836 cmdline_fixed_string_t port; 9837 portid_t port_id; 9838 cmdline_fixed_string_t cmd; 9839 cmdline_fixed_string_t user_priority; 9840 uint8_t user_priority_id; 9841 cmdline_fixed_string_t region; 9842 uint8_t region_id; 9843 }; 9844 9845 static void 9846 cmd_user_priority_region_parsed(void *parsed_result, 9847 __rte_unused struct cmdline *cl, 9848 __rte_unused void *data) 9849 { 9850 struct cmd_user_priority_region_result *res = parsed_result; 9851 int ret = -ENOTSUP; 9852 #ifdef RTE_NET_I40E 9853 struct rte_pmd_i40e_queue_region_conf region_conf; 9854 enum rte_pmd_i40e_queue_region_op op_type; 9855 #endif 9856 9857 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9858 return; 9859 9860 #ifdef RTE_NET_I40E 9861 memset(®ion_conf, 0, sizeof(region_conf)); 9862 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 9863 region_conf.user_priority = res->user_priority_id; 9864 region_conf.region_id = res->region_id; 9865 9866 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9867 op_type, ®ion_conf); 9868 #endif 9869 9870 switch (ret) { 9871 case 0: 9872 break; 9873 case -ENOTSUP: 9874 fprintf(stderr, "function not implemented or supported\n"); 9875 break; 9876 default: 9877 fprintf(stderr, "user_priority region config error: (%s)\n", 9878 strerror(-ret)); 9879 } 9880 } 9881 9882 cmdline_parse_token_string_t cmd_user_priority_region_set = 9883 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9884 set, "set"); 9885 cmdline_parse_token_string_t cmd_user_priority_region_port = 9886 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9887 port, "port"); 9888 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 9889 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9890 port_id, RTE_UINT16); 9891 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 9892 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9893 cmd, "queue-region"); 9894 cmdline_parse_token_string_t cmd_user_priority_region_UP = 9895 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9896 user_priority, "UP"); 9897 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 9898 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9899 user_priority_id, RTE_UINT8); 9900 cmdline_parse_token_string_t cmd_user_priority_region_region = 9901 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9902 region, "region_id"); 9903 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 9904 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9905 region_id, RTE_UINT8); 9906 9907 cmdline_parse_inst_t cmd_user_priority_region = { 9908 .f = cmd_user_priority_region_parsed, 9909 .data = NULL, 9910 .help_str = "set port <port_id> queue-region UP <value> " 9911 "region_id <value>: Set the mapping of User Priority (UP) " 9912 "to queue region (region_id) ", 9913 .tokens = { 9914 (void *)&cmd_user_priority_region_set, 9915 (void *)&cmd_user_priority_region_port, 9916 (void *)&cmd_user_priority_region_port_index, 9917 (void *)&cmd_user_priority_region_cmd, 9918 (void *)&cmd_user_priority_region_UP, 9919 (void *)&cmd_user_priority_region_UP_id, 9920 (void *)&cmd_user_priority_region_region, 9921 (void *)&cmd_user_priority_region_region_id, 9922 NULL, 9923 }, 9924 }; 9925 9926 /* *** flush all queue region related configuration *** */ 9927 struct cmd_flush_queue_region_result { 9928 cmdline_fixed_string_t set; 9929 cmdline_fixed_string_t port; 9930 portid_t port_id; 9931 cmdline_fixed_string_t cmd; 9932 cmdline_fixed_string_t flush; 9933 cmdline_fixed_string_t what; 9934 }; 9935 9936 static void 9937 cmd_flush_queue_region_parsed(void *parsed_result, 9938 __rte_unused struct cmdline *cl, 9939 __rte_unused void *data) 9940 { 9941 struct cmd_flush_queue_region_result *res = parsed_result; 9942 int ret = -ENOTSUP; 9943 #ifdef RTE_NET_I40E 9944 struct rte_pmd_i40e_queue_region_conf region_conf; 9945 enum rte_pmd_i40e_queue_region_op op_type; 9946 #endif 9947 9948 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9949 return; 9950 9951 #ifdef RTE_NET_I40E 9952 memset(®ion_conf, 0, sizeof(region_conf)); 9953 9954 if (strcmp(res->what, "on") == 0) 9955 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 9956 else 9957 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 9958 9959 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9960 op_type, ®ion_conf); 9961 #endif 9962 9963 switch (ret) { 9964 case 0: 9965 break; 9966 case -ENOTSUP: 9967 fprintf(stderr, "function not implemented or supported\n"); 9968 break; 9969 default: 9970 fprintf(stderr, "queue region config flush error: (%s)\n", 9971 strerror(-ret)); 9972 } 9973 } 9974 9975 cmdline_parse_token_string_t cmd_flush_queue_region_set = 9976 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9977 set, "set"); 9978 cmdline_parse_token_string_t cmd_flush_queue_region_port = 9979 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9980 port, "port"); 9981 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 9982 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 9983 port_id, RTE_UINT16); 9984 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 9985 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9986 cmd, "queue-region"); 9987 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 9988 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9989 flush, "flush"); 9990 cmdline_parse_token_string_t cmd_flush_queue_region_what = 9991 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9992 what, "on#off"); 9993 9994 cmdline_parse_inst_t cmd_flush_queue_region = { 9995 .f = cmd_flush_queue_region_parsed, 9996 .data = NULL, 9997 .help_str = "set port <port_id> queue-region flush on|off" 9998 ": flush all queue region related configuration", 9999 .tokens = { 10000 (void *)&cmd_flush_queue_region_set, 10001 (void *)&cmd_flush_queue_region_port, 10002 (void *)&cmd_flush_queue_region_port_index, 10003 (void *)&cmd_flush_queue_region_cmd, 10004 (void *)&cmd_flush_queue_region_flush, 10005 (void *)&cmd_flush_queue_region_what, 10006 NULL, 10007 }, 10008 }; 10009 10010 /* *** get all queue region related configuration info *** */ 10011 struct cmd_show_queue_region_info { 10012 cmdline_fixed_string_t show; 10013 cmdline_fixed_string_t port; 10014 portid_t port_id; 10015 cmdline_fixed_string_t cmd; 10016 }; 10017 10018 static void 10019 cmd_show_queue_region_info_parsed(void *parsed_result, 10020 __rte_unused struct cmdline *cl, 10021 __rte_unused void *data) 10022 { 10023 struct cmd_show_queue_region_info *res = parsed_result; 10024 int ret = -ENOTSUP; 10025 #ifdef RTE_NET_I40E 10026 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 10027 enum rte_pmd_i40e_queue_region_op op_type; 10028 #endif 10029 10030 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10031 return; 10032 10033 #ifdef RTE_NET_I40E 10034 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 10035 10036 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 10037 10038 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10039 op_type, &rte_pmd_regions); 10040 10041 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 10042 #endif 10043 10044 switch (ret) { 10045 case 0: 10046 break; 10047 case -ENOTSUP: 10048 fprintf(stderr, "function not implemented or supported\n"); 10049 break; 10050 default: 10051 fprintf(stderr, "queue region config info show error: (%s)\n", 10052 strerror(-ret)); 10053 } 10054 } 10055 10056 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 10057 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10058 show, "show"); 10059 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 10060 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10061 port, "port"); 10062 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 10063 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 10064 port_id, RTE_UINT16); 10065 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 10066 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10067 cmd, "queue-region"); 10068 10069 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 10070 .f = cmd_show_queue_region_info_parsed, 10071 .data = NULL, 10072 .help_str = "show port <port_id> queue-region" 10073 ": show all queue region related configuration info", 10074 .tokens = { 10075 (void *)&cmd_show_queue_region_info_get, 10076 (void *)&cmd_show_queue_region_info_port, 10077 (void *)&cmd_show_queue_region_info_port_index, 10078 (void *)&cmd_show_queue_region_info_cmd, 10079 NULL, 10080 }, 10081 }; 10082 10083 /* *** Filters Control *** */ 10084 10085 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10086 do { \ 10087 if ((ip_addr).family == AF_INET) \ 10088 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10089 else { \ 10090 fprintf(stderr, "invalid parameter.\n"); \ 10091 return; \ 10092 } \ 10093 } while (0) 10094 10095 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10096 do { \ 10097 if ((ip_addr).family == AF_INET6) \ 10098 rte_memcpy(&(ip), \ 10099 &((ip_addr).addr.ipv6), \ 10100 sizeof(struct in6_addr)); \ 10101 else { \ 10102 fprintf(stderr, "invalid parameter.\n"); \ 10103 return; \ 10104 } \ 10105 } while (0) 10106 10107 #ifdef RTE_NET_I40E 10108 10109 static uint16_t 10110 str2flowtype(char *string) 10111 { 10112 uint8_t i = 0; 10113 static const struct { 10114 char str[32]; 10115 uint16_t type; 10116 } flowtype_str[] = { 10117 {"raw", RTE_ETH_FLOW_RAW}, 10118 {"ipv4", RTE_ETH_FLOW_IPV4}, 10119 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10120 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10121 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10122 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10123 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10124 {"ipv6", RTE_ETH_FLOW_IPV6}, 10125 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10126 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10127 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10128 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10129 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10130 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10131 }; 10132 10133 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10134 if (!strcmp(flowtype_str[i].str, string)) 10135 return flowtype_str[i].type; 10136 } 10137 10138 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10139 return (uint16_t)atoi(string); 10140 10141 return RTE_ETH_FLOW_UNKNOWN; 10142 } 10143 10144 /* *** deal with flow director filter *** */ 10145 struct cmd_flow_director_result { 10146 cmdline_fixed_string_t flow_director_filter; 10147 portid_t port_id; 10148 cmdline_fixed_string_t mode; 10149 cmdline_fixed_string_t mode_value; 10150 cmdline_fixed_string_t ops; 10151 cmdline_fixed_string_t flow; 10152 cmdline_fixed_string_t flow_type; 10153 cmdline_fixed_string_t drop; 10154 cmdline_fixed_string_t queue; 10155 uint16_t queue_id; 10156 cmdline_fixed_string_t fd_id; 10157 uint32_t fd_id_value; 10158 cmdline_fixed_string_t packet; 10159 char filepath[]; 10160 }; 10161 10162 static void 10163 cmd_flow_director_filter_parsed(void *parsed_result, 10164 __rte_unused struct cmdline *cl, 10165 __rte_unused void *data) 10166 { 10167 struct cmd_flow_director_result *res = parsed_result; 10168 int ret = 0; 10169 struct rte_pmd_i40e_flow_type_mapping 10170 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 10171 struct rte_pmd_i40e_pkt_template_conf conf; 10172 uint16_t flow_type = str2flowtype(res->flow_type); 10173 uint16_t i, port = res->port_id; 10174 uint8_t add; 10175 10176 memset(&conf, 0, sizeof(conf)); 10177 10178 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 10179 fprintf(stderr, "Invalid flow type specified.\n"); 10180 return; 10181 } 10182 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 10183 mapping); 10184 if (ret) 10185 return; 10186 if (mapping[flow_type].pctype == 0ULL) { 10187 fprintf(stderr, "Invalid flow type specified.\n"); 10188 return; 10189 } 10190 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 10191 if (mapping[flow_type].pctype & (1ULL << i)) { 10192 conf.input.pctype = i; 10193 break; 10194 } 10195 } 10196 10197 conf.input.packet = open_file(res->filepath, 10198 &conf.input.length); 10199 if (!conf.input.packet) 10200 return; 10201 if (!strcmp(res->drop, "drop")) 10202 conf.action.behavior = 10203 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 10204 else 10205 conf.action.behavior = 10206 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 10207 conf.action.report_status = 10208 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 10209 conf.action.rx_queue = res->queue_id; 10210 conf.soft_id = res->fd_id_value; 10211 add = strcmp(res->ops, "del") ? 1 : 0; 10212 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 10213 &conf, 10214 add); 10215 if (ret < 0) 10216 fprintf(stderr, "flow director config error: (%s)\n", 10217 strerror(-ret)); 10218 close_file(conf.input.packet); 10219 } 10220 10221 cmdline_parse_token_string_t cmd_flow_director_filter = 10222 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10223 flow_director_filter, "flow_director_filter"); 10224 cmdline_parse_token_num_t cmd_flow_director_port_id = 10225 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10226 port_id, RTE_UINT16); 10227 cmdline_parse_token_string_t cmd_flow_director_ops = 10228 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10229 ops, "add#del#update"); 10230 cmdline_parse_token_string_t cmd_flow_director_flow = 10231 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10232 flow, "flow"); 10233 cmdline_parse_token_string_t cmd_flow_director_flow_type = 10234 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10235 flow_type, NULL); 10236 cmdline_parse_token_string_t cmd_flow_director_drop = 10237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10238 drop, "drop#fwd"); 10239 cmdline_parse_token_string_t cmd_flow_director_queue = 10240 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10241 queue, "queue"); 10242 cmdline_parse_token_num_t cmd_flow_director_queue_id = 10243 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10244 queue_id, RTE_UINT16); 10245 cmdline_parse_token_string_t cmd_flow_director_fd_id = 10246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10247 fd_id, "fd_id"); 10248 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 10249 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10250 fd_id_value, RTE_UINT32); 10251 10252 cmdline_parse_token_string_t cmd_flow_director_mode = 10253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10254 mode, "mode"); 10255 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 10256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10257 mode_value, "raw"); 10258 cmdline_parse_token_string_t cmd_flow_director_packet = 10259 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10260 packet, "packet"); 10261 cmdline_parse_token_string_t cmd_flow_director_filepath = 10262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10263 filepath, NULL); 10264 10265 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 10266 .f = cmd_flow_director_filter_parsed, 10267 .data = NULL, 10268 .help_str = "flow_director_filter ... : Add or delete a raw flow " 10269 "director entry on NIC", 10270 .tokens = { 10271 (void *)&cmd_flow_director_filter, 10272 (void *)&cmd_flow_director_port_id, 10273 (void *)&cmd_flow_director_mode, 10274 (void *)&cmd_flow_director_mode_raw, 10275 (void *)&cmd_flow_director_ops, 10276 (void *)&cmd_flow_director_flow, 10277 (void *)&cmd_flow_director_flow_type, 10278 (void *)&cmd_flow_director_drop, 10279 (void *)&cmd_flow_director_queue, 10280 (void *)&cmd_flow_director_queue_id, 10281 (void *)&cmd_flow_director_fd_id, 10282 (void *)&cmd_flow_director_fd_id_value, 10283 (void *)&cmd_flow_director_packet, 10284 (void *)&cmd_flow_director_filepath, 10285 NULL, 10286 }, 10287 }; 10288 10289 #endif /* RTE_NET_I40E */ 10290 10291 /* *** deal with flow director mask *** */ 10292 struct cmd_flow_director_mask_result { 10293 cmdline_fixed_string_t flow_director_mask; 10294 portid_t port_id; 10295 cmdline_fixed_string_t mode; 10296 cmdline_fixed_string_t mode_value; 10297 cmdline_fixed_string_t vlan; 10298 uint16_t vlan_mask; 10299 cmdline_fixed_string_t src_mask; 10300 cmdline_ipaddr_t ipv4_src; 10301 cmdline_ipaddr_t ipv6_src; 10302 uint16_t port_src; 10303 cmdline_fixed_string_t dst_mask; 10304 cmdline_ipaddr_t ipv4_dst; 10305 cmdline_ipaddr_t ipv6_dst; 10306 uint16_t port_dst; 10307 cmdline_fixed_string_t mac; 10308 uint8_t mac_addr_byte_mask; 10309 cmdline_fixed_string_t tunnel_id; 10310 uint32_t tunnel_id_mask; 10311 cmdline_fixed_string_t tunnel_type; 10312 uint8_t tunnel_type_mask; 10313 }; 10314 10315 static void 10316 cmd_flow_director_mask_parsed(void *parsed_result, 10317 __rte_unused struct cmdline *cl, 10318 __rte_unused void *data) 10319 { 10320 struct cmd_flow_director_mask_result *res = parsed_result; 10321 struct rte_eth_fdir_masks *mask; 10322 struct rte_port *port; 10323 10324 port = &ports[res->port_id]; 10325 /** Check if the port is not started **/ 10326 if (port->port_status != RTE_PORT_STOPPED) { 10327 fprintf(stderr, "Please stop port %d first\n", res->port_id); 10328 return; 10329 } 10330 10331 mask = &port->dev_conf.fdir_conf.mask; 10332 10333 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10334 if (strcmp(res->mode_value, "MAC-VLAN")) { 10335 fprintf(stderr, "Please set mode to MAC-VLAN.\n"); 10336 return; 10337 } 10338 10339 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10340 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10341 if (strcmp(res->mode_value, "Tunnel")) { 10342 fprintf(stderr, "Please set mode to Tunnel.\n"); 10343 return; 10344 } 10345 10346 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10347 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 10348 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 10349 mask->tunnel_type_mask = res->tunnel_type_mask; 10350 } else { 10351 if (strcmp(res->mode_value, "IP")) { 10352 fprintf(stderr, "Please set mode to IP.\n"); 10353 return; 10354 } 10355 10356 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10357 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 10358 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 10359 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 10360 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 10361 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 10362 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 10363 } 10364 10365 cmd_reconfig_device_queue(res->port_id, 1, 1); 10366 } 10367 10368 cmdline_parse_token_string_t cmd_flow_director_mask = 10369 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10370 flow_director_mask, "flow_director_mask"); 10371 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 10372 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10373 port_id, RTE_UINT16); 10374 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 10375 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10376 vlan, "vlan"); 10377 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 10378 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10379 vlan_mask, RTE_UINT16); 10380 cmdline_parse_token_string_t cmd_flow_director_mask_src = 10381 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10382 src_mask, "src_mask"); 10383 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 10384 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10385 ipv4_src); 10386 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 10387 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10388 ipv6_src); 10389 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 10390 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10391 port_src, RTE_UINT16); 10392 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 10393 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10394 dst_mask, "dst_mask"); 10395 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 10396 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10397 ipv4_dst); 10398 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 10399 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10400 ipv6_dst); 10401 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 10402 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10403 port_dst, RTE_UINT16); 10404 10405 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 10406 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10407 mode, "mode"); 10408 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 10409 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10410 mode_value, "IP"); 10411 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 10412 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10413 mode_value, "MAC-VLAN"); 10414 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 10415 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10416 mode_value, "Tunnel"); 10417 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 10418 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10419 mac, "mac"); 10420 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 10421 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10422 mac_addr_byte_mask, RTE_UINT8); 10423 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 10424 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10425 tunnel_type, "tunnel-type"); 10426 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 10427 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10428 tunnel_type_mask, RTE_UINT8); 10429 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 10430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10431 tunnel_id, "tunnel-id"); 10432 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 10433 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10434 tunnel_id_mask, RTE_UINT32); 10435 10436 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 10437 .f = cmd_flow_director_mask_parsed, 10438 .data = NULL, 10439 .help_str = "flow_director_mask ... : " 10440 "Set IP mode flow director's mask on NIC", 10441 .tokens = { 10442 (void *)&cmd_flow_director_mask, 10443 (void *)&cmd_flow_director_mask_port_id, 10444 (void *)&cmd_flow_director_mask_mode, 10445 (void *)&cmd_flow_director_mask_mode_ip, 10446 (void *)&cmd_flow_director_mask_vlan, 10447 (void *)&cmd_flow_director_mask_vlan_value, 10448 (void *)&cmd_flow_director_mask_src, 10449 (void *)&cmd_flow_director_mask_ipv4_src, 10450 (void *)&cmd_flow_director_mask_ipv6_src, 10451 (void *)&cmd_flow_director_mask_port_src, 10452 (void *)&cmd_flow_director_mask_dst, 10453 (void *)&cmd_flow_director_mask_ipv4_dst, 10454 (void *)&cmd_flow_director_mask_ipv6_dst, 10455 (void *)&cmd_flow_director_mask_port_dst, 10456 NULL, 10457 }, 10458 }; 10459 10460 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 10461 .f = cmd_flow_director_mask_parsed, 10462 .data = NULL, 10463 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 10464 "flow director's mask on NIC", 10465 .tokens = { 10466 (void *)&cmd_flow_director_mask, 10467 (void *)&cmd_flow_director_mask_port_id, 10468 (void *)&cmd_flow_director_mask_mode, 10469 (void *)&cmd_flow_director_mask_mode_mac_vlan, 10470 (void *)&cmd_flow_director_mask_vlan, 10471 (void *)&cmd_flow_director_mask_vlan_value, 10472 NULL, 10473 }, 10474 }; 10475 10476 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 10477 .f = cmd_flow_director_mask_parsed, 10478 .data = NULL, 10479 .help_str = "flow_director_mask ... : Set tunnel mode " 10480 "flow director's mask on NIC", 10481 .tokens = { 10482 (void *)&cmd_flow_director_mask, 10483 (void *)&cmd_flow_director_mask_port_id, 10484 (void *)&cmd_flow_director_mask_mode, 10485 (void *)&cmd_flow_director_mask_mode_tunnel, 10486 (void *)&cmd_flow_director_mask_vlan, 10487 (void *)&cmd_flow_director_mask_vlan_value, 10488 (void *)&cmd_flow_director_mask_mac, 10489 (void *)&cmd_flow_director_mask_mac_value, 10490 (void *)&cmd_flow_director_mask_tunnel_type, 10491 (void *)&cmd_flow_director_mask_tunnel_type_value, 10492 (void *)&cmd_flow_director_mask_tunnel_id, 10493 (void *)&cmd_flow_director_mask_tunnel_id_value, 10494 NULL, 10495 }, 10496 }; 10497 10498 /* *** deal with flow director flexible payload configuration *** */ 10499 struct cmd_flow_director_flexpayload_result { 10500 cmdline_fixed_string_t flow_director_flexpayload; 10501 portid_t port_id; 10502 cmdline_fixed_string_t payload_layer; 10503 cmdline_fixed_string_t payload_cfg; 10504 }; 10505 10506 static inline int 10507 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 10508 { 10509 char s[256]; 10510 const char *p, *p0 = q_arg; 10511 char *end; 10512 unsigned long int_fld; 10513 char *str_fld[max_num]; 10514 int i; 10515 unsigned size; 10516 int ret = -1; 10517 10518 p = strchr(p0, '('); 10519 if (p == NULL) 10520 return -1; 10521 ++p; 10522 p0 = strchr(p, ')'); 10523 if (p0 == NULL) 10524 return -1; 10525 10526 size = p0 - p; 10527 if (size >= sizeof(s)) 10528 return -1; 10529 10530 snprintf(s, sizeof(s), "%.*s", size, p); 10531 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10532 if (ret < 0 || ret > max_num) 10533 return -1; 10534 for (i = 0; i < ret; i++) { 10535 errno = 0; 10536 int_fld = strtoul(str_fld[i], &end, 0); 10537 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 10538 return -1; 10539 offsets[i] = (uint16_t)int_fld; 10540 } 10541 return ret; 10542 } 10543 10544 static void 10545 cmd_flow_director_flxpld_parsed(void *parsed_result, 10546 __rte_unused struct cmdline *cl, 10547 __rte_unused void *data) 10548 { 10549 struct cmd_flow_director_flexpayload_result *res = parsed_result; 10550 struct rte_eth_flex_payload_cfg flex_cfg; 10551 struct rte_port *port; 10552 int ret = 0; 10553 10554 port = &ports[res->port_id]; 10555 /** Check if the port is not started **/ 10556 if (port->port_status != RTE_PORT_STOPPED) { 10557 fprintf(stderr, "Please stop port %d first\n", res->port_id); 10558 return; 10559 } 10560 10561 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 10562 10563 if (!strcmp(res->payload_layer, "raw")) 10564 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 10565 else if (!strcmp(res->payload_layer, "l2")) 10566 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 10567 else if (!strcmp(res->payload_layer, "l3")) 10568 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 10569 else if (!strcmp(res->payload_layer, "l4")) 10570 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 10571 10572 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 10573 RTE_ETH_FDIR_MAX_FLEXLEN); 10574 if (ret < 0) { 10575 fprintf(stderr, "error: Cannot parse flex payload input.\n"); 10576 return; 10577 } 10578 10579 fdir_set_flex_payload(res->port_id, &flex_cfg); 10580 cmd_reconfig_device_queue(res->port_id, 1, 1); 10581 } 10582 10583 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 10584 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10585 flow_director_flexpayload, 10586 "flow_director_flex_payload"); 10587 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 10588 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10589 port_id, RTE_UINT16); 10590 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 10591 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10592 payload_layer, "raw#l2#l3#l4"); 10593 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 10594 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10595 payload_cfg, NULL); 10596 10597 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 10598 .f = cmd_flow_director_flxpld_parsed, 10599 .data = NULL, 10600 .help_str = "flow_director_flexpayload ... : " 10601 "Set flow director's flex payload on NIC", 10602 .tokens = { 10603 (void *)&cmd_flow_director_flexpayload, 10604 (void *)&cmd_flow_director_flexpayload_port_id, 10605 (void *)&cmd_flow_director_flexpayload_payload_layer, 10606 (void *)&cmd_flow_director_flexpayload_payload_cfg, 10607 NULL, 10608 }, 10609 }; 10610 10611 /* Generic flow interface command. */ 10612 extern cmdline_parse_inst_t cmd_flow; 10613 10614 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 10615 struct cmd_mcast_addr_result { 10616 cmdline_fixed_string_t mcast_addr_cmd; 10617 cmdline_fixed_string_t what; 10618 uint16_t port_num; 10619 struct rte_ether_addr mc_addr; 10620 }; 10621 10622 static void cmd_mcast_addr_parsed(void *parsed_result, 10623 __rte_unused struct cmdline *cl, 10624 __rte_unused void *data) 10625 { 10626 struct cmd_mcast_addr_result *res = parsed_result; 10627 10628 if (!rte_is_multicast_ether_addr(&res->mc_addr)) { 10629 fprintf(stderr, 10630 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n", 10631 RTE_ETHER_ADDR_BYTES(&res->mc_addr)); 10632 return; 10633 } 10634 if (strcmp(res->what, "add") == 0) 10635 mcast_addr_add(res->port_num, &res->mc_addr); 10636 else 10637 mcast_addr_remove(res->port_num, &res->mc_addr); 10638 } 10639 10640 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 10641 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 10642 mcast_addr_cmd, "mcast_addr"); 10643 cmdline_parse_token_string_t cmd_mcast_addr_what = 10644 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 10645 "add#remove"); 10646 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 10647 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, 10648 RTE_UINT16); 10649 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 10650 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 10651 10652 cmdline_parse_inst_t cmd_mcast_addr = { 10653 .f = cmd_mcast_addr_parsed, 10654 .data = (void *)0, 10655 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 10656 "Add/Remove multicast MAC address on port_id", 10657 .tokens = { 10658 (void *)&cmd_mcast_addr_cmd, 10659 (void *)&cmd_mcast_addr_what, 10660 (void *)&cmd_mcast_addr_portnum, 10661 (void *)&cmd_mcast_addr_addr, 10662 NULL, 10663 }, 10664 }; 10665 10666 /* vf vlan anti spoof configuration */ 10667 10668 /* Common result structure for vf vlan anti spoof */ 10669 struct cmd_vf_vlan_anti_spoof_result { 10670 cmdline_fixed_string_t set; 10671 cmdline_fixed_string_t vf; 10672 cmdline_fixed_string_t vlan; 10673 cmdline_fixed_string_t antispoof; 10674 portid_t port_id; 10675 uint32_t vf_id; 10676 cmdline_fixed_string_t on_off; 10677 }; 10678 10679 /* Common CLI fields for vf vlan anti spoof enable disable */ 10680 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 10681 TOKEN_STRING_INITIALIZER 10682 (struct cmd_vf_vlan_anti_spoof_result, 10683 set, "set"); 10684 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 10685 TOKEN_STRING_INITIALIZER 10686 (struct cmd_vf_vlan_anti_spoof_result, 10687 vf, "vf"); 10688 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 10689 TOKEN_STRING_INITIALIZER 10690 (struct cmd_vf_vlan_anti_spoof_result, 10691 vlan, "vlan"); 10692 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 10693 TOKEN_STRING_INITIALIZER 10694 (struct cmd_vf_vlan_anti_spoof_result, 10695 antispoof, "antispoof"); 10696 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 10697 TOKEN_NUM_INITIALIZER 10698 (struct cmd_vf_vlan_anti_spoof_result, 10699 port_id, RTE_UINT16); 10700 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 10701 TOKEN_NUM_INITIALIZER 10702 (struct cmd_vf_vlan_anti_spoof_result, 10703 vf_id, RTE_UINT32); 10704 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 10705 TOKEN_STRING_INITIALIZER 10706 (struct cmd_vf_vlan_anti_spoof_result, 10707 on_off, "on#off"); 10708 10709 static void 10710 cmd_set_vf_vlan_anti_spoof_parsed( 10711 void *parsed_result, 10712 __rte_unused struct cmdline *cl, 10713 __rte_unused void *data) 10714 { 10715 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 10716 int ret = -ENOTSUP; 10717 10718 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 10719 10720 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10721 return; 10722 10723 #ifdef RTE_NET_IXGBE 10724 if (ret == -ENOTSUP) 10725 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 10726 res->vf_id, is_on); 10727 #endif 10728 #ifdef RTE_NET_I40E 10729 if (ret == -ENOTSUP) 10730 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 10731 res->vf_id, is_on); 10732 #endif 10733 #ifdef RTE_NET_BNXT 10734 if (ret == -ENOTSUP) 10735 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 10736 res->vf_id, is_on); 10737 #endif 10738 10739 switch (ret) { 10740 case 0: 10741 break; 10742 case -EINVAL: 10743 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 10744 break; 10745 case -ENODEV: 10746 fprintf(stderr, "invalid port_id %d\n", res->port_id); 10747 break; 10748 case -ENOTSUP: 10749 fprintf(stderr, "function not implemented\n"); 10750 break; 10751 default: 10752 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 10753 } 10754 } 10755 10756 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 10757 .f = cmd_set_vf_vlan_anti_spoof_parsed, 10758 .data = NULL, 10759 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 10760 .tokens = { 10761 (void *)&cmd_vf_vlan_anti_spoof_set, 10762 (void *)&cmd_vf_vlan_anti_spoof_vf, 10763 (void *)&cmd_vf_vlan_anti_spoof_vlan, 10764 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 10765 (void *)&cmd_vf_vlan_anti_spoof_port_id, 10766 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 10767 (void *)&cmd_vf_vlan_anti_spoof_on_off, 10768 NULL, 10769 }, 10770 }; 10771 10772 /* vf mac anti spoof configuration */ 10773 10774 /* Common result structure for vf mac anti spoof */ 10775 struct cmd_vf_mac_anti_spoof_result { 10776 cmdline_fixed_string_t set; 10777 cmdline_fixed_string_t vf; 10778 cmdline_fixed_string_t mac; 10779 cmdline_fixed_string_t antispoof; 10780 portid_t port_id; 10781 uint32_t vf_id; 10782 cmdline_fixed_string_t on_off; 10783 }; 10784 10785 /* Common CLI fields for vf mac anti spoof enable disable */ 10786 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 10787 TOKEN_STRING_INITIALIZER 10788 (struct cmd_vf_mac_anti_spoof_result, 10789 set, "set"); 10790 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 10791 TOKEN_STRING_INITIALIZER 10792 (struct cmd_vf_mac_anti_spoof_result, 10793 vf, "vf"); 10794 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 10795 TOKEN_STRING_INITIALIZER 10796 (struct cmd_vf_mac_anti_spoof_result, 10797 mac, "mac"); 10798 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 10799 TOKEN_STRING_INITIALIZER 10800 (struct cmd_vf_mac_anti_spoof_result, 10801 antispoof, "antispoof"); 10802 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 10803 TOKEN_NUM_INITIALIZER 10804 (struct cmd_vf_mac_anti_spoof_result, 10805 port_id, RTE_UINT16); 10806 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 10807 TOKEN_NUM_INITIALIZER 10808 (struct cmd_vf_mac_anti_spoof_result, 10809 vf_id, RTE_UINT32); 10810 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 10811 TOKEN_STRING_INITIALIZER 10812 (struct cmd_vf_mac_anti_spoof_result, 10813 on_off, "on#off"); 10814 10815 static void 10816 cmd_set_vf_mac_anti_spoof_parsed( 10817 void *parsed_result, 10818 __rte_unused struct cmdline *cl, 10819 __rte_unused void *data) 10820 { 10821 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 10822 int ret = -ENOTSUP; 10823 10824 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 10825 10826 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10827 return; 10828 10829 #ifdef RTE_NET_IXGBE 10830 if (ret == -ENOTSUP) 10831 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 10832 res->vf_id, is_on); 10833 #endif 10834 #ifdef RTE_NET_I40E 10835 if (ret == -ENOTSUP) 10836 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 10837 res->vf_id, is_on); 10838 #endif 10839 #ifdef RTE_NET_BNXT 10840 if (ret == -ENOTSUP) 10841 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 10842 res->vf_id, is_on); 10843 #endif 10844 10845 switch (ret) { 10846 case 0: 10847 break; 10848 case -EINVAL: 10849 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 10850 res->vf_id, is_on); 10851 break; 10852 case -ENODEV: 10853 fprintf(stderr, "invalid port_id %d\n", res->port_id); 10854 break; 10855 case -ENOTSUP: 10856 fprintf(stderr, "function not implemented\n"); 10857 break; 10858 default: 10859 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 10860 } 10861 } 10862 10863 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 10864 .f = cmd_set_vf_mac_anti_spoof_parsed, 10865 .data = NULL, 10866 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 10867 .tokens = { 10868 (void *)&cmd_vf_mac_anti_spoof_set, 10869 (void *)&cmd_vf_mac_anti_spoof_vf, 10870 (void *)&cmd_vf_mac_anti_spoof_mac, 10871 (void *)&cmd_vf_mac_anti_spoof_antispoof, 10872 (void *)&cmd_vf_mac_anti_spoof_port_id, 10873 (void *)&cmd_vf_mac_anti_spoof_vf_id, 10874 (void *)&cmd_vf_mac_anti_spoof_on_off, 10875 NULL, 10876 }, 10877 }; 10878 10879 /* vf vlan strip queue configuration */ 10880 10881 /* Common result structure for vf mac anti spoof */ 10882 struct cmd_vf_vlan_stripq_result { 10883 cmdline_fixed_string_t set; 10884 cmdline_fixed_string_t vf; 10885 cmdline_fixed_string_t vlan; 10886 cmdline_fixed_string_t stripq; 10887 portid_t port_id; 10888 uint16_t vf_id; 10889 cmdline_fixed_string_t on_off; 10890 }; 10891 10892 /* Common CLI fields for vf vlan strip enable disable */ 10893 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 10894 TOKEN_STRING_INITIALIZER 10895 (struct cmd_vf_vlan_stripq_result, 10896 set, "set"); 10897 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 10898 TOKEN_STRING_INITIALIZER 10899 (struct cmd_vf_vlan_stripq_result, 10900 vf, "vf"); 10901 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 10902 TOKEN_STRING_INITIALIZER 10903 (struct cmd_vf_vlan_stripq_result, 10904 vlan, "vlan"); 10905 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 10906 TOKEN_STRING_INITIALIZER 10907 (struct cmd_vf_vlan_stripq_result, 10908 stripq, "stripq"); 10909 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 10910 TOKEN_NUM_INITIALIZER 10911 (struct cmd_vf_vlan_stripq_result, 10912 port_id, RTE_UINT16); 10913 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 10914 TOKEN_NUM_INITIALIZER 10915 (struct cmd_vf_vlan_stripq_result, 10916 vf_id, RTE_UINT16); 10917 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 10918 TOKEN_STRING_INITIALIZER 10919 (struct cmd_vf_vlan_stripq_result, 10920 on_off, "on#off"); 10921 10922 static void 10923 cmd_set_vf_vlan_stripq_parsed( 10924 void *parsed_result, 10925 __rte_unused struct cmdline *cl, 10926 __rte_unused void *data) 10927 { 10928 struct cmd_vf_vlan_stripq_result *res = parsed_result; 10929 int ret = -ENOTSUP; 10930 10931 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 10932 10933 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10934 return; 10935 10936 #ifdef RTE_NET_IXGBE 10937 if (ret == -ENOTSUP) 10938 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 10939 res->vf_id, is_on); 10940 #endif 10941 #ifdef RTE_NET_I40E 10942 if (ret == -ENOTSUP) 10943 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 10944 res->vf_id, is_on); 10945 #endif 10946 #ifdef RTE_NET_BNXT 10947 if (ret == -ENOTSUP) 10948 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 10949 res->vf_id, is_on); 10950 #endif 10951 10952 switch (ret) { 10953 case 0: 10954 break; 10955 case -EINVAL: 10956 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 10957 res->vf_id, is_on); 10958 break; 10959 case -ENODEV: 10960 fprintf(stderr, "invalid port_id %d\n", res->port_id); 10961 break; 10962 case -ENOTSUP: 10963 fprintf(stderr, "function not implemented\n"); 10964 break; 10965 default: 10966 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 10967 } 10968 } 10969 10970 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 10971 .f = cmd_set_vf_vlan_stripq_parsed, 10972 .data = NULL, 10973 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 10974 .tokens = { 10975 (void *)&cmd_vf_vlan_stripq_set, 10976 (void *)&cmd_vf_vlan_stripq_vf, 10977 (void *)&cmd_vf_vlan_stripq_vlan, 10978 (void *)&cmd_vf_vlan_stripq_stripq, 10979 (void *)&cmd_vf_vlan_stripq_port_id, 10980 (void *)&cmd_vf_vlan_stripq_vf_id, 10981 (void *)&cmd_vf_vlan_stripq_on_off, 10982 NULL, 10983 }, 10984 }; 10985 10986 /* vf vlan insert configuration */ 10987 10988 /* Common result structure for vf vlan insert */ 10989 struct cmd_vf_vlan_insert_result { 10990 cmdline_fixed_string_t set; 10991 cmdline_fixed_string_t vf; 10992 cmdline_fixed_string_t vlan; 10993 cmdline_fixed_string_t insert; 10994 portid_t port_id; 10995 uint16_t vf_id; 10996 uint16_t vlan_id; 10997 }; 10998 10999 /* Common CLI fields for vf vlan insert enable disable */ 11000 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 11001 TOKEN_STRING_INITIALIZER 11002 (struct cmd_vf_vlan_insert_result, 11003 set, "set"); 11004 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 11005 TOKEN_STRING_INITIALIZER 11006 (struct cmd_vf_vlan_insert_result, 11007 vf, "vf"); 11008 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 11009 TOKEN_STRING_INITIALIZER 11010 (struct cmd_vf_vlan_insert_result, 11011 vlan, "vlan"); 11012 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 11013 TOKEN_STRING_INITIALIZER 11014 (struct cmd_vf_vlan_insert_result, 11015 insert, "insert"); 11016 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 11017 TOKEN_NUM_INITIALIZER 11018 (struct cmd_vf_vlan_insert_result, 11019 port_id, RTE_UINT16); 11020 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 11021 TOKEN_NUM_INITIALIZER 11022 (struct cmd_vf_vlan_insert_result, 11023 vf_id, RTE_UINT16); 11024 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 11025 TOKEN_NUM_INITIALIZER 11026 (struct cmd_vf_vlan_insert_result, 11027 vlan_id, RTE_UINT16); 11028 11029 static void 11030 cmd_set_vf_vlan_insert_parsed( 11031 void *parsed_result, 11032 __rte_unused struct cmdline *cl, 11033 __rte_unused void *data) 11034 { 11035 struct cmd_vf_vlan_insert_result *res = parsed_result; 11036 int ret = -ENOTSUP; 11037 11038 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11039 return; 11040 11041 #ifdef RTE_NET_IXGBE 11042 if (ret == -ENOTSUP) 11043 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 11044 res->vlan_id); 11045 #endif 11046 #ifdef RTE_NET_I40E 11047 if (ret == -ENOTSUP) 11048 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 11049 res->vlan_id); 11050 #endif 11051 #ifdef RTE_NET_BNXT 11052 if (ret == -ENOTSUP) 11053 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 11054 res->vlan_id); 11055 #endif 11056 11057 switch (ret) { 11058 case 0: 11059 break; 11060 case -EINVAL: 11061 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n", 11062 res->vf_id, res->vlan_id); 11063 break; 11064 case -ENODEV: 11065 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11066 break; 11067 case -ENOTSUP: 11068 fprintf(stderr, "function not implemented\n"); 11069 break; 11070 default: 11071 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11072 } 11073 } 11074 11075 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 11076 .f = cmd_set_vf_vlan_insert_parsed, 11077 .data = NULL, 11078 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 11079 .tokens = { 11080 (void *)&cmd_vf_vlan_insert_set, 11081 (void *)&cmd_vf_vlan_insert_vf, 11082 (void *)&cmd_vf_vlan_insert_vlan, 11083 (void *)&cmd_vf_vlan_insert_insert, 11084 (void *)&cmd_vf_vlan_insert_port_id, 11085 (void *)&cmd_vf_vlan_insert_vf_id, 11086 (void *)&cmd_vf_vlan_insert_vlan_id, 11087 NULL, 11088 }, 11089 }; 11090 11091 /* tx loopback configuration */ 11092 11093 /* Common result structure for tx loopback */ 11094 struct cmd_tx_loopback_result { 11095 cmdline_fixed_string_t set; 11096 cmdline_fixed_string_t tx; 11097 cmdline_fixed_string_t loopback; 11098 portid_t port_id; 11099 cmdline_fixed_string_t on_off; 11100 }; 11101 11102 /* Common CLI fields for tx loopback enable disable */ 11103 cmdline_parse_token_string_t cmd_tx_loopback_set = 11104 TOKEN_STRING_INITIALIZER 11105 (struct cmd_tx_loopback_result, 11106 set, "set"); 11107 cmdline_parse_token_string_t cmd_tx_loopback_tx = 11108 TOKEN_STRING_INITIALIZER 11109 (struct cmd_tx_loopback_result, 11110 tx, "tx"); 11111 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 11112 TOKEN_STRING_INITIALIZER 11113 (struct cmd_tx_loopback_result, 11114 loopback, "loopback"); 11115 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 11116 TOKEN_NUM_INITIALIZER 11117 (struct cmd_tx_loopback_result, 11118 port_id, RTE_UINT16); 11119 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 11120 TOKEN_STRING_INITIALIZER 11121 (struct cmd_tx_loopback_result, 11122 on_off, "on#off"); 11123 11124 static void 11125 cmd_set_tx_loopback_parsed( 11126 void *parsed_result, 11127 __rte_unused struct cmdline *cl, 11128 __rte_unused void *data) 11129 { 11130 struct cmd_tx_loopback_result *res = parsed_result; 11131 int ret = -ENOTSUP; 11132 11133 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11134 11135 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11136 return; 11137 11138 #ifdef RTE_NET_IXGBE 11139 if (ret == -ENOTSUP) 11140 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 11141 #endif 11142 #ifdef RTE_NET_I40E 11143 if (ret == -ENOTSUP) 11144 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 11145 #endif 11146 #ifdef RTE_NET_BNXT 11147 if (ret == -ENOTSUP) 11148 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 11149 #endif 11150 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA 11151 if (ret == -ENOTSUP) 11152 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 11153 #endif 11154 11155 switch (ret) { 11156 case 0: 11157 break; 11158 case -EINVAL: 11159 fprintf(stderr, "invalid is_on %d\n", is_on); 11160 break; 11161 case -ENODEV: 11162 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11163 break; 11164 case -ENOTSUP: 11165 fprintf(stderr, "function not implemented\n"); 11166 break; 11167 default: 11168 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11169 } 11170 } 11171 11172 cmdline_parse_inst_t cmd_set_tx_loopback = { 11173 .f = cmd_set_tx_loopback_parsed, 11174 .data = NULL, 11175 .help_str = "set tx loopback <port_id> on|off", 11176 .tokens = { 11177 (void *)&cmd_tx_loopback_set, 11178 (void *)&cmd_tx_loopback_tx, 11179 (void *)&cmd_tx_loopback_loopback, 11180 (void *)&cmd_tx_loopback_port_id, 11181 (void *)&cmd_tx_loopback_on_off, 11182 NULL, 11183 }, 11184 }; 11185 11186 /* all queues drop enable configuration */ 11187 11188 /* Common result structure for all queues drop enable */ 11189 struct cmd_all_queues_drop_en_result { 11190 cmdline_fixed_string_t set; 11191 cmdline_fixed_string_t all; 11192 cmdline_fixed_string_t queues; 11193 cmdline_fixed_string_t drop; 11194 portid_t port_id; 11195 cmdline_fixed_string_t on_off; 11196 }; 11197 11198 /* Common CLI fields for tx loopback enable disable */ 11199 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 11200 TOKEN_STRING_INITIALIZER 11201 (struct cmd_all_queues_drop_en_result, 11202 set, "set"); 11203 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 11204 TOKEN_STRING_INITIALIZER 11205 (struct cmd_all_queues_drop_en_result, 11206 all, "all"); 11207 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 11208 TOKEN_STRING_INITIALIZER 11209 (struct cmd_all_queues_drop_en_result, 11210 queues, "queues"); 11211 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 11212 TOKEN_STRING_INITIALIZER 11213 (struct cmd_all_queues_drop_en_result, 11214 drop, "drop"); 11215 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 11216 TOKEN_NUM_INITIALIZER 11217 (struct cmd_all_queues_drop_en_result, 11218 port_id, RTE_UINT16); 11219 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 11220 TOKEN_STRING_INITIALIZER 11221 (struct cmd_all_queues_drop_en_result, 11222 on_off, "on#off"); 11223 11224 static void 11225 cmd_set_all_queues_drop_en_parsed( 11226 void *parsed_result, 11227 __rte_unused struct cmdline *cl, 11228 __rte_unused void *data) 11229 { 11230 struct cmd_all_queues_drop_en_result *res = parsed_result; 11231 int ret = -ENOTSUP; 11232 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11233 11234 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11235 return; 11236 11237 #ifdef RTE_NET_IXGBE 11238 if (ret == -ENOTSUP) 11239 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 11240 #endif 11241 #ifdef RTE_NET_BNXT 11242 if (ret == -ENOTSUP) 11243 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 11244 #endif 11245 switch (ret) { 11246 case 0: 11247 break; 11248 case -EINVAL: 11249 fprintf(stderr, "invalid is_on %d\n", is_on); 11250 break; 11251 case -ENODEV: 11252 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11253 break; 11254 case -ENOTSUP: 11255 fprintf(stderr, "function not implemented\n"); 11256 break; 11257 default: 11258 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11259 } 11260 } 11261 11262 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 11263 .f = cmd_set_all_queues_drop_en_parsed, 11264 .data = NULL, 11265 .help_str = "set all queues drop <port_id> on|off", 11266 .tokens = { 11267 (void *)&cmd_all_queues_drop_en_set, 11268 (void *)&cmd_all_queues_drop_en_all, 11269 (void *)&cmd_all_queues_drop_en_queues, 11270 (void *)&cmd_all_queues_drop_en_drop, 11271 (void *)&cmd_all_queues_drop_en_port_id, 11272 (void *)&cmd_all_queues_drop_en_on_off, 11273 NULL, 11274 }, 11275 }; 11276 11277 /* vf split drop enable configuration */ 11278 11279 /* Common result structure for vf split drop enable */ 11280 struct cmd_vf_split_drop_en_result { 11281 cmdline_fixed_string_t set; 11282 cmdline_fixed_string_t vf; 11283 cmdline_fixed_string_t split; 11284 cmdline_fixed_string_t drop; 11285 portid_t port_id; 11286 uint16_t vf_id; 11287 cmdline_fixed_string_t on_off; 11288 }; 11289 11290 /* Common CLI fields for vf split drop enable disable */ 11291 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 11292 TOKEN_STRING_INITIALIZER 11293 (struct cmd_vf_split_drop_en_result, 11294 set, "set"); 11295 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 11296 TOKEN_STRING_INITIALIZER 11297 (struct cmd_vf_split_drop_en_result, 11298 vf, "vf"); 11299 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 11300 TOKEN_STRING_INITIALIZER 11301 (struct cmd_vf_split_drop_en_result, 11302 split, "split"); 11303 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 11304 TOKEN_STRING_INITIALIZER 11305 (struct cmd_vf_split_drop_en_result, 11306 drop, "drop"); 11307 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 11308 TOKEN_NUM_INITIALIZER 11309 (struct cmd_vf_split_drop_en_result, 11310 port_id, RTE_UINT16); 11311 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 11312 TOKEN_NUM_INITIALIZER 11313 (struct cmd_vf_split_drop_en_result, 11314 vf_id, RTE_UINT16); 11315 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 11316 TOKEN_STRING_INITIALIZER 11317 (struct cmd_vf_split_drop_en_result, 11318 on_off, "on#off"); 11319 11320 static void 11321 cmd_set_vf_split_drop_en_parsed( 11322 void *parsed_result, 11323 __rte_unused struct cmdline *cl, 11324 __rte_unused void *data) 11325 { 11326 struct cmd_vf_split_drop_en_result *res = parsed_result; 11327 int ret = -ENOTSUP; 11328 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11329 11330 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11331 return; 11332 11333 #ifdef RTE_NET_IXGBE 11334 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 11335 is_on); 11336 #endif 11337 switch (ret) { 11338 case 0: 11339 break; 11340 case -EINVAL: 11341 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 11342 res->vf_id, is_on); 11343 break; 11344 case -ENODEV: 11345 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11346 break; 11347 case -ENOTSUP: 11348 fprintf(stderr, "not supported on port %d\n", res->port_id); 11349 break; 11350 default: 11351 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11352 } 11353 } 11354 11355 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 11356 .f = cmd_set_vf_split_drop_en_parsed, 11357 .data = NULL, 11358 .help_str = "set vf split drop <port_id> <vf_id> on|off", 11359 .tokens = { 11360 (void *)&cmd_vf_split_drop_en_set, 11361 (void *)&cmd_vf_split_drop_en_vf, 11362 (void *)&cmd_vf_split_drop_en_split, 11363 (void *)&cmd_vf_split_drop_en_drop, 11364 (void *)&cmd_vf_split_drop_en_port_id, 11365 (void *)&cmd_vf_split_drop_en_vf_id, 11366 (void *)&cmd_vf_split_drop_en_on_off, 11367 NULL, 11368 }, 11369 }; 11370 11371 /* vf mac address configuration */ 11372 11373 /* Common result structure for vf mac address */ 11374 struct cmd_set_vf_mac_addr_result { 11375 cmdline_fixed_string_t set; 11376 cmdline_fixed_string_t vf; 11377 cmdline_fixed_string_t mac; 11378 cmdline_fixed_string_t addr; 11379 portid_t port_id; 11380 uint16_t vf_id; 11381 struct rte_ether_addr mac_addr; 11382 11383 }; 11384 11385 /* Common CLI fields for vf split drop enable disable */ 11386 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 11387 TOKEN_STRING_INITIALIZER 11388 (struct cmd_set_vf_mac_addr_result, 11389 set, "set"); 11390 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 11391 TOKEN_STRING_INITIALIZER 11392 (struct cmd_set_vf_mac_addr_result, 11393 vf, "vf"); 11394 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 11395 TOKEN_STRING_INITIALIZER 11396 (struct cmd_set_vf_mac_addr_result, 11397 mac, "mac"); 11398 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 11399 TOKEN_STRING_INITIALIZER 11400 (struct cmd_set_vf_mac_addr_result, 11401 addr, "addr"); 11402 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 11403 TOKEN_NUM_INITIALIZER 11404 (struct cmd_set_vf_mac_addr_result, 11405 port_id, RTE_UINT16); 11406 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 11407 TOKEN_NUM_INITIALIZER 11408 (struct cmd_set_vf_mac_addr_result, 11409 vf_id, RTE_UINT16); 11410 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 11411 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 11412 mac_addr); 11413 11414 static void 11415 cmd_set_vf_mac_addr_parsed( 11416 void *parsed_result, 11417 __rte_unused struct cmdline *cl, 11418 __rte_unused void *data) 11419 { 11420 struct cmd_set_vf_mac_addr_result *res = parsed_result; 11421 int ret = -ENOTSUP; 11422 11423 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11424 return; 11425 11426 #ifdef RTE_NET_IXGBE 11427 if (ret == -ENOTSUP) 11428 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 11429 &res->mac_addr); 11430 #endif 11431 #ifdef RTE_NET_I40E 11432 if (ret == -ENOTSUP) 11433 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 11434 &res->mac_addr); 11435 #endif 11436 #ifdef RTE_NET_BNXT 11437 if (ret == -ENOTSUP) 11438 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 11439 &res->mac_addr); 11440 #endif 11441 11442 switch (ret) { 11443 case 0: 11444 break; 11445 case -EINVAL: 11446 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id); 11447 break; 11448 case -ENODEV: 11449 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11450 break; 11451 case -ENOTSUP: 11452 fprintf(stderr, "function not implemented\n"); 11453 break; 11454 default: 11455 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11456 } 11457 } 11458 11459 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 11460 .f = cmd_set_vf_mac_addr_parsed, 11461 .data = NULL, 11462 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 11463 .tokens = { 11464 (void *)&cmd_set_vf_mac_addr_set, 11465 (void *)&cmd_set_vf_mac_addr_vf, 11466 (void *)&cmd_set_vf_mac_addr_mac, 11467 (void *)&cmd_set_vf_mac_addr_addr, 11468 (void *)&cmd_set_vf_mac_addr_port_id, 11469 (void *)&cmd_set_vf_mac_addr_vf_id, 11470 (void *)&cmd_set_vf_mac_addr_mac_addr, 11471 NULL, 11472 }, 11473 }; 11474 11475 /* MACsec configuration */ 11476 11477 /* Common result structure for MACsec offload enable */ 11478 struct cmd_macsec_offload_on_result { 11479 cmdline_fixed_string_t set; 11480 cmdline_fixed_string_t macsec; 11481 cmdline_fixed_string_t offload; 11482 portid_t port_id; 11483 cmdline_fixed_string_t on; 11484 cmdline_fixed_string_t encrypt; 11485 cmdline_fixed_string_t en_on_off; 11486 cmdline_fixed_string_t replay_protect; 11487 cmdline_fixed_string_t rp_on_off; 11488 }; 11489 11490 /* Common CLI fields for MACsec offload disable */ 11491 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 11492 TOKEN_STRING_INITIALIZER 11493 (struct cmd_macsec_offload_on_result, 11494 set, "set"); 11495 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 11496 TOKEN_STRING_INITIALIZER 11497 (struct cmd_macsec_offload_on_result, 11498 macsec, "macsec"); 11499 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 11500 TOKEN_STRING_INITIALIZER 11501 (struct cmd_macsec_offload_on_result, 11502 offload, "offload"); 11503 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 11504 TOKEN_NUM_INITIALIZER 11505 (struct cmd_macsec_offload_on_result, 11506 port_id, RTE_UINT16); 11507 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 11508 TOKEN_STRING_INITIALIZER 11509 (struct cmd_macsec_offload_on_result, 11510 on, "on"); 11511 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 11512 TOKEN_STRING_INITIALIZER 11513 (struct cmd_macsec_offload_on_result, 11514 encrypt, "encrypt"); 11515 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 11516 TOKEN_STRING_INITIALIZER 11517 (struct cmd_macsec_offload_on_result, 11518 en_on_off, "on#off"); 11519 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 11520 TOKEN_STRING_INITIALIZER 11521 (struct cmd_macsec_offload_on_result, 11522 replay_protect, "replay-protect"); 11523 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 11524 TOKEN_STRING_INITIALIZER 11525 (struct cmd_macsec_offload_on_result, 11526 rp_on_off, "on#off"); 11527 11528 static void 11529 cmd_set_macsec_offload_on_parsed( 11530 void *parsed_result, 11531 __rte_unused struct cmdline *cl, 11532 __rte_unused void *data) 11533 { 11534 struct cmd_macsec_offload_on_result *res = parsed_result; 11535 int ret = -ENOTSUP; 11536 portid_t port_id = res->port_id; 11537 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 11538 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 11539 struct rte_eth_dev_info dev_info; 11540 11541 if (port_id_is_invalid(port_id, ENABLED_WARN)) 11542 return; 11543 if (!port_is_stopped(port_id)) { 11544 fprintf(stderr, "Please stop port %d first\n", port_id); 11545 return; 11546 } 11547 11548 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11549 if (ret != 0) 11550 return; 11551 11552 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 11553 #ifdef RTE_NET_IXGBE 11554 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 11555 #endif 11556 } 11557 RTE_SET_USED(en); 11558 RTE_SET_USED(rp); 11559 11560 switch (ret) { 11561 case 0: 11562 ports[port_id].dev_conf.txmode.offloads |= 11563 DEV_TX_OFFLOAD_MACSEC_INSERT; 11564 cmd_reconfig_device_queue(port_id, 1, 1); 11565 break; 11566 case -ENODEV: 11567 fprintf(stderr, "invalid port_id %d\n", port_id); 11568 break; 11569 case -ENOTSUP: 11570 fprintf(stderr, "not supported on port %d\n", port_id); 11571 break; 11572 default: 11573 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11574 } 11575 } 11576 11577 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 11578 .f = cmd_set_macsec_offload_on_parsed, 11579 .data = NULL, 11580 .help_str = "set macsec offload <port_id> on " 11581 "encrypt on|off replay-protect on|off", 11582 .tokens = { 11583 (void *)&cmd_macsec_offload_on_set, 11584 (void *)&cmd_macsec_offload_on_macsec, 11585 (void *)&cmd_macsec_offload_on_offload, 11586 (void *)&cmd_macsec_offload_on_port_id, 11587 (void *)&cmd_macsec_offload_on_on, 11588 (void *)&cmd_macsec_offload_on_encrypt, 11589 (void *)&cmd_macsec_offload_on_en_on_off, 11590 (void *)&cmd_macsec_offload_on_replay_protect, 11591 (void *)&cmd_macsec_offload_on_rp_on_off, 11592 NULL, 11593 }, 11594 }; 11595 11596 /* Common result structure for MACsec offload disable */ 11597 struct cmd_macsec_offload_off_result { 11598 cmdline_fixed_string_t set; 11599 cmdline_fixed_string_t macsec; 11600 cmdline_fixed_string_t offload; 11601 portid_t port_id; 11602 cmdline_fixed_string_t off; 11603 }; 11604 11605 /* Common CLI fields for MACsec offload disable */ 11606 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 11607 TOKEN_STRING_INITIALIZER 11608 (struct cmd_macsec_offload_off_result, 11609 set, "set"); 11610 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 11611 TOKEN_STRING_INITIALIZER 11612 (struct cmd_macsec_offload_off_result, 11613 macsec, "macsec"); 11614 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 11615 TOKEN_STRING_INITIALIZER 11616 (struct cmd_macsec_offload_off_result, 11617 offload, "offload"); 11618 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 11619 TOKEN_NUM_INITIALIZER 11620 (struct cmd_macsec_offload_off_result, 11621 port_id, RTE_UINT16); 11622 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 11623 TOKEN_STRING_INITIALIZER 11624 (struct cmd_macsec_offload_off_result, 11625 off, "off"); 11626 11627 static void 11628 cmd_set_macsec_offload_off_parsed( 11629 void *parsed_result, 11630 __rte_unused struct cmdline *cl, 11631 __rte_unused void *data) 11632 { 11633 struct cmd_macsec_offload_off_result *res = parsed_result; 11634 int ret = -ENOTSUP; 11635 struct rte_eth_dev_info dev_info; 11636 portid_t port_id = res->port_id; 11637 11638 if (port_id_is_invalid(port_id, ENABLED_WARN)) 11639 return; 11640 if (!port_is_stopped(port_id)) { 11641 fprintf(stderr, "Please stop port %d first\n", port_id); 11642 return; 11643 } 11644 11645 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11646 if (ret != 0) 11647 return; 11648 11649 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 11650 #ifdef RTE_NET_IXGBE 11651 ret = rte_pmd_ixgbe_macsec_disable(port_id); 11652 #endif 11653 } 11654 switch (ret) { 11655 case 0: 11656 ports[port_id].dev_conf.txmode.offloads &= 11657 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 11658 cmd_reconfig_device_queue(port_id, 1, 1); 11659 break; 11660 case -ENODEV: 11661 fprintf(stderr, "invalid port_id %d\n", port_id); 11662 break; 11663 case -ENOTSUP: 11664 fprintf(stderr, "not supported on port %d\n", port_id); 11665 break; 11666 default: 11667 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11668 } 11669 } 11670 11671 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 11672 .f = cmd_set_macsec_offload_off_parsed, 11673 .data = NULL, 11674 .help_str = "set macsec offload <port_id> off", 11675 .tokens = { 11676 (void *)&cmd_macsec_offload_off_set, 11677 (void *)&cmd_macsec_offload_off_macsec, 11678 (void *)&cmd_macsec_offload_off_offload, 11679 (void *)&cmd_macsec_offload_off_port_id, 11680 (void *)&cmd_macsec_offload_off_off, 11681 NULL, 11682 }, 11683 }; 11684 11685 /* Common result structure for MACsec secure connection configure */ 11686 struct cmd_macsec_sc_result { 11687 cmdline_fixed_string_t set; 11688 cmdline_fixed_string_t macsec; 11689 cmdline_fixed_string_t sc; 11690 cmdline_fixed_string_t tx_rx; 11691 portid_t port_id; 11692 struct rte_ether_addr mac; 11693 uint16_t pi; 11694 }; 11695 11696 /* Common CLI fields for MACsec secure connection configure */ 11697 cmdline_parse_token_string_t cmd_macsec_sc_set = 11698 TOKEN_STRING_INITIALIZER 11699 (struct cmd_macsec_sc_result, 11700 set, "set"); 11701 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 11702 TOKEN_STRING_INITIALIZER 11703 (struct cmd_macsec_sc_result, 11704 macsec, "macsec"); 11705 cmdline_parse_token_string_t cmd_macsec_sc_sc = 11706 TOKEN_STRING_INITIALIZER 11707 (struct cmd_macsec_sc_result, 11708 sc, "sc"); 11709 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 11710 TOKEN_STRING_INITIALIZER 11711 (struct cmd_macsec_sc_result, 11712 tx_rx, "tx#rx"); 11713 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 11714 TOKEN_NUM_INITIALIZER 11715 (struct cmd_macsec_sc_result, 11716 port_id, RTE_UINT16); 11717 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 11718 TOKEN_ETHERADDR_INITIALIZER 11719 (struct cmd_macsec_sc_result, 11720 mac); 11721 cmdline_parse_token_num_t cmd_macsec_sc_pi = 11722 TOKEN_NUM_INITIALIZER 11723 (struct cmd_macsec_sc_result, 11724 pi, RTE_UINT16); 11725 11726 static void 11727 cmd_set_macsec_sc_parsed( 11728 void *parsed_result, 11729 __rte_unused struct cmdline *cl, 11730 __rte_unused void *data) 11731 { 11732 struct cmd_macsec_sc_result *res = parsed_result; 11733 int ret = -ENOTSUP; 11734 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 11735 11736 #ifdef RTE_NET_IXGBE 11737 ret = is_tx ? 11738 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 11739 res->mac.addr_bytes) : 11740 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 11741 res->mac.addr_bytes, res->pi); 11742 #endif 11743 RTE_SET_USED(is_tx); 11744 11745 switch (ret) { 11746 case 0: 11747 break; 11748 case -ENODEV: 11749 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11750 break; 11751 case -ENOTSUP: 11752 fprintf(stderr, "not supported on port %d\n", res->port_id); 11753 break; 11754 default: 11755 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11756 } 11757 } 11758 11759 cmdline_parse_inst_t cmd_set_macsec_sc = { 11760 .f = cmd_set_macsec_sc_parsed, 11761 .data = NULL, 11762 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 11763 .tokens = { 11764 (void *)&cmd_macsec_sc_set, 11765 (void *)&cmd_macsec_sc_macsec, 11766 (void *)&cmd_macsec_sc_sc, 11767 (void *)&cmd_macsec_sc_tx_rx, 11768 (void *)&cmd_macsec_sc_port_id, 11769 (void *)&cmd_macsec_sc_mac, 11770 (void *)&cmd_macsec_sc_pi, 11771 NULL, 11772 }, 11773 }; 11774 11775 /* Common result structure for MACsec secure connection configure */ 11776 struct cmd_macsec_sa_result { 11777 cmdline_fixed_string_t set; 11778 cmdline_fixed_string_t macsec; 11779 cmdline_fixed_string_t sa; 11780 cmdline_fixed_string_t tx_rx; 11781 portid_t port_id; 11782 uint8_t idx; 11783 uint8_t an; 11784 uint32_t pn; 11785 cmdline_fixed_string_t key; 11786 }; 11787 11788 /* Common CLI fields for MACsec secure connection configure */ 11789 cmdline_parse_token_string_t cmd_macsec_sa_set = 11790 TOKEN_STRING_INITIALIZER 11791 (struct cmd_macsec_sa_result, 11792 set, "set"); 11793 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 11794 TOKEN_STRING_INITIALIZER 11795 (struct cmd_macsec_sa_result, 11796 macsec, "macsec"); 11797 cmdline_parse_token_string_t cmd_macsec_sa_sa = 11798 TOKEN_STRING_INITIALIZER 11799 (struct cmd_macsec_sa_result, 11800 sa, "sa"); 11801 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 11802 TOKEN_STRING_INITIALIZER 11803 (struct cmd_macsec_sa_result, 11804 tx_rx, "tx#rx"); 11805 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 11806 TOKEN_NUM_INITIALIZER 11807 (struct cmd_macsec_sa_result, 11808 port_id, RTE_UINT16); 11809 cmdline_parse_token_num_t cmd_macsec_sa_idx = 11810 TOKEN_NUM_INITIALIZER 11811 (struct cmd_macsec_sa_result, 11812 idx, RTE_UINT8); 11813 cmdline_parse_token_num_t cmd_macsec_sa_an = 11814 TOKEN_NUM_INITIALIZER 11815 (struct cmd_macsec_sa_result, 11816 an, RTE_UINT8); 11817 cmdline_parse_token_num_t cmd_macsec_sa_pn = 11818 TOKEN_NUM_INITIALIZER 11819 (struct cmd_macsec_sa_result, 11820 pn, RTE_UINT32); 11821 cmdline_parse_token_string_t cmd_macsec_sa_key = 11822 TOKEN_STRING_INITIALIZER 11823 (struct cmd_macsec_sa_result, 11824 key, NULL); 11825 11826 static void 11827 cmd_set_macsec_sa_parsed( 11828 void *parsed_result, 11829 __rte_unused struct cmdline *cl, 11830 __rte_unused void *data) 11831 { 11832 struct cmd_macsec_sa_result *res = parsed_result; 11833 int ret = -ENOTSUP; 11834 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 11835 uint8_t key[16] = { 0 }; 11836 uint8_t xdgt0; 11837 uint8_t xdgt1; 11838 int key_len; 11839 int i; 11840 11841 key_len = strlen(res->key) / 2; 11842 if (key_len > 16) 11843 key_len = 16; 11844 11845 for (i = 0; i < key_len; i++) { 11846 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 11847 if (xdgt0 == 0xFF) 11848 return; 11849 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 11850 if (xdgt1 == 0xFF) 11851 return; 11852 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 11853 } 11854 11855 #ifdef RTE_NET_IXGBE 11856 ret = is_tx ? 11857 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 11858 res->idx, res->an, res->pn, key) : 11859 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 11860 res->idx, res->an, res->pn, key); 11861 #endif 11862 RTE_SET_USED(is_tx); 11863 RTE_SET_USED(key); 11864 11865 switch (ret) { 11866 case 0: 11867 break; 11868 case -EINVAL: 11869 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an); 11870 break; 11871 case -ENODEV: 11872 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11873 break; 11874 case -ENOTSUP: 11875 fprintf(stderr, "not supported on port %d\n", res->port_id); 11876 break; 11877 default: 11878 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11879 } 11880 } 11881 11882 cmdline_parse_inst_t cmd_set_macsec_sa = { 11883 .f = cmd_set_macsec_sa_parsed, 11884 .data = NULL, 11885 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 11886 .tokens = { 11887 (void *)&cmd_macsec_sa_set, 11888 (void *)&cmd_macsec_sa_macsec, 11889 (void *)&cmd_macsec_sa_sa, 11890 (void *)&cmd_macsec_sa_tx_rx, 11891 (void *)&cmd_macsec_sa_port_id, 11892 (void *)&cmd_macsec_sa_idx, 11893 (void *)&cmd_macsec_sa_an, 11894 (void *)&cmd_macsec_sa_pn, 11895 (void *)&cmd_macsec_sa_key, 11896 NULL, 11897 }, 11898 }; 11899 11900 /* VF unicast promiscuous mode configuration */ 11901 11902 /* Common result structure for VF unicast promiscuous mode */ 11903 struct cmd_vf_promisc_result { 11904 cmdline_fixed_string_t set; 11905 cmdline_fixed_string_t vf; 11906 cmdline_fixed_string_t promisc; 11907 portid_t port_id; 11908 uint32_t vf_id; 11909 cmdline_fixed_string_t on_off; 11910 }; 11911 11912 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 11913 cmdline_parse_token_string_t cmd_vf_promisc_set = 11914 TOKEN_STRING_INITIALIZER 11915 (struct cmd_vf_promisc_result, 11916 set, "set"); 11917 cmdline_parse_token_string_t cmd_vf_promisc_vf = 11918 TOKEN_STRING_INITIALIZER 11919 (struct cmd_vf_promisc_result, 11920 vf, "vf"); 11921 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 11922 TOKEN_STRING_INITIALIZER 11923 (struct cmd_vf_promisc_result, 11924 promisc, "promisc"); 11925 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 11926 TOKEN_NUM_INITIALIZER 11927 (struct cmd_vf_promisc_result, 11928 port_id, RTE_UINT16); 11929 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 11930 TOKEN_NUM_INITIALIZER 11931 (struct cmd_vf_promisc_result, 11932 vf_id, RTE_UINT32); 11933 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 11934 TOKEN_STRING_INITIALIZER 11935 (struct cmd_vf_promisc_result, 11936 on_off, "on#off"); 11937 11938 static void 11939 cmd_set_vf_promisc_parsed( 11940 void *parsed_result, 11941 __rte_unused struct cmdline *cl, 11942 __rte_unused void *data) 11943 { 11944 struct cmd_vf_promisc_result *res = parsed_result; 11945 int ret = -ENOTSUP; 11946 11947 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11948 11949 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11950 return; 11951 11952 #ifdef RTE_NET_I40E 11953 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 11954 res->vf_id, is_on); 11955 #endif 11956 11957 switch (ret) { 11958 case 0: 11959 break; 11960 case -EINVAL: 11961 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 11962 break; 11963 case -ENODEV: 11964 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11965 break; 11966 case -ENOTSUP: 11967 fprintf(stderr, "function not implemented\n"); 11968 break; 11969 default: 11970 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11971 } 11972 } 11973 11974 cmdline_parse_inst_t cmd_set_vf_promisc = { 11975 .f = cmd_set_vf_promisc_parsed, 11976 .data = NULL, 11977 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 11978 "Set unicast promiscuous mode for a VF from the PF", 11979 .tokens = { 11980 (void *)&cmd_vf_promisc_set, 11981 (void *)&cmd_vf_promisc_vf, 11982 (void *)&cmd_vf_promisc_promisc, 11983 (void *)&cmd_vf_promisc_port_id, 11984 (void *)&cmd_vf_promisc_vf_id, 11985 (void *)&cmd_vf_promisc_on_off, 11986 NULL, 11987 }, 11988 }; 11989 11990 /* VF multicast promiscuous mode configuration */ 11991 11992 /* Common result structure for VF multicast promiscuous mode */ 11993 struct cmd_vf_allmulti_result { 11994 cmdline_fixed_string_t set; 11995 cmdline_fixed_string_t vf; 11996 cmdline_fixed_string_t allmulti; 11997 portid_t port_id; 11998 uint32_t vf_id; 11999 cmdline_fixed_string_t on_off; 12000 }; 12001 12002 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 12003 cmdline_parse_token_string_t cmd_vf_allmulti_set = 12004 TOKEN_STRING_INITIALIZER 12005 (struct cmd_vf_allmulti_result, 12006 set, "set"); 12007 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 12008 TOKEN_STRING_INITIALIZER 12009 (struct cmd_vf_allmulti_result, 12010 vf, "vf"); 12011 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 12012 TOKEN_STRING_INITIALIZER 12013 (struct cmd_vf_allmulti_result, 12014 allmulti, "allmulti"); 12015 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 12016 TOKEN_NUM_INITIALIZER 12017 (struct cmd_vf_allmulti_result, 12018 port_id, RTE_UINT16); 12019 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 12020 TOKEN_NUM_INITIALIZER 12021 (struct cmd_vf_allmulti_result, 12022 vf_id, RTE_UINT32); 12023 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 12024 TOKEN_STRING_INITIALIZER 12025 (struct cmd_vf_allmulti_result, 12026 on_off, "on#off"); 12027 12028 static void 12029 cmd_set_vf_allmulti_parsed( 12030 void *parsed_result, 12031 __rte_unused struct cmdline *cl, 12032 __rte_unused void *data) 12033 { 12034 struct cmd_vf_allmulti_result *res = parsed_result; 12035 int ret = -ENOTSUP; 12036 12037 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12038 12039 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12040 return; 12041 12042 #ifdef RTE_NET_I40E 12043 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 12044 res->vf_id, is_on); 12045 #endif 12046 12047 switch (ret) { 12048 case 0: 12049 break; 12050 case -EINVAL: 12051 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 12052 break; 12053 case -ENODEV: 12054 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12055 break; 12056 case -ENOTSUP: 12057 fprintf(stderr, "function not implemented\n"); 12058 break; 12059 default: 12060 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12061 } 12062 } 12063 12064 cmdline_parse_inst_t cmd_set_vf_allmulti = { 12065 .f = cmd_set_vf_allmulti_parsed, 12066 .data = NULL, 12067 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 12068 "Set multicast promiscuous mode for a VF from the PF", 12069 .tokens = { 12070 (void *)&cmd_vf_allmulti_set, 12071 (void *)&cmd_vf_allmulti_vf, 12072 (void *)&cmd_vf_allmulti_allmulti, 12073 (void *)&cmd_vf_allmulti_port_id, 12074 (void *)&cmd_vf_allmulti_vf_id, 12075 (void *)&cmd_vf_allmulti_on_off, 12076 NULL, 12077 }, 12078 }; 12079 12080 /* vf broadcast mode configuration */ 12081 12082 /* Common result structure for vf broadcast */ 12083 struct cmd_set_vf_broadcast_result { 12084 cmdline_fixed_string_t set; 12085 cmdline_fixed_string_t vf; 12086 cmdline_fixed_string_t broadcast; 12087 portid_t port_id; 12088 uint16_t vf_id; 12089 cmdline_fixed_string_t on_off; 12090 }; 12091 12092 /* Common CLI fields for vf broadcast enable disable */ 12093 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 12094 TOKEN_STRING_INITIALIZER 12095 (struct cmd_set_vf_broadcast_result, 12096 set, "set"); 12097 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 12098 TOKEN_STRING_INITIALIZER 12099 (struct cmd_set_vf_broadcast_result, 12100 vf, "vf"); 12101 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 12102 TOKEN_STRING_INITIALIZER 12103 (struct cmd_set_vf_broadcast_result, 12104 broadcast, "broadcast"); 12105 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 12106 TOKEN_NUM_INITIALIZER 12107 (struct cmd_set_vf_broadcast_result, 12108 port_id, RTE_UINT16); 12109 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 12110 TOKEN_NUM_INITIALIZER 12111 (struct cmd_set_vf_broadcast_result, 12112 vf_id, RTE_UINT16); 12113 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 12114 TOKEN_STRING_INITIALIZER 12115 (struct cmd_set_vf_broadcast_result, 12116 on_off, "on#off"); 12117 12118 static void 12119 cmd_set_vf_broadcast_parsed( 12120 void *parsed_result, 12121 __rte_unused struct cmdline *cl, 12122 __rte_unused void *data) 12123 { 12124 struct cmd_set_vf_broadcast_result *res = parsed_result; 12125 int ret = -ENOTSUP; 12126 12127 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12128 12129 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12130 return; 12131 12132 #ifdef RTE_NET_I40E 12133 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 12134 res->vf_id, is_on); 12135 #endif 12136 12137 switch (ret) { 12138 case 0: 12139 break; 12140 case -EINVAL: 12141 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 12142 res->vf_id, is_on); 12143 break; 12144 case -ENODEV: 12145 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12146 break; 12147 case -ENOTSUP: 12148 fprintf(stderr, "function not implemented\n"); 12149 break; 12150 default: 12151 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12152 } 12153 } 12154 12155 cmdline_parse_inst_t cmd_set_vf_broadcast = { 12156 .f = cmd_set_vf_broadcast_parsed, 12157 .data = NULL, 12158 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 12159 .tokens = { 12160 (void *)&cmd_set_vf_broadcast_set, 12161 (void *)&cmd_set_vf_broadcast_vf, 12162 (void *)&cmd_set_vf_broadcast_broadcast, 12163 (void *)&cmd_set_vf_broadcast_port_id, 12164 (void *)&cmd_set_vf_broadcast_vf_id, 12165 (void *)&cmd_set_vf_broadcast_on_off, 12166 NULL, 12167 }, 12168 }; 12169 12170 /* vf vlan tag configuration */ 12171 12172 /* Common result structure for vf vlan tag */ 12173 struct cmd_set_vf_vlan_tag_result { 12174 cmdline_fixed_string_t set; 12175 cmdline_fixed_string_t vf; 12176 cmdline_fixed_string_t vlan; 12177 cmdline_fixed_string_t tag; 12178 portid_t port_id; 12179 uint16_t vf_id; 12180 cmdline_fixed_string_t on_off; 12181 }; 12182 12183 /* Common CLI fields for vf vlan tag enable disable */ 12184 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 12185 TOKEN_STRING_INITIALIZER 12186 (struct cmd_set_vf_vlan_tag_result, 12187 set, "set"); 12188 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 12189 TOKEN_STRING_INITIALIZER 12190 (struct cmd_set_vf_vlan_tag_result, 12191 vf, "vf"); 12192 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 12193 TOKEN_STRING_INITIALIZER 12194 (struct cmd_set_vf_vlan_tag_result, 12195 vlan, "vlan"); 12196 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 12197 TOKEN_STRING_INITIALIZER 12198 (struct cmd_set_vf_vlan_tag_result, 12199 tag, "tag"); 12200 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 12201 TOKEN_NUM_INITIALIZER 12202 (struct cmd_set_vf_vlan_tag_result, 12203 port_id, RTE_UINT16); 12204 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 12205 TOKEN_NUM_INITIALIZER 12206 (struct cmd_set_vf_vlan_tag_result, 12207 vf_id, RTE_UINT16); 12208 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 12209 TOKEN_STRING_INITIALIZER 12210 (struct cmd_set_vf_vlan_tag_result, 12211 on_off, "on#off"); 12212 12213 static void 12214 cmd_set_vf_vlan_tag_parsed( 12215 void *parsed_result, 12216 __rte_unused struct cmdline *cl, 12217 __rte_unused void *data) 12218 { 12219 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 12220 int ret = -ENOTSUP; 12221 12222 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12223 12224 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12225 return; 12226 12227 #ifdef RTE_NET_I40E 12228 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 12229 res->vf_id, is_on); 12230 #endif 12231 12232 switch (ret) { 12233 case 0: 12234 break; 12235 case -EINVAL: 12236 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 12237 res->vf_id, is_on); 12238 break; 12239 case -ENODEV: 12240 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12241 break; 12242 case -ENOTSUP: 12243 fprintf(stderr, "function not implemented\n"); 12244 break; 12245 default: 12246 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12247 } 12248 } 12249 12250 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 12251 .f = cmd_set_vf_vlan_tag_parsed, 12252 .data = NULL, 12253 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 12254 .tokens = { 12255 (void *)&cmd_set_vf_vlan_tag_set, 12256 (void *)&cmd_set_vf_vlan_tag_vf, 12257 (void *)&cmd_set_vf_vlan_tag_vlan, 12258 (void *)&cmd_set_vf_vlan_tag_tag, 12259 (void *)&cmd_set_vf_vlan_tag_port_id, 12260 (void *)&cmd_set_vf_vlan_tag_vf_id, 12261 (void *)&cmd_set_vf_vlan_tag_on_off, 12262 NULL, 12263 }, 12264 }; 12265 12266 /* Common definition of VF and TC TX bandwidth configuration */ 12267 struct cmd_vf_tc_bw_result { 12268 cmdline_fixed_string_t set; 12269 cmdline_fixed_string_t vf; 12270 cmdline_fixed_string_t tc; 12271 cmdline_fixed_string_t tx; 12272 cmdline_fixed_string_t min_bw; 12273 cmdline_fixed_string_t max_bw; 12274 cmdline_fixed_string_t strict_link_prio; 12275 portid_t port_id; 12276 uint16_t vf_id; 12277 uint8_t tc_no; 12278 uint32_t bw; 12279 cmdline_fixed_string_t bw_list; 12280 uint8_t tc_map; 12281 }; 12282 12283 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 12284 TOKEN_STRING_INITIALIZER 12285 (struct cmd_vf_tc_bw_result, 12286 set, "set"); 12287 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 12288 TOKEN_STRING_INITIALIZER 12289 (struct cmd_vf_tc_bw_result, 12290 vf, "vf"); 12291 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 12292 TOKEN_STRING_INITIALIZER 12293 (struct cmd_vf_tc_bw_result, 12294 tc, "tc"); 12295 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 12296 TOKEN_STRING_INITIALIZER 12297 (struct cmd_vf_tc_bw_result, 12298 tx, "tx"); 12299 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 12300 TOKEN_STRING_INITIALIZER 12301 (struct cmd_vf_tc_bw_result, 12302 strict_link_prio, "strict-link-priority"); 12303 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 12304 TOKEN_STRING_INITIALIZER 12305 (struct cmd_vf_tc_bw_result, 12306 min_bw, "min-bandwidth"); 12307 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 12308 TOKEN_STRING_INITIALIZER 12309 (struct cmd_vf_tc_bw_result, 12310 max_bw, "max-bandwidth"); 12311 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 12312 TOKEN_NUM_INITIALIZER 12313 (struct cmd_vf_tc_bw_result, 12314 port_id, RTE_UINT16); 12315 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 12316 TOKEN_NUM_INITIALIZER 12317 (struct cmd_vf_tc_bw_result, 12318 vf_id, RTE_UINT16); 12319 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 12320 TOKEN_NUM_INITIALIZER 12321 (struct cmd_vf_tc_bw_result, 12322 tc_no, RTE_UINT8); 12323 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 12324 TOKEN_NUM_INITIALIZER 12325 (struct cmd_vf_tc_bw_result, 12326 bw, RTE_UINT32); 12327 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 12328 TOKEN_STRING_INITIALIZER 12329 (struct cmd_vf_tc_bw_result, 12330 bw_list, NULL); 12331 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 12332 TOKEN_NUM_INITIALIZER 12333 (struct cmd_vf_tc_bw_result, 12334 tc_map, RTE_UINT8); 12335 12336 /* VF max bandwidth setting */ 12337 static void 12338 cmd_vf_max_bw_parsed( 12339 void *parsed_result, 12340 __rte_unused struct cmdline *cl, 12341 __rte_unused void *data) 12342 { 12343 struct cmd_vf_tc_bw_result *res = parsed_result; 12344 int ret = -ENOTSUP; 12345 12346 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12347 return; 12348 12349 #ifdef RTE_NET_I40E 12350 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 12351 res->vf_id, res->bw); 12352 #endif 12353 12354 switch (ret) { 12355 case 0: 12356 break; 12357 case -EINVAL: 12358 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n", 12359 res->vf_id, res->bw); 12360 break; 12361 case -ENODEV: 12362 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12363 break; 12364 case -ENOTSUP: 12365 fprintf(stderr, "function not implemented\n"); 12366 break; 12367 default: 12368 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12369 } 12370 } 12371 12372 cmdline_parse_inst_t cmd_vf_max_bw = { 12373 .f = cmd_vf_max_bw_parsed, 12374 .data = NULL, 12375 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 12376 .tokens = { 12377 (void *)&cmd_vf_tc_bw_set, 12378 (void *)&cmd_vf_tc_bw_vf, 12379 (void *)&cmd_vf_tc_bw_tx, 12380 (void *)&cmd_vf_tc_bw_max_bw, 12381 (void *)&cmd_vf_tc_bw_port_id, 12382 (void *)&cmd_vf_tc_bw_vf_id, 12383 (void *)&cmd_vf_tc_bw_bw, 12384 NULL, 12385 }, 12386 }; 12387 12388 static int 12389 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 12390 uint8_t *tc_num, 12391 char *str) 12392 { 12393 uint32_t size; 12394 const char *p, *p0 = str; 12395 char s[256]; 12396 char *end; 12397 char *str_fld[16]; 12398 uint16_t i; 12399 int ret; 12400 12401 p = strchr(p0, '('); 12402 if (p == NULL) { 12403 fprintf(stderr, 12404 "The bandwidth-list should be '(bw1, bw2, ...)'\n"); 12405 return -1; 12406 } 12407 p++; 12408 p0 = strchr(p, ')'); 12409 if (p0 == NULL) { 12410 fprintf(stderr, 12411 "The bandwidth-list should be '(bw1, bw2, ...)'\n"); 12412 return -1; 12413 } 12414 size = p0 - p; 12415 if (size >= sizeof(s)) { 12416 fprintf(stderr, 12417 "The string size exceeds the internal buffer size\n"); 12418 return -1; 12419 } 12420 snprintf(s, sizeof(s), "%.*s", size, p); 12421 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 12422 if (ret <= 0) { 12423 fprintf(stderr, "Failed to get the bandwidth list.\n"); 12424 return -1; 12425 } 12426 *tc_num = ret; 12427 for (i = 0; i < ret; i++) 12428 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 12429 12430 return 0; 12431 } 12432 12433 /* TC min bandwidth setting */ 12434 static void 12435 cmd_vf_tc_min_bw_parsed( 12436 void *parsed_result, 12437 __rte_unused struct cmdline *cl, 12438 __rte_unused void *data) 12439 { 12440 struct cmd_vf_tc_bw_result *res = parsed_result; 12441 uint8_t tc_num; 12442 uint8_t bw[16]; 12443 int ret = -ENOTSUP; 12444 12445 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12446 return; 12447 12448 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 12449 if (ret) 12450 return; 12451 12452 #ifdef RTE_NET_I40E 12453 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 12454 tc_num, bw); 12455 #endif 12456 12457 switch (ret) { 12458 case 0: 12459 break; 12460 case -EINVAL: 12461 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id); 12462 break; 12463 case -ENODEV: 12464 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12465 break; 12466 case -ENOTSUP: 12467 fprintf(stderr, "function not implemented\n"); 12468 break; 12469 default: 12470 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12471 } 12472 } 12473 12474 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 12475 .f = cmd_vf_tc_min_bw_parsed, 12476 .data = NULL, 12477 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 12478 " <bw1, bw2, ...>", 12479 .tokens = { 12480 (void *)&cmd_vf_tc_bw_set, 12481 (void *)&cmd_vf_tc_bw_vf, 12482 (void *)&cmd_vf_tc_bw_tc, 12483 (void *)&cmd_vf_tc_bw_tx, 12484 (void *)&cmd_vf_tc_bw_min_bw, 12485 (void *)&cmd_vf_tc_bw_port_id, 12486 (void *)&cmd_vf_tc_bw_vf_id, 12487 (void *)&cmd_vf_tc_bw_bw_list, 12488 NULL, 12489 }, 12490 }; 12491 12492 static void 12493 cmd_tc_min_bw_parsed( 12494 void *parsed_result, 12495 __rte_unused struct cmdline *cl, 12496 __rte_unused void *data) 12497 { 12498 struct cmd_vf_tc_bw_result *res = parsed_result; 12499 struct rte_port *port; 12500 uint8_t tc_num; 12501 uint8_t bw[16]; 12502 int ret = -ENOTSUP; 12503 12504 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12505 return; 12506 12507 port = &ports[res->port_id]; 12508 /** Check if the port is not started **/ 12509 if (port->port_status != RTE_PORT_STOPPED) { 12510 fprintf(stderr, "Please stop port %d first\n", res->port_id); 12511 return; 12512 } 12513 12514 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 12515 if (ret) 12516 return; 12517 12518 #ifdef RTE_NET_IXGBE 12519 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 12520 #endif 12521 12522 switch (ret) { 12523 case 0: 12524 break; 12525 case -EINVAL: 12526 fprintf(stderr, "invalid bandwidth\n"); 12527 break; 12528 case -ENODEV: 12529 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12530 break; 12531 case -ENOTSUP: 12532 fprintf(stderr, "function not implemented\n"); 12533 break; 12534 default: 12535 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12536 } 12537 } 12538 12539 cmdline_parse_inst_t cmd_tc_min_bw = { 12540 .f = cmd_tc_min_bw_parsed, 12541 .data = NULL, 12542 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 12543 .tokens = { 12544 (void *)&cmd_vf_tc_bw_set, 12545 (void *)&cmd_vf_tc_bw_tc, 12546 (void *)&cmd_vf_tc_bw_tx, 12547 (void *)&cmd_vf_tc_bw_min_bw, 12548 (void *)&cmd_vf_tc_bw_port_id, 12549 (void *)&cmd_vf_tc_bw_bw_list, 12550 NULL, 12551 }, 12552 }; 12553 12554 /* TC max bandwidth setting */ 12555 static void 12556 cmd_vf_tc_max_bw_parsed( 12557 void *parsed_result, 12558 __rte_unused struct cmdline *cl, 12559 __rte_unused void *data) 12560 { 12561 struct cmd_vf_tc_bw_result *res = parsed_result; 12562 int ret = -ENOTSUP; 12563 12564 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12565 return; 12566 12567 #ifdef RTE_NET_I40E 12568 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 12569 res->tc_no, res->bw); 12570 #endif 12571 12572 switch (ret) { 12573 case 0: 12574 break; 12575 case -EINVAL: 12576 fprintf(stderr, 12577 "invalid vf_id %d, tc_no %d or bandwidth %d\n", 12578 res->vf_id, res->tc_no, res->bw); 12579 break; 12580 case -ENODEV: 12581 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12582 break; 12583 case -ENOTSUP: 12584 fprintf(stderr, "function not implemented\n"); 12585 break; 12586 default: 12587 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12588 } 12589 } 12590 12591 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 12592 .f = cmd_vf_tc_max_bw_parsed, 12593 .data = NULL, 12594 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 12595 " <bandwidth>", 12596 .tokens = { 12597 (void *)&cmd_vf_tc_bw_set, 12598 (void *)&cmd_vf_tc_bw_vf, 12599 (void *)&cmd_vf_tc_bw_tc, 12600 (void *)&cmd_vf_tc_bw_tx, 12601 (void *)&cmd_vf_tc_bw_max_bw, 12602 (void *)&cmd_vf_tc_bw_port_id, 12603 (void *)&cmd_vf_tc_bw_vf_id, 12604 (void *)&cmd_vf_tc_bw_tc_no, 12605 (void *)&cmd_vf_tc_bw_bw, 12606 NULL, 12607 }, 12608 }; 12609 12610 /** Set VXLAN encapsulation details */ 12611 struct cmd_set_vxlan_result { 12612 cmdline_fixed_string_t set; 12613 cmdline_fixed_string_t vxlan; 12614 cmdline_fixed_string_t pos_token; 12615 cmdline_fixed_string_t ip_version; 12616 uint32_t vlan_present:1; 12617 uint32_t vni; 12618 uint16_t udp_src; 12619 uint16_t udp_dst; 12620 cmdline_ipaddr_t ip_src; 12621 cmdline_ipaddr_t ip_dst; 12622 uint16_t tci; 12623 uint8_t tos; 12624 uint8_t ttl; 12625 struct rte_ether_addr eth_src; 12626 struct rte_ether_addr eth_dst; 12627 }; 12628 12629 cmdline_parse_token_string_t cmd_set_vxlan_set = 12630 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 12631 cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 12632 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 12633 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl = 12634 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 12635 "vxlan-tos-ttl"); 12636 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 12637 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 12638 "vxlan-with-vlan"); 12639 cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 12640 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12641 "ip-version"); 12642 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 12643 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 12644 "ipv4#ipv6"); 12645 cmdline_parse_token_string_t cmd_set_vxlan_vni = 12646 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12647 "vni"); 12648 cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 12649 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32); 12650 cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 12651 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12652 "udp-src"); 12653 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 12654 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16); 12655 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 12656 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12657 "udp-dst"); 12658 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 12659 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16); 12660 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos = 12661 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12662 "ip-tos"); 12663 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value = 12664 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8); 12665 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl = 12666 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12667 "ip-ttl"); 12668 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value = 12669 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8); 12670 cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 12671 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12672 "ip-src"); 12673 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 12674 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 12675 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 12676 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12677 "ip-dst"); 12678 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 12679 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 12680 cmdline_parse_token_string_t cmd_set_vxlan_vlan = 12681 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12682 "vlan-tci"); 12683 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 12684 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16); 12685 cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 12686 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12687 "eth-src"); 12688 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 12689 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 12690 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 12691 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12692 "eth-dst"); 12693 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 12694 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 12695 12696 static void cmd_set_vxlan_parsed(void *parsed_result, 12697 __rte_unused struct cmdline *cl, 12698 __rte_unused void *data) 12699 { 12700 struct cmd_set_vxlan_result *res = parsed_result; 12701 union { 12702 uint32_t vxlan_id; 12703 uint8_t vni[4]; 12704 } id = { 12705 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 12706 }; 12707 12708 vxlan_encap_conf.select_tos_ttl = 0; 12709 if (strcmp(res->vxlan, "vxlan") == 0) 12710 vxlan_encap_conf.select_vlan = 0; 12711 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 12712 vxlan_encap_conf.select_vlan = 1; 12713 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) { 12714 vxlan_encap_conf.select_vlan = 0; 12715 vxlan_encap_conf.select_tos_ttl = 1; 12716 } 12717 if (strcmp(res->ip_version, "ipv4") == 0) 12718 vxlan_encap_conf.select_ipv4 = 1; 12719 else if (strcmp(res->ip_version, "ipv6") == 0) 12720 vxlan_encap_conf.select_ipv4 = 0; 12721 else 12722 return; 12723 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 12724 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 12725 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 12726 vxlan_encap_conf.ip_tos = res->tos; 12727 vxlan_encap_conf.ip_ttl = res->ttl; 12728 if (vxlan_encap_conf.select_ipv4) { 12729 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 12730 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 12731 } else { 12732 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 12733 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 12734 } 12735 if (vxlan_encap_conf.select_vlan) 12736 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 12737 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 12738 RTE_ETHER_ADDR_LEN); 12739 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 12740 RTE_ETHER_ADDR_LEN); 12741 } 12742 12743 cmdline_parse_inst_t cmd_set_vxlan = { 12744 .f = cmd_set_vxlan_parsed, 12745 .data = NULL, 12746 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 12747 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 12748 " eth-src <eth-src> eth-dst <eth-dst>", 12749 .tokens = { 12750 (void *)&cmd_set_vxlan_set, 12751 (void *)&cmd_set_vxlan_vxlan, 12752 (void *)&cmd_set_vxlan_ip_version, 12753 (void *)&cmd_set_vxlan_ip_version_value, 12754 (void *)&cmd_set_vxlan_vni, 12755 (void *)&cmd_set_vxlan_vni_value, 12756 (void *)&cmd_set_vxlan_udp_src, 12757 (void *)&cmd_set_vxlan_udp_src_value, 12758 (void *)&cmd_set_vxlan_udp_dst, 12759 (void *)&cmd_set_vxlan_udp_dst_value, 12760 (void *)&cmd_set_vxlan_ip_src, 12761 (void *)&cmd_set_vxlan_ip_src_value, 12762 (void *)&cmd_set_vxlan_ip_dst, 12763 (void *)&cmd_set_vxlan_ip_dst_value, 12764 (void *)&cmd_set_vxlan_eth_src, 12765 (void *)&cmd_set_vxlan_eth_src_value, 12766 (void *)&cmd_set_vxlan_eth_dst, 12767 (void *)&cmd_set_vxlan_eth_dst_value, 12768 NULL, 12769 }, 12770 }; 12771 12772 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = { 12773 .f = cmd_set_vxlan_parsed, 12774 .data = NULL, 12775 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src" 12776 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>" 12777 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 12778 " eth-dst <eth-dst>", 12779 .tokens = { 12780 (void *)&cmd_set_vxlan_set, 12781 (void *)&cmd_set_vxlan_vxlan_tos_ttl, 12782 (void *)&cmd_set_vxlan_ip_version, 12783 (void *)&cmd_set_vxlan_ip_version_value, 12784 (void *)&cmd_set_vxlan_vni, 12785 (void *)&cmd_set_vxlan_vni_value, 12786 (void *)&cmd_set_vxlan_udp_src, 12787 (void *)&cmd_set_vxlan_udp_src_value, 12788 (void *)&cmd_set_vxlan_udp_dst, 12789 (void *)&cmd_set_vxlan_udp_dst_value, 12790 (void *)&cmd_set_vxlan_ip_tos, 12791 (void *)&cmd_set_vxlan_ip_tos_value, 12792 (void *)&cmd_set_vxlan_ip_ttl, 12793 (void *)&cmd_set_vxlan_ip_ttl_value, 12794 (void *)&cmd_set_vxlan_ip_src, 12795 (void *)&cmd_set_vxlan_ip_src_value, 12796 (void *)&cmd_set_vxlan_ip_dst, 12797 (void *)&cmd_set_vxlan_ip_dst_value, 12798 (void *)&cmd_set_vxlan_eth_src, 12799 (void *)&cmd_set_vxlan_eth_src_value, 12800 (void *)&cmd_set_vxlan_eth_dst, 12801 (void *)&cmd_set_vxlan_eth_dst_value, 12802 NULL, 12803 }, 12804 }; 12805 12806 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 12807 .f = cmd_set_vxlan_parsed, 12808 .data = NULL, 12809 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 12810 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 12811 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 12812 " <eth-dst>", 12813 .tokens = { 12814 (void *)&cmd_set_vxlan_set, 12815 (void *)&cmd_set_vxlan_vxlan_with_vlan, 12816 (void *)&cmd_set_vxlan_ip_version, 12817 (void *)&cmd_set_vxlan_ip_version_value, 12818 (void *)&cmd_set_vxlan_vni, 12819 (void *)&cmd_set_vxlan_vni_value, 12820 (void *)&cmd_set_vxlan_udp_src, 12821 (void *)&cmd_set_vxlan_udp_src_value, 12822 (void *)&cmd_set_vxlan_udp_dst, 12823 (void *)&cmd_set_vxlan_udp_dst_value, 12824 (void *)&cmd_set_vxlan_ip_src, 12825 (void *)&cmd_set_vxlan_ip_src_value, 12826 (void *)&cmd_set_vxlan_ip_dst, 12827 (void *)&cmd_set_vxlan_ip_dst_value, 12828 (void *)&cmd_set_vxlan_vlan, 12829 (void *)&cmd_set_vxlan_vlan_value, 12830 (void *)&cmd_set_vxlan_eth_src, 12831 (void *)&cmd_set_vxlan_eth_src_value, 12832 (void *)&cmd_set_vxlan_eth_dst, 12833 (void *)&cmd_set_vxlan_eth_dst_value, 12834 NULL, 12835 }, 12836 }; 12837 12838 /** Set NVGRE encapsulation details */ 12839 struct cmd_set_nvgre_result { 12840 cmdline_fixed_string_t set; 12841 cmdline_fixed_string_t nvgre; 12842 cmdline_fixed_string_t pos_token; 12843 cmdline_fixed_string_t ip_version; 12844 uint32_t tni; 12845 cmdline_ipaddr_t ip_src; 12846 cmdline_ipaddr_t ip_dst; 12847 uint16_t tci; 12848 struct rte_ether_addr eth_src; 12849 struct rte_ether_addr eth_dst; 12850 }; 12851 12852 cmdline_parse_token_string_t cmd_set_nvgre_set = 12853 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 12854 cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 12855 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 12856 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 12857 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 12858 "nvgre-with-vlan"); 12859 cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 12860 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12861 "ip-version"); 12862 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 12863 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 12864 "ipv4#ipv6"); 12865 cmdline_parse_token_string_t cmd_set_nvgre_tni = 12866 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12867 "tni"); 12868 cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 12869 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32); 12870 cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 12871 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12872 "ip-src"); 12873 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 12874 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 12875 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 12876 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12877 "ip-dst"); 12878 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 12879 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 12880 cmdline_parse_token_string_t cmd_set_nvgre_vlan = 12881 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12882 "vlan-tci"); 12883 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 12884 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16); 12885 cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 12886 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12887 "eth-src"); 12888 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 12889 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 12890 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 12891 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12892 "eth-dst"); 12893 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 12894 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 12895 12896 static void cmd_set_nvgre_parsed(void *parsed_result, 12897 __rte_unused struct cmdline *cl, 12898 __rte_unused void *data) 12899 { 12900 struct cmd_set_nvgre_result *res = parsed_result; 12901 union { 12902 uint32_t nvgre_tni; 12903 uint8_t tni[4]; 12904 } id = { 12905 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 12906 }; 12907 12908 if (strcmp(res->nvgre, "nvgre") == 0) 12909 nvgre_encap_conf.select_vlan = 0; 12910 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 12911 nvgre_encap_conf.select_vlan = 1; 12912 if (strcmp(res->ip_version, "ipv4") == 0) 12913 nvgre_encap_conf.select_ipv4 = 1; 12914 else if (strcmp(res->ip_version, "ipv6") == 0) 12915 nvgre_encap_conf.select_ipv4 = 0; 12916 else 12917 return; 12918 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 12919 if (nvgre_encap_conf.select_ipv4) { 12920 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 12921 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 12922 } else { 12923 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 12924 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 12925 } 12926 if (nvgre_encap_conf.select_vlan) 12927 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 12928 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 12929 RTE_ETHER_ADDR_LEN); 12930 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 12931 RTE_ETHER_ADDR_LEN); 12932 } 12933 12934 cmdline_parse_inst_t cmd_set_nvgre = { 12935 .f = cmd_set_nvgre_parsed, 12936 .data = NULL, 12937 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 12938 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 12939 " eth-dst <eth-dst>", 12940 .tokens = { 12941 (void *)&cmd_set_nvgre_set, 12942 (void *)&cmd_set_nvgre_nvgre, 12943 (void *)&cmd_set_nvgre_ip_version, 12944 (void *)&cmd_set_nvgre_ip_version_value, 12945 (void *)&cmd_set_nvgre_tni, 12946 (void *)&cmd_set_nvgre_tni_value, 12947 (void *)&cmd_set_nvgre_ip_src, 12948 (void *)&cmd_set_nvgre_ip_src_value, 12949 (void *)&cmd_set_nvgre_ip_dst, 12950 (void *)&cmd_set_nvgre_ip_dst_value, 12951 (void *)&cmd_set_nvgre_eth_src, 12952 (void *)&cmd_set_nvgre_eth_src_value, 12953 (void *)&cmd_set_nvgre_eth_dst, 12954 (void *)&cmd_set_nvgre_eth_dst_value, 12955 NULL, 12956 }, 12957 }; 12958 12959 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 12960 .f = cmd_set_nvgre_parsed, 12961 .data = NULL, 12962 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 12963 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 12964 " eth-src <eth-src> eth-dst <eth-dst>", 12965 .tokens = { 12966 (void *)&cmd_set_nvgre_set, 12967 (void *)&cmd_set_nvgre_nvgre_with_vlan, 12968 (void *)&cmd_set_nvgre_ip_version, 12969 (void *)&cmd_set_nvgre_ip_version_value, 12970 (void *)&cmd_set_nvgre_tni, 12971 (void *)&cmd_set_nvgre_tni_value, 12972 (void *)&cmd_set_nvgre_ip_src, 12973 (void *)&cmd_set_nvgre_ip_src_value, 12974 (void *)&cmd_set_nvgre_ip_dst, 12975 (void *)&cmd_set_nvgre_ip_dst_value, 12976 (void *)&cmd_set_nvgre_vlan, 12977 (void *)&cmd_set_nvgre_vlan_value, 12978 (void *)&cmd_set_nvgre_eth_src, 12979 (void *)&cmd_set_nvgre_eth_src_value, 12980 (void *)&cmd_set_nvgre_eth_dst, 12981 (void *)&cmd_set_nvgre_eth_dst_value, 12982 NULL, 12983 }, 12984 }; 12985 12986 /** Set L2 encapsulation details */ 12987 struct cmd_set_l2_encap_result { 12988 cmdline_fixed_string_t set; 12989 cmdline_fixed_string_t l2_encap; 12990 cmdline_fixed_string_t pos_token; 12991 cmdline_fixed_string_t ip_version; 12992 uint32_t vlan_present:1; 12993 uint16_t tci; 12994 struct rte_ether_addr eth_src; 12995 struct rte_ether_addr eth_dst; 12996 }; 12997 12998 cmdline_parse_token_string_t cmd_set_l2_encap_set = 12999 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); 13000 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = 13001 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); 13002 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = 13003 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, 13004 "l2_encap-with-vlan"); 13005 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = 13006 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13007 "ip-version"); 13008 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = 13009 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, 13010 "ipv4#ipv6"); 13011 cmdline_parse_token_string_t cmd_set_l2_encap_vlan = 13012 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13013 "vlan-tci"); 13014 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = 13015 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16); 13016 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = 13017 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13018 "eth-src"); 13019 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = 13020 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); 13021 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = 13022 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13023 "eth-dst"); 13024 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = 13025 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); 13026 13027 static void cmd_set_l2_encap_parsed(void *parsed_result, 13028 __rte_unused struct cmdline *cl, 13029 __rte_unused void *data) 13030 { 13031 struct cmd_set_l2_encap_result *res = parsed_result; 13032 13033 if (strcmp(res->l2_encap, "l2_encap") == 0) 13034 l2_encap_conf.select_vlan = 0; 13035 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) 13036 l2_encap_conf.select_vlan = 1; 13037 if (strcmp(res->ip_version, "ipv4") == 0) 13038 l2_encap_conf.select_ipv4 = 1; 13039 else if (strcmp(res->ip_version, "ipv6") == 0) 13040 l2_encap_conf.select_ipv4 = 0; 13041 else 13042 return; 13043 if (l2_encap_conf.select_vlan) 13044 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13045 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, 13046 RTE_ETHER_ADDR_LEN); 13047 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13048 RTE_ETHER_ADDR_LEN); 13049 } 13050 13051 cmdline_parse_inst_t cmd_set_l2_encap = { 13052 .f = cmd_set_l2_encap_parsed, 13053 .data = NULL, 13054 .help_str = "set l2_encap ip-version ipv4|ipv6" 13055 " eth-src <eth-src> eth-dst <eth-dst>", 13056 .tokens = { 13057 (void *)&cmd_set_l2_encap_set, 13058 (void *)&cmd_set_l2_encap_l2_encap, 13059 (void *)&cmd_set_l2_encap_ip_version, 13060 (void *)&cmd_set_l2_encap_ip_version_value, 13061 (void *)&cmd_set_l2_encap_eth_src, 13062 (void *)&cmd_set_l2_encap_eth_src_value, 13063 (void *)&cmd_set_l2_encap_eth_dst, 13064 (void *)&cmd_set_l2_encap_eth_dst_value, 13065 NULL, 13066 }, 13067 }; 13068 13069 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { 13070 .f = cmd_set_l2_encap_parsed, 13071 .data = NULL, 13072 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" 13073 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 13074 .tokens = { 13075 (void *)&cmd_set_l2_encap_set, 13076 (void *)&cmd_set_l2_encap_l2_encap_with_vlan, 13077 (void *)&cmd_set_l2_encap_ip_version, 13078 (void *)&cmd_set_l2_encap_ip_version_value, 13079 (void *)&cmd_set_l2_encap_vlan, 13080 (void *)&cmd_set_l2_encap_vlan_value, 13081 (void *)&cmd_set_l2_encap_eth_src, 13082 (void *)&cmd_set_l2_encap_eth_src_value, 13083 (void *)&cmd_set_l2_encap_eth_dst, 13084 (void *)&cmd_set_l2_encap_eth_dst_value, 13085 NULL, 13086 }, 13087 }; 13088 13089 /** Set L2 decapsulation details */ 13090 struct cmd_set_l2_decap_result { 13091 cmdline_fixed_string_t set; 13092 cmdline_fixed_string_t l2_decap; 13093 cmdline_fixed_string_t pos_token; 13094 uint32_t vlan_present:1; 13095 }; 13096 13097 cmdline_parse_token_string_t cmd_set_l2_decap_set = 13098 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); 13099 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = 13100 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 13101 "l2_decap"); 13102 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = 13103 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 13104 "l2_decap-with-vlan"); 13105 13106 static void cmd_set_l2_decap_parsed(void *parsed_result, 13107 __rte_unused struct cmdline *cl, 13108 __rte_unused void *data) 13109 { 13110 struct cmd_set_l2_decap_result *res = parsed_result; 13111 13112 if (strcmp(res->l2_decap, "l2_decap") == 0) 13113 l2_decap_conf.select_vlan = 0; 13114 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) 13115 l2_decap_conf.select_vlan = 1; 13116 } 13117 13118 cmdline_parse_inst_t cmd_set_l2_decap = { 13119 .f = cmd_set_l2_decap_parsed, 13120 .data = NULL, 13121 .help_str = "set l2_decap", 13122 .tokens = { 13123 (void *)&cmd_set_l2_decap_set, 13124 (void *)&cmd_set_l2_decap_l2_decap, 13125 NULL, 13126 }, 13127 }; 13128 13129 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { 13130 .f = cmd_set_l2_decap_parsed, 13131 .data = NULL, 13132 .help_str = "set l2_decap-with-vlan", 13133 .tokens = { 13134 (void *)&cmd_set_l2_decap_set, 13135 (void *)&cmd_set_l2_decap_l2_decap_with_vlan, 13136 NULL, 13137 }, 13138 }; 13139 13140 /** Set MPLSoGRE encapsulation details */ 13141 struct cmd_set_mplsogre_encap_result { 13142 cmdline_fixed_string_t set; 13143 cmdline_fixed_string_t mplsogre; 13144 cmdline_fixed_string_t pos_token; 13145 cmdline_fixed_string_t ip_version; 13146 uint32_t vlan_present:1; 13147 uint32_t label; 13148 cmdline_ipaddr_t ip_src; 13149 cmdline_ipaddr_t ip_dst; 13150 uint16_t tci; 13151 struct rte_ether_addr eth_src; 13152 struct rte_ether_addr eth_dst; 13153 }; 13154 13155 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = 13156 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, 13157 "set"); 13158 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = 13159 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, 13160 "mplsogre_encap"); 13161 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = 13162 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13163 mplsogre, "mplsogre_encap-with-vlan"); 13164 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = 13165 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13166 pos_token, "ip-version"); 13167 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = 13168 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13169 ip_version, "ipv4#ipv6"); 13170 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = 13171 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13172 pos_token, "label"); 13173 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = 13174 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, 13175 RTE_UINT32); 13176 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = 13177 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13178 pos_token, "ip-src"); 13179 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = 13180 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); 13181 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = 13182 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13183 pos_token, "ip-dst"); 13184 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = 13185 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); 13186 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = 13187 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13188 pos_token, "vlan-tci"); 13189 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = 13190 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, 13191 RTE_UINT16); 13192 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = 13193 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13194 pos_token, "eth-src"); 13195 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = 13196 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13197 eth_src); 13198 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = 13199 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13200 pos_token, "eth-dst"); 13201 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = 13202 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13203 eth_dst); 13204 13205 static void cmd_set_mplsogre_encap_parsed(void *parsed_result, 13206 __rte_unused struct cmdline *cl, 13207 __rte_unused void *data) 13208 { 13209 struct cmd_set_mplsogre_encap_result *res = parsed_result; 13210 union { 13211 uint32_t mplsogre_label; 13212 uint8_t label[4]; 13213 } id = { 13214 .mplsogre_label = rte_cpu_to_be_32(res->label<<12), 13215 }; 13216 13217 if (strcmp(res->mplsogre, "mplsogre_encap") == 0) 13218 mplsogre_encap_conf.select_vlan = 0; 13219 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) 13220 mplsogre_encap_conf.select_vlan = 1; 13221 if (strcmp(res->ip_version, "ipv4") == 0) 13222 mplsogre_encap_conf.select_ipv4 = 1; 13223 else if (strcmp(res->ip_version, "ipv6") == 0) 13224 mplsogre_encap_conf.select_ipv4 = 0; 13225 else 13226 return; 13227 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3); 13228 if (mplsogre_encap_conf.select_ipv4) { 13229 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); 13230 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); 13231 } else { 13232 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); 13233 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); 13234 } 13235 if (mplsogre_encap_conf.select_vlan) 13236 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13237 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, 13238 RTE_ETHER_ADDR_LEN); 13239 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13240 RTE_ETHER_ADDR_LEN); 13241 } 13242 13243 cmdline_parse_inst_t cmd_set_mplsogre_encap = { 13244 .f = cmd_set_mplsogre_encap_parsed, 13245 .data = NULL, 13246 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" 13247 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 13248 " eth-dst <eth-dst>", 13249 .tokens = { 13250 (void *)&cmd_set_mplsogre_encap_set, 13251 (void *)&cmd_set_mplsogre_encap_mplsogre_encap, 13252 (void *)&cmd_set_mplsogre_encap_ip_version, 13253 (void *)&cmd_set_mplsogre_encap_ip_version_value, 13254 (void *)&cmd_set_mplsogre_encap_label, 13255 (void *)&cmd_set_mplsogre_encap_label_value, 13256 (void *)&cmd_set_mplsogre_encap_ip_src, 13257 (void *)&cmd_set_mplsogre_encap_ip_src_value, 13258 (void *)&cmd_set_mplsogre_encap_ip_dst, 13259 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 13260 (void *)&cmd_set_mplsogre_encap_eth_src, 13261 (void *)&cmd_set_mplsogre_encap_eth_src_value, 13262 (void *)&cmd_set_mplsogre_encap_eth_dst, 13263 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 13264 NULL, 13265 }, 13266 }; 13267 13268 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { 13269 .f = cmd_set_mplsogre_encap_parsed, 13270 .data = NULL, 13271 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" 13272 " label <label> ip-src <ip-src> ip-dst <ip-dst>" 13273 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 13274 .tokens = { 13275 (void *)&cmd_set_mplsogre_encap_set, 13276 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, 13277 (void *)&cmd_set_mplsogre_encap_ip_version, 13278 (void *)&cmd_set_mplsogre_encap_ip_version_value, 13279 (void *)&cmd_set_mplsogre_encap_label, 13280 (void *)&cmd_set_mplsogre_encap_label_value, 13281 (void *)&cmd_set_mplsogre_encap_ip_src, 13282 (void *)&cmd_set_mplsogre_encap_ip_src_value, 13283 (void *)&cmd_set_mplsogre_encap_ip_dst, 13284 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 13285 (void *)&cmd_set_mplsogre_encap_vlan, 13286 (void *)&cmd_set_mplsogre_encap_vlan_value, 13287 (void *)&cmd_set_mplsogre_encap_eth_src, 13288 (void *)&cmd_set_mplsogre_encap_eth_src_value, 13289 (void *)&cmd_set_mplsogre_encap_eth_dst, 13290 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 13291 NULL, 13292 }, 13293 }; 13294 13295 /** Set MPLSoGRE decapsulation details */ 13296 struct cmd_set_mplsogre_decap_result { 13297 cmdline_fixed_string_t set; 13298 cmdline_fixed_string_t mplsogre; 13299 cmdline_fixed_string_t pos_token; 13300 cmdline_fixed_string_t ip_version; 13301 uint32_t vlan_present:1; 13302 }; 13303 13304 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = 13305 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, 13306 "set"); 13307 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = 13308 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, 13309 "mplsogre_decap"); 13310 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = 13311 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 13312 mplsogre, "mplsogre_decap-with-vlan"); 13313 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = 13314 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 13315 pos_token, "ip-version"); 13316 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = 13317 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 13318 ip_version, "ipv4#ipv6"); 13319 13320 static void cmd_set_mplsogre_decap_parsed(void *parsed_result, 13321 __rte_unused struct cmdline *cl, 13322 __rte_unused void *data) 13323 { 13324 struct cmd_set_mplsogre_decap_result *res = parsed_result; 13325 13326 if (strcmp(res->mplsogre, "mplsogre_decap") == 0) 13327 mplsogre_decap_conf.select_vlan = 0; 13328 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) 13329 mplsogre_decap_conf.select_vlan = 1; 13330 if (strcmp(res->ip_version, "ipv4") == 0) 13331 mplsogre_decap_conf.select_ipv4 = 1; 13332 else if (strcmp(res->ip_version, "ipv6") == 0) 13333 mplsogre_decap_conf.select_ipv4 = 0; 13334 } 13335 13336 cmdline_parse_inst_t cmd_set_mplsogre_decap = { 13337 .f = cmd_set_mplsogre_decap_parsed, 13338 .data = NULL, 13339 .help_str = "set mplsogre_decap ip-version ipv4|ipv6", 13340 .tokens = { 13341 (void *)&cmd_set_mplsogre_decap_set, 13342 (void *)&cmd_set_mplsogre_decap_mplsogre_decap, 13343 (void *)&cmd_set_mplsogre_decap_ip_version, 13344 (void *)&cmd_set_mplsogre_decap_ip_version_value, 13345 NULL, 13346 }, 13347 }; 13348 13349 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { 13350 .f = cmd_set_mplsogre_decap_parsed, 13351 .data = NULL, 13352 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", 13353 .tokens = { 13354 (void *)&cmd_set_mplsogre_decap_set, 13355 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, 13356 (void *)&cmd_set_mplsogre_decap_ip_version, 13357 (void *)&cmd_set_mplsogre_decap_ip_version_value, 13358 NULL, 13359 }, 13360 }; 13361 13362 /** Set MPLSoUDP encapsulation details */ 13363 struct cmd_set_mplsoudp_encap_result { 13364 cmdline_fixed_string_t set; 13365 cmdline_fixed_string_t mplsoudp; 13366 cmdline_fixed_string_t pos_token; 13367 cmdline_fixed_string_t ip_version; 13368 uint32_t vlan_present:1; 13369 uint32_t label; 13370 uint16_t udp_src; 13371 uint16_t udp_dst; 13372 cmdline_ipaddr_t ip_src; 13373 cmdline_ipaddr_t ip_dst; 13374 uint16_t tci; 13375 struct rte_ether_addr eth_src; 13376 struct rte_ether_addr eth_dst; 13377 }; 13378 13379 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = 13380 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, 13381 "set"); 13382 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = 13383 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, 13384 "mplsoudp_encap"); 13385 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = 13386 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13387 mplsoudp, "mplsoudp_encap-with-vlan"); 13388 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = 13389 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13390 pos_token, "ip-version"); 13391 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = 13392 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13393 ip_version, "ipv4#ipv6"); 13394 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = 13395 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13396 pos_token, "label"); 13397 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = 13398 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, 13399 RTE_UINT32); 13400 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = 13401 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13402 pos_token, "udp-src"); 13403 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = 13404 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, 13405 RTE_UINT16); 13406 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = 13407 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13408 pos_token, "udp-dst"); 13409 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = 13410 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, 13411 RTE_UINT16); 13412 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = 13413 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13414 pos_token, "ip-src"); 13415 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = 13416 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); 13417 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = 13418 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13419 pos_token, "ip-dst"); 13420 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = 13421 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); 13422 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = 13423 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13424 pos_token, "vlan-tci"); 13425 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = 13426 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, 13427 RTE_UINT16); 13428 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = 13429 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13430 pos_token, "eth-src"); 13431 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = 13432 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13433 eth_src); 13434 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = 13435 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13436 pos_token, "eth-dst"); 13437 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = 13438 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13439 eth_dst); 13440 13441 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, 13442 __rte_unused struct cmdline *cl, 13443 __rte_unused void *data) 13444 { 13445 struct cmd_set_mplsoudp_encap_result *res = parsed_result; 13446 union { 13447 uint32_t mplsoudp_label; 13448 uint8_t label[4]; 13449 } id = { 13450 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12), 13451 }; 13452 13453 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) 13454 mplsoudp_encap_conf.select_vlan = 0; 13455 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) 13456 mplsoudp_encap_conf.select_vlan = 1; 13457 if (strcmp(res->ip_version, "ipv4") == 0) 13458 mplsoudp_encap_conf.select_ipv4 = 1; 13459 else if (strcmp(res->ip_version, "ipv6") == 0) 13460 mplsoudp_encap_conf.select_ipv4 = 0; 13461 else 13462 return; 13463 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3); 13464 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 13465 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 13466 if (mplsoudp_encap_conf.select_ipv4) { 13467 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); 13468 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); 13469 } else { 13470 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); 13471 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); 13472 } 13473 if (mplsoudp_encap_conf.select_vlan) 13474 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13475 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, 13476 RTE_ETHER_ADDR_LEN); 13477 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13478 RTE_ETHER_ADDR_LEN); 13479 } 13480 13481 cmdline_parse_inst_t cmd_set_mplsoudp_encap = { 13482 .f = cmd_set_mplsoudp_encap_parsed, 13483 .data = NULL, 13484 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" 13485 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" 13486 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", 13487 .tokens = { 13488 (void *)&cmd_set_mplsoudp_encap_set, 13489 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, 13490 (void *)&cmd_set_mplsoudp_encap_ip_version, 13491 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 13492 (void *)&cmd_set_mplsoudp_encap_label, 13493 (void *)&cmd_set_mplsoudp_encap_label_value, 13494 (void *)&cmd_set_mplsoudp_encap_udp_src, 13495 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 13496 (void *)&cmd_set_mplsoudp_encap_udp_dst, 13497 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 13498 (void *)&cmd_set_mplsoudp_encap_ip_src, 13499 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 13500 (void *)&cmd_set_mplsoudp_encap_ip_dst, 13501 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 13502 (void *)&cmd_set_mplsoudp_encap_eth_src, 13503 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 13504 (void *)&cmd_set_mplsoudp_encap_eth_dst, 13505 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 13506 NULL, 13507 }, 13508 }; 13509 13510 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { 13511 .f = cmd_set_mplsoudp_encap_parsed, 13512 .data = NULL, 13513 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" 13514 " label <label> udp-src <udp-src> udp-dst <udp-dst>" 13515 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 13516 " eth-src <eth-src> eth-dst <eth-dst>", 13517 .tokens = { 13518 (void *)&cmd_set_mplsoudp_encap_set, 13519 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, 13520 (void *)&cmd_set_mplsoudp_encap_ip_version, 13521 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 13522 (void *)&cmd_set_mplsoudp_encap_label, 13523 (void *)&cmd_set_mplsoudp_encap_label_value, 13524 (void *)&cmd_set_mplsoudp_encap_udp_src, 13525 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 13526 (void *)&cmd_set_mplsoudp_encap_udp_dst, 13527 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 13528 (void *)&cmd_set_mplsoudp_encap_ip_src, 13529 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 13530 (void *)&cmd_set_mplsoudp_encap_ip_dst, 13531 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 13532 (void *)&cmd_set_mplsoudp_encap_vlan, 13533 (void *)&cmd_set_mplsoudp_encap_vlan_value, 13534 (void *)&cmd_set_mplsoudp_encap_eth_src, 13535 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 13536 (void *)&cmd_set_mplsoudp_encap_eth_dst, 13537 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 13538 NULL, 13539 }, 13540 }; 13541 13542 /** Set MPLSoUDP decapsulation details */ 13543 struct cmd_set_mplsoudp_decap_result { 13544 cmdline_fixed_string_t set; 13545 cmdline_fixed_string_t mplsoudp; 13546 cmdline_fixed_string_t pos_token; 13547 cmdline_fixed_string_t ip_version; 13548 uint32_t vlan_present:1; 13549 }; 13550 13551 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = 13552 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, 13553 "set"); 13554 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = 13555 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, 13556 "mplsoudp_decap"); 13557 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = 13558 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 13559 mplsoudp, "mplsoudp_decap-with-vlan"); 13560 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = 13561 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 13562 pos_token, "ip-version"); 13563 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = 13564 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 13565 ip_version, "ipv4#ipv6"); 13566 13567 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, 13568 __rte_unused struct cmdline *cl, 13569 __rte_unused void *data) 13570 { 13571 struct cmd_set_mplsoudp_decap_result *res = parsed_result; 13572 13573 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) 13574 mplsoudp_decap_conf.select_vlan = 0; 13575 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) 13576 mplsoudp_decap_conf.select_vlan = 1; 13577 if (strcmp(res->ip_version, "ipv4") == 0) 13578 mplsoudp_decap_conf.select_ipv4 = 1; 13579 else if (strcmp(res->ip_version, "ipv6") == 0) 13580 mplsoudp_decap_conf.select_ipv4 = 0; 13581 } 13582 13583 cmdline_parse_inst_t cmd_set_mplsoudp_decap = { 13584 .f = cmd_set_mplsoudp_decap_parsed, 13585 .data = NULL, 13586 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", 13587 .tokens = { 13588 (void *)&cmd_set_mplsoudp_decap_set, 13589 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, 13590 (void *)&cmd_set_mplsoudp_decap_ip_version, 13591 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 13592 NULL, 13593 }, 13594 }; 13595 13596 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { 13597 .f = cmd_set_mplsoudp_decap_parsed, 13598 .data = NULL, 13599 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", 13600 .tokens = { 13601 (void *)&cmd_set_mplsoudp_decap_set, 13602 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, 13603 (void *)&cmd_set_mplsoudp_decap_ip_version, 13604 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 13605 NULL, 13606 }, 13607 }; 13608 13609 /** Set connection tracking object common details */ 13610 struct cmd_set_conntrack_common_result { 13611 cmdline_fixed_string_t set; 13612 cmdline_fixed_string_t conntrack; 13613 cmdline_fixed_string_t common; 13614 cmdline_fixed_string_t peer; 13615 cmdline_fixed_string_t is_orig; 13616 cmdline_fixed_string_t enable; 13617 cmdline_fixed_string_t live; 13618 cmdline_fixed_string_t sack; 13619 cmdline_fixed_string_t cack; 13620 cmdline_fixed_string_t last_dir; 13621 cmdline_fixed_string_t liberal; 13622 cmdline_fixed_string_t state; 13623 cmdline_fixed_string_t max_ack_win; 13624 cmdline_fixed_string_t retrans; 13625 cmdline_fixed_string_t last_win; 13626 cmdline_fixed_string_t last_seq; 13627 cmdline_fixed_string_t last_ack; 13628 cmdline_fixed_string_t last_end; 13629 cmdline_fixed_string_t last_index; 13630 uint8_t stat; 13631 uint8_t factor; 13632 uint16_t peer_port; 13633 uint32_t is_original; 13634 uint32_t en; 13635 uint32_t is_live; 13636 uint32_t s_ack; 13637 uint32_t c_ack; 13638 uint32_t ld; 13639 uint32_t lb; 13640 uint8_t re_num; 13641 uint8_t li; 13642 uint16_t lw; 13643 uint32_t ls; 13644 uint32_t la; 13645 uint32_t le; 13646 }; 13647 13648 cmdline_parse_token_string_t cmd_set_conntrack_set = 13649 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13650 set, "set"); 13651 cmdline_parse_token_string_t cmd_set_conntrack_conntrack = 13652 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13653 conntrack, "conntrack"); 13654 cmdline_parse_token_string_t cmd_set_conntrack_common_com = 13655 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13656 common, "com"); 13657 cmdline_parse_token_string_t cmd_set_conntrack_common_peer = 13658 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13659 peer, "peer"); 13660 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value = 13661 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13662 peer_port, RTE_UINT16); 13663 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig = 13664 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13665 is_orig, "is_orig"); 13666 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value = 13667 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13668 is_original, RTE_UINT32); 13669 cmdline_parse_token_string_t cmd_set_conntrack_common_enable = 13670 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13671 enable, "enable"); 13672 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value = 13673 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13674 en, RTE_UINT32); 13675 cmdline_parse_token_string_t cmd_set_conntrack_common_live = 13676 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13677 live, "live"); 13678 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value = 13679 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13680 is_live, RTE_UINT32); 13681 cmdline_parse_token_string_t cmd_set_conntrack_common_sack = 13682 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13683 sack, "sack"); 13684 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value = 13685 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13686 s_ack, RTE_UINT32); 13687 cmdline_parse_token_string_t cmd_set_conntrack_common_cack = 13688 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13689 cack, "cack"); 13690 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value = 13691 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13692 c_ack, RTE_UINT32); 13693 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir = 13694 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13695 last_dir, "last_dir"); 13696 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value = 13697 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13698 ld, RTE_UINT32); 13699 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal = 13700 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13701 liberal, "liberal"); 13702 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value = 13703 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13704 lb, RTE_UINT32); 13705 cmdline_parse_token_string_t cmd_set_conntrack_common_state = 13706 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13707 state, "state"); 13708 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value = 13709 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13710 stat, RTE_UINT8); 13711 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin = 13712 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13713 max_ack_win, "max_ack_win"); 13714 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value = 13715 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13716 factor, RTE_UINT8); 13717 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans = 13718 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13719 retrans, "r_lim"); 13720 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value = 13721 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13722 re_num, RTE_UINT8); 13723 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win = 13724 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13725 last_win, "last_win"); 13726 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value = 13727 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13728 lw, RTE_UINT16); 13729 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq = 13730 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13731 last_seq, "last_seq"); 13732 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value = 13733 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13734 ls, RTE_UINT32); 13735 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack = 13736 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13737 last_ack, "last_ack"); 13738 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value = 13739 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13740 la, RTE_UINT32); 13741 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end = 13742 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13743 last_end, "last_end"); 13744 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value = 13745 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13746 le, RTE_UINT32); 13747 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index = 13748 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13749 last_index, "last_index"); 13750 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value = 13751 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13752 li, RTE_UINT8); 13753 13754 static void cmd_set_conntrack_common_parsed(void *parsed_result, 13755 __rte_unused struct cmdline *cl, 13756 __rte_unused void *data) 13757 { 13758 struct cmd_set_conntrack_common_result *res = parsed_result; 13759 13760 /* No need to swap to big endian. */ 13761 conntrack_context.peer_port = res->peer_port; 13762 conntrack_context.is_original_dir = res->is_original; 13763 conntrack_context.enable = res->en; 13764 conntrack_context.live_connection = res->is_live; 13765 conntrack_context.selective_ack = res->s_ack; 13766 conntrack_context.challenge_ack_passed = res->c_ack; 13767 conntrack_context.last_direction = res->ld; 13768 conntrack_context.liberal_mode = res->lb; 13769 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat; 13770 conntrack_context.max_ack_window = res->factor; 13771 conntrack_context.retransmission_limit = res->re_num; 13772 conntrack_context.last_window = res->lw; 13773 conntrack_context.last_index = 13774 (enum rte_flow_conntrack_tcp_last_index)res->li; 13775 conntrack_context.last_seq = res->ls; 13776 conntrack_context.last_ack = res->la; 13777 conntrack_context.last_end = res->le; 13778 } 13779 13780 cmdline_parse_inst_t cmd_set_conntrack_common = { 13781 .f = cmd_set_conntrack_common_parsed, 13782 .data = NULL, 13783 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>" 13784 " live <ack_seen> sack <en> cack <passed> last_dir <dir>" 13785 " liberal <en> state <s> max_ack_win <factor> r_lim <num>" 13786 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>" 13787 " last_index <flag>", 13788 .tokens = { 13789 (void *)&cmd_set_conntrack_set, 13790 (void *)&cmd_set_conntrack_conntrack, 13791 (void *)&cmd_set_conntrack_common_com, 13792 (void *)&cmd_set_conntrack_common_peer, 13793 (void *)&cmd_set_conntrack_common_peer_value, 13794 (void *)&cmd_set_conntrack_common_is_orig, 13795 (void *)&cmd_set_conntrack_common_is_orig_value, 13796 (void *)&cmd_set_conntrack_common_enable, 13797 (void *)&cmd_set_conntrack_common_enable_value, 13798 (void *)&cmd_set_conntrack_common_live, 13799 (void *)&cmd_set_conntrack_common_live_value, 13800 (void *)&cmd_set_conntrack_common_sack, 13801 (void *)&cmd_set_conntrack_common_sack_value, 13802 (void *)&cmd_set_conntrack_common_cack, 13803 (void *)&cmd_set_conntrack_common_cack_value, 13804 (void *)&cmd_set_conntrack_common_last_dir, 13805 (void *)&cmd_set_conntrack_common_last_dir_value, 13806 (void *)&cmd_set_conntrack_common_liberal, 13807 (void *)&cmd_set_conntrack_common_liberal_value, 13808 (void *)&cmd_set_conntrack_common_state, 13809 (void *)&cmd_set_conntrack_common_state_value, 13810 (void *)&cmd_set_conntrack_common_max_ackwin, 13811 (void *)&cmd_set_conntrack_common_max_ackwin_value, 13812 (void *)&cmd_set_conntrack_common_retrans, 13813 (void *)&cmd_set_conntrack_common_retrans_value, 13814 (void *)&cmd_set_conntrack_common_last_win, 13815 (void *)&cmd_set_conntrack_common_last_win_value, 13816 (void *)&cmd_set_conntrack_common_last_seq, 13817 (void *)&cmd_set_conntrack_common_last_seq_value, 13818 (void *)&cmd_set_conntrack_common_last_ack, 13819 (void *)&cmd_set_conntrack_common_last_ack_value, 13820 (void *)&cmd_set_conntrack_common_last_end, 13821 (void *)&cmd_set_conntrack_common_last_end_value, 13822 (void *)&cmd_set_conntrack_common_last_index, 13823 (void *)&cmd_set_conntrack_common_last_index_value, 13824 NULL, 13825 }, 13826 }; 13827 13828 /** Set connection tracking object both directions' details */ 13829 struct cmd_set_conntrack_dir_result { 13830 cmdline_fixed_string_t set; 13831 cmdline_fixed_string_t conntrack; 13832 cmdline_fixed_string_t dir; 13833 cmdline_fixed_string_t scale; 13834 cmdline_fixed_string_t fin; 13835 cmdline_fixed_string_t ack_seen; 13836 cmdline_fixed_string_t unack; 13837 cmdline_fixed_string_t sent_end; 13838 cmdline_fixed_string_t reply_end; 13839 cmdline_fixed_string_t max_win; 13840 cmdline_fixed_string_t max_ack; 13841 uint32_t factor; 13842 uint32_t f; 13843 uint32_t as; 13844 uint32_t un; 13845 uint32_t se; 13846 uint32_t re; 13847 uint32_t mw; 13848 uint32_t ma; 13849 }; 13850 13851 cmdline_parse_token_string_t cmd_set_conntrack_dir_set = 13852 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 13853 set, "set"); 13854 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack = 13855 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 13856 conntrack, "conntrack"); 13857 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir = 13858 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 13859 dir, "orig#rply"); 13860 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale = 13861 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 13862 scale, "scale"); 13863 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value = 13864 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 13865 factor, RTE_UINT32); 13866 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin = 13867 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 13868 fin, "fin"); 13869 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value = 13870 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 13871 f, RTE_UINT32); 13872 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack = 13873 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 13874 ack_seen, "acked"); 13875 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value = 13876 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 13877 as, RTE_UINT32); 13878 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data = 13879 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 13880 unack, "unack_data"); 13881 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value = 13882 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 13883 un, RTE_UINT32); 13884 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end = 13885 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 13886 sent_end, "sent_end"); 13887 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value = 13888 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 13889 se, RTE_UINT32); 13890 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end = 13891 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 13892 reply_end, "reply_end"); 13893 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value = 13894 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 13895 re, RTE_UINT32); 13896 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win = 13897 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 13898 max_win, "max_win"); 13899 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value = 13900 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 13901 mw, RTE_UINT32); 13902 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack = 13903 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 13904 max_ack, "max_ack"); 13905 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value = 13906 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 13907 ma, RTE_UINT32); 13908 13909 static void cmd_set_conntrack_dir_parsed(void *parsed_result, 13910 __rte_unused struct cmdline *cl, 13911 __rte_unused void *data) 13912 { 13913 struct cmd_set_conntrack_dir_result *res = parsed_result; 13914 struct rte_flow_tcp_dir_param *dir = NULL; 13915 13916 if (strcmp(res->dir, "orig") == 0) 13917 dir = &conntrack_context.original_dir; 13918 else if (strcmp(res->dir, "rply") == 0) 13919 dir = &conntrack_context.reply_dir; 13920 else 13921 return; 13922 dir->scale = res->factor; 13923 dir->close_initiated = res->f; 13924 dir->last_ack_seen = res->as; 13925 dir->data_unacked = res->un; 13926 dir->sent_end = res->se; 13927 dir->reply_end = res->re; 13928 dir->max_ack = res->ma; 13929 dir->max_win = res->mw; 13930 } 13931 13932 cmdline_parse_inst_t cmd_set_conntrack_dir = { 13933 .f = cmd_set_conntrack_dir_parsed, 13934 .data = NULL, 13935 .help_str = "set conntrack orig|rply scale <factor> fin <sent>" 13936 " acked <seen> unack_data <unack> sent_end <sent>" 13937 " reply_end <reply> max_win <win> max_ack <ack>", 13938 .tokens = { 13939 (void *)&cmd_set_conntrack_set, 13940 (void *)&cmd_set_conntrack_conntrack, 13941 (void *)&cmd_set_conntrack_dir_dir, 13942 (void *)&cmd_set_conntrack_dir_scale, 13943 (void *)&cmd_set_conntrack_dir_scale_value, 13944 (void *)&cmd_set_conntrack_dir_fin, 13945 (void *)&cmd_set_conntrack_dir_fin_value, 13946 (void *)&cmd_set_conntrack_dir_ack, 13947 (void *)&cmd_set_conntrack_dir_ack_value, 13948 (void *)&cmd_set_conntrack_dir_unack_data, 13949 (void *)&cmd_set_conntrack_dir_unack_data_value, 13950 (void *)&cmd_set_conntrack_dir_sent_end, 13951 (void *)&cmd_set_conntrack_dir_sent_end_value, 13952 (void *)&cmd_set_conntrack_dir_reply_end, 13953 (void *)&cmd_set_conntrack_dir_reply_end_value, 13954 (void *)&cmd_set_conntrack_dir_max_win, 13955 (void *)&cmd_set_conntrack_dir_max_win_value, 13956 (void *)&cmd_set_conntrack_dir_max_ack, 13957 (void *)&cmd_set_conntrack_dir_max_ack_value, 13958 NULL, 13959 }, 13960 }; 13961 13962 /* Strict link priority scheduling mode setting */ 13963 static void 13964 cmd_strict_link_prio_parsed( 13965 void *parsed_result, 13966 __rte_unused struct cmdline *cl, 13967 __rte_unused void *data) 13968 { 13969 struct cmd_vf_tc_bw_result *res = parsed_result; 13970 int ret = -ENOTSUP; 13971 13972 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13973 return; 13974 13975 #ifdef RTE_NET_I40E 13976 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 13977 #endif 13978 13979 switch (ret) { 13980 case 0: 13981 break; 13982 case -EINVAL: 13983 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map); 13984 break; 13985 case -ENODEV: 13986 fprintf(stderr, "invalid port_id %d\n", res->port_id); 13987 break; 13988 case -ENOTSUP: 13989 fprintf(stderr, "function not implemented\n"); 13990 break; 13991 default: 13992 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 13993 } 13994 } 13995 13996 cmdline_parse_inst_t cmd_strict_link_prio = { 13997 .f = cmd_strict_link_prio_parsed, 13998 .data = NULL, 13999 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 14000 .tokens = { 14001 (void *)&cmd_vf_tc_bw_set, 14002 (void *)&cmd_vf_tc_bw_tx, 14003 (void *)&cmd_vf_tc_bw_strict_link_prio, 14004 (void *)&cmd_vf_tc_bw_port_id, 14005 (void *)&cmd_vf_tc_bw_tc_map, 14006 NULL, 14007 }, 14008 }; 14009 14010 /* Load dynamic device personalization*/ 14011 struct cmd_ddp_add_result { 14012 cmdline_fixed_string_t ddp; 14013 cmdline_fixed_string_t add; 14014 portid_t port_id; 14015 char filepath[]; 14016 }; 14017 14018 cmdline_parse_token_string_t cmd_ddp_add_ddp = 14019 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 14020 cmdline_parse_token_string_t cmd_ddp_add_add = 14021 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 14022 cmdline_parse_token_num_t cmd_ddp_add_port_id = 14023 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, 14024 RTE_UINT16); 14025 cmdline_parse_token_string_t cmd_ddp_add_filepath = 14026 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 14027 14028 static void 14029 cmd_ddp_add_parsed( 14030 void *parsed_result, 14031 __rte_unused struct cmdline *cl, 14032 __rte_unused void *data) 14033 { 14034 struct cmd_ddp_add_result *res = parsed_result; 14035 uint8_t *buff; 14036 uint32_t size; 14037 char *filepath; 14038 char *file_fld[2]; 14039 int file_num; 14040 int ret = -ENOTSUP; 14041 14042 if (!all_ports_stopped()) { 14043 fprintf(stderr, "Please stop all ports first\n"); 14044 return; 14045 } 14046 14047 filepath = strdup(res->filepath); 14048 if (filepath == NULL) { 14049 fprintf(stderr, "Failed to allocate memory\n"); 14050 return; 14051 } 14052 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 14053 14054 buff = open_file(file_fld[0], &size); 14055 if (!buff) { 14056 free((void *)filepath); 14057 return; 14058 } 14059 14060 #ifdef RTE_NET_I40E 14061 if (ret == -ENOTSUP) 14062 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 14063 buff, size, 14064 RTE_PMD_I40E_PKG_OP_WR_ADD); 14065 #endif 14066 14067 if (ret == -EEXIST) 14068 fprintf(stderr, "Profile has already existed.\n"); 14069 else if (ret < 0) 14070 fprintf(stderr, "Failed to load profile.\n"); 14071 else if (file_num == 2) 14072 save_file(file_fld[1], buff, size); 14073 14074 close_file(buff); 14075 free((void *)filepath); 14076 } 14077 14078 cmdline_parse_inst_t cmd_ddp_add = { 14079 .f = cmd_ddp_add_parsed, 14080 .data = NULL, 14081 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 14082 .tokens = { 14083 (void *)&cmd_ddp_add_ddp, 14084 (void *)&cmd_ddp_add_add, 14085 (void *)&cmd_ddp_add_port_id, 14086 (void *)&cmd_ddp_add_filepath, 14087 NULL, 14088 }, 14089 }; 14090 14091 /* Delete dynamic device personalization*/ 14092 struct cmd_ddp_del_result { 14093 cmdline_fixed_string_t ddp; 14094 cmdline_fixed_string_t del; 14095 portid_t port_id; 14096 char filepath[]; 14097 }; 14098 14099 cmdline_parse_token_string_t cmd_ddp_del_ddp = 14100 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 14101 cmdline_parse_token_string_t cmd_ddp_del_del = 14102 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 14103 cmdline_parse_token_num_t cmd_ddp_del_port_id = 14104 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16); 14105 cmdline_parse_token_string_t cmd_ddp_del_filepath = 14106 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 14107 14108 static void 14109 cmd_ddp_del_parsed( 14110 void *parsed_result, 14111 __rte_unused struct cmdline *cl, 14112 __rte_unused void *data) 14113 { 14114 struct cmd_ddp_del_result *res = parsed_result; 14115 uint8_t *buff; 14116 uint32_t size; 14117 int ret = -ENOTSUP; 14118 14119 if (!all_ports_stopped()) { 14120 fprintf(stderr, "Please stop all ports first\n"); 14121 return; 14122 } 14123 14124 buff = open_file(res->filepath, &size); 14125 if (!buff) 14126 return; 14127 14128 #ifdef RTE_NET_I40E 14129 if (ret == -ENOTSUP) 14130 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 14131 buff, size, 14132 RTE_PMD_I40E_PKG_OP_WR_DEL); 14133 #endif 14134 14135 if (ret == -EACCES) 14136 fprintf(stderr, "Profile does not exist.\n"); 14137 else if (ret < 0) 14138 fprintf(stderr, "Failed to delete profile.\n"); 14139 14140 close_file(buff); 14141 } 14142 14143 cmdline_parse_inst_t cmd_ddp_del = { 14144 .f = cmd_ddp_del_parsed, 14145 .data = NULL, 14146 .help_str = "ddp del <port_id> <backup_profile_path>", 14147 .tokens = { 14148 (void *)&cmd_ddp_del_ddp, 14149 (void *)&cmd_ddp_del_del, 14150 (void *)&cmd_ddp_del_port_id, 14151 (void *)&cmd_ddp_del_filepath, 14152 NULL, 14153 }, 14154 }; 14155 14156 /* Get dynamic device personalization profile info */ 14157 struct cmd_ddp_info_result { 14158 cmdline_fixed_string_t ddp; 14159 cmdline_fixed_string_t get; 14160 cmdline_fixed_string_t info; 14161 char filepath[]; 14162 }; 14163 14164 cmdline_parse_token_string_t cmd_ddp_info_ddp = 14165 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 14166 cmdline_parse_token_string_t cmd_ddp_info_get = 14167 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 14168 cmdline_parse_token_string_t cmd_ddp_info_info = 14169 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 14170 cmdline_parse_token_string_t cmd_ddp_info_filepath = 14171 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 14172 14173 static void 14174 cmd_ddp_info_parsed( 14175 void *parsed_result, 14176 __rte_unused struct cmdline *cl, 14177 __rte_unused void *data) 14178 { 14179 struct cmd_ddp_info_result *res = parsed_result; 14180 uint8_t *pkg; 14181 uint32_t pkg_size; 14182 int ret = -ENOTSUP; 14183 #ifdef RTE_NET_I40E 14184 uint32_t i, j, n; 14185 uint8_t *buff; 14186 uint32_t buff_size = 0; 14187 struct rte_pmd_i40e_profile_info info; 14188 uint32_t dev_num = 0; 14189 struct rte_pmd_i40e_ddp_device_id *devs; 14190 uint32_t proto_num = 0; 14191 struct rte_pmd_i40e_proto_info *proto = NULL; 14192 uint32_t pctype_num = 0; 14193 struct rte_pmd_i40e_ptype_info *pctype; 14194 uint32_t ptype_num = 0; 14195 struct rte_pmd_i40e_ptype_info *ptype; 14196 uint8_t proto_id; 14197 14198 #endif 14199 14200 pkg = open_file(res->filepath, &pkg_size); 14201 if (!pkg) 14202 return; 14203 14204 #ifdef RTE_NET_I40E 14205 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14206 (uint8_t *)&info, sizeof(info), 14207 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 14208 if (!ret) { 14209 printf("Global Track id: 0x%x\n", info.track_id); 14210 printf("Global Version: %d.%d.%d.%d\n", 14211 info.version.major, 14212 info.version.minor, 14213 info.version.update, 14214 info.version.draft); 14215 printf("Global Package name: %s\n\n", info.name); 14216 } 14217 14218 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14219 (uint8_t *)&info, sizeof(info), 14220 RTE_PMD_I40E_PKG_INFO_HEADER); 14221 if (!ret) { 14222 printf("i40e Profile Track id: 0x%x\n", info.track_id); 14223 printf("i40e Profile Version: %d.%d.%d.%d\n", 14224 info.version.major, 14225 info.version.minor, 14226 info.version.update, 14227 info.version.draft); 14228 printf("i40e Profile name: %s\n\n", info.name); 14229 } 14230 14231 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14232 (uint8_t *)&buff_size, sizeof(buff_size), 14233 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 14234 if (!ret && buff_size) { 14235 buff = (uint8_t *)malloc(buff_size); 14236 if (buff) { 14237 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14238 buff, buff_size, 14239 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 14240 if (!ret) 14241 printf("Package Notes:\n%s\n\n", buff); 14242 free(buff); 14243 } 14244 } 14245 14246 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14247 (uint8_t *)&dev_num, sizeof(dev_num), 14248 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 14249 if (!ret && dev_num) { 14250 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 14251 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 14252 if (devs) { 14253 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14254 (uint8_t *)devs, buff_size, 14255 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 14256 if (!ret) { 14257 printf("List of supported devices:\n"); 14258 for (i = 0; i < dev_num; i++) { 14259 printf(" %04X:%04X %04X:%04X\n", 14260 devs[i].vendor_dev_id >> 16, 14261 devs[i].vendor_dev_id & 0xFFFF, 14262 devs[i].sub_vendor_dev_id >> 16, 14263 devs[i].sub_vendor_dev_id & 0xFFFF); 14264 } 14265 printf("\n"); 14266 } 14267 free(devs); 14268 } 14269 } 14270 14271 /* get information about protocols and packet types */ 14272 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14273 (uint8_t *)&proto_num, sizeof(proto_num), 14274 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 14275 if (ret || !proto_num) 14276 goto no_print_return; 14277 14278 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 14279 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 14280 if (!proto) 14281 goto no_print_return; 14282 14283 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 14284 buff_size, 14285 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 14286 if (!ret) { 14287 printf("List of used protocols:\n"); 14288 for (i = 0; i < proto_num; i++) 14289 printf(" %2u: %s\n", proto[i].proto_id, 14290 proto[i].name); 14291 printf("\n"); 14292 } 14293 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14294 (uint8_t *)&pctype_num, sizeof(pctype_num), 14295 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 14296 if (ret || !pctype_num) 14297 goto no_print_pctypes; 14298 14299 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 14300 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 14301 if (!pctype) 14302 goto no_print_pctypes; 14303 14304 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 14305 buff_size, 14306 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 14307 if (ret) { 14308 free(pctype); 14309 goto no_print_pctypes; 14310 } 14311 14312 printf("List of defined packet classification types:\n"); 14313 for (i = 0; i < pctype_num; i++) { 14314 printf(" %2u:", pctype[i].ptype_id); 14315 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 14316 proto_id = pctype[i].protocols[j]; 14317 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 14318 for (n = 0; n < proto_num; n++) { 14319 if (proto[n].proto_id == proto_id) { 14320 printf(" %s", proto[n].name); 14321 break; 14322 } 14323 } 14324 } 14325 } 14326 printf("\n"); 14327 } 14328 printf("\n"); 14329 free(pctype); 14330 14331 no_print_pctypes: 14332 14333 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 14334 sizeof(ptype_num), 14335 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 14336 if (ret || !ptype_num) 14337 goto no_print_return; 14338 14339 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 14340 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 14341 if (!ptype) 14342 goto no_print_return; 14343 14344 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 14345 buff_size, 14346 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 14347 if (ret) { 14348 free(ptype); 14349 goto no_print_return; 14350 } 14351 printf("List of defined packet types:\n"); 14352 for (i = 0; i < ptype_num; i++) { 14353 printf(" %2u:", ptype[i].ptype_id); 14354 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 14355 proto_id = ptype[i].protocols[j]; 14356 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 14357 for (n = 0; n < proto_num; n++) { 14358 if (proto[n].proto_id == proto_id) { 14359 printf(" %s", proto[n].name); 14360 break; 14361 } 14362 } 14363 } 14364 } 14365 printf("\n"); 14366 } 14367 free(ptype); 14368 printf("\n"); 14369 14370 ret = 0; 14371 no_print_return: 14372 if (proto) 14373 free(proto); 14374 #endif 14375 if (ret == -ENOTSUP) 14376 fprintf(stderr, "Function not supported in PMD driver\n"); 14377 close_file(pkg); 14378 } 14379 14380 cmdline_parse_inst_t cmd_ddp_get_info = { 14381 .f = cmd_ddp_info_parsed, 14382 .data = NULL, 14383 .help_str = "ddp get info <profile_path>", 14384 .tokens = { 14385 (void *)&cmd_ddp_info_ddp, 14386 (void *)&cmd_ddp_info_get, 14387 (void *)&cmd_ddp_info_info, 14388 (void *)&cmd_ddp_info_filepath, 14389 NULL, 14390 }, 14391 }; 14392 14393 /* Get dynamic device personalization profile info list*/ 14394 #define PROFILE_INFO_SIZE 48 14395 #define MAX_PROFILE_NUM 16 14396 14397 struct cmd_ddp_get_list_result { 14398 cmdline_fixed_string_t ddp; 14399 cmdline_fixed_string_t get; 14400 cmdline_fixed_string_t list; 14401 portid_t port_id; 14402 }; 14403 14404 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 14405 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 14406 cmdline_parse_token_string_t cmd_ddp_get_list_get = 14407 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 14408 cmdline_parse_token_string_t cmd_ddp_get_list_list = 14409 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 14410 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 14411 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, 14412 RTE_UINT16); 14413 14414 static void 14415 cmd_ddp_get_list_parsed( 14416 __rte_unused void *parsed_result, 14417 __rte_unused struct cmdline *cl, 14418 __rte_unused void *data) 14419 { 14420 #ifdef RTE_NET_I40E 14421 struct cmd_ddp_get_list_result *res = parsed_result; 14422 struct rte_pmd_i40e_profile_list *p_list; 14423 struct rte_pmd_i40e_profile_info *p_info; 14424 uint32_t p_num; 14425 uint32_t size; 14426 uint32_t i; 14427 #endif 14428 int ret = -ENOTSUP; 14429 14430 #ifdef RTE_NET_I40E 14431 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 14432 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 14433 if (!p_list) { 14434 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__); 14435 return; 14436 } 14437 14438 if (ret == -ENOTSUP) 14439 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 14440 (uint8_t *)p_list, size); 14441 14442 if (!ret) { 14443 p_num = p_list->p_count; 14444 printf("Profile number is: %d\n\n", p_num); 14445 14446 for (i = 0; i < p_num; i++) { 14447 p_info = &p_list->p_info[i]; 14448 printf("Profile %d:\n", i); 14449 printf("Track id: 0x%x\n", p_info->track_id); 14450 printf("Version: %d.%d.%d.%d\n", 14451 p_info->version.major, 14452 p_info->version.minor, 14453 p_info->version.update, 14454 p_info->version.draft); 14455 printf("Profile name: %s\n\n", p_info->name); 14456 } 14457 } 14458 14459 free(p_list); 14460 #endif 14461 14462 if (ret < 0) 14463 fprintf(stderr, "Failed to get ddp list\n"); 14464 } 14465 14466 cmdline_parse_inst_t cmd_ddp_get_list = { 14467 .f = cmd_ddp_get_list_parsed, 14468 .data = NULL, 14469 .help_str = "ddp get list <port_id>", 14470 .tokens = { 14471 (void *)&cmd_ddp_get_list_ddp, 14472 (void *)&cmd_ddp_get_list_get, 14473 (void *)&cmd_ddp_get_list_list, 14474 (void *)&cmd_ddp_get_list_port_id, 14475 NULL, 14476 }, 14477 }; 14478 14479 /* Configure input set */ 14480 struct cmd_cfg_input_set_result { 14481 cmdline_fixed_string_t port; 14482 cmdline_fixed_string_t cfg; 14483 portid_t port_id; 14484 cmdline_fixed_string_t pctype; 14485 uint8_t pctype_id; 14486 cmdline_fixed_string_t inset_type; 14487 cmdline_fixed_string_t opt; 14488 cmdline_fixed_string_t field; 14489 uint8_t field_idx; 14490 }; 14491 14492 static void 14493 cmd_cfg_input_set_parsed( 14494 __rte_unused void *parsed_result, 14495 __rte_unused struct cmdline *cl, 14496 __rte_unused void *data) 14497 { 14498 #ifdef RTE_NET_I40E 14499 struct cmd_cfg_input_set_result *res = parsed_result; 14500 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 14501 struct rte_pmd_i40e_inset inset; 14502 #endif 14503 int ret = -ENOTSUP; 14504 14505 if (!all_ports_stopped()) { 14506 fprintf(stderr, "Please stop all ports first\n"); 14507 return; 14508 } 14509 14510 #ifdef RTE_NET_I40E 14511 if (!strcmp(res->inset_type, "hash_inset")) 14512 inset_type = INSET_HASH; 14513 else if (!strcmp(res->inset_type, "fdir_inset")) 14514 inset_type = INSET_FDIR; 14515 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 14516 inset_type = INSET_FDIR_FLX; 14517 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 14518 &inset, inset_type); 14519 if (ret) { 14520 fprintf(stderr, "Failed to get input set.\n"); 14521 return; 14522 } 14523 14524 if (!strcmp(res->opt, "get")) { 14525 ret = rte_pmd_i40e_inset_field_get(inset.inset, 14526 res->field_idx); 14527 if (ret) 14528 printf("Field index %d is enabled.\n", res->field_idx); 14529 else 14530 printf("Field index %d is disabled.\n", res->field_idx); 14531 return; 14532 } else if (!strcmp(res->opt, "set")) 14533 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 14534 res->field_idx); 14535 else if (!strcmp(res->opt, "clear")) 14536 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 14537 res->field_idx); 14538 if (ret) { 14539 fprintf(stderr, "Failed to configure input set field.\n"); 14540 return; 14541 } 14542 14543 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 14544 &inset, inset_type); 14545 if (ret) { 14546 fprintf(stderr, "Failed to set input set.\n"); 14547 return; 14548 } 14549 #endif 14550 14551 if (ret == -ENOTSUP) 14552 fprintf(stderr, "Function not supported\n"); 14553 } 14554 14555 cmdline_parse_token_string_t cmd_cfg_input_set_port = 14556 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14557 port, "port"); 14558 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 14559 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14560 cfg, "config"); 14561 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 14562 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 14563 port_id, RTE_UINT16); 14564 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 14565 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14566 pctype, "pctype"); 14567 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 14568 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 14569 pctype_id, RTE_UINT8); 14570 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 14571 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14572 inset_type, 14573 "hash_inset#fdir_inset#fdir_flx_inset"); 14574 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 14575 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14576 opt, "get#set#clear"); 14577 cmdline_parse_token_string_t cmd_cfg_input_set_field = 14578 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14579 field, "field"); 14580 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 14581 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 14582 field_idx, RTE_UINT8); 14583 14584 cmdline_parse_inst_t cmd_cfg_input_set = { 14585 .f = cmd_cfg_input_set_parsed, 14586 .data = NULL, 14587 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 14588 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 14589 .tokens = { 14590 (void *)&cmd_cfg_input_set_port, 14591 (void *)&cmd_cfg_input_set_cfg, 14592 (void *)&cmd_cfg_input_set_port_id, 14593 (void *)&cmd_cfg_input_set_pctype, 14594 (void *)&cmd_cfg_input_set_pctype_id, 14595 (void *)&cmd_cfg_input_set_inset_type, 14596 (void *)&cmd_cfg_input_set_opt, 14597 (void *)&cmd_cfg_input_set_field, 14598 (void *)&cmd_cfg_input_set_field_idx, 14599 NULL, 14600 }, 14601 }; 14602 14603 /* Clear input set */ 14604 struct cmd_clear_input_set_result { 14605 cmdline_fixed_string_t port; 14606 cmdline_fixed_string_t cfg; 14607 portid_t port_id; 14608 cmdline_fixed_string_t pctype; 14609 uint8_t pctype_id; 14610 cmdline_fixed_string_t inset_type; 14611 cmdline_fixed_string_t clear; 14612 cmdline_fixed_string_t all; 14613 }; 14614 14615 static void 14616 cmd_clear_input_set_parsed( 14617 __rte_unused void *parsed_result, 14618 __rte_unused struct cmdline *cl, 14619 __rte_unused void *data) 14620 { 14621 #ifdef RTE_NET_I40E 14622 struct cmd_clear_input_set_result *res = parsed_result; 14623 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 14624 struct rte_pmd_i40e_inset inset; 14625 #endif 14626 int ret = -ENOTSUP; 14627 14628 if (!all_ports_stopped()) { 14629 fprintf(stderr, "Please stop all ports first\n"); 14630 return; 14631 } 14632 14633 #ifdef RTE_NET_I40E 14634 if (!strcmp(res->inset_type, "hash_inset")) 14635 inset_type = INSET_HASH; 14636 else if (!strcmp(res->inset_type, "fdir_inset")) 14637 inset_type = INSET_FDIR; 14638 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 14639 inset_type = INSET_FDIR_FLX; 14640 14641 memset(&inset, 0, sizeof(inset)); 14642 14643 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 14644 &inset, inset_type); 14645 if (ret) { 14646 fprintf(stderr, "Failed to clear input set.\n"); 14647 return; 14648 } 14649 14650 #endif 14651 14652 if (ret == -ENOTSUP) 14653 fprintf(stderr, "Function not supported\n"); 14654 } 14655 14656 cmdline_parse_token_string_t cmd_clear_input_set_port = 14657 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14658 port, "port"); 14659 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 14660 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14661 cfg, "config"); 14662 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 14663 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 14664 port_id, RTE_UINT16); 14665 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 14666 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14667 pctype, "pctype"); 14668 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 14669 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 14670 pctype_id, RTE_UINT8); 14671 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 14672 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14673 inset_type, 14674 "hash_inset#fdir_inset#fdir_flx_inset"); 14675 cmdline_parse_token_string_t cmd_clear_input_set_clear = 14676 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14677 clear, "clear"); 14678 cmdline_parse_token_string_t cmd_clear_input_set_all = 14679 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14680 all, "all"); 14681 14682 cmdline_parse_inst_t cmd_clear_input_set = { 14683 .f = cmd_clear_input_set_parsed, 14684 .data = NULL, 14685 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 14686 "fdir_inset|fdir_flx_inset clear all", 14687 .tokens = { 14688 (void *)&cmd_clear_input_set_port, 14689 (void *)&cmd_clear_input_set_cfg, 14690 (void *)&cmd_clear_input_set_port_id, 14691 (void *)&cmd_clear_input_set_pctype, 14692 (void *)&cmd_clear_input_set_pctype_id, 14693 (void *)&cmd_clear_input_set_inset_type, 14694 (void *)&cmd_clear_input_set_clear, 14695 (void *)&cmd_clear_input_set_all, 14696 NULL, 14697 }, 14698 }; 14699 14700 /* show vf stats */ 14701 14702 /* Common result structure for show vf stats */ 14703 struct cmd_show_vf_stats_result { 14704 cmdline_fixed_string_t show; 14705 cmdline_fixed_string_t vf; 14706 cmdline_fixed_string_t stats; 14707 portid_t port_id; 14708 uint16_t vf_id; 14709 }; 14710 14711 /* Common CLI fields show vf stats*/ 14712 cmdline_parse_token_string_t cmd_show_vf_stats_show = 14713 TOKEN_STRING_INITIALIZER 14714 (struct cmd_show_vf_stats_result, 14715 show, "show"); 14716 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 14717 TOKEN_STRING_INITIALIZER 14718 (struct cmd_show_vf_stats_result, 14719 vf, "vf"); 14720 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 14721 TOKEN_STRING_INITIALIZER 14722 (struct cmd_show_vf_stats_result, 14723 stats, "stats"); 14724 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 14725 TOKEN_NUM_INITIALIZER 14726 (struct cmd_show_vf_stats_result, 14727 port_id, RTE_UINT16); 14728 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 14729 TOKEN_NUM_INITIALIZER 14730 (struct cmd_show_vf_stats_result, 14731 vf_id, RTE_UINT16); 14732 14733 static void 14734 cmd_show_vf_stats_parsed( 14735 void *parsed_result, 14736 __rte_unused struct cmdline *cl, 14737 __rte_unused void *data) 14738 { 14739 struct cmd_show_vf_stats_result *res = parsed_result; 14740 struct rte_eth_stats stats; 14741 int ret = -ENOTSUP; 14742 static const char *nic_stats_border = "########################"; 14743 14744 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14745 return; 14746 14747 memset(&stats, 0, sizeof(stats)); 14748 14749 #ifdef RTE_NET_I40E 14750 if (ret == -ENOTSUP) 14751 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 14752 res->vf_id, 14753 &stats); 14754 #endif 14755 #ifdef RTE_NET_BNXT 14756 if (ret == -ENOTSUP) 14757 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 14758 res->vf_id, 14759 &stats); 14760 #endif 14761 14762 switch (ret) { 14763 case 0: 14764 break; 14765 case -EINVAL: 14766 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 14767 break; 14768 case -ENODEV: 14769 fprintf(stderr, "invalid port_id %d\n", res->port_id); 14770 break; 14771 case -ENOTSUP: 14772 fprintf(stderr, "function not implemented\n"); 14773 break; 14774 default: 14775 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 14776 } 14777 14778 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 14779 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 14780 14781 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 14782 "%-"PRIu64"\n", 14783 stats.ipackets, stats.imissed, stats.ibytes); 14784 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 14785 printf(" RX-nombuf: %-10"PRIu64"\n", 14786 stats.rx_nombuf); 14787 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 14788 "%-"PRIu64"\n", 14789 stats.opackets, stats.oerrors, stats.obytes); 14790 14791 printf(" %s############################%s\n", 14792 nic_stats_border, nic_stats_border); 14793 } 14794 14795 cmdline_parse_inst_t cmd_show_vf_stats = { 14796 .f = cmd_show_vf_stats_parsed, 14797 .data = NULL, 14798 .help_str = "show vf stats <port_id> <vf_id>", 14799 .tokens = { 14800 (void *)&cmd_show_vf_stats_show, 14801 (void *)&cmd_show_vf_stats_vf, 14802 (void *)&cmd_show_vf_stats_stats, 14803 (void *)&cmd_show_vf_stats_port_id, 14804 (void *)&cmd_show_vf_stats_vf_id, 14805 NULL, 14806 }, 14807 }; 14808 14809 /* clear vf stats */ 14810 14811 /* Common result structure for clear vf stats */ 14812 struct cmd_clear_vf_stats_result { 14813 cmdline_fixed_string_t clear; 14814 cmdline_fixed_string_t vf; 14815 cmdline_fixed_string_t stats; 14816 portid_t port_id; 14817 uint16_t vf_id; 14818 }; 14819 14820 /* Common CLI fields clear vf stats*/ 14821 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 14822 TOKEN_STRING_INITIALIZER 14823 (struct cmd_clear_vf_stats_result, 14824 clear, "clear"); 14825 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 14826 TOKEN_STRING_INITIALIZER 14827 (struct cmd_clear_vf_stats_result, 14828 vf, "vf"); 14829 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 14830 TOKEN_STRING_INITIALIZER 14831 (struct cmd_clear_vf_stats_result, 14832 stats, "stats"); 14833 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 14834 TOKEN_NUM_INITIALIZER 14835 (struct cmd_clear_vf_stats_result, 14836 port_id, RTE_UINT16); 14837 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 14838 TOKEN_NUM_INITIALIZER 14839 (struct cmd_clear_vf_stats_result, 14840 vf_id, RTE_UINT16); 14841 14842 static void 14843 cmd_clear_vf_stats_parsed( 14844 void *parsed_result, 14845 __rte_unused struct cmdline *cl, 14846 __rte_unused void *data) 14847 { 14848 struct cmd_clear_vf_stats_result *res = parsed_result; 14849 int ret = -ENOTSUP; 14850 14851 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14852 return; 14853 14854 #ifdef RTE_NET_I40E 14855 if (ret == -ENOTSUP) 14856 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 14857 res->vf_id); 14858 #endif 14859 #ifdef RTE_NET_BNXT 14860 if (ret == -ENOTSUP) 14861 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 14862 res->vf_id); 14863 #endif 14864 14865 switch (ret) { 14866 case 0: 14867 break; 14868 case -EINVAL: 14869 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 14870 break; 14871 case -ENODEV: 14872 fprintf(stderr, "invalid port_id %d\n", res->port_id); 14873 break; 14874 case -ENOTSUP: 14875 fprintf(stderr, "function not implemented\n"); 14876 break; 14877 default: 14878 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 14879 } 14880 } 14881 14882 cmdline_parse_inst_t cmd_clear_vf_stats = { 14883 .f = cmd_clear_vf_stats_parsed, 14884 .data = NULL, 14885 .help_str = "clear vf stats <port_id> <vf_id>", 14886 .tokens = { 14887 (void *)&cmd_clear_vf_stats_clear, 14888 (void *)&cmd_clear_vf_stats_vf, 14889 (void *)&cmd_clear_vf_stats_stats, 14890 (void *)&cmd_clear_vf_stats_port_id, 14891 (void *)&cmd_clear_vf_stats_vf_id, 14892 NULL, 14893 }, 14894 }; 14895 14896 /* port config pctype mapping reset */ 14897 14898 /* Common result structure for port config pctype mapping reset */ 14899 struct cmd_pctype_mapping_reset_result { 14900 cmdline_fixed_string_t port; 14901 cmdline_fixed_string_t config; 14902 portid_t port_id; 14903 cmdline_fixed_string_t pctype; 14904 cmdline_fixed_string_t mapping; 14905 cmdline_fixed_string_t reset; 14906 }; 14907 14908 /* Common CLI fields for port config pctype mapping reset*/ 14909 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 14910 TOKEN_STRING_INITIALIZER 14911 (struct cmd_pctype_mapping_reset_result, 14912 port, "port"); 14913 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 14914 TOKEN_STRING_INITIALIZER 14915 (struct cmd_pctype_mapping_reset_result, 14916 config, "config"); 14917 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 14918 TOKEN_NUM_INITIALIZER 14919 (struct cmd_pctype_mapping_reset_result, 14920 port_id, RTE_UINT16); 14921 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 14922 TOKEN_STRING_INITIALIZER 14923 (struct cmd_pctype_mapping_reset_result, 14924 pctype, "pctype"); 14925 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 14926 TOKEN_STRING_INITIALIZER 14927 (struct cmd_pctype_mapping_reset_result, 14928 mapping, "mapping"); 14929 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 14930 TOKEN_STRING_INITIALIZER 14931 (struct cmd_pctype_mapping_reset_result, 14932 reset, "reset"); 14933 14934 static void 14935 cmd_pctype_mapping_reset_parsed( 14936 void *parsed_result, 14937 __rte_unused struct cmdline *cl, 14938 __rte_unused void *data) 14939 { 14940 struct cmd_pctype_mapping_reset_result *res = parsed_result; 14941 int ret = -ENOTSUP; 14942 14943 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14944 return; 14945 14946 #ifdef RTE_NET_I40E 14947 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 14948 #endif 14949 14950 switch (ret) { 14951 case 0: 14952 break; 14953 case -ENODEV: 14954 fprintf(stderr, "invalid port_id %d\n", res->port_id); 14955 break; 14956 case -ENOTSUP: 14957 fprintf(stderr, "function not implemented\n"); 14958 break; 14959 default: 14960 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 14961 } 14962 } 14963 14964 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 14965 .f = cmd_pctype_mapping_reset_parsed, 14966 .data = NULL, 14967 .help_str = "port config <port_id> pctype mapping reset", 14968 .tokens = { 14969 (void *)&cmd_pctype_mapping_reset_port, 14970 (void *)&cmd_pctype_mapping_reset_config, 14971 (void *)&cmd_pctype_mapping_reset_port_id, 14972 (void *)&cmd_pctype_mapping_reset_pctype, 14973 (void *)&cmd_pctype_mapping_reset_mapping, 14974 (void *)&cmd_pctype_mapping_reset_reset, 14975 NULL, 14976 }, 14977 }; 14978 14979 /* show port pctype mapping */ 14980 14981 /* Common result structure for show port pctype mapping */ 14982 struct cmd_pctype_mapping_get_result { 14983 cmdline_fixed_string_t show; 14984 cmdline_fixed_string_t port; 14985 portid_t port_id; 14986 cmdline_fixed_string_t pctype; 14987 cmdline_fixed_string_t mapping; 14988 }; 14989 14990 /* Common CLI fields for pctype mapping get */ 14991 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 14992 TOKEN_STRING_INITIALIZER 14993 (struct cmd_pctype_mapping_get_result, 14994 show, "show"); 14995 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 14996 TOKEN_STRING_INITIALIZER 14997 (struct cmd_pctype_mapping_get_result, 14998 port, "port"); 14999 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 15000 TOKEN_NUM_INITIALIZER 15001 (struct cmd_pctype_mapping_get_result, 15002 port_id, RTE_UINT16); 15003 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 15004 TOKEN_STRING_INITIALIZER 15005 (struct cmd_pctype_mapping_get_result, 15006 pctype, "pctype"); 15007 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 15008 TOKEN_STRING_INITIALIZER 15009 (struct cmd_pctype_mapping_get_result, 15010 mapping, "mapping"); 15011 15012 static void 15013 cmd_pctype_mapping_get_parsed( 15014 void *parsed_result, 15015 __rte_unused struct cmdline *cl, 15016 __rte_unused void *data) 15017 { 15018 struct cmd_pctype_mapping_get_result *res = parsed_result; 15019 int ret = -ENOTSUP; 15020 #ifdef RTE_NET_I40E 15021 struct rte_pmd_i40e_flow_type_mapping 15022 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 15023 int i, j, first_pctype; 15024 #endif 15025 15026 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15027 return; 15028 15029 #ifdef RTE_NET_I40E 15030 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 15031 #endif 15032 15033 switch (ret) { 15034 case 0: 15035 break; 15036 case -ENODEV: 15037 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15038 return; 15039 case -ENOTSUP: 15040 fprintf(stderr, "function not implemented\n"); 15041 return; 15042 default: 15043 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15044 return; 15045 } 15046 15047 #ifdef RTE_NET_I40E 15048 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 15049 if (mapping[i].pctype != 0ULL) { 15050 first_pctype = 1; 15051 15052 printf("pctype: "); 15053 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 15054 if (mapping[i].pctype & (1ULL << j)) { 15055 printf(first_pctype ? 15056 "%02d" : ",%02d", j); 15057 first_pctype = 0; 15058 } 15059 } 15060 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 15061 } 15062 } 15063 #endif 15064 } 15065 15066 cmdline_parse_inst_t cmd_pctype_mapping_get = { 15067 .f = cmd_pctype_mapping_get_parsed, 15068 .data = NULL, 15069 .help_str = "show port <port_id> pctype mapping", 15070 .tokens = { 15071 (void *)&cmd_pctype_mapping_get_show, 15072 (void *)&cmd_pctype_mapping_get_port, 15073 (void *)&cmd_pctype_mapping_get_port_id, 15074 (void *)&cmd_pctype_mapping_get_pctype, 15075 (void *)&cmd_pctype_mapping_get_mapping, 15076 NULL, 15077 }, 15078 }; 15079 15080 /* port config pctype mapping update */ 15081 15082 /* Common result structure for port config pctype mapping update */ 15083 struct cmd_pctype_mapping_update_result { 15084 cmdline_fixed_string_t port; 15085 cmdline_fixed_string_t config; 15086 portid_t port_id; 15087 cmdline_fixed_string_t pctype; 15088 cmdline_fixed_string_t mapping; 15089 cmdline_fixed_string_t update; 15090 cmdline_fixed_string_t pctype_list; 15091 uint16_t flow_type; 15092 }; 15093 15094 /* Common CLI fields for pctype mapping update*/ 15095 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 15096 TOKEN_STRING_INITIALIZER 15097 (struct cmd_pctype_mapping_update_result, 15098 port, "port"); 15099 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 15100 TOKEN_STRING_INITIALIZER 15101 (struct cmd_pctype_mapping_update_result, 15102 config, "config"); 15103 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 15104 TOKEN_NUM_INITIALIZER 15105 (struct cmd_pctype_mapping_update_result, 15106 port_id, RTE_UINT16); 15107 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 15108 TOKEN_STRING_INITIALIZER 15109 (struct cmd_pctype_mapping_update_result, 15110 pctype, "pctype"); 15111 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 15112 TOKEN_STRING_INITIALIZER 15113 (struct cmd_pctype_mapping_update_result, 15114 mapping, "mapping"); 15115 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 15116 TOKEN_STRING_INITIALIZER 15117 (struct cmd_pctype_mapping_update_result, 15118 update, "update"); 15119 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 15120 TOKEN_STRING_INITIALIZER 15121 (struct cmd_pctype_mapping_update_result, 15122 pctype_list, NULL); 15123 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 15124 TOKEN_NUM_INITIALIZER 15125 (struct cmd_pctype_mapping_update_result, 15126 flow_type, RTE_UINT16); 15127 15128 static void 15129 cmd_pctype_mapping_update_parsed( 15130 void *parsed_result, 15131 __rte_unused struct cmdline *cl, 15132 __rte_unused void *data) 15133 { 15134 struct cmd_pctype_mapping_update_result *res = parsed_result; 15135 int ret = -ENOTSUP; 15136 #ifdef RTE_NET_I40E 15137 struct rte_pmd_i40e_flow_type_mapping mapping; 15138 unsigned int i; 15139 unsigned int nb_item; 15140 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 15141 #endif 15142 15143 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15144 return; 15145 15146 #ifdef RTE_NET_I40E 15147 nb_item = parse_item_list(res->pctype_list, "pctypes", 15148 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 15149 mapping.flow_type = res->flow_type; 15150 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 15151 mapping.pctype |= (1ULL << pctype_list[i]); 15152 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 15153 &mapping, 15154 1, 15155 0); 15156 #endif 15157 15158 switch (ret) { 15159 case 0: 15160 break; 15161 case -EINVAL: 15162 fprintf(stderr, "invalid pctype or flow type\n"); 15163 break; 15164 case -ENODEV: 15165 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15166 break; 15167 case -ENOTSUP: 15168 fprintf(stderr, "function not implemented\n"); 15169 break; 15170 default: 15171 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15172 } 15173 } 15174 15175 cmdline_parse_inst_t cmd_pctype_mapping_update = { 15176 .f = cmd_pctype_mapping_update_parsed, 15177 .data = NULL, 15178 .help_str = "port config <port_id> pctype mapping update" 15179 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 15180 .tokens = { 15181 (void *)&cmd_pctype_mapping_update_port, 15182 (void *)&cmd_pctype_mapping_update_config, 15183 (void *)&cmd_pctype_mapping_update_port_id, 15184 (void *)&cmd_pctype_mapping_update_pctype, 15185 (void *)&cmd_pctype_mapping_update_mapping, 15186 (void *)&cmd_pctype_mapping_update_update, 15187 (void *)&cmd_pctype_mapping_update_pc_type, 15188 (void *)&cmd_pctype_mapping_update_flow_type, 15189 NULL, 15190 }, 15191 }; 15192 15193 /* ptype mapping get */ 15194 15195 /* Common result structure for ptype mapping get */ 15196 struct cmd_ptype_mapping_get_result { 15197 cmdline_fixed_string_t ptype; 15198 cmdline_fixed_string_t mapping; 15199 cmdline_fixed_string_t get; 15200 portid_t port_id; 15201 uint8_t valid_only; 15202 }; 15203 15204 /* Common CLI fields for ptype mapping get */ 15205 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 15206 TOKEN_STRING_INITIALIZER 15207 (struct cmd_ptype_mapping_get_result, 15208 ptype, "ptype"); 15209 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 15210 TOKEN_STRING_INITIALIZER 15211 (struct cmd_ptype_mapping_get_result, 15212 mapping, "mapping"); 15213 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 15214 TOKEN_STRING_INITIALIZER 15215 (struct cmd_ptype_mapping_get_result, 15216 get, "get"); 15217 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 15218 TOKEN_NUM_INITIALIZER 15219 (struct cmd_ptype_mapping_get_result, 15220 port_id, RTE_UINT16); 15221 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 15222 TOKEN_NUM_INITIALIZER 15223 (struct cmd_ptype_mapping_get_result, 15224 valid_only, RTE_UINT8); 15225 15226 static void 15227 cmd_ptype_mapping_get_parsed( 15228 void *parsed_result, 15229 __rte_unused struct cmdline *cl, 15230 __rte_unused void *data) 15231 { 15232 struct cmd_ptype_mapping_get_result *res = parsed_result; 15233 int ret = -ENOTSUP; 15234 #ifdef RTE_NET_I40E 15235 int max_ptype_num = 256; 15236 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 15237 uint16_t count; 15238 int i; 15239 #endif 15240 15241 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15242 return; 15243 15244 #ifdef RTE_NET_I40E 15245 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 15246 mapping, 15247 max_ptype_num, 15248 &count, 15249 res->valid_only); 15250 #endif 15251 15252 switch (ret) { 15253 case 0: 15254 break; 15255 case -ENODEV: 15256 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15257 break; 15258 case -ENOTSUP: 15259 fprintf(stderr, "function not implemented\n"); 15260 break; 15261 default: 15262 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15263 } 15264 15265 #ifdef RTE_NET_I40E 15266 if (!ret) { 15267 for (i = 0; i < count; i++) 15268 printf("%3d\t0x%08x\n", 15269 mapping[i].hw_ptype, mapping[i].sw_ptype); 15270 } 15271 #endif 15272 } 15273 15274 cmdline_parse_inst_t cmd_ptype_mapping_get = { 15275 .f = cmd_ptype_mapping_get_parsed, 15276 .data = NULL, 15277 .help_str = "ptype mapping get <port_id> <valid_only>", 15278 .tokens = { 15279 (void *)&cmd_ptype_mapping_get_ptype, 15280 (void *)&cmd_ptype_mapping_get_mapping, 15281 (void *)&cmd_ptype_mapping_get_get, 15282 (void *)&cmd_ptype_mapping_get_port_id, 15283 (void *)&cmd_ptype_mapping_get_valid_only, 15284 NULL, 15285 }, 15286 }; 15287 15288 /* ptype mapping replace */ 15289 15290 /* Common result structure for ptype mapping replace */ 15291 struct cmd_ptype_mapping_replace_result { 15292 cmdline_fixed_string_t ptype; 15293 cmdline_fixed_string_t mapping; 15294 cmdline_fixed_string_t replace; 15295 portid_t port_id; 15296 uint32_t target; 15297 uint8_t mask; 15298 uint32_t pkt_type; 15299 }; 15300 15301 /* Common CLI fields for ptype mapping replace */ 15302 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 15303 TOKEN_STRING_INITIALIZER 15304 (struct cmd_ptype_mapping_replace_result, 15305 ptype, "ptype"); 15306 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 15307 TOKEN_STRING_INITIALIZER 15308 (struct cmd_ptype_mapping_replace_result, 15309 mapping, "mapping"); 15310 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 15311 TOKEN_STRING_INITIALIZER 15312 (struct cmd_ptype_mapping_replace_result, 15313 replace, "replace"); 15314 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 15315 TOKEN_NUM_INITIALIZER 15316 (struct cmd_ptype_mapping_replace_result, 15317 port_id, RTE_UINT16); 15318 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 15319 TOKEN_NUM_INITIALIZER 15320 (struct cmd_ptype_mapping_replace_result, 15321 target, RTE_UINT32); 15322 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 15323 TOKEN_NUM_INITIALIZER 15324 (struct cmd_ptype_mapping_replace_result, 15325 mask, RTE_UINT8); 15326 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 15327 TOKEN_NUM_INITIALIZER 15328 (struct cmd_ptype_mapping_replace_result, 15329 pkt_type, RTE_UINT32); 15330 15331 static void 15332 cmd_ptype_mapping_replace_parsed( 15333 void *parsed_result, 15334 __rte_unused struct cmdline *cl, 15335 __rte_unused void *data) 15336 { 15337 struct cmd_ptype_mapping_replace_result *res = parsed_result; 15338 int ret = -ENOTSUP; 15339 15340 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15341 return; 15342 15343 #ifdef RTE_NET_I40E 15344 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 15345 res->target, 15346 res->mask, 15347 res->pkt_type); 15348 #endif 15349 15350 switch (ret) { 15351 case 0: 15352 break; 15353 case -EINVAL: 15354 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n", 15355 res->target, res->pkt_type); 15356 break; 15357 case -ENODEV: 15358 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15359 break; 15360 case -ENOTSUP: 15361 fprintf(stderr, "function not implemented\n"); 15362 break; 15363 default: 15364 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15365 } 15366 } 15367 15368 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 15369 .f = cmd_ptype_mapping_replace_parsed, 15370 .data = NULL, 15371 .help_str = 15372 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 15373 .tokens = { 15374 (void *)&cmd_ptype_mapping_replace_ptype, 15375 (void *)&cmd_ptype_mapping_replace_mapping, 15376 (void *)&cmd_ptype_mapping_replace_replace, 15377 (void *)&cmd_ptype_mapping_replace_port_id, 15378 (void *)&cmd_ptype_mapping_replace_target, 15379 (void *)&cmd_ptype_mapping_replace_mask, 15380 (void *)&cmd_ptype_mapping_replace_pkt_type, 15381 NULL, 15382 }, 15383 }; 15384 15385 /* ptype mapping reset */ 15386 15387 /* Common result structure for ptype mapping reset */ 15388 struct cmd_ptype_mapping_reset_result { 15389 cmdline_fixed_string_t ptype; 15390 cmdline_fixed_string_t mapping; 15391 cmdline_fixed_string_t reset; 15392 portid_t port_id; 15393 }; 15394 15395 /* Common CLI fields for ptype mapping reset*/ 15396 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 15397 TOKEN_STRING_INITIALIZER 15398 (struct cmd_ptype_mapping_reset_result, 15399 ptype, "ptype"); 15400 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 15401 TOKEN_STRING_INITIALIZER 15402 (struct cmd_ptype_mapping_reset_result, 15403 mapping, "mapping"); 15404 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 15405 TOKEN_STRING_INITIALIZER 15406 (struct cmd_ptype_mapping_reset_result, 15407 reset, "reset"); 15408 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 15409 TOKEN_NUM_INITIALIZER 15410 (struct cmd_ptype_mapping_reset_result, 15411 port_id, RTE_UINT16); 15412 15413 static void 15414 cmd_ptype_mapping_reset_parsed( 15415 void *parsed_result, 15416 __rte_unused struct cmdline *cl, 15417 __rte_unused void *data) 15418 { 15419 struct cmd_ptype_mapping_reset_result *res = parsed_result; 15420 int ret = -ENOTSUP; 15421 15422 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15423 return; 15424 15425 #ifdef RTE_NET_I40E 15426 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 15427 #endif 15428 15429 switch (ret) { 15430 case 0: 15431 break; 15432 case -ENODEV: 15433 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15434 break; 15435 case -ENOTSUP: 15436 fprintf(stderr, "function not implemented\n"); 15437 break; 15438 default: 15439 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15440 } 15441 } 15442 15443 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 15444 .f = cmd_ptype_mapping_reset_parsed, 15445 .data = NULL, 15446 .help_str = "ptype mapping reset <port_id>", 15447 .tokens = { 15448 (void *)&cmd_ptype_mapping_reset_ptype, 15449 (void *)&cmd_ptype_mapping_reset_mapping, 15450 (void *)&cmd_ptype_mapping_reset_reset, 15451 (void *)&cmd_ptype_mapping_reset_port_id, 15452 NULL, 15453 }, 15454 }; 15455 15456 /* ptype mapping update */ 15457 15458 /* Common result structure for ptype mapping update */ 15459 struct cmd_ptype_mapping_update_result { 15460 cmdline_fixed_string_t ptype; 15461 cmdline_fixed_string_t mapping; 15462 cmdline_fixed_string_t reset; 15463 portid_t port_id; 15464 uint8_t hw_ptype; 15465 uint32_t sw_ptype; 15466 }; 15467 15468 /* Common CLI fields for ptype mapping update*/ 15469 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 15470 TOKEN_STRING_INITIALIZER 15471 (struct cmd_ptype_mapping_update_result, 15472 ptype, "ptype"); 15473 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 15474 TOKEN_STRING_INITIALIZER 15475 (struct cmd_ptype_mapping_update_result, 15476 mapping, "mapping"); 15477 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 15478 TOKEN_STRING_INITIALIZER 15479 (struct cmd_ptype_mapping_update_result, 15480 reset, "update"); 15481 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 15482 TOKEN_NUM_INITIALIZER 15483 (struct cmd_ptype_mapping_update_result, 15484 port_id, RTE_UINT16); 15485 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 15486 TOKEN_NUM_INITIALIZER 15487 (struct cmd_ptype_mapping_update_result, 15488 hw_ptype, RTE_UINT8); 15489 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 15490 TOKEN_NUM_INITIALIZER 15491 (struct cmd_ptype_mapping_update_result, 15492 sw_ptype, RTE_UINT32); 15493 15494 static void 15495 cmd_ptype_mapping_update_parsed( 15496 void *parsed_result, 15497 __rte_unused struct cmdline *cl, 15498 __rte_unused void *data) 15499 { 15500 struct cmd_ptype_mapping_update_result *res = parsed_result; 15501 int ret = -ENOTSUP; 15502 #ifdef RTE_NET_I40E 15503 struct rte_pmd_i40e_ptype_mapping mapping; 15504 #endif 15505 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15506 return; 15507 15508 #ifdef RTE_NET_I40E 15509 mapping.hw_ptype = res->hw_ptype; 15510 mapping.sw_ptype = res->sw_ptype; 15511 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 15512 &mapping, 15513 1, 15514 0); 15515 #endif 15516 15517 switch (ret) { 15518 case 0: 15519 break; 15520 case -EINVAL: 15521 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype); 15522 break; 15523 case -ENODEV: 15524 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15525 break; 15526 case -ENOTSUP: 15527 fprintf(stderr, "function not implemented\n"); 15528 break; 15529 default: 15530 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15531 } 15532 } 15533 15534 cmdline_parse_inst_t cmd_ptype_mapping_update = { 15535 .f = cmd_ptype_mapping_update_parsed, 15536 .data = NULL, 15537 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 15538 .tokens = { 15539 (void *)&cmd_ptype_mapping_update_ptype, 15540 (void *)&cmd_ptype_mapping_update_mapping, 15541 (void *)&cmd_ptype_mapping_update_update, 15542 (void *)&cmd_ptype_mapping_update_port_id, 15543 (void *)&cmd_ptype_mapping_update_hw_ptype, 15544 (void *)&cmd_ptype_mapping_update_sw_ptype, 15545 NULL, 15546 }, 15547 }; 15548 15549 /* Common result structure for file commands */ 15550 struct cmd_cmdfile_result { 15551 cmdline_fixed_string_t load; 15552 cmdline_fixed_string_t filename; 15553 }; 15554 15555 /* Common CLI fields for file commands */ 15556 cmdline_parse_token_string_t cmd_load_cmdfile = 15557 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 15558 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 15559 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 15560 15561 static void 15562 cmd_load_from_file_parsed( 15563 void *parsed_result, 15564 __rte_unused struct cmdline *cl, 15565 __rte_unused void *data) 15566 { 15567 struct cmd_cmdfile_result *res = parsed_result; 15568 15569 cmdline_read_from_file(res->filename); 15570 } 15571 15572 cmdline_parse_inst_t cmd_load_from_file = { 15573 .f = cmd_load_from_file_parsed, 15574 .data = NULL, 15575 .help_str = "load <filename>", 15576 .tokens = { 15577 (void *)&cmd_load_cmdfile, 15578 (void *)&cmd_load_cmdfile_filename, 15579 NULL, 15580 }, 15581 }; 15582 15583 /* Get Rx offloads capabilities */ 15584 struct cmd_rx_offload_get_capa_result { 15585 cmdline_fixed_string_t show; 15586 cmdline_fixed_string_t port; 15587 portid_t port_id; 15588 cmdline_fixed_string_t rx_offload; 15589 cmdline_fixed_string_t capabilities; 15590 }; 15591 15592 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 15593 TOKEN_STRING_INITIALIZER 15594 (struct cmd_rx_offload_get_capa_result, 15595 show, "show"); 15596 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 15597 TOKEN_STRING_INITIALIZER 15598 (struct cmd_rx_offload_get_capa_result, 15599 port, "port"); 15600 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 15601 TOKEN_NUM_INITIALIZER 15602 (struct cmd_rx_offload_get_capa_result, 15603 port_id, RTE_UINT16); 15604 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 15605 TOKEN_STRING_INITIALIZER 15606 (struct cmd_rx_offload_get_capa_result, 15607 rx_offload, "rx_offload"); 15608 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 15609 TOKEN_STRING_INITIALIZER 15610 (struct cmd_rx_offload_get_capa_result, 15611 capabilities, "capabilities"); 15612 15613 static void 15614 print_rx_offloads(uint64_t offloads) 15615 { 15616 uint64_t single_offload; 15617 int begin; 15618 int end; 15619 int bit; 15620 15621 if (offloads == 0) 15622 return; 15623 15624 begin = __builtin_ctzll(offloads); 15625 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 15626 15627 single_offload = 1ULL << begin; 15628 for (bit = begin; bit < end; bit++) { 15629 if (offloads & single_offload) 15630 printf(" %s", 15631 rte_eth_dev_rx_offload_name(single_offload)); 15632 single_offload <<= 1; 15633 } 15634 } 15635 15636 static void 15637 cmd_rx_offload_get_capa_parsed( 15638 void *parsed_result, 15639 __rte_unused struct cmdline *cl, 15640 __rte_unused void *data) 15641 { 15642 struct cmd_rx_offload_get_capa_result *res = parsed_result; 15643 struct rte_eth_dev_info dev_info; 15644 portid_t port_id = res->port_id; 15645 uint64_t queue_offloads; 15646 uint64_t port_offloads; 15647 int ret; 15648 15649 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15650 if (ret != 0) 15651 return; 15652 15653 queue_offloads = dev_info.rx_queue_offload_capa; 15654 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 15655 15656 printf("Rx Offloading Capabilities of port %d :\n", port_id); 15657 printf(" Per Queue :"); 15658 print_rx_offloads(queue_offloads); 15659 15660 printf("\n"); 15661 printf(" Per Port :"); 15662 print_rx_offloads(port_offloads); 15663 printf("\n\n"); 15664 } 15665 15666 cmdline_parse_inst_t cmd_rx_offload_get_capa = { 15667 .f = cmd_rx_offload_get_capa_parsed, 15668 .data = NULL, 15669 .help_str = "show port <port_id> rx_offload capabilities", 15670 .tokens = { 15671 (void *)&cmd_rx_offload_get_capa_show, 15672 (void *)&cmd_rx_offload_get_capa_port, 15673 (void *)&cmd_rx_offload_get_capa_port_id, 15674 (void *)&cmd_rx_offload_get_capa_rx_offload, 15675 (void *)&cmd_rx_offload_get_capa_capabilities, 15676 NULL, 15677 } 15678 }; 15679 15680 /* Get Rx offloads configuration */ 15681 struct cmd_rx_offload_get_configuration_result { 15682 cmdline_fixed_string_t show; 15683 cmdline_fixed_string_t port; 15684 portid_t port_id; 15685 cmdline_fixed_string_t rx_offload; 15686 cmdline_fixed_string_t configuration; 15687 }; 15688 15689 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 15690 TOKEN_STRING_INITIALIZER 15691 (struct cmd_rx_offload_get_configuration_result, 15692 show, "show"); 15693 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 15694 TOKEN_STRING_INITIALIZER 15695 (struct cmd_rx_offload_get_configuration_result, 15696 port, "port"); 15697 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 15698 TOKEN_NUM_INITIALIZER 15699 (struct cmd_rx_offload_get_configuration_result, 15700 port_id, RTE_UINT16); 15701 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 15702 TOKEN_STRING_INITIALIZER 15703 (struct cmd_rx_offload_get_configuration_result, 15704 rx_offload, "rx_offload"); 15705 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 15706 TOKEN_STRING_INITIALIZER 15707 (struct cmd_rx_offload_get_configuration_result, 15708 configuration, "configuration"); 15709 15710 static void 15711 cmd_rx_offload_get_configuration_parsed( 15712 void *parsed_result, 15713 __rte_unused struct cmdline *cl, 15714 __rte_unused void *data) 15715 { 15716 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 15717 struct rte_eth_dev_info dev_info; 15718 portid_t port_id = res->port_id; 15719 struct rte_port *port = &ports[port_id]; 15720 uint64_t port_offloads; 15721 uint64_t queue_offloads; 15722 uint16_t nb_rx_queues; 15723 int q; 15724 int ret; 15725 15726 printf("Rx Offloading Configuration of port %d :\n", port_id); 15727 15728 port_offloads = port->dev_conf.rxmode.offloads; 15729 printf(" Port :"); 15730 print_rx_offloads(port_offloads); 15731 printf("\n"); 15732 15733 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15734 if (ret != 0) 15735 return; 15736 15737 nb_rx_queues = dev_info.nb_rx_queues; 15738 for (q = 0; q < nb_rx_queues; q++) { 15739 queue_offloads = port->rx_conf[q].offloads; 15740 printf(" Queue[%2d] :", q); 15741 print_rx_offloads(queue_offloads); 15742 printf("\n"); 15743 } 15744 printf("\n"); 15745 } 15746 15747 cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 15748 .f = cmd_rx_offload_get_configuration_parsed, 15749 .data = NULL, 15750 .help_str = "show port <port_id> rx_offload configuration", 15751 .tokens = { 15752 (void *)&cmd_rx_offload_get_configuration_show, 15753 (void *)&cmd_rx_offload_get_configuration_port, 15754 (void *)&cmd_rx_offload_get_configuration_port_id, 15755 (void *)&cmd_rx_offload_get_configuration_rx_offload, 15756 (void *)&cmd_rx_offload_get_configuration_configuration, 15757 NULL, 15758 } 15759 }; 15760 15761 /* Enable/Disable a per port offloading */ 15762 struct cmd_config_per_port_rx_offload_result { 15763 cmdline_fixed_string_t port; 15764 cmdline_fixed_string_t config; 15765 portid_t port_id; 15766 cmdline_fixed_string_t rx_offload; 15767 cmdline_fixed_string_t offload; 15768 cmdline_fixed_string_t on_off; 15769 }; 15770 15771 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 15772 TOKEN_STRING_INITIALIZER 15773 (struct cmd_config_per_port_rx_offload_result, 15774 port, "port"); 15775 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 15776 TOKEN_STRING_INITIALIZER 15777 (struct cmd_config_per_port_rx_offload_result, 15778 config, "config"); 15779 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 15780 TOKEN_NUM_INITIALIZER 15781 (struct cmd_config_per_port_rx_offload_result, 15782 port_id, RTE_UINT16); 15783 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 15784 TOKEN_STRING_INITIALIZER 15785 (struct cmd_config_per_port_rx_offload_result, 15786 rx_offload, "rx_offload"); 15787 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 15788 TOKEN_STRING_INITIALIZER 15789 (struct cmd_config_per_port_rx_offload_result, 15790 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 15791 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 15792 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 15793 "scatter#buffer_split#timestamp#security#" 15794 "keep_crc#rss_hash"); 15795 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 15796 TOKEN_STRING_INITIALIZER 15797 (struct cmd_config_per_port_rx_offload_result, 15798 on_off, "on#off"); 15799 15800 static uint64_t 15801 search_rx_offload(const char *name) 15802 { 15803 uint64_t single_offload; 15804 const char *single_name; 15805 int found = 0; 15806 unsigned int bit; 15807 15808 single_offload = 1; 15809 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 15810 single_name = rte_eth_dev_rx_offload_name(single_offload); 15811 if (!strcasecmp(single_name, name)) { 15812 found = 1; 15813 break; 15814 } 15815 single_offload <<= 1; 15816 } 15817 15818 if (found) 15819 return single_offload; 15820 15821 return 0; 15822 } 15823 15824 static void 15825 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 15826 __rte_unused struct cmdline *cl, 15827 __rte_unused void *data) 15828 { 15829 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 15830 portid_t port_id = res->port_id; 15831 struct rte_eth_dev_info dev_info; 15832 struct rte_port *port = &ports[port_id]; 15833 uint64_t single_offload; 15834 uint16_t nb_rx_queues; 15835 int q; 15836 int ret; 15837 15838 if (port->port_status != RTE_PORT_STOPPED) { 15839 fprintf(stderr, 15840 "Error: Can't config offload when Port %d is not stopped\n", 15841 port_id); 15842 return; 15843 } 15844 15845 single_offload = search_rx_offload(res->offload); 15846 if (single_offload == 0) { 15847 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 15848 return; 15849 } 15850 15851 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15852 if (ret != 0) 15853 return; 15854 15855 nb_rx_queues = dev_info.nb_rx_queues; 15856 if (!strcmp(res->on_off, "on")) { 15857 port->dev_conf.rxmode.offloads |= single_offload; 15858 for (q = 0; q < nb_rx_queues; q++) 15859 port->rx_conf[q].offloads |= single_offload; 15860 } else { 15861 port->dev_conf.rxmode.offloads &= ~single_offload; 15862 for (q = 0; q < nb_rx_queues; q++) 15863 port->rx_conf[q].offloads &= ~single_offload; 15864 } 15865 15866 cmd_reconfig_device_queue(port_id, 1, 1); 15867 } 15868 15869 cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 15870 .f = cmd_config_per_port_rx_offload_parsed, 15871 .data = NULL, 15872 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 15873 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 15874 "macsec_strip|header_split|vlan_filter|vlan_extend|" 15875 "jumbo_frame|scatter|buffer_split|timestamp|security|" 15876 "keep_crc|rss_hash on|off", 15877 .tokens = { 15878 (void *)&cmd_config_per_port_rx_offload_result_port, 15879 (void *)&cmd_config_per_port_rx_offload_result_config, 15880 (void *)&cmd_config_per_port_rx_offload_result_port_id, 15881 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 15882 (void *)&cmd_config_per_port_rx_offload_result_offload, 15883 (void *)&cmd_config_per_port_rx_offload_result_on_off, 15884 NULL, 15885 } 15886 }; 15887 15888 /* Enable/Disable a per queue offloading */ 15889 struct cmd_config_per_queue_rx_offload_result { 15890 cmdline_fixed_string_t port; 15891 portid_t port_id; 15892 cmdline_fixed_string_t rxq; 15893 uint16_t queue_id; 15894 cmdline_fixed_string_t rx_offload; 15895 cmdline_fixed_string_t offload; 15896 cmdline_fixed_string_t on_off; 15897 }; 15898 15899 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 15900 TOKEN_STRING_INITIALIZER 15901 (struct cmd_config_per_queue_rx_offload_result, 15902 port, "port"); 15903 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 15904 TOKEN_NUM_INITIALIZER 15905 (struct cmd_config_per_queue_rx_offload_result, 15906 port_id, RTE_UINT16); 15907 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 15908 TOKEN_STRING_INITIALIZER 15909 (struct cmd_config_per_queue_rx_offload_result, 15910 rxq, "rxq"); 15911 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 15912 TOKEN_NUM_INITIALIZER 15913 (struct cmd_config_per_queue_rx_offload_result, 15914 queue_id, RTE_UINT16); 15915 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 15916 TOKEN_STRING_INITIALIZER 15917 (struct cmd_config_per_queue_rx_offload_result, 15918 rx_offload, "rx_offload"); 15919 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 15920 TOKEN_STRING_INITIALIZER 15921 (struct cmd_config_per_queue_rx_offload_result, 15922 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 15923 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 15924 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 15925 "scatter#buffer_split#timestamp#security#keep_crc"); 15926 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 15927 TOKEN_STRING_INITIALIZER 15928 (struct cmd_config_per_queue_rx_offload_result, 15929 on_off, "on#off"); 15930 15931 static void 15932 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 15933 __rte_unused struct cmdline *cl, 15934 __rte_unused void *data) 15935 { 15936 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 15937 struct rte_eth_dev_info dev_info; 15938 portid_t port_id = res->port_id; 15939 uint16_t queue_id = res->queue_id; 15940 struct rte_port *port = &ports[port_id]; 15941 uint64_t single_offload; 15942 int ret; 15943 15944 if (port->port_status != RTE_PORT_STOPPED) { 15945 fprintf(stderr, 15946 "Error: Can't config offload when Port %d is not stopped\n", 15947 port_id); 15948 return; 15949 } 15950 15951 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15952 if (ret != 0) 15953 return; 15954 15955 if (queue_id >= dev_info.nb_rx_queues) { 15956 fprintf(stderr, 15957 "Error: input queue_id should be 0 ... %d\n", 15958 dev_info.nb_rx_queues - 1); 15959 return; 15960 } 15961 15962 single_offload = search_rx_offload(res->offload); 15963 if (single_offload == 0) { 15964 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 15965 return; 15966 } 15967 15968 if (!strcmp(res->on_off, "on")) 15969 port->rx_conf[queue_id].offloads |= single_offload; 15970 else 15971 port->rx_conf[queue_id].offloads &= ~single_offload; 15972 15973 cmd_reconfig_device_queue(port_id, 1, 1); 15974 } 15975 15976 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 15977 .f = cmd_config_per_queue_rx_offload_parsed, 15978 .data = NULL, 15979 .help_str = "port <port_id> rxq <queue_id> rx_offload " 15980 "vlan_strip|ipv4_cksum|" 15981 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 15982 "macsec_strip|header_split|vlan_filter|vlan_extend|" 15983 "jumbo_frame|scatter|buffer_split|timestamp|security|" 15984 "keep_crc on|off", 15985 .tokens = { 15986 (void *)&cmd_config_per_queue_rx_offload_result_port, 15987 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 15988 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 15989 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 15990 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 15991 (void *)&cmd_config_per_queue_rx_offload_result_offload, 15992 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 15993 NULL, 15994 } 15995 }; 15996 15997 /* Get Tx offloads capabilities */ 15998 struct cmd_tx_offload_get_capa_result { 15999 cmdline_fixed_string_t show; 16000 cmdline_fixed_string_t port; 16001 portid_t port_id; 16002 cmdline_fixed_string_t tx_offload; 16003 cmdline_fixed_string_t capabilities; 16004 }; 16005 16006 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 16007 TOKEN_STRING_INITIALIZER 16008 (struct cmd_tx_offload_get_capa_result, 16009 show, "show"); 16010 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 16011 TOKEN_STRING_INITIALIZER 16012 (struct cmd_tx_offload_get_capa_result, 16013 port, "port"); 16014 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 16015 TOKEN_NUM_INITIALIZER 16016 (struct cmd_tx_offload_get_capa_result, 16017 port_id, RTE_UINT16); 16018 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 16019 TOKEN_STRING_INITIALIZER 16020 (struct cmd_tx_offload_get_capa_result, 16021 tx_offload, "tx_offload"); 16022 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 16023 TOKEN_STRING_INITIALIZER 16024 (struct cmd_tx_offload_get_capa_result, 16025 capabilities, "capabilities"); 16026 16027 static void 16028 print_tx_offloads(uint64_t offloads) 16029 { 16030 uint64_t single_offload; 16031 int begin; 16032 int end; 16033 int bit; 16034 16035 if (offloads == 0) 16036 return; 16037 16038 begin = __builtin_ctzll(offloads); 16039 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 16040 16041 single_offload = 1ULL << begin; 16042 for (bit = begin; bit < end; bit++) { 16043 if (offloads & single_offload) 16044 printf(" %s", 16045 rte_eth_dev_tx_offload_name(single_offload)); 16046 single_offload <<= 1; 16047 } 16048 } 16049 16050 static void 16051 cmd_tx_offload_get_capa_parsed( 16052 void *parsed_result, 16053 __rte_unused struct cmdline *cl, 16054 __rte_unused void *data) 16055 { 16056 struct cmd_tx_offload_get_capa_result *res = parsed_result; 16057 struct rte_eth_dev_info dev_info; 16058 portid_t port_id = res->port_id; 16059 uint64_t queue_offloads; 16060 uint64_t port_offloads; 16061 int ret; 16062 16063 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16064 if (ret != 0) 16065 return; 16066 16067 queue_offloads = dev_info.tx_queue_offload_capa; 16068 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 16069 16070 printf("Tx Offloading Capabilities of port %d :\n", port_id); 16071 printf(" Per Queue :"); 16072 print_tx_offloads(queue_offloads); 16073 16074 printf("\n"); 16075 printf(" Per Port :"); 16076 print_tx_offloads(port_offloads); 16077 printf("\n\n"); 16078 } 16079 16080 cmdline_parse_inst_t cmd_tx_offload_get_capa = { 16081 .f = cmd_tx_offload_get_capa_parsed, 16082 .data = NULL, 16083 .help_str = "show port <port_id> tx_offload capabilities", 16084 .tokens = { 16085 (void *)&cmd_tx_offload_get_capa_show, 16086 (void *)&cmd_tx_offload_get_capa_port, 16087 (void *)&cmd_tx_offload_get_capa_port_id, 16088 (void *)&cmd_tx_offload_get_capa_tx_offload, 16089 (void *)&cmd_tx_offload_get_capa_capabilities, 16090 NULL, 16091 } 16092 }; 16093 16094 /* Get Tx offloads configuration */ 16095 struct cmd_tx_offload_get_configuration_result { 16096 cmdline_fixed_string_t show; 16097 cmdline_fixed_string_t port; 16098 portid_t port_id; 16099 cmdline_fixed_string_t tx_offload; 16100 cmdline_fixed_string_t configuration; 16101 }; 16102 16103 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 16104 TOKEN_STRING_INITIALIZER 16105 (struct cmd_tx_offload_get_configuration_result, 16106 show, "show"); 16107 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 16108 TOKEN_STRING_INITIALIZER 16109 (struct cmd_tx_offload_get_configuration_result, 16110 port, "port"); 16111 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 16112 TOKEN_NUM_INITIALIZER 16113 (struct cmd_tx_offload_get_configuration_result, 16114 port_id, RTE_UINT16); 16115 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 16116 TOKEN_STRING_INITIALIZER 16117 (struct cmd_tx_offload_get_configuration_result, 16118 tx_offload, "tx_offload"); 16119 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 16120 TOKEN_STRING_INITIALIZER 16121 (struct cmd_tx_offload_get_configuration_result, 16122 configuration, "configuration"); 16123 16124 static void 16125 cmd_tx_offload_get_configuration_parsed( 16126 void *parsed_result, 16127 __rte_unused struct cmdline *cl, 16128 __rte_unused void *data) 16129 { 16130 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 16131 struct rte_eth_dev_info dev_info; 16132 portid_t port_id = res->port_id; 16133 struct rte_port *port = &ports[port_id]; 16134 uint64_t port_offloads; 16135 uint64_t queue_offloads; 16136 uint16_t nb_tx_queues; 16137 int q; 16138 int ret; 16139 16140 printf("Tx Offloading Configuration of port %d :\n", port_id); 16141 16142 port_offloads = port->dev_conf.txmode.offloads; 16143 printf(" Port :"); 16144 print_tx_offloads(port_offloads); 16145 printf("\n"); 16146 16147 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16148 if (ret != 0) 16149 return; 16150 16151 nb_tx_queues = dev_info.nb_tx_queues; 16152 for (q = 0; q < nb_tx_queues; q++) { 16153 queue_offloads = port->tx_conf[q].offloads; 16154 printf(" Queue[%2d] :", q); 16155 print_tx_offloads(queue_offloads); 16156 printf("\n"); 16157 } 16158 printf("\n"); 16159 } 16160 16161 cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 16162 .f = cmd_tx_offload_get_configuration_parsed, 16163 .data = NULL, 16164 .help_str = "show port <port_id> tx_offload configuration", 16165 .tokens = { 16166 (void *)&cmd_tx_offload_get_configuration_show, 16167 (void *)&cmd_tx_offload_get_configuration_port, 16168 (void *)&cmd_tx_offload_get_configuration_port_id, 16169 (void *)&cmd_tx_offload_get_configuration_tx_offload, 16170 (void *)&cmd_tx_offload_get_configuration_configuration, 16171 NULL, 16172 } 16173 }; 16174 16175 /* Enable/Disable a per port offloading */ 16176 struct cmd_config_per_port_tx_offload_result { 16177 cmdline_fixed_string_t port; 16178 cmdline_fixed_string_t config; 16179 portid_t port_id; 16180 cmdline_fixed_string_t tx_offload; 16181 cmdline_fixed_string_t offload; 16182 cmdline_fixed_string_t on_off; 16183 }; 16184 16185 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 16186 TOKEN_STRING_INITIALIZER 16187 (struct cmd_config_per_port_tx_offload_result, 16188 port, "port"); 16189 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 16190 TOKEN_STRING_INITIALIZER 16191 (struct cmd_config_per_port_tx_offload_result, 16192 config, "config"); 16193 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 16194 TOKEN_NUM_INITIALIZER 16195 (struct cmd_config_per_port_tx_offload_result, 16196 port_id, RTE_UINT16); 16197 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 16198 TOKEN_STRING_INITIALIZER 16199 (struct cmd_config_per_port_tx_offload_result, 16200 tx_offload, "tx_offload"); 16201 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 16202 TOKEN_STRING_INITIALIZER 16203 (struct cmd_config_per_port_tx_offload_result, 16204 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 16205 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 16206 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 16207 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 16208 "mt_lockfree#multi_segs#mbuf_fast_free#security#" 16209 "send_on_timestamp"); 16210 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = 16211 TOKEN_STRING_INITIALIZER 16212 (struct cmd_config_per_port_tx_offload_result, 16213 on_off, "on#off"); 16214 16215 static uint64_t 16216 search_tx_offload(const char *name) 16217 { 16218 uint64_t single_offload; 16219 const char *single_name; 16220 int found = 0; 16221 unsigned int bit; 16222 16223 single_offload = 1; 16224 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 16225 single_name = rte_eth_dev_tx_offload_name(single_offload); 16226 if (single_name == NULL) 16227 break; 16228 if (!strcasecmp(single_name, name)) { 16229 found = 1; 16230 break; 16231 } else if (!strcasecmp(single_name, "UNKNOWN")) 16232 break; 16233 single_offload <<= 1; 16234 } 16235 16236 if (found) 16237 return single_offload; 16238 16239 return 0; 16240 } 16241 16242 static void 16243 cmd_config_per_port_tx_offload_parsed(void *parsed_result, 16244 __rte_unused struct cmdline *cl, 16245 __rte_unused void *data) 16246 { 16247 struct cmd_config_per_port_tx_offload_result *res = parsed_result; 16248 portid_t port_id = res->port_id; 16249 struct rte_eth_dev_info dev_info; 16250 struct rte_port *port = &ports[port_id]; 16251 uint64_t single_offload; 16252 uint16_t nb_tx_queues; 16253 int q; 16254 int ret; 16255 16256 if (port->port_status != RTE_PORT_STOPPED) { 16257 fprintf(stderr, 16258 "Error: Can't config offload when Port %d is not stopped\n", 16259 port_id); 16260 return; 16261 } 16262 16263 single_offload = search_tx_offload(res->offload); 16264 if (single_offload == 0) { 16265 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 16266 return; 16267 } 16268 16269 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16270 if (ret != 0) 16271 return; 16272 16273 nb_tx_queues = dev_info.nb_tx_queues; 16274 if (!strcmp(res->on_off, "on")) { 16275 port->dev_conf.txmode.offloads |= single_offload; 16276 for (q = 0; q < nb_tx_queues; q++) 16277 port->tx_conf[q].offloads |= single_offload; 16278 } else { 16279 port->dev_conf.txmode.offloads &= ~single_offload; 16280 for (q = 0; q < nb_tx_queues; q++) 16281 port->tx_conf[q].offloads &= ~single_offload; 16282 } 16283 16284 cmd_reconfig_device_queue(port_id, 1, 1); 16285 } 16286 16287 cmdline_parse_inst_t cmd_config_per_port_tx_offload = { 16288 .f = cmd_config_per_port_tx_offload_parsed, 16289 .data = NULL, 16290 .help_str = "port config <port_id> tx_offload " 16291 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 16292 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 16293 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 16294 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 16295 "mt_lockfree|multi_segs|mbuf_fast_free|security|" 16296 "send_on_timestamp on|off", 16297 .tokens = { 16298 (void *)&cmd_config_per_port_tx_offload_result_port, 16299 (void *)&cmd_config_per_port_tx_offload_result_config, 16300 (void *)&cmd_config_per_port_tx_offload_result_port_id, 16301 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 16302 (void *)&cmd_config_per_port_tx_offload_result_offload, 16303 (void *)&cmd_config_per_port_tx_offload_result_on_off, 16304 NULL, 16305 } 16306 }; 16307 16308 /* Enable/Disable a per queue offloading */ 16309 struct cmd_config_per_queue_tx_offload_result { 16310 cmdline_fixed_string_t port; 16311 portid_t port_id; 16312 cmdline_fixed_string_t txq; 16313 uint16_t queue_id; 16314 cmdline_fixed_string_t tx_offload; 16315 cmdline_fixed_string_t offload; 16316 cmdline_fixed_string_t on_off; 16317 }; 16318 16319 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 16320 TOKEN_STRING_INITIALIZER 16321 (struct cmd_config_per_queue_tx_offload_result, 16322 port, "port"); 16323 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 16324 TOKEN_NUM_INITIALIZER 16325 (struct cmd_config_per_queue_tx_offload_result, 16326 port_id, RTE_UINT16); 16327 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 16328 TOKEN_STRING_INITIALIZER 16329 (struct cmd_config_per_queue_tx_offload_result, 16330 txq, "txq"); 16331 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 16332 TOKEN_NUM_INITIALIZER 16333 (struct cmd_config_per_queue_tx_offload_result, 16334 queue_id, RTE_UINT16); 16335 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 16336 TOKEN_STRING_INITIALIZER 16337 (struct cmd_config_per_queue_tx_offload_result, 16338 tx_offload, "tx_offload"); 16339 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 16340 TOKEN_STRING_INITIALIZER 16341 (struct cmd_config_per_queue_tx_offload_result, 16342 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 16343 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 16344 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 16345 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 16346 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 16347 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 16348 TOKEN_STRING_INITIALIZER 16349 (struct cmd_config_per_queue_tx_offload_result, 16350 on_off, "on#off"); 16351 16352 static void 16353 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 16354 __rte_unused struct cmdline *cl, 16355 __rte_unused void *data) 16356 { 16357 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 16358 struct rte_eth_dev_info dev_info; 16359 portid_t port_id = res->port_id; 16360 uint16_t queue_id = res->queue_id; 16361 struct rte_port *port = &ports[port_id]; 16362 uint64_t single_offload; 16363 int ret; 16364 16365 if (port->port_status != RTE_PORT_STOPPED) { 16366 fprintf(stderr, 16367 "Error: Can't config offload when Port %d is not stopped\n", 16368 port_id); 16369 return; 16370 } 16371 16372 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16373 if (ret != 0) 16374 return; 16375 16376 if (queue_id >= dev_info.nb_tx_queues) { 16377 fprintf(stderr, 16378 "Error: input queue_id should be 0 ... %d\n", 16379 dev_info.nb_tx_queues - 1); 16380 return; 16381 } 16382 16383 single_offload = search_tx_offload(res->offload); 16384 if (single_offload == 0) { 16385 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 16386 return; 16387 } 16388 16389 if (!strcmp(res->on_off, "on")) 16390 port->tx_conf[queue_id].offloads |= single_offload; 16391 else 16392 port->tx_conf[queue_id].offloads &= ~single_offload; 16393 16394 cmd_reconfig_device_queue(port_id, 1, 1); 16395 } 16396 16397 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 16398 .f = cmd_config_per_queue_tx_offload_parsed, 16399 .data = NULL, 16400 .help_str = "port <port_id> txq <queue_id> tx_offload " 16401 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 16402 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 16403 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 16404 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 16405 "mt_lockfree|multi_segs|mbuf_fast_free|security " 16406 "on|off", 16407 .tokens = { 16408 (void *)&cmd_config_per_queue_tx_offload_result_port, 16409 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 16410 (void *)&cmd_config_per_queue_tx_offload_result_txq, 16411 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 16412 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 16413 (void *)&cmd_config_per_queue_tx_offload_result_offload, 16414 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 16415 NULL, 16416 } 16417 }; 16418 16419 /* *** configure tx_metadata for specific port *** */ 16420 struct cmd_config_tx_metadata_specific_result { 16421 cmdline_fixed_string_t port; 16422 cmdline_fixed_string_t keyword; 16423 uint16_t port_id; 16424 cmdline_fixed_string_t item; 16425 uint32_t value; 16426 }; 16427 16428 static void 16429 cmd_config_tx_metadata_specific_parsed(void *parsed_result, 16430 __rte_unused struct cmdline *cl, 16431 __rte_unused void *data) 16432 { 16433 struct cmd_config_tx_metadata_specific_result *res = parsed_result; 16434 16435 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16436 return; 16437 ports[res->port_id].tx_metadata = res->value; 16438 /* Add/remove callback to insert valid metadata in every Tx packet. */ 16439 if (ports[res->port_id].tx_metadata) 16440 add_tx_md_callback(res->port_id); 16441 else 16442 remove_tx_md_callback(res->port_id); 16443 rte_flow_dynf_metadata_register(); 16444 } 16445 16446 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = 16447 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16448 port, "port"); 16449 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = 16450 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16451 keyword, "config"); 16452 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = 16453 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16454 port_id, RTE_UINT16); 16455 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = 16456 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16457 item, "tx_metadata"); 16458 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = 16459 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16460 value, RTE_UINT32); 16461 16462 cmdline_parse_inst_t cmd_config_tx_metadata_specific = { 16463 .f = cmd_config_tx_metadata_specific_parsed, 16464 .data = NULL, 16465 .help_str = "port config <port_id> tx_metadata <value>", 16466 .tokens = { 16467 (void *)&cmd_config_tx_metadata_specific_port, 16468 (void *)&cmd_config_tx_metadata_specific_keyword, 16469 (void *)&cmd_config_tx_metadata_specific_id, 16470 (void *)&cmd_config_tx_metadata_specific_item, 16471 (void *)&cmd_config_tx_metadata_specific_value, 16472 NULL, 16473 }, 16474 }; 16475 16476 /* *** set dynf *** */ 16477 struct cmd_config_tx_dynf_specific_result { 16478 cmdline_fixed_string_t port; 16479 cmdline_fixed_string_t keyword; 16480 uint16_t port_id; 16481 cmdline_fixed_string_t item; 16482 cmdline_fixed_string_t name; 16483 cmdline_fixed_string_t value; 16484 }; 16485 16486 static void 16487 cmd_config_dynf_specific_parsed(void *parsed_result, 16488 __rte_unused struct cmdline *cl, 16489 __rte_unused void *data) 16490 { 16491 struct cmd_config_tx_dynf_specific_result *res = parsed_result; 16492 struct rte_mbuf_dynflag desc_flag; 16493 int flag; 16494 uint64_t old_port_flags; 16495 16496 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16497 return; 16498 flag = rte_mbuf_dynflag_lookup(res->name, NULL); 16499 if (flag <= 0) { 16500 if (strlcpy(desc_flag.name, res->name, 16501 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) { 16502 fprintf(stderr, "Flag name too long\n"); 16503 return; 16504 } 16505 desc_flag.flags = 0; 16506 flag = rte_mbuf_dynflag_register(&desc_flag); 16507 if (flag < 0) { 16508 fprintf(stderr, "Can't register flag\n"); 16509 return; 16510 } 16511 strcpy(dynf_names[flag], desc_flag.name); 16512 } 16513 old_port_flags = ports[res->port_id].mbuf_dynf; 16514 if (!strcmp(res->value, "set")) { 16515 ports[res->port_id].mbuf_dynf |= 1UL << flag; 16516 if (old_port_flags == 0) 16517 add_tx_dynf_callback(res->port_id); 16518 } else { 16519 ports[res->port_id].mbuf_dynf &= ~(1UL << flag); 16520 if (ports[res->port_id].mbuf_dynf == 0) 16521 remove_tx_dynf_callback(res->port_id); 16522 } 16523 } 16524 16525 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port = 16526 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16527 keyword, "port"); 16528 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword = 16529 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16530 keyword, "config"); 16531 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id = 16532 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16533 port_id, RTE_UINT16); 16534 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item = 16535 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16536 item, "dynf"); 16537 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name = 16538 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16539 name, NULL); 16540 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value = 16541 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16542 value, "set#clear"); 16543 16544 cmdline_parse_inst_t cmd_config_tx_dynf_specific = { 16545 .f = cmd_config_dynf_specific_parsed, 16546 .data = NULL, 16547 .help_str = "port config <port id> dynf <name> set|clear", 16548 .tokens = { 16549 (void *)&cmd_config_tx_dynf_specific_port, 16550 (void *)&cmd_config_tx_dynf_specific_keyword, 16551 (void *)&cmd_config_tx_dynf_specific_port_id, 16552 (void *)&cmd_config_tx_dynf_specific_item, 16553 (void *)&cmd_config_tx_dynf_specific_name, 16554 (void *)&cmd_config_tx_dynf_specific_value, 16555 NULL, 16556 }, 16557 }; 16558 16559 /* *** display tx_metadata per port configuration *** */ 16560 struct cmd_show_tx_metadata_result { 16561 cmdline_fixed_string_t cmd_show; 16562 cmdline_fixed_string_t cmd_port; 16563 cmdline_fixed_string_t cmd_keyword; 16564 portid_t cmd_pid; 16565 }; 16566 16567 static void 16568 cmd_show_tx_metadata_parsed(void *parsed_result, 16569 __rte_unused struct cmdline *cl, 16570 __rte_unused void *data) 16571 { 16572 struct cmd_show_tx_metadata_result *res = parsed_result; 16573 16574 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16575 fprintf(stderr, "invalid port id %u\n", res->cmd_pid); 16576 return; 16577 } 16578 if (!strcmp(res->cmd_keyword, "tx_metadata")) { 16579 printf("Port %u tx_metadata: %u\n", res->cmd_pid, 16580 ports[res->cmd_pid].tx_metadata); 16581 } 16582 } 16583 16584 cmdline_parse_token_string_t cmd_show_tx_metadata_show = 16585 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 16586 cmd_show, "show"); 16587 cmdline_parse_token_string_t cmd_show_tx_metadata_port = 16588 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 16589 cmd_port, "port"); 16590 cmdline_parse_token_num_t cmd_show_tx_metadata_pid = 16591 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, 16592 cmd_pid, RTE_UINT16); 16593 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = 16594 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 16595 cmd_keyword, "tx_metadata"); 16596 16597 cmdline_parse_inst_t cmd_show_tx_metadata = { 16598 .f = cmd_show_tx_metadata_parsed, 16599 .data = NULL, 16600 .help_str = "show port <port_id> tx_metadata", 16601 .tokens = { 16602 (void *)&cmd_show_tx_metadata_show, 16603 (void *)&cmd_show_tx_metadata_port, 16604 (void *)&cmd_show_tx_metadata_pid, 16605 (void *)&cmd_show_tx_metadata_keyword, 16606 NULL, 16607 }, 16608 }; 16609 16610 /* *** show fec capability per port configuration *** */ 16611 struct cmd_show_fec_capability_result { 16612 cmdline_fixed_string_t cmd_show; 16613 cmdline_fixed_string_t cmd_port; 16614 cmdline_fixed_string_t cmd_fec; 16615 cmdline_fixed_string_t cmd_keyword; 16616 portid_t cmd_pid; 16617 }; 16618 16619 static void 16620 cmd_show_fec_capability_parsed(void *parsed_result, 16621 __rte_unused struct cmdline *cl, 16622 __rte_unused void *data) 16623 { 16624 struct cmd_show_fec_capability_result *res = parsed_result; 16625 struct rte_eth_fec_capa *speed_fec_capa; 16626 unsigned int num; 16627 int ret; 16628 16629 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16630 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid); 16631 return; 16632 } 16633 16634 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0); 16635 if (ret == -ENOTSUP) { 16636 fprintf(stderr, "Function not implemented\n"); 16637 return; 16638 } else if (ret < 0) { 16639 fprintf(stderr, "Get FEC capability failed: %d\n", ret); 16640 return; 16641 } 16642 16643 num = (unsigned int)ret; 16644 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa)); 16645 if (speed_fec_capa == NULL) { 16646 fprintf(stderr, "Failed to alloc FEC capability buffer\n"); 16647 return; 16648 } 16649 16650 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num); 16651 if (ret < 0) { 16652 fprintf(stderr, "Error getting FEC capability: %d\n", ret); 16653 goto out; 16654 } 16655 16656 show_fec_capability(num, speed_fec_capa); 16657 out: 16658 free(speed_fec_capa); 16659 } 16660 16661 cmdline_parse_token_string_t cmd_show_fec_capability_show = 16662 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16663 cmd_show, "show"); 16664 cmdline_parse_token_string_t cmd_show_fec_capability_port = 16665 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16666 cmd_port, "port"); 16667 cmdline_parse_token_num_t cmd_show_fec_capability_pid = 16668 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result, 16669 cmd_pid, RTE_UINT16); 16670 cmdline_parse_token_string_t cmd_show_fec_capability_fec = 16671 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16672 cmd_fec, "fec"); 16673 cmdline_parse_token_string_t cmd_show_fec_capability_keyword = 16674 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16675 cmd_keyword, "capabilities"); 16676 16677 cmdline_parse_inst_t cmd_show_capability = { 16678 .f = cmd_show_fec_capability_parsed, 16679 .data = NULL, 16680 .help_str = "show port <port_id> fec capabilities", 16681 .tokens = { 16682 (void *)&cmd_show_fec_capability_show, 16683 (void *)&cmd_show_fec_capability_port, 16684 (void *)&cmd_show_fec_capability_pid, 16685 (void *)&cmd_show_fec_capability_fec, 16686 (void *)&cmd_show_fec_capability_keyword, 16687 NULL, 16688 }, 16689 }; 16690 16691 /* *** show fec mode per port configuration *** */ 16692 struct cmd_show_fec_metadata_result { 16693 cmdline_fixed_string_t cmd_show; 16694 cmdline_fixed_string_t cmd_port; 16695 cmdline_fixed_string_t cmd_keyword; 16696 portid_t cmd_pid; 16697 }; 16698 16699 static void 16700 cmd_show_fec_mode_parsed(void *parsed_result, 16701 __rte_unused struct cmdline *cl, 16702 __rte_unused void *data) 16703 { 16704 #define FEC_NAME_SIZE 16 16705 struct cmd_show_fec_metadata_result *res = parsed_result; 16706 uint32_t mode; 16707 char buf[FEC_NAME_SIZE]; 16708 int ret; 16709 16710 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16711 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid); 16712 return; 16713 } 16714 ret = rte_eth_fec_get(res->cmd_pid, &mode); 16715 if (ret == -ENOTSUP) { 16716 fprintf(stderr, "Function not implemented\n"); 16717 return; 16718 } else if (ret < 0) { 16719 fprintf(stderr, "Get FEC mode failed\n"); 16720 return; 16721 } 16722 16723 switch (mode) { 16724 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC): 16725 strlcpy(buf, "off", sizeof(buf)); 16726 break; 16727 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO): 16728 strlcpy(buf, "auto", sizeof(buf)); 16729 break; 16730 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER): 16731 strlcpy(buf, "baser", sizeof(buf)); 16732 break; 16733 case RTE_ETH_FEC_MODE_CAPA_MASK(RS): 16734 strlcpy(buf, "rs", sizeof(buf)); 16735 break; 16736 default: 16737 return; 16738 } 16739 16740 printf("%s\n", buf); 16741 } 16742 16743 cmdline_parse_token_string_t cmd_show_fec_mode_show = 16744 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 16745 cmd_show, "show"); 16746 cmdline_parse_token_string_t cmd_show_fec_mode_port = 16747 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 16748 cmd_port, "port"); 16749 cmdline_parse_token_num_t cmd_show_fec_mode_pid = 16750 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result, 16751 cmd_pid, RTE_UINT16); 16752 cmdline_parse_token_string_t cmd_show_fec_mode_keyword = 16753 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 16754 cmd_keyword, "fec_mode"); 16755 16756 cmdline_parse_inst_t cmd_show_fec_mode = { 16757 .f = cmd_show_fec_mode_parsed, 16758 .data = NULL, 16759 .help_str = "show port <port_id> fec_mode", 16760 .tokens = { 16761 (void *)&cmd_show_fec_mode_show, 16762 (void *)&cmd_show_fec_mode_port, 16763 (void *)&cmd_show_fec_mode_pid, 16764 (void *)&cmd_show_fec_mode_keyword, 16765 NULL, 16766 }, 16767 }; 16768 16769 /* *** set fec mode per port configuration *** */ 16770 struct cmd_set_port_fec_mode { 16771 cmdline_fixed_string_t set; 16772 cmdline_fixed_string_t port; 16773 portid_t port_id; 16774 cmdline_fixed_string_t fec_mode; 16775 cmdline_fixed_string_t fec_value; 16776 }; 16777 16778 /* Common CLI fields for set fec mode */ 16779 cmdline_parse_token_string_t cmd_set_port_fec_mode_set = 16780 TOKEN_STRING_INITIALIZER 16781 (struct cmd_set_port_fec_mode, 16782 set, "set"); 16783 cmdline_parse_token_string_t cmd_set_port_fec_mode_port = 16784 TOKEN_STRING_INITIALIZER 16785 (struct cmd_set_port_fec_mode, 16786 port, "port"); 16787 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id = 16788 TOKEN_NUM_INITIALIZER 16789 (struct cmd_set_port_fec_mode, 16790 port_id, RTE_UINT16); 16791 cmdline_parse_token_string_t cmd_set_port_fec_mode_str = 16792 TOKEN_STRING_INITIALIZER 16793 (struct cmd_set_port_fec_mode, 16794 fec_mode, "fec_mode"); 16795 cmdline_parse_token_string_t cmd_set_port_fec_mode_value = 16796 TOKEN_STRING_INITIALIZER 16797 (struct cmd_set_port_fec_mode, 16798 fec_value, NULL); 16799 16800 static void 16801 cmd_set_port_fec_mode_parsed( 16802 void *parsed_result, 16803 __rte_unused struct cmdline *cl, 16804 __rte_unused void *data) 16805 { 16806 struct cmd_set_port_fec_mode *res = parsed_result; 16807 uint16_t port_id = res->port_id; 16808 uint32_t fec_capa; 16809 int ret; 16810 16811 ret = parse_fec_mode(res->fec_value, &fec_capa); 16812 if (ret < 0) { 16813 fprintf(stderr, "Unknown fec mode: %s for port %d\n", 16814 res->fec_value, port_id); 16815 return; 16816 } 16817 16818 ret = rte_eth_fec_set(port_id, fec_capa); 16819 if (ret == -ENOTSUP) { 16820 fprintf(stderr, "Function not implemented\n"); 16821 return; 16822 } else if (ret < 0) { 16823 fprintf(stderr, "Set FEC mode failed\n"); 16824 return; 16825 } 16826 } 16827 16828 cmdline_parse_inst_t cmd_set_fec_mode = { 16829 .f = cmd_set_port_fec_mode_parsed, 16830 .data = NULL, 16831 .help_str = "set port <port_id> fec_mode auto|off|rs|baser", 16832 .tokens = { 16833 (void *)&cmd_set_port_fec_mode_set, 16834 (void *)&cmd_set_port_fec_mode_port, 16835 (void *)&cmd_set_port_fec_mode_port_id, 16836 (void *)&cmd_set_port_fec_mode_str, 16837 (void *)&cmd_set_port_fec_mode_value, 16838 NULL, 16839 }, 16840 }; 16841 16842 /* show port supported ptypes */ 16843 16844 /* Common result structure for show port ptypes */ 16845 struct cmd_show_port_supported_ptypes_result { 16846 cmdline_fixed_string_t show; 16847 cmdline_fixed_string_t port; 16848 portid_t port_id; 16849 cmdline_fixed_string_t ptypes; 16850 }; 16851 16852 /* Common CLI fields for show port ptypes */ 16853 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show = 16854 TOKEN_STRING_INITIALIZER 16855 (struct cmd_show_port_supported_ptypes_result, 16856 show, "show"); 16857 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port = 16858 TOKEN_STRING_INITIALIZER 16859 (struct cmd_show_port_supported_ptypes_result, 16860 port, "port"); 16861 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id = 16862 TOKEN_NUM_INITIALIZER 16863 (struct cmd_show_port_supported_ptypes_result, 16864 port_id, RTE_UINT16); 16865 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes = 16866 TOKEN_STRING_INITIALIZER 16867 (struct cmd_show_port_supported_ptypes_result, 16868 ptypes, "ptypes"); 16869 16870 static void 16871 cmd_show_port_supported_ptypes_parsed( 16872 void *parsed_result, 16873 __rte_unused struct cmdline *cl, 16874 __rte_unused void *data) 16875 { 16876 #define RSVD_PTYPE_MASK 0xf0000000 16877 #define MAX_PTYPES_PER_LAYER 16 16878 #define LTYPE_NAMESIZE 32 16879 #define PTYPE_NAMESIZE 256 16880 struct cmd_show_port_supported_ptypes_result *res = parsed_result; 16881 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE]; 16882 uint32_t ptype_mask = RTE_PTYPE_L2_MASK; 16883 uint32_t ptypes[MAX_PTYPES_PER_LAYER]; 16884 uint16_t port_id = res->port_id; 16885 int ret, i; 16886 16887 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0); 16888 if (ret < 0) 16889 return; 16890 16891 while (ptype_mask != RSVD_PTYPE_MASK) { 16892 16893 switch (ptype_mask) { 16894 case RTE_PTYPE_L2_MASK: 16895 strlcpy(ltype, "L2", sizeof(ltype)); 16896 break; 16897 case RTE_PTYPE_L3_MASK: 16898 strlcpy(ltype, "L3", sizeof(ltype)); 16899 break; 16900 case RTE_PTYPE_L4_MASK: 16901 strlcpy(ltype, "L4", sizeof(ltype)); 16902 break; 16903 case RTE_PTYPE_TUNNEL_MASK: 16904 strlcpy(ltype, "Tunnel", sizeof(ltype)); 16905 break; 16906 case RTE_PTYPE_INNER_L2_MASK: 16907 strlcpy(ltype, "Inner L2", sizeof(ltype)); 16908 break; 16909 case RTE_PTYPE_INNER_L3_MASK: 16910 strlcpy(ltype, "Inner L3", sizeof(ltype)); 16911 break; 16912 case RTE_PTYPE_INNER_L4_MASK: 16913 strlcpy(ltype, "Inner L4", sizeof(ltype)); 16914 break; 16915 default: 16916 return; 16917 } 16918 16919 ret = rte_eth_dev_get_supported_ptypes(res->port_id, 16920 ptype_mask, ptypes, 16921 MAX_PTYPES_PER_LAYER); 16922 16923 if (ret > 0) 16924 printf("Supported %s ptypes:\n", ltype); 16925 else 16926 printf("%s ptypes unsupported\n", ltype); 16927 16928 for (i = 0; i < ret; ++i) { 16929 rte_get_ptype_name(ptypes[i], buf, sizeof(buf)); 16930 printf("%s\n", buf); 16931 } 16932 16933 ptype_mask <<= 4; 16934 } 16935 } 16936 16937 cmdline_parse_inst_t cmd_show_port_supported_ptypes = { 16938 .f = cmd_show_port_supported_ptypes_parsed, 16939 .data = NULL, 16940 .help_str = "show port <port_id> ptypes", 16941 .tokens = { 16942 (void *)&cmd_show_port_supported_ptypes_show, 16943 (void *)&cmd_show_port_supported_ptypes_port, 16944 (void *)&cmd_show_port_supported_ptypes_port_id, 16945 (void *)&cmd_show_port_supported_ptypes_ptypes, 16946 NULL, 16947 }, 16948 }; 16949 16950 /* *** display rx/tx descriptor status *** */ 16951 struct cmd_show_rx_tx_desc_status_result { 16952 cmdline_fixed_string_t cmd_show; 16953 cmdline_fixed_string_t cmd_port; 16954 cmdline_fixed_string_t cmd_keyword; 16955 cmdline_fixed_string_t cmd_desc; 16956 cmdline_fixed_string_t cmd_status; 16957 portid_t cmd_pid; 16958 portid_t cmd_qid; 16959 portid_t cmd_did; 16960 }; 16961 16962 static void 16963 cmd_show_rx_tx_desc_status_parsed(void *parsed_result, 16964 __rte_unused struct cmdline *cl, 16965 __rte_unused void *data) 16966 { 16967 struct cmd_show_rx_tx_desc_status_result *res = parsed_result; 16968 int rc; 16969 16970 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16971 fprintf(stderr, "invalid port id %u\n", res->cmd_pid); 16972 return; 16973 } 16974 16975 if (!strcmp(res->cmd_keyword, "rxq")) { 16976 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid, 16977 res->cmd_did); 16978 if (rc < 0) { 16979 fprintf(stderr, 16980 "Invalid input: queue id = %d, desc id = %d\n", 16981 res->cmd_qid, res->cmd_did); 16982 return; 16983 } 16984 if (rc == RTE_ETH_RX_DESC_AVAIL) 16985 printf("Desc status = AVAILABLE\n"); 16986 else if (rc == RTE_ETH_RX_DESC_DONE) 16987 printf("Desc status = DONE\n"); 16988 else 16989 printf("Desc status = UNAVAILABLE\n"); 16990 } else if (!strcmp(res->cmd_keyword, "txq")) { 16991 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid, 16992 res->cmd_did); 16993 if (rc < 0) { 16994 fprintf(stderr, 16995 "Invalid input: queue id = %d, desc id = %d\n", 16996 res->cmd_qid, res->cmd_did); 16997 return; 16998 } 16999 if (rc == RTE_ETH_TX_DESC_FULL) 17000 printf("Desc status = FULL\n"); 17001 else if (rc == RTE_ETH_TX_DESC_DONE) 17002 printf("Desc status = DONE\n"); 17003 else 17004 printf("Desc status = UNAVAILABLE\n"); 17005 } 17006 } 17007 17008 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show = 17009 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17010 cmd_show, "show"); 17011 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port = 17012 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17013 cmd_port, "port"); 17014 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid = 17015 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17016 cmd_pid, RTE_UINT16); 17017 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword = 17018 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17019 cmd_keyword, "rxq#txq"); 17020 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid = 17021 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17022 cmd_qid, RTE_UINT16); 17023 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc = 17024 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17025 cmd_desc, "desc"); 17026 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did = 17027 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17028 cmd_did, RTE_UINT16); 17029 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status = 17030 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17031 cmd_status, "status"); 17032 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = { 17033 .f = cmd_show_rx_tx_desc_status_parsed, 17034 .data = NULL, 17035 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> " 17036 "status", 17037 .tokens = { 17038 (void *)&cmd_show_rx_tx_desc_status_show, 17039 (void *)&cmd_show_rx_tx_desc_status_port, 17040 (void *)&cmd_show_rx_tx_desc_status_pid, 17041 (void *)&cmd_show_rx_tx_desc_status_keyword, 17042 (void *)&cmd_show_rx_tx_desc_status_qid, 17043 (void *)&cmd_show_rx_tx_desc_status_desc, 17044 (void *)&cmd_show_rx_tx_desc_status_did, 17045 (void *)&cmd_show_rx_tx_desc_status_status, 17046 NULL, 17047 }, 17048 }; 17049 17050 /* *** display rx queue desc used count *** */ 17051 struct cmd_show_rx_queue_desc_used_count_result { 17052 cmdline_fixed_string_t cmd_show; 17053 cmdline_fixed_string_t cmd_port; 17054 cmdline_fixed_string_t cmd_rxq; 17055 cmdline_fixed_string_t cmd_desc; 17056 cmdline_fixed_string_t cmd_used; 17057 cmdline_fixed_string_t cmd_count; 17058 portid_t cmd_pid; 17059 portid_t cmd_qid; 17060 }; 17061 17062 static void 17063 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result, 17064 __rte_unused struct cmdline *cl, 17065 __rte_unused void *data) 17066 { 17067 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result; 17068 int rc; 17069 17070 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 17071 fprintf(stderr, "invalid port id %u\n", res->cmd_pid); 17072 return; 17073 } 17074 17075 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid); 17076 if (rc < 0) { 17077 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid); 17078 return; 17079 } 17080 printf("Used desc count = %d\n", rc); 17081 } 17082 17083 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show = 17084 TOKEN_STRING_INITIALIZER 17085 (struct cmd_show_rx_queue_desc_used_count_result, 17086 cmd_show, "show"); 17087 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port = 17088 TOKEN_STRING_INITIALIZER 17089 (struct cmd_show_rx_queue_desc_used_count_result, 17090 cmd_port, "port"); 17091 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid = 17092 TOKEN_NUM_INITIALIZER 17093 (struct cmd_show_rx_queue_desc_used_count_result, 17094 cmd_pid, RTE_UINT16); 17095 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq = 17096 TOKEN_STRING_INITIALIZER 17097 (struct cmd_show_rx_queue_desc_used_count_result, 17098 cmd_rxq, "rxq"); 17099 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid = 17100 TOKEN_NUM_INITIALIZER 17101 (struct cmd_show_rx_queue_desc_used_count_result, 17102 cmd_qid, RTE_UINT16); 17103 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc = 17104 TOKEN_STRING_INITIALIZER 17105 (struct cmd_show_rx_queue_desc_used_count_result, 17106 cmd_count, "desc"); 17107 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used = 17108 TOKEN_STRING_INITIALIZER 17109 (struct cmd_show_rx_queue_desc_used_count_result, 17110 cmd_count, "used"); 17111 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count = 17112 TOKEN_STRING_INITIALIZER 17113 (struct cmd_show_rx_queue_desc_used_count_result, 17114 cmd_count, "count"); 17115 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = { 17116 .f = cmd_show_rx_queue_desc_used_count_parsed, 17117 .data = NULL, 17118 .help_str = "show port <port_id> rxq <queue_id> desc used count", 17119 .tokens = { 17120 (void *)&cmd_show_rx_queue_desc_used_count_show, 17121 (void *)&cmd_show_rx_queue_desc_used_count_port, 17122 (void *)&cmd_show_rx_queue_desc_used_count_pid, 17123 (void *)&cmd_show_rx_queue_desc_used_count_rxq, 17124 (void *)&cmd_show_rx_queue_desc_used_count_qid, 17125 (void *)&cmd_show_rx_queue_desc_used_count_desc, 17126 (void *)&cmd_show_rx_queue_desc_used_count_used, 17127 (void *)&cmd_show_rx_queue_desc_used_count_count, 17128 NULL, 17129 }, 17130 }; 17131 17132 /* Common result structure for set port ptypes */ 17133 struct cmd_set_port_ptypes_result { 17134 cmdline_fixed_string_t set; 17135 cmdline_fixed_string_t port; 17136 portid_t port_id; 17137 cmdline_fixed_string_t ptype_mask; 17138 uint32_t mask; 17139 }; 17140 17141 /* Common CLI fields for set port ptypes */ 17142 cmdline_parse_token_string_t cmd_set_port_ptypes_set = 17143 TOKEN_STRING_INITIALIZER 17144 (struct cmd_set_port_ptypes_result, 17145 set, "set"); 17146 cmdline_parse_token_string_t cmd_set_port_ptypes_port = 17147 TOKEN_STRING_INITIALIZER 17148 (struct cmd_set_port_ptypes_result, 17149 port, "port"); 17150 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id = 17151 TOKEN_NUM_INITIALIZER 17152 (struct cmd_set_port_ptypes_result, 17153 port_id, RTE_UINT16); 17154 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str = 17155 TOKEN_STRING_INITIALIZER 17156 (struct cmd_set_port_ptypes_result, 17157 ptype_mask, "ptype_mask"); 17158 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 = 17159 TOKEN_NUM_INITIALIZER 17160 (struct cmd_set_port_ptypes_result, 17161 mask, RTE_UINT32); 17162 17163 static void 17164 cmd_set_port_ptypes_parsed( 17165 void *parsed_result, 17166 __rte_unused struct cmdline *cl, 17167 __rte_unused void *data) 17168 { 17169 struct cmd_set_port_ptypes_result *res = parsed_result; 17170 #define PTYPE_NAMESIZE 256 17171 char ptype_name[PTYPE_NAMESIZE]; 17172 uint16_t port_id = res->port_id; 17173 uint32_t ptype_mask = res->mask; 17174 int ret, i; 17175 17176 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK, 17177 NULL, 0); 17178 if (ret <= 0) { 17179 fprintf(stderr, "Port %d doesn't support any ptypes.\n", 17180 port_id); 17181 return; 17182 } 17183 17184 uint32_t ptypes[ret]; 17185 17186 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); 17187 if (ret < 0) { 17188 fprintf(stderr, "Unable to set requested ptypes for Port %d\n", 17189 port_id); 17190 return; 17191 } 17192 17193 printf("Successfully set following ptypes for Port %d\n", port_id); 17194 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) { 17195 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name)); 17196 printf("%s\n", ptype_name); 17197 } 17198 17199 clear_ptypes = false; 17200 } 17201 17202 cmdline_parse_inst_t cmd_set_port_ptypes = { 17203 .f = cmd_set_port_ptypes_parsed, 17204 .data = NULL, 17205 .help_str = "set port <port_id> ptype_mask <mask>", 17206 .tokens = { 17207 (void *)&cmd_set_port_ptypes_set, 17208 (void *)&cmd_set_port_ptypes_port, 17209 (void *)&cmd_set_port_ptypes_port_id, 17210 (void *)&cmd_set_port_ptypes_mask_str, 17211 (void *)&cmd_set_port_ptypes_mask_u32, 17212 NULL, 17213 }, 17214 }; 17215 17216 /* *** display mac addresses added to a port *** */ 17217 struct cmd_showport_macs_result { 17218 cmdline_fixed_string_t cmd_show; 17219 cmdline_fixed_string_t cmd_port; 17220 cmdline_fixed_string_t cmd_keyword; 17221 portid_t cmd_pid; 17222 }; 17223 17224 static void 17225 cmd_showport_macs_parsed(void *parsed_result, 17226 __rte_unused struct cmdline *cl, 17227 __rte_unused void *data) 17228 { 17229 struct cmd_showport_macs_result *res = parsed_result; 17230 17231 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN)) 17232 return; 17233 17234 if (!strcmp(res->cmd_keyword, "macs")) 17235 show_macs(res->cmd_pid); 17236 else if (!strcmp(res->cmd_keyword, "mcast_macs")) 17237 show_mcast_macs(res->cmd_pid); 17238 } 17239 17240 cmdline_parse_token_string_t cmd_showport_macs_show = 17241 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 17242 cmd_show, "show"); 17243 cmdline_parse_token_string_t cmd_showport_macs_port = 17244 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 17245 cmd_port, "port"); 17246 cmdline_parse_token_num_t cmd_showport_macs_pid = 17247 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result, 17248 cmd_pid, RTE_UINT16); 17249 cmdline_parse_token_string_t cmd_showport_macs_keyword = 17250 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 17251 cmd_keyword, "macs#mcast_macs"); 17252 17253 cmdline_parse_inst_t cmd_showport_macs = { 17254 .f = cmd_showport_macs_parsed, 17255 .data = NULL, 17256 .help_str = "show port <port_id> macs|mcast_macs", 17257 .tokens = { 17258 (void *)&cmd_showport_macs_show, 17259 (void *)&cmd_showport_macs_port, 17260 (void *)&cmd_showport_macs_pid, 17261 (void *)&cmd_showport_macs_keyword, 17262 NULL, 17263 }, 17264 }; 17265 17266 /* ******************************************************************************** */ 17267 17268 /* list of instructions */ 17269 cmdline_parse_ctx_t main_ctx[] = { 17270 (cmdline_parse_inst_t *)&cmd_help_brief, 17271 (cmdline_parse_inst_t *)&cmd_help_long, 17272 (cmdline_parse_inst_t *)&cmd_quit, 17273 (cmdline_parse_inst_t *)&cmd_load_from_file, 17274 (cmdline_parse_inst_t *)&cmd_showport, 17275 (cmdline_parse_inst_t *)&cmd_showqueue, 17276 (cmdline_parse_inst_t *)&cmd_showeeprom, 17277 (cmdline_parse_inst_t *)&cmd_showportall, 17278 (cmdline_parse_inst_t *)&cmd_showdevice, 17279 (cmdline_parse_inst_t *)&cmd_showcfg, 17280 (cmdline_parse_inst_t *)&cmd_showfwdall, 17281 (cmdline_parse_inst_t *)&cmd_start, 17282 (cmdline_parse_inst_t *)&cmd_start_tx_first, 17283 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 17284 (cmdline_parse_inst_t *)&cmd_set_link_up, 17285 (cmdline_parse_inst_t *)&cmd_set_link_down, 17286 (cmdline_parse_inst_t *)&cmd_reset, 17287 (cmdline_parse_inst_t *)&cmd_set_numbers, 17288 (cmdline_parse_inst_t *)&cmd_set_log, 17289 (cmdline_parse_inst_t *)&cmd_set_rxoffs, 17290 (cmdline_parse_inst_t *)&cmd_set_rxpkts, 17291 (cmdline_parse_inst_t *)&cmd_set_txpkts, 17292 (cmdline_parse_inst_t *)&cmd_set_txsplit, 17293 (cmdline_parse_inst_t *)&cmd_set_txtimes, 17294 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 17295 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 17296 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 17297 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 17298 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 17299 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 17300 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 17301 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 17302 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 17303 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 17304 (cmdline_parse_inst_t *)&cmd_set_link_check, 17305 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 17306 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 17307 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 17308 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 17309 #ifdef RTE_NET_BOND 17310 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 17311 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 17312 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 17313 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 17314 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 17315 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 17316 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 17317 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 17318 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 17319 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 17320 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 17321 #endif 17322 (cmdline_parse_inst_t *)&cmd_vlan_offload, 17323 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 17324 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 17325 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 17326 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 17327 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 17328 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 17329 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 17330 (cmdline_parse_inst_t *)&cmd_csum_set, 17331 (cmdline_parse_inst_t *)&cmd_csum_show, 17332 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 17333 (cmdline_parse_inst_t *)&cmd_tso_set, 17334 (cmdline_parse_inst_t *)&cmd_tso_show, 17335 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 17336 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 17337 (cmdline_parse_inst_t *)&cmd_gro_enable, 17338 (cmdline_parse_inst_t *)&cmd_gro_flush, 17339 (cmdline_parse_inst_t *)&cmd_gro_show, 17340 (cmdline_parse_inst_t *)&cmd_gso_enable, 17341 (cmdline_parse_inst_t *)&cmd_gso_size, 17342 (cmdline_parse_inst_t *)&cmd_gso_show, 17343 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 17344 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 17345 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 17346 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 17347 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 17348 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 17349 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 17350 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 17351 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 17352 (cmdline_parse_inst_t *)&cmd_link_flow_control_show, 17353 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 17354 (cmdline_parse_inst_t *)&cmd_config_dcb, 17355 (cmdline_parse_inst_t *)&cmd_read_reg, 17356 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 17357 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 17358 (cmdline_parse_inst_t *)&cmd_write_reg, 17359 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 17360 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 17361 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 17362 (cmdline_parse_inst_t *)&cmd_stop, 17363 (cmdline_parse_inst_t *)&cmd_mac_addr, 17364 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 17365 (cmdline_parse_inst_t *)&cmd_set_qmap, 17366 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 17367 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles, 17368 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats, 17369 (cmdline_parse_inst_t *)&cmd_operate_port, 17370 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 17371 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 17372 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 17373 (cmdline_parse_inst_t *)&cmd_operate_detach_device, 17374 (cmdline_parse_inst_t *)&cmd_set_port_setup_on, 17375 (cmdline_parse_inst_t *)&cmd_config_speed_all, 17376 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 17377 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 17378 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 17379 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 17380 (cmdline_parse_inst_t *)&cmd_config_mtu, 17381 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 17382 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size, 17383 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 17384 (cmdline_parse_inst_t *)&cmd_config_rss, 17385 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 17386 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 17387 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 17388 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 17389 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 17390 (cmdline_parse_inst_t *)&cmd_showport_reta, 17391 (cmdline_parse_inst_t *)&cmd_showport_macs, 17392 (cmdline_parse_inst_t *)&cmd_config_burst, 17393 (cmdline_parse_inst_t *)&cmd_config_thresh, 17394 (cmdline_parse_inst_t *)&cmd_config_threshold, 17395 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 17396 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 17397 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 17398 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 17399 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 17400 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 17401 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 17402 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 17403 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs, 17404 (cmdline_parse_inst_t *)&cmd_dump, 17405 (cmdline_parse_inst_t *)&cmd_dump_one, 17406 #ifdef RTE_NET_I40E 17407 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 17408 #endif 17409 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 17410 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 17411 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 17412 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 17413 (cmdline_parse_inst_t *)&cmd_flow, 17414 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 17415 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 17416 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 17417 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 17418 (cmdline_parse_inst_t *)&cmd_create_port_meter, 17419 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 17420 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 17421 (cmdline_parse_inst_t *)&cmd_del_port_meter, 17422 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy, 17423 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 17424 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 17425 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 17426 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 17427 (cmdline_parse_inst_t *)&cmd_mcast_addr, 17428 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 17429 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 17430 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 17431 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 17432 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 17433 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 17434 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 17435 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 17436 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 17437 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 17438 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 17439 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 17440 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 17441 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 17442 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 17443 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 17444 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 17445 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 17446 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 17447 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 17448 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 17449 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 17450 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 17451 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 17452 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 17453 (cmdline_parse_inst_t *)&cmd_set_vxlan, 17454 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl, 17455 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 17456 (cmdline_parse_inst_t *)&cmd_set_nvgre, 17457 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 17458 (cmdline_parse_inst_t *)&cmd_set_l2_encap, 17459 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, 17460 (cmdline_parse_inst_t *)&cmd_set_l2_decap, 17461 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, 17462 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, 17463 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, 17464 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, 17465 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, 17466 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, 17467 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, 17468 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, 17469 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, 17470 (cmdline_parse_inst_t *)&cmd_set_conntrack_common, 17471 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir, 17472 (cmdline_parse_inst_t *)&cmd_ddp_add, 17473 (cmdline_parse_inst_t *)&cmd_ddp_del, 17474 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 17475 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 17476 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 17477 (cmdline_parse_inst_t *)&cmd_clear_input_set, 17478 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 17479 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 17480 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes, 17481 (cmdline_parse_inst_t *)&cmd_set_port_ptypes, 17482 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 17483 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 17484 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 17485 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 17486 17487 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 17488 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 17489 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 17490 (cmdline_parse_inst_t *)&cmd_queue_region, 17491 (cmdline_parse_inst_t *)&cmd_region_flowtype, 17492 (cmdline_parse_inst_t *)&cmd_user_priority_region, 17493 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 17494 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 17495 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 17496 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 17497 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 17498 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 17499 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 17500 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 17501 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 17502 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 17503 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 17504 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 17505 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 17506 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 17507 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 17508 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode, 17509 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 17510 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 17511 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 17512 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 17513 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 17514 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 17515 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, 17516 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, 17517 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, 17518 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 17519 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 17520 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 17521 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 17522 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 17523 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 17524 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 17525 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 17526 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 17527 #ifdef RTE_LIB_BPF 17528 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 17529 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 17530 #endif 17531 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, 17532 (cmdline_parse_inst_t *)&cmd_show_tx_metadata, 17533 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status, 17534 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count, 17535 (cmdline_parse_inst_t *)&cmd_set_raw, 17536 (cmdline_parse_inst_t *)&cmd_show_set_raw, 17537 (cmdline_parse_inst_t *)&cmd_show_set_raw_all, 17538 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific, 17539 (cmdline_parse_inst_t *)&cmd_show_fec_mode, 17540 (cmdline_parse_inst_t *)&cmd_set_fec_mode, 17541 (cmdline_parse_inst_t *)&cmd_show_capability, 17542 NULL, 17543 }; 17544 17545 /* read cmdline commands from file */ 17546 void 17547 cmdline_read_from_file(const char *filename) 17548 { 17549 struct cmdline *cl; 17550 17551 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 17552 if (cl == NULL) { 17553 fprintf(stderr, 17554 "Failed to create file based cmdline context: %s\n", 17555 filename); 17556 return; 17557 } 17558 17559 cmdline_interact(cl); 17560 cmdline_quit(cl); 17561 17562 cmdline_free(cl); 17563 17564 printf("Read CLI commands from %s\n", filename); 17565 } 17566 17567 /* prompt function, called from main on MAIN lcore */ 17568 void 17569 prompt(void) 17570 { 17571 int ret; 17572 /* initialize non-constant commands */ 17573 cmd_set_fwd_mode_init(); 17574 cmd_set_fwd_retry_mode_init(); 17575 17576 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 17577 if (testpmd_cl == NULL) 17578 return; 17579 17580 ret = atexit(prompt_exit); 17581 if (ret != 0) 17582 fprintf(stderr, "Cannot set exit function for cmdline\n"); 17583 17584 cmdline_interact(testpmd_cl); 17585 if (ret != 0) 17586 cmdline_stdin_exit(testpmd_cl); 17587 } 17588 17589 void 17590 prompt_exit(void) 17591 { 17592 if (testpmd_cl != NULL) { 17593 cmdline_quit(testpmd_cl); 17594 cmdline_stdin_exit(testpmd_cl); 17595 } 17596 } 17597 17598 static void 17599 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 17600 { 17601 if (id == (portid_t)RTE_PORT_ALL) { 17602 portid_t pid; 17603 17604 RTE_ETH_FOREACH_DEV(pid) { 17605 /* check if need_reconfig has been set to 1 */ 17606 if (ports[pid].need_reconfig == 0) 17607 ports[pid].need_reconfig = dev; 17608 /* check if need_reconfig_queues has been set to 1 */ 17609 if (ports[pid].need_reconfig_queues == 0) 17610 ports[pid].need_reconfig_queues = queue; 17611 } 17612 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 17613 /* check if need_reconfig has been set to 1 */ 17614 if (ports[id].need_reconfig == 0) 17615 ports[id].need_reconfig = dev; 17616 /* check if need_reconfig_queues has been set to 1 */ 17617 if (ports[id].need_reconfig_queues == 0) 17618 ports[id].need_reconfig_queues = queue; 17619 } 17620 } 17621