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 port (port_id) mirror-rule (rule_id)" 571 " (pool-mirror-up|pool-mirror-down|vlan-mirror)" 572 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n" 573 " Set pool or vlan type mirror rule on a port.\n" 574 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1" 575 " dst-pool 0 on' enable mirror traffic with vlan 0,1" 576 " to pool 0.\n\n" 577 578 "set port (port_id) mirror-rule (rule_id)" 579 " (uplink-mirror|downlink-mirror) dst-pool" 580 " (pool_id) (on|off)\n" 581 " Set uplink or downlink type mirror rule on a port.\n" 582 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool" 583 " 0 on' enable mirror income traffic to pool 0.\n\n" 584 585 "reset port (port_id) mirror-rule (rule_id)\n" 586 " Reset a mirror rule.\n\n" 587 588 "set flush_rx (on|off)\n" 589 " Flush (default) or don't flush RX streams before" 590 " forwarding. Mainly used with PCAP drivers.\n\n" 591 592 "set bypass mode (normal|bypass|isolate) (port_id)\n" 593 " Set the bypass mode for the lowest port on bypass enabled" 594 " NIC.\n\n" 595 596 "set bypass event (timeout|os_on|os_off|power_on|power_off) " 597 "mode (normal|bypass|isolate) (port_id)\n" 598 " Set the event required to initiate specified bypass mode for" 599 " the lowest port on a bypass enabled NIC where:\n" 600 " timeout = enable bypass after watchdog timeout.\n" 601 " os_on = enable bypass when OS/board is powered on.\n" 602 " os_off = enable bypass when OS/board is powered off.\n" 603 " power_on = enable bypass when power supply is turned on.\n" 604 " power_off = enable bypass when power supply is turned off." 605 "\n\n" 606 607 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" 608 " Set the bypass watchdog timeout to 'n' seconds" 609 " where 0 = instant.\n\n" 610 611 "show bypass config (port_id)\n" 612 " Show the bypass configuration for a bypass enabled NIC" 613 " using the lowest port on the NIC.\n\n" 614 615 #ifdef RTE_NET_BOND 616 "create bonded device (mode) (socket)\n" 617 " Create a new bonded device with specific bonding mode and socket.\n\n" 618 619 "add bonding slave (slave_id) (port_id)\n" 620 " Add a slave device to a bonded device.\n\n" 621 622 "remove bonding slave (slave_id) (port_id)\n" 623 " Remove a slave device from a bonded device.\n\n" 624 625 "set bonding mode (value) (port_id)\n" 626 " Set the bonding mode on a bonded device.\n\n" 627 628 "set bonding primary (slave_id) (port_id)\n" 629 " Set the primary slave for a bonded device.\n\n" 630 631 "show bonding config (port_id)\n" 632 " Show the bonding config for port_id.\n\n" 633 634 "set bonding mac_addr (port_id) (address)\n" 635 " Set the MAC address of a bonded device.\n\n" 636 637 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)" 638 " Set Aggregation mode for IEEE802.3AD (mode 4)" 639 640 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n" 641 " Set the transmit balance policy for bonded device running in balance mode.\n\n" 642 643 "set bonding mon_period (port_id) (value)\n" 644 " Set the bonding link status monitoring polling period in ms.\n\n" 645 646 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n" 647 " Enable/disable dedicated queues for LACP control traffic.\n\n" 648 649 #endif 650 "set link-up port (port_id)\n" 651 " Set link up for a port.\n\n" 652 653 "set link-down port (port_id)\n" 654 " Set link down for a port.\n\n" 655 656 "ddp add (port_id) (profile_path[,backup_profile_path])\n" 657 " Load a profile package on a port\n\n" 658 659 "ddp del (port_id) (backup_profile_path)\n" 660 " Delete a profile package from a port\n\n" 661 662 "ptype mapping get (port_id) (valid_only)\n" 663 " Get ptype mapping on a port\n\n" 664 665 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n" 666 " Replace target with the pkt_type in ptype mapping\n\n" 667 668 "ptype mapping reset (port_id)\n" 669 " Reset ptype mapping on a port\n\n" 670 671 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" 672 " Update a ptype mapping item on a port\n\n" 673 674 "set port (port_id) ptype_mask (ptype_mask)\n" 675 " set packet types classification for a specific port\n\n" 676 677 "set port (port_id) queue-region region_id (value) " 678 "queue_start_index (value) queue_num (value)\n" 679 " Set a queue region on a port\n\n" 680 681 "set port (port_id) queue-region region_id (value) " 682 "flowtype (value)\n" 683 " Set a flowtype region index on a port\n\n" 684 685 "set port (port_id) queue-region UP (value) region_id (value)\n" 686 " Set the mapping of User Priority to " 687 "queue region on a port\n\n" 688 689 "set port (port_id) queue-region flush (on|off)\n" 690 " flush all queue region related configuration\n\n" 691 692 "show port meter cap (port_id)\n" 693 " Show port meter capability information\n\n" 694 695 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n" 696 " meter profile add - srtcm rfc 2697\n\n" 697 698 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n" 699 " meter profile add - trtcm rfc 2698\n\n" 700 701 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n" 702 " meter profile add - trtcm rfc 4115\n\n" 703 704 "del port meter profile (port_id) (profile_id)\n" 705 " meter profile delete\n\n" 706 707 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n" 708 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 709 "(dscp_tbl_entry63)]\n" 710 " meter create\n\n" 711 712 "enable port meter (port_id) (mtr_id)\n" 713 " meter enable\n\n" 714 715 "disable port meter (port_id) (mtr_id)\n" 716 " meter disable\n\n" 717 718 "del port meter (port_id) (mtr_id)\n" 719 " meter delete\n\n" 720 721 "add port meter policy (port_id) (policy_id) g_actions (actions)\n" 722 "y_actions (actions) r_actions (actions)\n" 723 " meter policy add\n\n" 724 725 "del port meter policy (port_id) (policy_id)\n" 726 " meter policy delete\n\n" 727 728 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 729 " meter update meter profile\n\n" 730 731 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 732 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 733 " update meter dscp table entries\n\n" 734 735 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 736 "(action0) [(action1) (action2)]\n" 737 " meter update policer action\n\n" 738 739 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 740 " meter update stats\n\n" 741 742 "show port (port_id) queue-region\n" 743 " show all queue region related configuration info\n\n" 744 745 "set port (port_id) fec_mode auto|off|rs|baser\n" 746 " set fec mode for a specific port\n\n" 747 748 , list_pkt_forwarding_modes() 749 ); 750 } 751 752 if (show_all || !strcmp(res->section, "ports")) { 753 754 cmdline_printf( 755 cl, 756 "\n" 757 "Port Operations:\n" 758 "----------------\n\n" 759 760 "port start (port_id|all)\n" 761 " Start all ports or port_id.\n\n" 762 763 "port stop (port_id|all)\n" 764 " Stop all ports or port_id.\n\n" 765 766 "port close (port_id|all)\n" 767 " Close all ports or port_id.\n\n" 768 769 "port reset (port_id|all)\n" 770 " Reset all ports or port_id.\n\n" 771 772 "port attach (ident)\n" 773 " Attach physical or virtual dev by pci address or virtual device name\n\n" 774 775 "port detach (port_id)\n" 776 " Detach physical or virtual dev by port_id\n\n" 777 778 "port config (port_id|all)" 779 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)" 780 " duplex (half|full|auto)\n" 781 " Set speed and duplex for all ports or port_id\n\n" 782 783 "port config (port_id|all) loopback (mode)\n" 784 " Set loopback mode for all ports or port_id\n\n" 785 786 "port config all (rxq|txq|rxd|txd) (value)\n" 787 " Set number for rxq/txq/rxd/txd.\n\n" 788 789 "port config all max-pkt-len (value)\n" 790 " Set the max packet length.\n\n" 791 792 "port config all max-lro-pkt-size (value)\n" 793 " Set the max LRO aggregated packet size.\n\n" 794 795 "port config all drop-en (on|off)\n" 796 " Enable or disable packet drop on all RX queues of all ports when no " 797 "receive buffers available.\n\n" 798 799 "port config all rss (all|default|ip|tcp|udp|sctp|" 800 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|" 801 "level-outer|level-inner|<flowtype_id>)\n" 802 " Set the RSS mode.\n\n" 803 804 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 805 " Set the RSS redirection table.\n\n" 806 807 "port config (port_id) dcb vt (on|off) (traffic_class)" 808 " pfc (on|off)\n" 809 " Set the DCB mode.\n\n" 810 811 "port config all burst (value)\n" 812 " Set the number of packets per burst.\n\n" 813 814 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 815 " (value)\n" 816 " Set the ring prefetch/host/writeback threshold" 817 " for tx/rx queue.\n\n" 818 819 "port config all (txfreet|txrst|rxfreet) (value)\n" 820 " Set free threshold for rx/tx, or set" 821 " tx rs bit threshold.\n\n" 822 "port config mtu X value\n" 823 " Set the MTU of port X to a given value\n\n" 824 825 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n" 826 " Set a rx/tx queue's ring size configuration, the new" 827 " value will take effect after command that (re-)start the port" 828 " or command that setup the specific queue\n\n" 829 830 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 831 " Start/stop a rx/tx queue of port X. Only take effect" 832 " when port X is started\n\n" 833 834 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n" 835 " Switch on/off a deferred start of port X rx/tx queue. Only" 836 " take effect when port X is stopped.\n\n" 837 838 "port (port_id) (rxq|txq) (queue_id) setup\n" 839 " Setup a rx/tx queue of port X.\n\n" 840 841 "port config (port_id) pctype mapping reset\n" 842 " Reset flow type to pctype mapping on a port\n\n" 843 844 "port config (port_id) pctype mapping update" 845 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 846 " Update a flow type to pctype mapping item on a port\n\n" 847 848 "port config (port_id) pctype (pctype_id) hash_inset|" 849 "fdir_inset|fdir_flx_inset get|set|clear field\n" 850 " (field_idx)\n" 851 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n" 852 853 "port config (port_id) pctype (pctype_id) hash_inset|" 854 "fdir_inset|fdir_flx_inset clear all" 855 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n" 856 857 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n" 858 " Add/remove UDP tunnel port for tunneling offload\n\n" 859 860 "port config <port_id> rx_offload vlan_strip|" 861 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 862 "outer_ipv4_cksum|macsec_strip|header_split|" 863 "vlan_filter|vlan_extend|jumbo_frame|scatter|" 864 "buffer_split|timestamp|security|keep_crc on|off\n" 865 " Enable or disable a per port Rx offloading" 866 " on all Rx queues of a port\n\n" 867 868 "port (port_id) rxq (queue_id) rx_offload vlan_strip|" 869 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 870 "outer_ipv4_cksum|macsec_strip|header_split|" 871 "vlan_filter|vlan_extend|jumbo_frame|scatter|" 872 "buffer_split|timestamp|security|keep_crc on|off\n" 873 " Enable or disable a per queue Rx offloading" 874 " only on a specific Rx queue\n\n" 875 876 "port config (port_id) tx_offload vlan_insert|" 877 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 878 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 879 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|" 880 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|" 881 "security on|off\n" 882 " Enable or disable a per port Tx offloading" 883 " on all Tx queues of a port\n\n" 884 885 "port (port_id) txq (queue_id) tx_offload vlan_insert|" 886 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 887 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 888 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert" 889 "|mt_lockfree|multi_segs|mbuf_fast_free|security" 890 " on|off\n" 891 " Enable or disable a per queue Tx offloading" 892 " only on a specific Tx queue\n\n" 893 894 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n" 895 " Load an eBPF program as a callback" 896 " for particular RX/TX queue\n\n" 897 898 "bpf-unload rx|tx (port) (queue)\n" 899 " Unload previously loaded eBPF program" 900 " for particular RX/TX queue\n\n" 901 902 "port config (port_id) tx_metadata (value)\n" 903 " Set Tx metadata value per port. Testpmd will add this value" 904 " to any Tx packet sent from this port\n\n" 905 906 "port config (port_id) dynf (name) set|clear\n" 907 " Register a dynf and Set/clear this flag on Tx. " 908 "Testpmd will set this value to any Tx packet " 909 "sent from this port\n\n" 910 911 "port cleanup (port_id) txq (queue_id) (free_cnt)\n" 912 " Cleanup txq mbufs for a specific Tx queue\n\n" 913 ); 914 } 915 916 if (show_all || !strcmp(res->section, "registers")) { 917 918 cmdline_printf( 919 cl, 920 "\n" 921 "Registers:\n" 922 "----------\n\n" 923 924 "read reg (port_id) (address)\n" 925 " Display value of a port register.\n\n" 926 927 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 928 " Display a port register bit field.\n\n" 929 930 "read regbit (port_id) (address) (bit_x)\n" 931 " Display a single port register bit.\n\n" 932 933 "write reg (port_id) (address) (value)\n" 934 " Set value of a port register.\n\n" 935 936 "write regfield (port_id) (address) (bit_x) (bit_y)" 937 " (value)\n" 938 " Set bit field of a port register.\n\n" 939 940 "write regbit (port_id) (address) (bit_x) (value)\n" 941 " Set single bit value of a port register.\n\n" 942 ); 943 } 944 if (show_all || !strcmp(res->section, "filters")) { 945 946 cmdline_printf( 947 cl, 948 "\n" 949 "filters:\n" 950 "--------\n\n" 951 952 #ifdef RTE_NET_I40E 953 "flow_director_filter (port_id) mode raw (add|del|update)" 954 " flow (flow_id) (drop|fwd) queue (queue_id)" 955 " fd_id (fd_id_value) packet (packet file name)\n" 956 " Add/Del a raw type flow director filter.\n\n" 957 #endif 958 959 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 960 " src_mask (ipv4_src) (ipv6_src) (src_port)" 961 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 962 " Set flow director IP mask.\n\n" 963 964 "flow_director_mask (port_id) mode MAC-VLAN" 965 " vlan (vlan_value)\n" 966 " Set flow director MAC-VLAN mask.\n\n" 967 968 "flow_director_mask (port_id) mode Tunnel" 969 " vlan (vlan_value) mac (mac_value)" 970 " tunnel-type (tunnel_type_value)" 971 " tunnel-id (tunnel_id_value)\n" 972 " Set flow director Tunnel mask.\n\n" 973 974 "flow_director_flex_payload (port_id)" 975 " (raw|l2|l3|l4) (config)\n" 976 " Configure flex payload selection.\n\n" 977 978 "flow validate {port_id}" 979 " [group {group_id}] [priority {level}]" 980 " [ingress] [egress]" 981 " pattern {item} [/ {item} [...]] / end" 982 " actions {action} [/ {action} [...]] / end\n" 983 " Check whether a flow rule can be created.\n\n" 984 985 "flow create {port_id}" 986 " [group {group_id}] [priority {level}]" 987 " [ingress] [egress]" 988 " pattern {item} [/ {item} [...]] / end" 989 " actions {action} [/ {action} [...]] / end\n" 990 " Create a flow rule.\n\n" 991 992 "flow destroy {port_id} rule {rule_id} [...]\n" 993 " Destroy specific flow rules.\n\n" 994 995 "flow flush {port_id}\n" 996 " Destroy all flow rules.\n\n" 997 998 "flow query {port_id} {rule_id} {action}\n" 999 " Query an existing flow rule.\n\n" 1000 1001 "flow list {port_id} [group {group_id}] [...]\n" 1002 " List existing flow rules sorted by priority," 1003 " filtered by group identifiers.\n\n" 1004 1005 "flow isolate {port_id} {boolean}\n" 1006 " Restrict ingress traffic to the defined" 1007 " flow rules\n\n" 1008 1009 "flow aged {port_id} [destroy]\n" 1010 " List and destroy aged flows" 1011 " flow rules\n\n" 1012 1013 "flow indirect_action {port_id} create" 1014 " [action_id {indirect_action_id}]" 1015 " [ingress] [egress]" 1016 " action {action} / end\n" 1017 " Create indirect action.\n\n" 1018 1019 "flow indirect_action {port_id} update" 1020 " {indirect_action_id} action {action} / end\n" 1021 " Update indirect action.\n\n" 1022 1023 "flow indirect_action {port_id} destroy" 1024 " action_id {indirect_action_id} [...]\n" 1025 " Destroy specific indirect actions.\n\n" 1026 1027 "flow indirect_action {port_id} query" 1028 " {indirect_action_id}\n" 1029 " Query an existing indirect action.\n\n" 1030 1031 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" 1032 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" 1033 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n" 1034 " Configure the VXLAN encapsulation for flows.\n\n" 1035 1036 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)" 1037 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)" 1038 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)" 1039 " eth-dst (eth-dst)\n" 1040 " Configure the VXLAN encapsulation for flows.\n\n" 1041 1042 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src" 1043 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)" 1044 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)" 1045 " eth-dst (eth-dst)\n" 1046 " Configure the VXLAN encapsulation for flows.\n\n" 1047 1048 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src" 1049 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst" 1050 " (eth-dst)\n" 1051 " Configure the NVGRE encapsulation for flows.\n\n" 1052 1053 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)" 1054 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)" 1055 " eth-src (eth-src) eth-dst (eth-dst)\n" 1056 " Configure the NVGRE encapsulation for flows.\n\n" 1057 1058 "set raw_encap {flow items}\n" 1059 " Configure the encapsulation with raw data.\n\n" 1060 1061 "set raw_decap {flow items}\n" 1062 " Configure the decapsulation with raw data.\n\n" 1063 1064 ); 1065 } 1066 1067 if (show_all || !strcmp(res->section, "traffic_management")) { 1068 cmdline_printf( 1069 cl, 1070 "\n" 1071 "Traffic Management:\n" 1072 "--------------\n" 1073 "show port tm cap (port_id)\n" 1074 " Display the port TM capability.\n\n" 1075 1076 "show port tm level cap (port_id) (level_id)\n" 1077 " Display the port TM hierarchical level capability.\n\n" 1078 1079 "show port tm node cap (port_id) (node_id)\n" 1080 " Display the port TM node capability.\n\n" 1081 1082 "show port tm node type (port_id) (node_id)\n" 1083 " Display the port TM node type.\n\n" 1084 1085 "show port tm node stats (port_id) (node_id) (clear)\n" 1086 " Display the port TM node stats.\n\n" 1087 1088 "add port tm node shaper profile (port_id) (shaper_profile_id)" 1089 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)" 1090 " (packet_length_adjust) (packet_mode)\n" 1091 " Add port tm node private shaper profile.\n\n" 1092 1093 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 1094 " Delete port tm node private shaper profile.\n\n" 1095 1096 "add port tm node shared shaper (port_id) (shared_shaper_id)" 1097 " (shaper_profile_id)\n" 1098 " Add/update port tm node shared shaper.\n\n" 1099 1100 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 1101 " Delete port tm node shared shaper.\n\n" 1102 1103 "set port tm node shaper profile (port_id) (node_id)" 1104 " (shaper_profile_id)\n" 1105 " Set port tm node shaper profile.\n\n" 1106 1107 "add port tm node wred profile (port_id) (wred_profile_id)" 1108 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 1109 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 1110 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 1111 " Add port tm node wred profile.\n\n" 1112 1113 "del port tm node wred profile (port_id) (wred_profile_id)\n" 1114 " Delete port tm node wred profile.\n\n" 1115 1116 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 1117 " (priority) (weight) (level_id) (shaper_profile_id)" 1118 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1119 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1120 " Add port tm nonleaf node.\n\n" 1121 1122 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)" 1123 " (priority) (weight) (level_id) (shaper_profile_id)" 1124 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1125 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1126 " Add port tm nonleaf node with pkt mode enabled.\n\n" 1127 1128 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 1129 " (priority) (weight) (level_id) (shaper_profile_id)" 1130 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 1131 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1132 " Add port tm leaf node.\n\n" 1133 1134 "del port tm node (port_id) (node_id)\n" 1135 " Delete port tm node.\n\n" 1136 1137 "set port tm node parent (port_id) (node_id) (parent_node_id)" 1138 " (priority) (weight)\n" 1139 " Set port tm node parent.\n\n" 1140 1141 "suspend port tm node (port_id) (node_id)" 1142 " Suspend tm node.\n\n" 1143 1144 "resume port tm node (port_id) (node_id)" 1145 " Resume tm node.\n\n" 1146 1147 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 1148 " Commit tm hierarchy.\n\n" 1149 1150 "set port tm mark ip_ecn (port) (green) (yellow)" 1151 " (red)\n" 1152 " Enables/Disables the traffic management marking" 1153 " for IP ECN (Explicit Congestion Notification)" 1154 " packets on a given port\n\n" 1155 1156 "set port tm mark ip_dscp (port) (green) (yellow)" 1157 " (red)\n" 1158 " Enables/Disables the traffic management marking" 1159 " on the port for IP dscp packets\n\n" 1160 1161 "set port tm mark vlan_dei (port) (green) (yellow)" 1162 " (red)\n" 1163 " Enables/Disables the traffic management marking" 1164 " on the port for VLAN packets with DEI enabled\n\n" 1165 ); 1166 } 1167 1168 if (show_all || !strcmp(res->section, "devices")) { 1169 cmdline_printf( 1170 cl, 1171 "\n" 1172 "Device Operations:\n" 1173 "--------------\n" 1174 "device detach (identifier)\n" 1175 " Detach device by identifier.\n\n" 1176 ); 1177 } 1178 1179 } 1180 1181 cmdline_parse_token_string_t cmd_help_long_help = 1182 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1183 1184 cmdline_parse_token_string_t cmd_help_long_section = 1185 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1186 "all#control#display#config#" 1187 "ports#registers#filters#traffic_management#devices"); 1188 1189 cmdline_parse_inst_t cmd_help_long = { 1190 .f = cmd_help_long_parsed, 1191 .data = NULL, 1192 .help_str = "help all|control|display|config|ports|register|" 1193 "filters|traffic_management|devices: " 1194 "Show help", 1195 .tokens = { 1196 (void *)&cmd_help_long_help, 1197 (void *)&cmd_help_long_section, 1198 NULL, 1199 }, 1200 }; 1201 1202 1203 /* *** start/stop/close all ports *** */ 1204 struct cmd_operate_port_result { 1205 cmdline_fixed_string_t keyword; 1206 cmdline_fixed_string_t name; 1207 cmdline_fixed_string_t value; 1208 }; 1209 1210 static void cmd_operate_port_parsed(void *parsed_result, 1211 __rte_unused struct cmdline *cl, 1212 __rte_unused void *data) 1213 { 1214 struct cmd_operate_port_result *res = parsed_result; 1215 1216 if (!strcmp(res->name, "start")) 1217 start_port(RTE_PORT_ALL); 1218 else if (!strcmp(res->name, "stop")) 1219 stop_port(RTE_PORT_ALL); 1220 else if (!strcmp(res->name, "close")) 1221 close_port(RTE_PORT_ALL); 1222 else if (!strcmp(res->name, "reset")) 1223 reset_port(RTE_PORT_ALL); 1224 else 1225 fprintf(stderr, "Unknown parameter\n"); 1226 } 1227 1228 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1229 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1230 "port"); 1231 cmdline_parse_token_string_t cmd_operate_port_all_port = 1232 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1233 "start#stop#close#reset"); 1234 cmdline_parse_token_string_t cmd_operate_port_all_all = 1235 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1236 1237 cmdline_parse_inst_t cmd_operate_port = { 1238 .f = cmd_operate_port_parsed, 1239 .data = NULL, 1240 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports", 1241 .tokens = { 1242 (void *)&cmd_operate_port_all_cmd, 1243 (void *)&cmd_operate_port_all_port, 1244 (void *)&cmd_operate_port_all_all, 1245 NULL, 1246 }, 1247 }; 1248 1249 /* *** start/stop/close specific port *** */ 1250 struct cmd_operate_specific_port_result { 1251 cmdline_fixed_string_t keyword; 1252 cmdline_fixed_string_t name; 1253 uint8_t value; 1254 }; 1255 1256 static void cmd_operate_specific_port_parsed(void *parsed_result, 1257 __rte_unused struct cmdline *cl, 1258 __rte_unused void *data) 1259 { 1260 struct cmd_operate_specific_port_result *res = parsed_result; 1261 1262 if (!strcmp(res->name, "start")) 1263 start_port(res->value); 1264 else if (!strcmp(res->name, "stop")) 1265 stop_port(res->value); 1266 else if (!strcmp(res->name, "close")) 1267 close_port(res->value); 1268 else if (!strcmp(res->name, "reset")) 1269 reset_port(res->value); 1270 else 1271 fprintf(stderr, "Unknown parameter\n"); 1272 } 1273 1274 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1275 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1276 keyword, "port"); 1277 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1278 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1279 name, "start#stop#close#reset"); 1280 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1281 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1282 value, RTE_UINT8); 1283 1284 cmdline_parse_inst_t cmd_operate_specific_port = { 1285 .f = cmd_operate_specific_port_parsed, 1286 .data = NULL, 1287 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id", 1288 .tokens = { 1289 (void *)&cmd_operate_specific_port_cmd, 1290 (void *)&cmd_operate_specific_port_port, 1291 (void *)&cmd_operate_specific_port_id, 1292 NULL, 1293 }, 1294 }; 1295 1296 /* *** enable port setup (after attach) via iterator or event *** */ 1297 struct cmd_set_port_setup_on_result { 1298 cmdline_fixed_string_t set; 1299 cmdline_fixed_string_t port; 1300 cmdline_fixed_string_t setup; 1301 cmdline_fixed_string_t on; 1302 cmdline_fixed_string_t mode; 1303 }; 1304 1305 static void cmd_set_port_setup_on_parsed(void *parsed_result, 1306 __rte_unused struct cmdline *cl, 1307 __rte_unused void *data) 1308 { 1309 struct cmd_set_port_setup_on_result *res = parsed_result; 1310 1311 if (strcmp(res->mode, "event") == 0) 1312 setup_on_probe_event = true; 1313 else if (strcmp(res->mode, "iterator") == 0) 1314 setup_on_probe_event = false; 1315 else 1316 fprintf(stderr, "Unknown mode\n"); 1317 } 1318 1319 cmdline_parse_token_string_t cmd_set_port_setup_on_set = 1320 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1321 set, "set"); 1322 cmdline_parse_token_string_t cmd_set_port_setup_on_port = 1323 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1324 port, "port"); 1325 cmdline_parse_token_string_t cmd_set_port_setup_on_setup = 1326 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1327 setup, "setup"); 1328 cmdline_parse_token_string_t cmd_set_port_setup_on_on = 1329 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1330 on, "on"); 1331 cmdline_parse_token_string_t cmd_set_port_setup_on_mode = 1332 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1333 mode, "iterator#event"); 1334 1335 cmdline_parse_inst_t cmd_set_port_setup_on = { 1336 .f = cmd_set_port_setup_on_parsed, 1337 .data = NULL, 1338 .help_str = "set port setup on iterator|event", 1339 .tokens = { 1340 (void *)&cmd_set_port_setup_on_set, 1341 (void *)&cmd_set_port_setup_on_port, 1342 (void *)&cmd_set_port_setup_on_setup, 1343 (void *)&cmd_set_port_setup_on_on, 1344 (void *)&cmd_set_port_setup_on_mode, 1345 NULL, 1346 }, 1347 }; 1348 1349 /* *** attach a specified port *** */ 1350 struct cmd_operate_attach_port_result { 1351 cmdline_fixed_string_t port; 1352 cmdline_fixed_string_t keyword; 1353 cmdline_multi_string_t identifier; 1354 }; 1355 1356 static void cmd_operate_attach_port_parsed(void *parsed_result, 1357 __rte_unused struct cmdline *cl, 1358 __rte_unused void *data) 1359 { 1360 struct cmd_operate_attach_port_result *res = parsed_result; 1361 1362 if (!strcmp(res->keyword, "attach")) 1363 attach_port(res->identifier); 1364 else 1365 fprintf(stderr, "Unknown parameter\n"); 1366 } 1367 1368 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1369 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1370 port, "port"); 1371 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1372 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1373 keyword, "attach"); 1374 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1375 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1376 identifier, TOKEN_STRING_MULTI); 1377 1378 cmdline_parse_inst_t cmd_operate_attach_port = { 1379 .f = cmd_operate_attach_port_parsed, 1380 .data = NULL, 1381 .help_str = "port attach <identifier>: " 1382 "(identifier: pci address or virtual dev name)", 1383 .tokens = { 1384 (void *)&cmd_operate_attach_port_port, 1385 (void *)&cmd_operate_attach_port_keyword, 1386 (void *)&cmd_operate_attach_port_identifier, 1387 NULL, 1388 }, 1389 }; 1390 1391 /* *** detach a specified port *** */ 1392 struct cmd_operate_detach_port_result { 1393 cmdline_fixed_string_t port; 1394 cmdline_fixed_string_t keyword; 1395 portid_t port_id; 1396 }; 1397 1398 static void cmd_operate_detach_port_parsed(void *parsed_result, 1399 __rte_unused struct cmdline *cl, 1400 __rte_unused void *data) 1401 { 1402 struct cmd_operate_detach_port_result *res = parsed_result; 1403 1404 if (!strcmp(res->keyword, "detach")) { 1405 RTE_ETH_VALID_PORTID_OR_RET(res->port_id); 1406 detach_port_device(res->port_id); 1407 } else { 1408 fprintf(stderr, "Unknown parameter\n"); 1409 } 1410 } 1411 1412 cmdline_parse_token_string_t cmd_operate_detach_port_port = 1413 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1414 port, "port"); 1415 cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1416 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1417 keyword, "detach"); 1418 cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1419 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1420 port_id, RTE_UINT16); 1421 1422 cmdline_parse_inst_t cmd_operate_detach_port = { 1423 .f = cmd_operate_detach_port_parsed, 1424 .data = NULL, 1425 .help_str = "port detach <port_id>", 1426 .tokens = { 1427 (void *)&cmd_operate_detach_port_port, 1428 (void *)&cmd_operate_detach_port_keyword, 1429 (void *)&cmd_operate_detach_port_port_id, 1430 NULL, 1431 }, 1432 }; 1433 1434 /* *** detach device by identifier *** */ 1435 struct cmd_operate_detach_device_result { 1436 cmdline_fixed_string_t device; 1437 cmdline_fixed_string_t keyword; 1438 cmdline_fixed_string_t identifier; 1439 }; 1440 1441 static void cmd_operate_detach_device_parsed(void *parsed_result, 1442 __rte_unused struct cmdline *cl, 1443 __rte_unused void *data) 1444 { 1445 struct cmd_operate_detach_device_result *res = parsed_result; 1446 1447 if (!strcmp(res->keyword, "detach")) 1448 detach_devargs(res->identifier); 1449 else 1450 fprintf(stderr, "Unknown parameter\n"); 1451 } 1452 1453 cmdline_parse_token_string_t cmd_operate_detach_device_device = 1454 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1455 device, "device"); 1456 cmdline_parse_token_string_t cmd_operate_detach_device_keyword = 1457 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1458 keyword, "detach"); 1459 cmdline_parse_token_string_t cmd_operate_detach_device_identifier = 1460 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1461 identifier, NULL); 1462 1463 cmdline_parse_inst_t cmd_operate_detach_device = { 1464 .f = cmd_operate_detach_device_parsed, 1465 .data = NULL, 1466 .help_str = "device detach <identifier>:" 1467 "(identifier: pci address or virtual dev name)", 1468 .tokens = { 1469 (void *)&cmd_operate_detach_device_device, 1470 (void *)&cmd_operate_detach_device_keyword, 1471 (void *)&cmd_operate_detach_device_identifier, 1472 NULL, 1473 }, 1474 }; 1475 /* *** configure speed for all ports *** */ 1476 struct cmd_config_speed_all { 1477 cmdline_fixed_string_t port; 1478 cmdline_fixed_string_t keyword; 1479 cmdline_fixed_string_t all; 1480 cmdline_fixed_string_t item1; 1481 cmdline_fixed_string_t item2; 1482 cmdline_fixed_string_t value1; 1483 cmdline_fixed_string_t value2; 1484 }; 1485 1486 static int 1487 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1488 { 1489 1490 int duplex; 1491 1492 if (!strcmp(duplexstr, "half")) { 1493 duplex = ETH_LINK_HALF_DUPLEX; 1494 } else if (!strcmp(duplexstr, "full")) { 1495 duplex = ETH_LINK_FULL_DUPLEX; 1496 } else if (!strcmp(duplexstr, "auto")) { 1497 duplex = ETH_LINK_FULL_DUPLEX; 1498 } else { 1499 fprintf(stderr, "Unknown duplex parameter\n"); 1500 return -1; 1501 } 1502 1503 if (!strcmp(speedstr, "10")) { 1504 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1505 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M; 1506 } else if (!strcmp(speedstr, "100")) { 1507 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1508 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M; 1509 } else { 1510 if (duplex != ETH_LINK_FULL_DUPLEX) { 1511 fprintf(stderr, "Invalid speed/duplex parameters\n"); 1512 return -1; 1513 } 1514 if (!strcmp(speedstr, "1000")) { 1515 *speed = ETH_LINK_SPEED_1G; 1516 } else if (!strcmp(speedstr, "10000")) { 1517 *speed = ETH_LINK_SPEED_10G; 1518 } else if (!strcmp(speedstr, "25000")) { 1519 *speed = ETH_LINK_SPEED_25G; 1520 } else if (!strcmp(speedstr, "40000")) { 1521 *speed = ETH_LINK_SPEED_40G; 1522 } else if (!strcmp(speedstr, "50000")) { 1523 *speed = ETH_LINK_SPEED_50G; 1524 } else if (!strcmp(speedstr, "100000")) { 1525 *speed = ETH_LINK_SPEED_100G; 1526 } else if (!strcmp(speedstr, "200000")) { 1527 *speed = ETH_LINK_SPEED_200G; 1528 } else if (!strcmp(speedstr, "auto")) { 1529 *speed = ETH_LINK_SPEED_AUTONEG; 1530 } else { 1531 fprintf(stderr, "Unknown speed parameter\n"); 1532 return -1; 1533 } 1534 } 1535 1536 if (*speed != ETH_LINK_SPEED_AUTONEG) 1537 *speed |= ETH_LINK_SPEED_FIXED; 1538 1539 return 0; 1540 } 1541 1542 static void 1543 cmd_config_speed_all_parsed(void *parsed_result, 1544 __rte_unused struct cmdline *cl, 1545 __rte_unused void *data) 1546 { 1547 struct cmd_config_speed_all *res = parsed_result; 1548 uint32_t link_speed; 1549 portid_t pid; 1550 1551 if (!all_ports_stopped()) { 1552 fprintf(stderr, "Please stop all ports first\n"); 1553 return; 1554 } 1555 1556 if (parse_and_check_speed_duplex(res->value1, res->value2, 1557 &link_speed) < 0) 1558 return; 1559 1560 RTE_ETH_FOREACH_DEV(pid) { 1561 ports[pid].dev_conf.link_speeds = link_speed; 1562 } 1563 1564 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1565 } 1566 1567 cmdline_parse_token_string_t cmd_config_speed_all_port = 1568 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1569 cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1570 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1571 "config"); 1572 cmdline_parse_token_string_t cmd_config_speed_all_all = 1573 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1574 cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1575 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1576 cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1577 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1578 "10#100#1000#10000#25000#40000#50000#100000#200000#auto"); 1579 cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1580 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1581 cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1582 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1583 "half#full#auto"); 1584 1585 cmdline_parse_inst_t cmd_config_speed_all = { 1586 .f = cmd_config_speed_all_parsed, 1587 .data = NULL, 1588 .help_str = "port config all speed " 1589 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex " 1590 "half|full|auto", 1591 .tokens = { 1592 (void *)&cmd_config_speed_all_port, 1593 (void *)&cmd_config_speed_all_keyword, 1594 (void *)&cmd_config_speed_all_all, 1595 (void *)&cmd_config_speed_all_item1, 1596 (void *)&cmd_config_speed_all_value1, 1597 (void *)&cmd_config_speed_all_item2, 1598 (void *)&cmd_config_speed_all_value2, 1599 NULL, 1600 }, 1601 }; 1602 1603 /* *** configure speed for specific port *** */ 1604 struct cmd_config_speed_specific { 1605 cmdline_fixed_string_t port; 1606 cmdline_fixed_string_t keyword; 1607 portid_t id; 1608 cmdline_fixed_string_t item1; 1609 cmdline_fixed_string_t item2; 1610 cmdline_fixed_string_t value1; 1611 cmdline_fixed_string_t value2; 1612 }; 1613 1614 static void 1615 cmd_config_speed_specific_parsed(void *parsed_result, 1616 __rte_unused struct cmdline *cl, 1617 __rte_unused void *data) 1618 { 1619 struct cmd_config_speed_specific *res = parsed_result; 1620 uint32_t link_speed; 1621 1622 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1623 return; 1624 1625 if (!port_is_stopped(res->id)) { 1626 fprintf(stderr, "Please stop port %d first\n", res->id); 1627 return; 1628 } 1629 1630 if (parse_and_check_speed_duplex(res->value1, res->value2, 1631 &link_speed) < 0) 1632 return; 1633 1634 ports[res->id].dev_conf.link_speeds = link_speed; 1635 1636 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1637 } 1638 1639 1640 cmdline_parse_token_string_t cmd_config_speed_specific_port = 1641 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1642 "port"); 1643 cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1644 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1645 "config"); 1646 cmdline_parse_token_num_t cmd_config_speed_specific_id = 1647 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16); 1648 cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1649 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1650 "speed"); 1651 cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1652 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1653 "10#100#1000#10000#25000#40000#50000#100000#200000#auto"); 1654 cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1655 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1656 "duplex"); 1657 cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1658 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1659 "half#full#auto"); 1660 1661 cmdline_parse_inst_t cmd_config_speed_specific = { 1662 .f = cmd_config_speed_specific_parsed, 1663 .data = NULL, 1664 .help_str = "port config <port_id> speed " 1665 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex " 1666 "half|full|auto", 1667 .tokens = { 1668 (void *)&cmd_config_speed_specific_port, 1669 (void *)&cmd_config_speed_specific_keyword, 1670 (void *)&cmd_config_speed_specific_id, 1671 (void *)&cmd_config_speed_specific_item1, 1672 (void *)&cmd_config_speed_specific_value1, 1673 (void *)&cmd_config_speed_specific_item2, 1674 (void *)&cmd_config_speed_specific_value2, 1675 NULL, 1676 }, 1677 }; 1678 1679 /* *** configure loopback for all ports *** */ 1680 struct cmd_config_loopback_all { 1681 cmdline_fixed_string_t port; 1682 cmdline_fixed_string_t keyword; 1683 cmdline_fixed_string_t all; 1684 cmdline_fixed_string_t item; 1685 uint32_t mode; 1686 }; 1687 1688 static void 1689 cmd_config_loopback_all_parsed(void *parsed_result, 1690 __rte_unused struct cmdline *cl, 1691 __rte_unused void *data) 1692 { 1693 struct cmd_config_loopback_all *res = parsed_result; 1694 portid_t pid; 1695 1696 if (!all_ports_stopped()) { 1697 fprintf(stderr, "Please stop all ports first\n"); 1698 return; 1699 } 1700 1701 RTE_ETH_FOREACH_DEV(pid) { 1702 ports[pid].dev_conf.lpbk_mode = res->mode; 1703 } 1704 1705 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1706 } 1707 1708 cmdline_parse_token_string_t cmd_config_loopback_all_port = 1709 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port"); 1710 cmdline_parse_token_string_t cmd_config_loopback_all_keyword = 1711 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword, 1712 "config"); 1713 cmdline_parse_token_string_t cmd_config_loopback_all_all = 1714 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all"); 1715 cmdline_parse_token_string_t cmd_config_loopback_all_item = 1716 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item, 1717 "loopback"); 1718 cmdline_parse_token_num_t cmd_config_loopback_all_mode = 1719 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32); 1720 1721 cmdline_parse_inst_t cmd_config_loopback_all = { 1722 .f = cmd_config_loopback_all_parsed, 1723 .data = NULL, 1724 .help_str = "port config all loopback <mode>", 1725 .tokens = { 1726 (void *)&cmd_config_loopback_all_port, 1727 (void *)&cmd_config_loopback_all_keyword, 1728 (void *)&cmd_config_loopback_all_all, 1729 (void *)&cmd_config_loopback_all_item, 1730 (void *)&cmd_config_loopback_all_mode, 1731 NULL, 1732 }, 1733 }; 1734 1735 /* *** configure loopback for specific port *** */ 1736 struct cmd_config_loopback_specific { 1737 cmdline_fixed_string_t port; 1738 cmdline_fixed_string_t keyword; 1739 uint16_t port_id; 1740 cmdline_fixed_string_t item; 1741 uint32_t mode; 1742 }; 1743 1744 static void 1745 cmd_config_loopback_specific_parsed(void *parsed_result, 1746 __rte_unused struct cmdline *cl, 1747 __rte_unused void *data) 1748 { 1749 struct cmd_config_loopback_specific *res = parsed_result; 1750 1751 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 1752 return; 1753 1754 if (!port_is_stopped(res->port_id)) { 1755 fprintf(stderr, "Please stop port %u first\n", res->port_id); 1756 return; 1757 } 1758 1759 ports[res->port_id].dev_conf.lpbk_mode = res->mode; 1760 1761 cmd_reconfig_device_queue(res->port_id, 1, 1); 1762 } 1763 1764 1765 cmdline_parse_token_string_t cmd_config_loopback_specific_port = 1766 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port, 1767 "port"); 1768 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword = 1769 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword, 1770 "config"); 1771 cmdline_parse_token_num_t cmd_config_loopback_specific_id = 1772 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id, 1773 RTE_UINT16); 1774 cmdline_parse_token_string_t cmd_config_loopback_specific_item = 1775 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item, 1776 "loopback"); 1777 cmdline_parse_token_num_t cmd_config_loopback_specific_mode = 1778 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode, 1779 RTE_UINT32); 1780 1781 cmdline_parse_inst_t cmd_config_loopback_specific = { 1782 .f = cmd_config_loopback_specific_parsed, 1783 .data = NULL, 1784 .help_str = "port config <port_id> loopback <mode>", 1785 .tokens = { 1786 (void *)&cmd_config_loopback_specific_port, 1787 (void *)&cmd_config_loopback_specific_keyword, 1788 (void *)&cmd_config_loopback_specific_id, 1789 (void *)&cmd_config_loopback_specific_item, 1790 (void *)&cmd_config_loopback_specific_mode, 1791 NULL, 1792 }, 1793 }; 1794 1795 /* *** configure txq/rxq, txd/rxd *** */ 1796 struct cmd_config_rx_tx { 1797 cmdline_fixed_string_t port; 1798 cmdline_fixed_string_t keyword; 1799 cmdline_fixed_string_t all; 1800 cmdline_fixed_string_t name; 1801 uint16_t value; 1802 }; 1803 1804 static void 1805 cmd_config_rx_tx_parsed(void *parsed_result, 1806 __rte_unused struct cmdline *cl, 1807 __rte_unused void *data) 1808 { 1809 struct cmd_config_rx_tx *res = parsed_result; 1810 1811 if (!all_ports_stopped()) { 1812 fprintf(stderr, "Please stop all ports first\n"); 1813 return; 1814 } 1815 if (!strcmp(res->name, "rxq")) { 1816 if (!res->value && !nb_txq) { 1817 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n"); 1818 return; 1819 } 1820 if (check_nb_rxq(res->value) != 0) 1821 return; 1822 nb_rxq = res->value; 1823 } 1824 else if (!strcmp(res->name, "txq")) { 1825 if (!res->value && !nb_rxq) { 1826 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n"); 1827 return; 1828 } 1829 if (check_nb_txq(res->value) != 0) 1830 return; 1831 nb_txq = res->value; 1832 } 1833 else if (!strcmp(res->name, "rxd")) { 1834 if (check_nb_rxd(res->value) != 0) 1835 return; 1836 nb_rxd = res->value; 1837 } else if (!strcmp(res->name, "txd")) { 1838 if (check_nb_txd(res->value) != 0) 1839 return; 1840 1841 nb_txd = res->value; 1842 } else { 1843 fprintf(stderr, "Unknown parameter\n"); 1844 return; 1845 } 1846 1847 fwd_config_setup(); 1848 1849 init_port_config(); 1850 1851 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1852 } 1853 1854 cmdline_parse_token_string_t cmd_config_rx_tx_port = 1855 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1856 cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1857 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1858 cmdline_parse_token_string_t cmd_config_rx_tx_all = 1859 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1860 cmdline_parse_token_string_t cmd_config_rx_tx_name = 1861 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1862 "rxq#txq#rxd#txd"); 1863 cmdline_parse_token_num_t cmd_config_rx_tx_value = 1864 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16); 1865 1866 cmdline_parse_inst_t cmd_config_rx_tx = { 1867 .f = cmd_config_rx_tx_parsed, 1868 .data = NULL, 1869 .help_str = "port config all rxq|txq|rxd|txd <value>", 1870 .tokens = { 1871 (void *)&cmd_config_rx_tx_port, 1872 (void *)&cmd_config_rx_tx_keyword, 1873 (void *)&cmd_config_rx_tx_all, 1874 (void *)&cmd_config_rx_tx_name, 1875 (void *)&cmd_config_rx_tx_value, 1876 NULL, 1877 }, 1878 }; 1879 1880 /* *** config max packet length *** */ 1881 struct cmd_config_max_pkt_len_result { 1882 cmdline_fixed_string_t port; 1883 cmdline_fixed_string_t keyword; 1884 cmdline_fixed_string_t all; 1885 cmdline_fixed_string_t name; 1886 uint32_t value; 1887 }; 1888 1889 static void 1890 cmd_config_max_pkt_len_parsed(void *parsed_result, 1891 __rte_unused struct cmdline *cl, 1892 __rte_unused void *data) 1893 { 1894 struct cmd_config_max_pkt_len_result *res = parsed_result; 1895 uint32_t max_rx_pkt_len_backup = 0; 1896 portid_t pid; 1897 int ret; 1898 1899 if (!all_ports_stopped()) { 1900 fprintf(stderr, "Please stop all ports first\n"); 1901 return; 1902 } 1903 1904 RTE_ETH_FOREACH_DEV(pid) { 1905 struct rte_port *port = &ports[pid]; 1906 1907 if (!strcmp(res->name, "max-pkt-len")) { 1908 if (res->value < RTE_ETHER_MIN_LEN) { 1909 fprintf(stderr, 1910 "max-pkt-len can not be less than %d\n", 1911 RTE_ETHER_MIN_LEN); 1912 return; 1913 } 1914 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len) 1915 return; 1916 1917 ret = eth_dev_info_get_print_err(pid, &port->dev_info); 1918 if (ret != 0) { 1919 fprintf(stderr, 1920 "rte_eth_dev_info_get() failed for port %u\n", 1921 pid); 1922 return; 1923 } 1924 1925 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len; 1926 1927 port->dev_conf.rxmode.max_rx_pkt_len = res->value; 1928 if (update_jumbo_frame_offload(pid) != 0) 1929 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup; 1930 } else { 1931 fprintf(stderr, "Unknown parameter\n"); 1932 return; 1933 } 1934 } 1935 1936 init_port_config(); 1937 1938 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1939 } 1940 1941 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 1942 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 1943 "port"); 1944 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 1945 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 1946 "config"); 1947 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 1948 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 1949 "all"); 1950 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 1951 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 1952 "max-pkt-len"); 1953 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 1954 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 1955 RTE_UINT32); 1956 1957 cmdline_parse_inst_t cmd_config_max_pkt_len = { 1958 .f = cmd_config_max_pkt_len_parsed, 1959 .data = NULL, 1960 .help_str = "port config all max-pkt-len <value>", 1961 .tokens = { 1962 (void *)&cmd_config_max_pkt_len_port, 1963 (void *)&cmd_config_max_pkt_len_keyword, 1964 (void *)&cmd_config_max_pkt_len_all, 1965 (void *)&cmd_config_max_pkt_len_name, 1966 (void *)&cmd_config_max_pkt_len_value, 1967 NULL, 1968 }, 1969 }; 1970 1971 /* *** config max LRO aggregated packet size *** */ 1972 struct cmd_config_max_lro_pkt_size_result { 1973 cmdline_fixed_string_t port; 1974 cmdline_fixed_string_t keyword; 1975 cmdline_fixed_string_t all; 1976 cmdline_fixed_string_t name; 1977 uint32_t value; 1978 }; 1979 1980 static void 1981 cmd_config_max_lro_pkt_size_parsed(void *parsed_result, 1982 __rte_unused struct cmdline *cl, 1983 __rte_unused void *data) 1984 { 1985 struct cmd_config_max_lro_pkt_size_result *res = parsed_result; 1986 portid_t pid; 1987 1988 if (!all_ports_stopped()) { 1989 fprintf(stderr, "Please stop all ports first\n"); 1990 return; 1991 } 1992 1993 RTE_ETH_FOREACH_DEV(pid) { 1994 struct rte_port *port = &ports[pid]; 1995 1996 if (!strcmp(res->name, "max-lro-pkt-size")) { 1997 if (res->value == 1998 port->dev_conf.rxmode.max_lro_pkt_size) 1999 return; 2000 2001 port->dev_conf.rxmode.max_lro_pkt_size = res->value; 2002 } else { 2003 fprintf(stderr, "Unknown parameter\n"); 2004 return; 2005 } 2006 } 2007 2008 init_port_config(); 2009 2010 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2011 } 2012 2013 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port = 2014 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2015 port, "port"); 2016 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword = 2017 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2018 keyword, "config"); 2019 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all = 2020 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2021 all, "all"); 2022 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name = 2023 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2024 name, "max-lro-pkt-size"); 2025 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value = 2026 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2027 value, RTE_UINT32); 2028 2029 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = { 2030 .f = cmd_config_max_lro_pkt_size_parsed, 2031 .data = NULL, 2032 .help_str = "port config all max-lro-pkt-size <value>", 2033 .tokens = { 2034 (void *)&cmd_config_max_lro_pkt_size_port, 2035 (void *)&cmd_config_max_lro_pkt_size_keyword, 2036 (void *)&cmd_config_max_lro_pkt_size_all, 2037 (void *)&cmd_config_max_lro_pkt_size_name, 2038 (void *)&cmd_config_max_lro_pkt_size_value, 2039 NULL, 2040 }, 2041 }; 2042 2043 /* *** configure port MTU *** */ 2044 struct cmd_config_mtu_result { 2045 cmdline_fixed_string_t port; 2046 cmdline_fixed_string_t keyword; 2047 cmdline_fixed_string_t mtu; 2048 portid_t port_id; 2049 uint16_t value; 2050 }; 2051 2052 static void 2053 cmd_config_mtu_parsed(void *parsed_result, 2054 __rte_unused struct cmdline *cl, 2055 __rte_unused void *data) 2056 { 2057 struct cmd_config_mtu_result *res = parsed_result; 2058 2059 if (res->value < RTE_ETHER_MIN_LEN) { 2060 fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN); 2061 return; 2062 } 2063 port_mtu_set(res->port_id, res->value); 2064 } 2065 2066 cmdline_parse_token_string_t cmd_config_mtu_port = 2067 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 2068 "port"); 2069 cmdline_parse_token_string_t cmd_config_mtu_keyword = 2070 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2071 "config"); 2072 cmdline_parse_token_string_t cmd_config_mtu_mtu = 2073 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2074 "mtu"); 2075 cmdline_parse_token_num_t cmd_config_mtu_port_id = 2076 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, 2077 RTE_UINT16); 2078 cmdline_parse_token_num_t cmd_config_mtu_value = 2079 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, 2080 RTE_UINT16); 2081 2082 cmdline_parse_inst_t cmd_config_mtu = { 2083 .f = cmd_config_mtu_parsed, 2084 .data = NULL, 2085 .help_str = "port config mtu <port_id> <value>", 2086 .tokens = { 2087 (void *)&cmd_config_mtu_port, 2088 (void *)&cmd_config_mtu_keyword, 2089 (void *)&cmd_config_mtu_mtu, 2090 (void *)&cmd_config_mtu_port_id, 2091 (void *)&cmd_config_mtu_value, 2092 NULL, 2093 }, 2094 }; 2095 2096 /* *** configure rx mode *** */ 2097 struct cmd_config_rx_mode_flag { 2098 cmdline_fixed_string_t port; 2099 cmdline_fixed_string_t keyword; 2100 cmdline_fixed_string_t all; 2101 cmdline_fixed_string_t name; 2102 cmdline_fixed_string_t value; 2103 }; 2104 2105 static void 2106 cmd_config_rx_mode_flag_parsed(void *parsed_result, 2107 __rte_unused struct cmdline *cl, 2108 __rte_unused void *data) 2109 { 2110 struct cmd_config_rx_mode_flag *res = parsed_result; 2111 2112 if (!all_ports_stopped()) { 2113 fprintf(stderr, "Please stop all ports first\n"); 2114 return; 2115 } 2116 2117 if (!strcmp(res->name, "drop-en")) { 2118 if (!strcmp(res->value, "on")) 2119 rx_drop_en = 1; 2120 else if (!strcmp(res->value, "off")) 2121 rx_drop_en = 0; 2122 else { 2123 fprintf(stderr, "Unknown parameter\n"); 2124 return; 2125 } 2126 } else { 2127 fprintf(stderr, "Unknown parameter\n"); 2128 return; 2129 } 2130 2131 init_port_config(); 2132 2133 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2134 } 2135 2136 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 2137 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 2138 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 2139 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 2140 "config"); 2141 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 2142 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 2143 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 2144 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 2145 "drop-en"); 2146 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 2147 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 2148 "on#off"); 2149 2150 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 2151 .f = cmd_config_rx_mode_flag_parsed, 2152 .data = NULL, 2153 .help_str = "port config all drop-en on|off", 2154 .tokens = { 2155 (void *)&cmd_config_rx_mode_flag_port, 2156 (void *)&cmd_config_rx_mode_flag_keyword, 2157 (void *)&cmd_config_rx_mode_flag_all, 2158 (void *)&cmd_config_rx_mode_flag_name, 2159 (void *)&cmd_config_rx_mode_flag_value, 2160 NULL, 2161 }, 2162 }; 2163 2164 /* *** configure rss *** */ 2165 struct cmd_config_rss { 2166 cmdline_fixed_string_t port; 2167 cmdline_fixed_string_t keyword; 2168 cmdline_fixed_string_t all; 2169 cmdline_fixed_string_t name; 2170 cmdline_fixed_string_t value; 2171 }; 2172 2173 static void 2174 cmd_config_rss_parsed(void *parsed_result, 2175 __rte_unused struct cmdline *cl, 2176 __rte_unused void *data) 2177 { 2178 struct cmd_config_rss *res = parsed_result; 2179 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2180 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2181 int use_default = 0; 2182 int all_updated = 1; 2183 int diag; 2184 uint16_t i; 2185 int ret; 2186 2187 if (!strcmp(res->value, "all")) 2188 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP | 2189 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP | 2190 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP | 2191 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU | 2192 ETH_RSS_ECPRI; 2193 else if (!strcmp(res->value, "eth")) 2194 rss_conf.rss_hf = ETH_RSS_ETH; 2195 else if (!strcmp(res->value, "vlan")) 2196 rss_conf.rss_hf = ETH_RSS_VLAN; 2197 else if (!strcmp(res->value, "ip")) 2198 rss_conf.rss_hf = ETH_RSS_IP; 2199 else if (!strcmp(res->value, "udp")) 2200 rss_conf.rss_hf = ETH_RSS_UDP; 2201 else if (!strcmp(res->value, "tcp")) 2202 rss_conf.rss_hf = ETH_RSS_TCP; 2203 else if (!strcmp(res->value, "sctp")) 2204 rss_conf.rss_hf = ETH_RSS_SCTP; 2205 else if (!strcmp(res->value, "ether")) 2206 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 2207 else if (!strcmp(res->value, "port")) 2208 rss_conf.rss_hf = ETH_RSS_PORT; 2209 else if (!strcmp(res->value, "vxlan")) 2210 rss_conf.rss_hf = ETH_RSS_VXLAN; 2211 else if (!strcmp(res->value, "geneve")) 2212 rss_conf.rss_hf = ETH_RSS_GENEVE; 2213 else if (!strcmp(res->value, "nvgre")) 2214 rss_conf.rss_hf = ETH_RSS_NVGRE; 2215 else if (!strcmp(res->value, "l3-pre32")) 2216 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32; 2217 else if (!strcmp(res->value, "l3-pre40")) 2218 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40; 2219 else if (!strcmp(res->value, "l3-pre48")) 2220 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48; 2221 else if (!strcmp(res->value, "l3-pre56")) 2222 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56; 2223 else if (!strcmp(res->value, "l3-pre64")) 2224 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64; 2225 else if (!strcmp(res->value, "l3-pre96")) 2226 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96; 2227 else if (!strcmp(res->value, "l3-src-only")) 2228 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY; 2229 else if (!strcmp(res->value, "l3-dst-only")) 2230 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY; 2231 else if (!strcmp(res->value, "l4-src-only")) 2232 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY; 2233 else if (!strcmp(res->value, "l4-dst-only")) 2234 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY; 2235 else if (!strcmp(res->value, "l2-src-only")) 2236 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY; 2237 else if (!strcmp(res->value, "l2-dst-only")) 2238 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY; 2239 else if (!strcmp(res->value, "l2tpv3")) 2240 rss_conf.rss_hf = ETH_RSS_L2TPV3; 2241 else if (!strcmp(res->value, "esp")) 2242 rss_conf.rss_hf = ETH_RSS_ESP; 2243 else if (!strcmp(res->value, "ah")) 2244 rss_conf.rss_hf = ETH_RSS_AH; 2245 else if (!strcmp(res->value, "pfcp")) 2246 rss_conf.rss_hf = ETH_RSS_PFCP; 2247 else if (!strcmp(res->value, "pppoe")) 2248 rss_conf.rss_hf = ETH_RSS_PPPOE; 2249 else if (!strcmp(res->value, "gtpu")) 2250 rss_conf.rss_hf = ETH_RSS_GTPU; 2251 else if (!strcmp(res->value, "ecpri")) 2252 rss_conf.rss_hf = ETH_RSS_ECPRI; 2253 else if (!strcmp(res->value, "mpls")) 2254 rss_conf.rss_hf = ETH_RSS_MPLS; 2255 else if (!strcmp(res->value, "none")) 2256 rss_conf.rss_hf = 0; 2257 else if (!strcmp(res->value, "level-default")) { 2258 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2259 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT); 2260 } else if (!strcmp(res->value, "level-outer")) { 2261 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2262 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST); 2263 } else if (!strcmp(res->value, "level-inner")) { 2264 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2265 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST); 2266 } else if (!strcmp(res->value, "default")) 2267 use_default = 1; 2268 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 2269 atoi(res->value) < 64) 2270 rss_conf.rss_hf = 1ULL << atoi(res->value); 2271 else { 2272 fprintf(stderr, "Unknown parameter\n"); 2273 return; 2274 } 2275 rss_conf.rss_key = NULL; 2276 /* Update global configuration for RSS types. */ 2277 RTE_ETH_FOREACH_DEV(i) { 2278 struct rte_eth_rss_conf local_rss_conf; 2279 2280 ret = eth_dev_info_get_print_err(i, &dev_info); 2281 if (ret != 0) 2282 return; 2283 2284 if (use_default) 2285 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2286 2287 local_rss_conf = rss_conf; 2288 local_rss_conf.rss_hf = rss_conf.rss_hf & 2289 dev_info.flow_type_rss_offloads; 2290 if (local_rss_conf.rss_hf != rss_conf.rss_hf) { 2291 printf("Port %u modified RSS hash function based on hardware support," 2292 "requested:%#"PRIx64" configured:%#"PRIx64"\n", 2293 i, rss_conf.rss_hf, local_rss_conf.rss_hf); 2294 } 2295 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf); 2296 if (diag < 0) { 2297 all_updated = 0; 2298 fprintf(stderr, 2299 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n", 2300 i, -diag, strerror(-diag)); 2301 } 2302 } 2303 if (all_updated && !use_default) { 2304 rss_hf = rss_conf.rss_hf; 2305 printf("rss_hf %#"PRIx64"\n", rss_hf); 2306 } 2307 } 2308 2309 cmdline_parse_token_string_t cmd_config_rss_port = 2310 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2311 cmdline_parse_token_string_t cmd_config_rss_keyword = 2312 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2313 cmdline_parse_token_string_t cmd_config_rss_all = 2314 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2315 cmdline_parse_token_string_t cmd_config_rss_name = 2316 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2317 cmdline_parse_token_string_t cmd_config_rss_value = 2318 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2319 2320 cmdline_parse_inst_t cmd_config_rss = { 2321 .f = cmd_config_rss_parsed, 2322 .data = NULL, 2323 .help_str = "port config all rss " 2324 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|" 2325 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|" 2326 "level-outer|level-inner|<flowtype_id>", 2327 .tokens = { 2328 (void *)&cmd_config_rss_port, 2329 (void *)&cmd_config_rss_keyword, 2330 (void *)&cmd_config_rss_all, 2331 (void *)&cmd_config_rss_name, 2332 (void *)&cmd_config_rss_value, 2333 NULL, 2334 }, 2335 }; 2336 2337 /* *** configure rss hash key *** */ 2338 struct cmd_config_rss_hash_key { 2339 cmdline_fixed_string_t port; 2340 cmdline_fixed_string_t config; 2341 portid_t port_id; 2342 cmdline_fixed_string_t rss_hash_key; 2343 cmdline_fixed_string_t rss_type; 2344 cmdline_fixed_string_t key; 2345 }; 2346 2347 static uint8_t 2348 hexa_digit_to_value(char hexa_digit) 2349 { 2350 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2351 return (uint8_t) (hexa_digit - '0'); 2352 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2353 return (uint8_t) ((hexa_digit - 'a') + 10); 2354 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2355 return (uint8_t) ((hexa_digit - 'A') + 10); 2356 /* Invalid hexa digit */ 2357 return 0xFF; 2358 } 2359 2360 static uint8_t 2361 parse_and_check_key_hexa_digit(char *key, int idx) 2362 { 2363 uint8_t hexa_v; 2364 2365 hexa_v = hexa_digit_to_value(key[idx]); 2366 if (hexa_v == 0xFF) 2367 fprintf(stderr, 2368 "invalid key: character %c at position %d is not a valid hexa digit\n", 2369 key[idx], idx); 2370 return hexa_v; 2371 } 2372 2373 static void 2374 cmd_config_rss_hash_key_parsed(void *parsed_result, 2375 __rte_unused struct cmdline *cl, 2376 __rte_unused void *data) 2377 { 2378 struct cmd_config_rss_hash_key *res = parsed_result; 2379 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2380 uint8_t xdgt0; 2381 uint8_t xdgt1; 2382 int i; 2383 struct rte_eth_dev_info dev_info; 2384 uint8_t hash_key_size; 2385 uint32_t key_len; 2386 int ret; 2387 2388 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2389 if (ret != 0) 2390 return; 2391 2392 if (dev_info.hash_key_size > 0 && 2393 dev_info.hash_key_size <= sizeof(hash_key)) 2394 hash_key_size = dev_info.hash_key_size; 2395 else { 2396 fprintf(stderr, 2397 "dev_info did not provide a valid hash key size\n"); 2398 return; 2399 } 2400 /* Check the length of the RSS hash key */ 2401 key_len = strlen(res->key); 2402 if (key_len != (hash_key_size * 2)) { 2403 fprintf(stderr, 2404 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n", 2405 (int)key_len, hash_key_size * 2); 2406 return; 2407 } 2408 /* Translate RSS hash key into binary representation */ 2409 for (i = 0; i < hash_key_size; i++) { 2410 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2411 if (xdgt0 == 0xFF) 2412 return; 2413 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2414 if (xdgt1 == 0xFF) 2415 return; 2416 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2417 } 2418 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2419 hash_key_size); 2420 } 2421 2422 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2423 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2424 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2425 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2426 "config"); 2427 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2428 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, 2429 RTE_UINT16); 2430 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2431 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2432 rss_hash_key, "rss-hash-key"); 2433 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2434 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2435 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2436 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2437 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2438 "ipv6-tcp-ex#ipv6-udp-ex#" 2439 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#" 2440 "l2-src-only#l2-dst-only#s-vlan#c-vlan#" 2441 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls"); 2442 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2443 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2444 2445 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2446 .f = cmd_config_rss_hash_key_parsed, 2447 .data = NULL, 2448 .help_str = "port config <port_id> rss-hash-key " 2449 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2450 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2451 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|" 2452 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|" 2453 "l2-src-only|l2-dst-only|s-vlan|c-vlan|" 2454 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls " 2455 "<string of hex digits (variable length, NIC dependent)>", 2456 .tokens = { 2457 (void *)&cmd_config_rss_hash_key_port, 2458 (void *)&cmd_config_rss_hash_key_config, 2459 (void *)&cmd_config_rss_hash_key_port_id, 2460 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2461 (void *)&cmd_config_rss_hash_key_rss_type, 2462 (void *)&cmd_config_rss_hash_key_value, 2463 NULL, 2464 }, 2465 }; 2466 2467 /* *** cleanup txq mbufs *** */ 2468 struct cmd_cleanup_txq_mbufs_result { 2469 cmdline_fixed_string_t port; 2470 cmdline_fixed_string_t keyword; 2471 cmdline_fixed_string_t name; 2472 uint16_t port_id; 2473 uint16_t queue_id; 2474 uint32_t free_cnt; 2475 }; 2476 2477 static void 2478 cmd_cleanup_txq_mbufs_parsed(void *parsed_result, 2479 __rte_unused struct cmdline *cl, 2480 __rte_unused void *data) 2481 { 2482 struct cmd_cleanup_txq_mbufs_result *res = parsed_result; 2483 uint16_t port_id = res->port_id; 2484 uint16_t queue_id = res->queue_id; 2485 uint32_t free_cnt = res->free_cnt; 2486 struct rte_eth_txq_info qinfo; 2487 int ret; 2488 2489 if (test_done == 0) { 2490 fprintf(stderr, "Please stop forwarding first\n"); 2491 return; 2492 } 2493 2494 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) { 2495 fprintf(stderr, "Failed to get port %u Tx queue %u info\n", 2496 port_id, queue_id); 2497 return; 2498 } 2499 2500 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) { 2501 fprintf(stderr, "Tx queue %u not started\n", queue_id); 2502 return; 2503 } 2504 2505 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt); 2506 if (ret < 0) { 2507 fprintf(stderr, 2508 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n", 2509 port_id, queue_id, strerror(-ret), ret); 2510 return; 2511 } 2512 2513 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n", 2514 port_id, queue_id, ret); 2515 } 2516 2517 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port = 2518 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port, 2519 "port"); 2520 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup = 2521 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword, 2522 "cleanup"); 2523 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id = 2524 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id, 2525 RTE_UINT16); 2526 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq = 2527 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name, 2528 "txq"); 2529 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id = 2530 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id, 2531 RTE_UINT16); 2532 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt = 2533 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt, 2534 RTE_UINT32); 2535 2536 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = { 2537 .f = cmd_cleanup_txq_mbufs_parsed, 2538 .data = NULL, 2539 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>", 2540 .tokens = { 2541 (void *)&cmd_cleanup_txq_mbufs_port, 2542 (void *)&cmd_cleanup_txq_mbufs_cleanup, 2543 (void *)&cmd_cleanup_txq_mbufs_port_id, 2544 (void *)&cmd_cleanup_txq_mbufs_txq, 2545 (void *)&cmd_cleanup_txq_mbufs_queue_id, 2546 (void *)&cmd_cleanup_txq_mbufs_free_cnt, 2547 NULL, 2548 }, 2549 }; 2550 2551 /* *** configure port rxq/txq ring size *** */ 2552 struct cmd_config_rxtx_ring_size { 2553 cmdline_fixed_string_t port; 2554 cmdline_fixed_string_t config; 2555 portid_t portid; 2556 cmdline_fixed_string_t rxtxq; 2557 uint16_t qid; 2558 cmdline_fixed_string_t rsize; 2559 uint16_t size; 2560 }; 2561 2562 static void 2563 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2564 __rte_unused struct cmdline *cl, 2565 __rte_unused void *data) 2566 { 2567 struct cmd_config_rxtx_ring_size *res = parsed_result; 2568 struct rte_port *port; 2569 uint8_t isrx; 2570 2571 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2572 return; 2573 2574 if (res->portid == (portid_t)RTE_PORT_ALL) { 2575 fprintf(stderr, "Invalid port id\n"); 2576 return; 2577 } 2578 2579 port = &ports[res->portid]; 2580 2581 if (!strcmp(res->rxtxq, "rxq")) 2582 isrx = 1; 2583 else if (!strcmp(res->rxtxq, "txq")) 2584 isrx = 0; 2585 else { 2586 fprintf(stderr, "Unknown parameter\n"); 2587 return; 2588 } 2589 2590 if (isrx && rx_queue_id_is_invalid(res->qid)) 2591 return; 2592 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2593 return; 2594 2595 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2596 fprintf(stderr, 2597 "Invalid rx ring_size, must > rx_free_thresh: %d\n", 2598 rx_free_thresh); 2599 return; 2600 } 2601 2602 if (isrx) 2603 port->nb_rx_desc[res->qid] = res->size; 2604 else 2605 port->nb_tx_desc[res->qid] = res->size; 2606 2607 cmd_reconfig_device_queue(res->portid, 0, 1); 2608 } 2609 2610 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2611 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2612 port, "port"); 2613 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2614 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2615 config, "config"); 2616 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2617 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2618 portid, RTE_UINT16); 2619 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2620 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2621 rxtxq, "rxq#txq"); 2622 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2623 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2624 qid, RTE_UINT16); 2625 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2626 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2627 rsize, "ring_size"); 2628 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2629 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2630 size, RTE_UINT16); 2631 2632 cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2633 .f = cmd_config_rxtx_ring_size_parsed, 2634 .data = NULL, 2635 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2636 .tokens = { 2637 (void *)&cmd_config_rxtx_ring_size_port, 2638 (void *)&cmd_config_rxtx_ring_size_config, 2639 (void *)&cmd_config_rxtx_ring_size_portid, 2640 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2641 (void *)&cmd_config_rxtx_ring_size_qid, 2642 (void *)&cmd_config_rxtx_ring_size_rsize, 2643 (void *)&cmd_config_rxtx_ring_size_size, 2644 NULL, 2645 }, 2646 }; 2647 2648 /* *** configure port rxq/txq start/stop *** */ 2649 struct cmd_config_rxtx_queue { 2650 cmdline_fixed_string_t port; 2651 portid_t portid; 2652 cmdline_fixed_string_t rxtxq; 2653 uint16_t qid; 2654 cmdline_fixed_string_t opname; 2655 }; 2656 2657 static void 2658 cmd_config_rxtx_queue_parsed(void *parsed_result, 2659 __rte_unused struct cmdline *cl, 2660 __rte_unused void *data) 2661 { 2662 struct cmd_config_rxtx_queue *res = parsed_result; 2663 uint8_t isrx; 2664 uint8_t isstart; 2665 int ret = 0; 2666 2667 if (test_done == 0) { 2668 fprintf(stderr, "Please stop forwarding first\n"); 2669 return; 2670 } 2671 2672 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2673 return; 2674 2675 if (port_is_started(res->portid) != 1) { 2676 fprintf(stderr, "Please start port %u first\n", res->portid); 2677 return; 2678 } 2679 2680 if (!strcmp(res->rxtxq, "rxq")) 2681 isrx = 1; 2682 else if (!strcmp(res->rxtxq, "txq")) 2683 isrx = 0; 2684 else { 2685 fprintf(stderr, "Unknown parameter\n"); 2686 return; 2687 } 2688 2689 if (isrx && rx_queue_id_is_invalid(res->qid)) 2690 return; 2691 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2692 return; 2693 2694 if (!strcmp(res->opname, "start")) 2695 isstart = 1; 2696 else if (!strcmp(res->opname, "stop")) 2697 isstart = 0; 2698 else { 2699 fprintf(stderr, "Unknown parameter\n"); 2700 return; 2701 } 2702 2703 if (isstart && isrx) 2704 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2705 else if (!isstart && isrx) 2706 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2707 else if (isstart && !isrx) 2708 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2709 else 2710 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2711 2712 if (ret == -ENOTSUP) 2713 fprintf(stderr, "Function not supported in PMD driver\n"); 2714 } 2715 2716 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2717 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2718 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2719 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16); 2720 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2721 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2722 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2723 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16); 2724 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2725 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2726 "start#stop"); 2727 2728 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2729 .f = cmd_config_rxtx_queue_parsed, 2730 .data = NULL, 2731 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2732 .tokens = { 2733 (void *)&cmd_config_rxtx_queue_port, 2734 (void *)&cmd_config_rxtx_queue_portid, 2735 (void *)&cmd_config_rxtx_queue_rxtxq, 2736 (void *)&cmd_config_rxtx_queue_qid, 2737 (void *)&cmd_config_rxtx_queue_opname, 2738 NULL, 2739 }, 2740 }; 2741 2742 /* *** configure port rxq/txq deferred start on/off *** */ 2743 struct cmd_config_deferred_start_rxtx_queue { 2744 cmdline_fixed_string_t port; 2745 portid_t port_id; 2746 cmdline_fixed_string_t rxtxq; 2747 uint16_t qid; 2748 cmdline_fixed_string_t opname; 2749 cmdline_fixed_string_t state; 2750 }; 2751 2752 static void 2753 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, 2754 __rte_unused struct cmdline *cl, 2755 __rte_unused void *data) 2756 { 2757 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; 2758 struct rte_port *port; 2759 uint8_t isrx; 2760 uint8_t ison; 2761 uint8_t needreconfig = 0; 2762 2763 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 2764 return; 2765 2766 if (port_is_started(res->port_id) != 0) { 2767 fprintf(stderr, "Please stop port %u first\n", res->port_id); 2768 return; 2769 } 2770 2771 port = &ports[res->port_id]; 2772 2773 isrx = !strcmp(res->rxtxq, "rxq"); 2774 2775 if (isrx && rx_queue_id_is_invalid(res->qid)) 2776 return; 2777 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2778 return; 2779 2780 ison = !strcmp(res->state, "on"); 2781 2782 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) { 2783 port->rx_conf[res->qid].rx_deferred_start = ison; 2784 needreconfig = 1; 2785 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) { 2786 port->tx_conf[res->qid].tx_deferred_start = ison; 2787 needreconfig = 1; 2788 } 2789 2790 if (needreconfig) 2791 cmd_reconfig_device_queue(res->port_id, 0, 1); 2792 } 2793 2794 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = 2795 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2796 port, "port"); 2797 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = 2798 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2799 port_id, RTE_UINT16); 2800 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = 2801 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2802 rxtxq, "rxq#txq"); 2803 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = 2804 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2805 qid, RTE_UINT16); 2806 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = 2807 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2808 opname, "deferred_start"); 2809 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = 2810 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2811 state, "on#off"); 2812 2813 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { 2814 .f = cmd_config_deferred_start_rxtx_queue_parsed, 2815 .data = NULL, 2816 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", 2817 .tokens = { 2818 (void *)&cmd_config_deferred_start_rxtx_queue_port, 2819 (void *)&cmd_config_deferred_start_rxtx_queue_port_id, 2820 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, 2821 (void *)&cmd_config_deferred_start_rxtx_queue_qid, 2822 (void *)&cmd_config_deferred_start_rxtx_queue_opname, 2823 (void *)&cmd_config_deferred_start_rxtx_queue_state, 2824 NULL, 2825 }, 2826 }; 2827 2828 /* *** configure port rxq/txq setup *** */ 2829 struct cmd_setup_rxtx_queue { 2830 cmdline_fixed_string_t port; 2831 portid_t portid; 2832 cmdline_fixed_string_t rxtxq; 2833 uint16_t qid; 2834 cmdline_fixed_string_t setup; 2835 }; 2836 2837 /* Common CLI fields for queue setup */ 2838 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2839 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2840 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2841 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16); 2842 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2843 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2844 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2845 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16); 2846 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2847 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2848 2849 static void 2850 cmd_setup_rxtx_queue_parsed( 2851 void *parsed_result, 2852 __rte_unused struct cmdline *cl, 2853 __rte_unused void *data) 2854 { 2855 struct cmd_setup_rxtx_queue *res = parsed_result; 2856 struct rte_port *port; 2857 struct rte_mempool *mp; 2858 unsigned int socket_id; 2859 uint8_t isrx = 0; 2860 int ret; 2861 2862 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2863 return; 2864 2865 if (res->portid == (portid_t)RTE_PORT_ALL) { 2866 fprintf(stderr, "Invalid port id\n"); 2867 return; 2868 } 2869 2870 if (!strcmp(res->rxtxq, "rxq")) 2871 isrx = 1; 2872 else if (!strcmp(res->rxtxq, "txq")) 2873 isrx = 0; 2874 else { 2875 fprintf(stderr, "Unknown parameter\n"); 2876 return; 2877 } 2878 2879 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2880 fprintf(stderr, "Invalid rx queue\n"); 2881 return; 2882 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2883 fprintf(stderr, "Invalid tx queue\n"); 2884 return; 2885 } 2886 2887 port = &ports[res->portid]; 2888 if (isrx) { 2889 socket_id = rxring_numa[res->portid]; 2890 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2891 socket_id = port->socket_id; 2892 2893 mp = mbuf_pool_find(socket_id, 0); 2894 if (mp == NULL) { 2895 fprintf(stderr, 2896 "Failed to setup RX queue: No mempool allocation on the socket %d\n", 2897 rxring_numa[res->portid]); 2898 return; 2899 } 2900 ret = rx_queue_setup(res->portid, 2901 res->qid, 2902 port->nb_rx_desc[res->qid], 2903 socket_id, 2904 &port->rx_conf[res->qid], 2905 mp); 2906 if (ret) 2907 fprintf(stderr, "Failed to setup RX queue\n"); 2908 } else { 2909 socket_id = txring_numa[res->portid]; 2910 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2911 socket_id = port->socket_id; 2912 2913 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) { 2914 fprintf(stderr, 2915 "Failed to setup TX queue: not enough descriptors\n"); 2916 return; 2917 } 2918 ret = rte_eth_tx_queue_setup(res->portid, 2919 res->qid, 2920 port->nb_tx_desc[res->qid], 2921 socket_id, 2922 &port->tx_conf[res->qid]); 2923 if (ret) 2924 fprintf(stderr, "Failed to setup TX queue\n"); 2925 } 2926 } 2927 2928 cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2929 .f = cmd_setup_rxtx_queue_parsed, 2930 .data = NULL, 2931 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2932 .tokens = { 2933 (void *)&cmd_setup_rxtx_queue_port, 2934 (void *)&cmd_setup_rxtx_queue_portid, 2935 (void *)&cmd_setup_rxtx_queue_rxtxq, 2936 (void *)&cmd_setup_rxtx_queue_qid, 2937 (void *)&cmd_setup_rxtx_queue_setup, 2938 NULL, 2939 }, 2940 }; 2941 2942 2943 /* *** Configure RSS RETA *** */ 2944 struct cmd_config_rss_reta { 2945 cmdline_fixed_string_t port; 2946 cmdline_fixed_string_t keyword; 2947 portid_t port_id; 2948 cmdline_fixed_string_t name; 2949 cmdline_fixed_string_t list_name; 2950 cmdline_fixed_string_t list_of_items; 2951 }; 2952 2953 static int 2954 parse_reta_config(const char *str, 2955 struct rte_eth_rss_reta_entry64 *reta_conf, 2956 uint16_t nb_entries) 2957 { 2958 int i; 2959 unsigned size; 2960 uint16_t hash_index, idx, shift; 2961 uint16_t nb_queue; 2962 char s[256]; 2963 const char *p, *p0 = str; 2964 char *end; 2965 enum fieldnames { 2966 FLD_HASH_INDEX = 0, 2967 FLD_QUEUE, 2968 _NUM_FLD 2969 }; 2970 unsigned long int_fld[_NUM_FLD]; 2971 char *str_fld[_NUM_FLD]; 2972 2973 while ((p = strchr(p0,'(')) != NULL) { 2974 ++p; 2975 if((p0 = strchr(p,')')) == NULL) 2976 return -1; 2977 2978 size = p0 - p; 2979 if(size >= sizeof(s)) 2980 return -1; 2981 2982 snprintf(s, sizeof(s), "%.*s", size, p); 2983 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2984 return -1; 2985 for (i = 0; i < _NUM_FLD; i++) { 2986 errno = 0; 2987 int_fld[i] = strtoul(str_fld[i], &end, 0); 2988 if (errno != 0 || end == str_fld[i] || 2989 int_fld[i] > 65535) 2990 return -1; 2991 } 2992 2993 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2994 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2995 2996 if (hash_index >= nb_entries) { 2997 fprintf(stderr, "Invalid RETA hash index=%d\n", 2998 hash_index); 2999 return -1; 3000 } 3001 3002 idx = hash_index / RTE_RETA_GROUP_SIZE; 3003 shift = hash_index % RTE_RETA_GROUP_SIZE; 3004 reta_conf[idx].mask |= (1ULL << shift); 3005 reta_conf[idx].reta[shift] = nb_queue; 3006 } 3007 3008 return 0; 3009 } 3010 3011 static void 3012 cmd_set_rss_reta_parsed(void *parsed_result, 3013 __rte_unused struct cmdline *cl, 3014 __rte_unused void *data) 3015 { 3016 int ret; 3017 struct rte_eth_dev_info dev_info; 3018 struct rte_eth_rss_reta_entry64 reta_conf[8]; 3019 struct cmd_config_rss_reta *res = parsed_result; 3020 3021 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 3022 if (ret != 0) 3023 return; 3024 3025 if (dev_info.reta_size == 0) { 3026 fprintf(stderr, 3027 "Redirection table size is 0 which is invalid for RSS\n"); 3028 return; 3029 } else 3030 printf("The reta size of port %d is %u\n", 3031 res->port_id, dev_info.reta_size); 3032 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 3033 fprintf(stderr, 3034 "Currently do not support more than %u entries of redirection table\n", 3035 ETH_RSS_RETA_SIZE_512); 3036 return; 3037 } 3038 3039 memset(reta_conf, 0, sizeof(reta_conf)); 3040 if (!strcmp(res->list_name, "reta")) { 3041 if (parse_reta_config(res->list_of_items, reta_conf, 3042 dev_info.reta_size)) { 3043 fprintf(stderr, 3044 "Invalid RSS Redirection Table config entered\n"); 3045 return; 3046 } 3047 ret = rte_eth_dev_rss_reta_update(res->port_id, 3048 reta_conf, dev_info.reta_size); 3049 if (ret != 0) 3050 fprintf(stderr, 3051 "Bad redirection table parameter, return code = %d\n", 3052 ret); 3053 } 3054 } 3055 3056 cmdline_parse_token_string_t cmd_config_rss_reta_port = 3057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 3058 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 3059 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 3060 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 3061 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16); 3062 cmdline_parse_token_string_t cmd_config_rss_reta_name = 3063 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 3064 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 3065 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 3066 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 3067 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 3068 NULL); 3069 cmdline_parse_inst_t cmd_config_rss_reta = { 3070 .f = cmd_set_rss_reta_parsed, 3071 .data = NULL, 3072 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 3073 .tokens = { 3074 (void *)&cmd_config_rss_reta_port, 3075 (void *)&cmd_config_rss_reta_keyword, 3076 (void *)&cmd_config_rss_reta_port_id, 3077 (void *)&cmd_config_rss_reta_name, 3078 (void *)&cmd_config_rss_reta_list_name, 3079 (void *)&cmd_config_rss_reta_list_of_items, 3080 NULL, 3081 }, 3082 }; 3083 3084 /* *** SHOW PORT RETA INFO *** */ 3085 struct cmd_showport_reta { 3086 cmdline_fixed_string_t show; 3087 cmdline_fixed_string_t port; 3088 portid_t port_id; 3089 cmdline_fixed_string_t rss; 3090 cmdline_fixed_string_t reta; 3091 uint16_t size; 3092 cmdline_fixed_string_t list_of_items; 3093 }; 3094 3095 static int 3096 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 3097 uint16_t nb_entries, 3098 char *str) 3099 { 3100 uint32_t size; 3101 const char *p, *p0 = str; 3102 char s[256]; 3103 char *end; 3104 char *str_fld[8]; 3105 uint16_t i; 3106 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 3107 RTE_RETA_GROUP_SIZE; 3108 int ret; 3109 3110 p = strchr(p0, '('); 3111 if (p == NULL) 3112 return -1; 3113 p++; 3114 p0 = strchr(p, ')'); 3115 if (p0 == NULL) 3116 return -1; 3117 size = p0 - p; 3118 if (size >= sizeof(s)) { 3119 fprintf(stderr, 3120 "The string size exceeds the internal buffer size\n"); 3121 return -1; 3122 } 3123 snprintf(s, sizeof(s), "%.*s", size, p); 3124 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 3125 if (ret <= 0 || ret != num) { 3126 fprintf(stderr, 3127 "The bits of masks do not match the number of reta entries: %u\n", 3128 num); 3129 return -1; 3130 } 3131 for (i = 0; i < ret; i++) 3132 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 3133 3134 return 0; 3135 } 3136 3137 static void 3138 cmd_showport_reta_parsed(void *parsed_result, 3139 __rte_unused struct cmdline *cl, 3140 __rte_unused void *data) 3141 { 3142 struct cmd_showport_reta *res = parsed_result; 3143 struct rte_eth_rss_reta_entry64 reta_conf[8]; 3144 struct rte_eth_dev_info dev_info; 3145 uint16_t max_reta_size; 3146 int ret; 3147 3148 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 3149 if (ret != 0) 3150 return; 3151 3152 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 3153 if (res->size == 0 || res->size > max_reta_size) { 3154 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n", 3155 res->size, max_reta_size); 3156 return; 3157 } 3158 3159 memset(reta_conf, 0, sizeof(reta_conf)); 3160 if (showport_parse_reta_config(reta_conf, res->size, 3161 res->list_of_items) < 0) { 3162 fprintf(stderr, "Invalid string: %s for reta masks\n", 3163 res->list_of_items); 3164 return; 3165 } 3166 port_rss_reta_info(res->port_id, reta_conf, res->size); 3167 } 3168 3169 cmdline_parse_token_string_t cmd_showport_reta_show = 3170 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 3171 cmdline_parse_token_string_t cmd_showport_reta_port = 3172 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 3173 cmdline_parse_token_num_t cmd_showport_reta_port_id = 3174 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16); 3175 cmdline_parse_token_string_t cmd_showport_reta_rss = 3176 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 3177 cmdline_parse_token_string_t cmd_showport_reta_reta = 3178 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 3179 cmdline_parse_token_num_t cmd_showport_reta_size = 3180 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16); 3181 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 3182 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 3183 list_of_items, NULL); 3184 3185 cmdline_parse_inst_t cmd_showport_reta = { 3186 .f = cmd_showport_reta_parsed, 3187 .data = NULL, 3188 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 3189 .tokens = { 3190 (void *)&cmd_showport_reta_show, 3191 (void *)&cmd_showport_reta_port, 3192 (void *)&cmd_showport_reta_port_id, 3193 (void *)&cmd_showport_reta_rss, 3194 (void *)&cmd_showport_reta_reta, 3195 (void *)&cmd_showport_reta_size, 3196 (void *)&cmd_showport_reta_list_of_items, 3197 NULL, 3198 }, 3199 }; 3200 3201 /* *** Show RSS hash configuration *** */ 3202 struct cmd_showport_rss_hash { 3203 cmdline_fixed_string_t show; 3204 cmdline_fixed_string_t port; 3205 portid_t port_id; 3206 cmdline_fixed_string_t rss_hash; 3207 cmdline_fixed_string_t rss_type; 3208 cmdline_fixed_string_t key; /* optional argument */ 3209 }; 3210 3211 static void cmd_showport_rss_hash_parsed(void *parsed_result, 3212 __rte_unused struct cmdline *cl, 3213 void *show_rss_key) 3214 { 3215 struct cmd_showport_rss_hash *res = parsed_result; 3216 3217 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); 3218 } 3219 3220 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 3221 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 3222 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 3223 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 3224 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 3225 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, 3226 RTE_UINT16); 3227 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 3228 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 3229 "rss-hash"); 3230 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 3231 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 3232 3233 cmdline_parse_inst_t cmd_showport_rss_hash = { 3234 .f = cmd_showport_rss_hash_parsed, 3235 .data = NULL, 3236 .help_str = "show port <port_id> rss-hash", 3237 .tokens = { 3238 (void *)&cmd_showport_rss_hash_show, 3239 (void *)&cmd_showport_rss_hash_port, 3240 (void *)&cmd_showport_rss_hash_port_id, 3241 (void *)&cmd_showport_rss_hash_rss_hash, 3242 NULL, 3243 }, 3244 }; 3245 3246 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 3247 .f = cmd_showport_rss_hash_parsed, 3248 .data = (void *)1, 3249 .help_str = "show port <port_id> rss-hash key", 3250 .tokens = { 3251 (void *)&cmd_showport_rss_hash_show, 3252 (void *)&cmd_showport_rss_hash_port, 3253 (void *)&cmd_showport_rss_hash_port_id, 3254 (void *)&cmd_showport_rss_hash_rss_hash, 3255 (void *)&cmd_showport_rss_hash_rss_key, 3256 NULL, 3257 }, 3258 }; 3259 3260 /* *** Configure DCB *** */ 3261 struct cmd_config_dcb { 3262 cmdline_fixed_string_t port; 3263 cmdline_fixed_string_t config; 3264 portid_t port_id; 3265 cmdline_fixed_string_t dcb; 3266 cmdline_fixed_string_t vt; 3267 cmdline_fixed_string_t vt_en; 3268 uint8_t num_tcs; 3269 cmdline_fixed_string_t pfc; 3270 cmdline_fixed_string_t pfc_en; 3271 }; 3272 3273 static void 3274 cmd_config_dcb_parsed(void *parsed_result, 3275 __rte_unused struct cmdline *cl, 3276 __rte_unused void *data) 3277 { 3278 struct cmd_config_dcb *res = parsed_result; 3279 struct rte_eth_dcb_info dcb_info; 3280 portid_t port_id = res->port_id; 3281 struct rte_port *port; 3282 uint8_t pfc_en; 3283 int ret; 3284 3285 port = &ports[port_id]; 3286 /** Check if the port is not started **/ 3287 if (port->port_status != RTE_PORT_STOPPED) { 3288 fprintf(stderr, "Please stop port %d first\n", port_id); 3289 return; 3290 } 3291 3292 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 3293 fprintf(stderr, 3294 "The invalid number of traffic class, only 4 or 8 allowed.\n"); 3295 return; 3296 } 3297 3298 if (nb_fwd_lcores < res->num_tcs) { 3299 fprintf(stderr, 3300 "nb_cores shouldn't be less than number of TCs.\n"); 3301 return; 3302 } 3303 3304 /* Check whether the port supports the report of DCB info. */ 3305 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info); 3306 if (ret == -ENOTSUP) { 3307 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n"); 3308 return; 3309 } 3310 3311 if (!strncmp(res->pfc_en, "on", 2)) 3312 pfc_en = 1; 3313 else 3314 pfc_en = 0; 3315 3316 /* DCB in VT mode */ 3317 if (!strncmp(res->vt_en, "on", 2)) 3318 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 3319 (enum rte_eth_nb_tcs)res->num_tcs, 3320 pfc_en); 3321 else 3322 ret = init_port_dcb_config(port_id, DCB_ENABLED, 3323 (enum rte_eth_nb_tcs)res->num_tcs, 3324 pfc_en); 3325 if (ret != 0) { 3326 fprintf(stderr, "Cannot initialize network ports.\n"); 3327 return; 3328 } 3329 3330 fwd_config_setup(); 3331 3332 cmd_reconfig_device_queue(port_id, 1, 1); 3333 } 3334 3335 cmdline_parse_token_string_t cmd_config_dcb_port = 3336 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 3337 cmdline_parse_token_string_t cmd_config_dcb_config = 3338 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 3339 cmdline_parse_token_num_t cmd_config_dcb_port_id = 3340 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16); 3341 cmdline_parse_token_string_t cmd_config_dcb_dcb = 3342 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 3343 cmdline_parse_token_string_t cmd_config_dcb_vt = 3344 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 3345 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 3346 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 3347 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 3348 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8); 3349 cmdline_parse_token_string_t cmd_config_dcb_pfc= 3350 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 3351 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 3352 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 3353 3354 cmdline_parse_inst_t cmd_config_dcb = { 3355 .f = cmd_config_dcb_parsed, 3356 .data = NULL, 3357 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 3358 .tokens = { 3359 (void *)&cmd_config_dcb_port, 3360 (void *)&cmd_config_dcb_config, 3361 (void *)&cmd_config_dcb_port_id, 3362 (void *)&cmd_config_dcb_dcb, 3363 (void *)&cmd_config_dcb_vt, 3364 (void *)&cmd_config_dcb_vt_en, 3365 (void *)&cmd_config_dcb_num_tcs, 3366 (void *)&cmd_config_dcb_pfc, 3367 (void *)&cmd_config_dcb_pfc_en, 3368 NULL, 3369 }, 3370 }; 3371 3372 /* *** configure number of packets per burst *** */ 3373 struct cmd_config_burst { 3374 cmdline_fixed_string_t port; 3375 cmdline_fixed_string_t keyword; 3376 cmdline_fixed_string_t all; 3377 cmdline_fixed_string_t name; 3378 uint16_t value; 3379 }; 3380 3381 static void 3382 cmd_config_burst_parsed(void *parsed_result, 3383 __rte_unused struct cmdline *cl, 3384 __rte_unused void *data) 3385 { 3386 struct cmd_config_burst *res = parsed_result; 3387 struct rte_eth_dev_info dev_info; 3388 uint16_t rec_nb_pkts; 3389 int ret; 3390 3391 if (!all_ports_stopped()) { 3392 fprintf(stderr, "Please stop all ports first\n"); 3393 return; 3394 } 3395 3396 if (!strcmp(res->name, "burst")) { 3397 if (res->value == 0) { 3398 /* If user gives a value of zero, query the PMD for 3399 * its recommended Rx burst size. Testpmd uses a single 3400 * size for all ports, so assume all ports are the same 3401 * NIC model and use the values from Port 0. 3402 */ 3403 ret = eth_dev_info_get_print_err(0, &dev_info); 3404 if (ret != 0) 3405 return; 3406 3407 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 3408 3409 if (rec_nb_pkts == 0) { 3410 printf("PMD does not recommend a burst size.\n" 3411 "User provided value must be between" 3412 " 1 and %d\n", MAX_PKT_BURST); 3413 return; 3414 } else if (rec_nb_pkts > MAX_PKT_BURST) { 3415 printf("PMD recommended burst size of %d" 3416 " exceeds maximum value of %d\n", 3417 rec_nb_pkts, MAX_PKT_BURST); 3418 return; 3419 } 3420 printf("Using PMD-provided burst value of %d\n", 3421 rec_nb_pkts); 3422 nb_pkt_per_burst = rec_nb_pkts; 3423 } else if (res->value > MAX_PKT_BURST) { 3424 fprintf(stderr, "burst must be >= 1 && <= %d\n", 3425 MAX_PKT_BURST); 3426 return; 3427 } else 3428 nb_pkt_per_burst = res->value; 3429 } else { 3430 fprintf(stderr, "Unknown parameter\n"); 3431 return; 3432 } 3433 3434 init_port_config(); 3435 3436 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3437 } 3438 3439 cmdline_parse_token_string_t cmd_config_burst_port = 3440 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3441 cmdline_parse_token_string_t cmd_config_burst_keyword = 3442 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3443 cmdline_parse_token_string_t cmd_config_burst_all = 3444 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3445 cmdline_parse_token_string_t cmd_config_burst_name = 3446 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3447 cmdline_parse_token_num_t cmd_config_burst_value = 3448 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16); 3449 3450 cmdline_parse_inst_t cmd_config_burst = { 3451 .f = cmd_config_burst_parsed, 3452 .data = NULL, 3453 .help_str = "port config all burst <value>", 3454 .tokens = { 3455 (void *)&cmd_config_burst_port, 3456 (void *)&cmd_config_burst_keyword, 3457 (void *)&cmd_config_burst_all, 3458 (void *)&cmd_config_burst_name, 3459 (void *)&cmd_config_burst_value, 3460 NULL, 3461 }, 3462 }; 3463 3464 /* *** configure rx/tx queues *** */ 3465 struct cmd_config_thresh { 3466 cmdline_fixed_string_t port; 3467 cmdline_fixed_string_t keyword; 3468 cmdline_fixed_string_t all; 3469 cmdline_fixed_string_t name; 3470 uint8_t value; 3471 }; 3472 3473 static void 3474 cmd_config_thresh_parsed(void *parsed_result, 3475 __rte_unused struct cmdline *cl, 3476 __rte_unused void *data) 3477 { 3478 struct cmd_config_thresh *res = parsed_result; 3479 3480 if (!all_ports_stopped()) { 3481 fprintf(stderr, "Please stop all ports first\n"); 3482 return; 3483 } 3484 3485 if (!strcmp(res->name, "txpt")) 3486 tx_pthresh = res->value; 3487 else if(!strcmp(res->name, "txht")) 3488 tx_hthresh = res->value; 3489 else if(!strcmp(res->name, "txwt")) 3490 tx_wthresh = res->value; 3491 else if(!strcmp(res->name, "rxpt")) 3492 rx_pthresh = res->value; 3493 else if(!strcmp(res->name, "rxht")) 3494 rx_hthresh = res->value; 3495 else if(!strcmp(res->name, "rxwt")) 3496 rx_wthresh = res->value; 3497 else { 3498 fprintf(stderr, "Unknown parameter\n"); 3499 return; 3500 } 3501 3502 init_port_config(); 3503 3504 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3505 } 3506 3507 cmdline_parse_token_string_t cmd_config_thresh_port = 3508 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3509 cmdline_parse_token_string_t cmd_config_thresh_keyword = 3510 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3511 cmdline_parse_token_string_t cmd_config_thresh_all = 3512 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3513 cmdline_parse_token_string_t cmd_config_thresh_name = 3514 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3515 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3516 cmdline_parse_token_num_t cmd_config_thresh_value = 3517 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8); 3518 3519 cmdline_parse_inst_t cmd_config_thresh = { 3520 .f = cmd_config_thresh_parsed, 3521 .data = NULL, 3522 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3523 .tokens = { 3524 (void *)&cmd_config_thresh_port, 3525 (void *)&cmd_config_thresh_keyword, 3526 (void *)&cmd_config_thresh_all, 3527 (void *)&cmd_config_thresh_name, 3528 (void *)&cmd_config_thresh_value, 3529 NULL, 3530 }, 3531 }; 3532 3533 /* *** configure free/rs threshold *** */ 3534 struct cmd_config_threshold { 3535 cmdline_fixed_string_t port; 3536 cmdline_fixed_string_t keyword; 3537 cmdline_fixed_string_t all; 3538 cmdline_fixed_string_t name; 3539 uint16_t value; 3540 }; 3541 3542 static void 3543 cmd_config_threshold_parsed(void *parsed_result, 3544 __rte_unused struct cmdline *cl, 3545 __rte_unused void *data) 3546 { 3547 struct cmd_config_threshold *res = parsed_result; 3548 3549 if (!all_ports_stopped()) { 3550 fprintf(stderr, "Please stop all ports first\n"); 3551 return; 3552 } 3553 3554 if (!strcmp(res->name, "txfreet")) 3555 tx_free_thresh = res->value; 3556 else if (!strcmp(res->name, "txrst")) 3557 tx_rs_thresh = res->value; 3558 else if (!strcmp(res->name, "rxfreet")) 3559 rx_free_thresh = res->value; 3560 else { 3561 fprintf(stderr, "Unknown parameter\n"); 3562 return; 3563 } 3564 3565 init_port_config(); 3566 3567 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3568 } 3569 3570 cmdline_parse_token_string_t cmd_config_threshold_port = 3571 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3572 cmdline_parse_token_string_t cmd_config_threshold_keyword = 3573 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3574 "config"); 3575 cmdline_parse_token_string_t cmd_config_threshold_all = 3576 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3577 cmdline_parse_token_string_t cmd_config_threshold_name = 3578 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3579 "txfreet#txrst#rxfreet"); 3580 cmdline_parse_token_num_t cmd_config_threshold_value = 3581 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16); 3582 3583 cmdline_parse_inst_t cmd_config_threshold = { 3584 .f = cmd_config_threshold_parsed, 3585 .data = NULL, 3586 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3587 .tokens = { 3588 (void *)&cmd_config_threshold_port, 3589 (void *)&cmd_config_threshold_keyword, 3590 (void *)&cmd_config_threshold_all, 3591 (void *)&cmd_config_threshold_name, 3592 (void *)&cmd_config_threshold_value, 3593 NULL, 3594 }, 3595 }; 3596 3597 /* *** stop *** */ 3598 struct cmd_stop_result { 3599 cmdline_fixed_string_t stop; 3600 }; 3601 3602 static void cmd_stop_parsed(__rte_unused void *parsed_result, 3603 __rte_unused struct cmdline *cl, 3604 __rte_unused void *data) 3605 { 3606 stop_packet_forwarding(); 3607 } 3608 3609 cmdline_parse_token_string_t cmd_stop_stop = 3610 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3611 3612 cmdline_parse_inst_t cmd_stop = { 3613 .f = cmd_stop_parsed, 3614 .data = NULL, 3615 .help_str = "stop: Stop packet forwarding", 3616 .tokens = { 3617 (void *)&cmd_stop_stop, 3618 NULL, 3619 }, 3620 }; 3621 3622 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3623 3624 unsigned int 3625 parse_item_list(const char *str, const char *item_name, unsigned int max_items, 3626 unsigned int *parsed_items, int check_unique_values) 3627 { 3628 unsigned int nb_item; 3629 unsigned int value; 3630 unsigned int i; 3631 unsigned int j; 3632 int value_ok; 3633 char c; 3634 3635 /* 3636 * First parse all items in the list and store their value. 3637 */ 3638 value = 0; 3639 nb_item = 0; 3640 value_ok = 0; 3641 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3642 c = str[i]; 3643 if ((c >= '0') && (c <= '9')) { 3644 value = (unsigned int) (value * 10 + (c - '0')); 3645 value_ok = 1; 3646 continue; 3647 } 3648 if (c != ',') { 3649 fprintf(stderr, "character %c is not a decimal digit\n", c); 3650 return 0; 3651 } 3652 if (! value_ok) { 3653 fprintf(stderr, "No valid value before comma\n"); 3654 return 0; 3655 } 3656 if (nb_item < max_items) { 3657 parsed_items[nb_item] = value; 3658 value_ok = 0; 3659 value = 0; 3660 } 3661 nb_item++; 3662 } 3663 if (nb_item >= max_items) { 3664 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n", 3665 item_name, nb_item + 1, max_items); 3666 return 0; 3667 } 3668 parsed_items[nb_item++] = value; 3669 if (! check_unique_values) 3670 return nb_item; 3671 3672 /* 3673 * Then, check that all values in the list are differents. 3674 * No optimization here... 3675 */ 3676 for (i = 0; i < nb_item; i++) { 3677 for (j = i + 1; j < nb_item; j++) { 3678 if (parsed_items[j] == parsed_items[i]) { 3679 fprintf(stderr, 3680 "duplicated %s %u at index %u and %u\n", 3681 item_name, parsed_items[i], i, j); 3682 return 0; 3683 } 3684 } 3685 } 3686 return nb_item; 3687 } 3688 3689 struct cmd_set_list_result { 3690 cmdline_fixed_string_t cmd_keyword; 3691 cmdline_fixed_string_t list_name; 3692 cmdline_fixed_string_t list_of_items; 3693 }; 3694 3695 static void cmd_set_list_parsed(void *parsed_result, 3696 __rte_unused struct cmdline *cl, 3697 __rte_unused void *data) 3698 { 3699 struct cmd_set_list_result *res; 3700 union { 3701 unsigned int lcorelist[RTE_MAX_LCORE]; 3702 unsigned int portlist[RTE_MAX_ETHPORTS]; 3703 } parsed_items; 3704 unsigned int nb_item; 3705 3706 if (test_done == 0) { 3707 fprintf(stderr, "Please stop forwarding first\n"); 3708 return; 3709 } 3710 3711 res = parsed_result; 3712 if (!strcmp(res->list_name, "corelist")) { 3713 nb_item = parse_item_list(res->list_of_items, "core", 3714 RTE_MAX_LCORE, 3715 parsed_items.lcorelist, 1); 3716 if (nb_item > 0) { 3717 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3718 fwd_config_setup(); 3719 } 3720 return; 3721 } 3722 if (!strcmp(res->list_name, "portlist")) { 3723 nb_item = parse_item_list(res->list_of_items, "port", 3724 RTE_MAX_ETHPORTS, 3725 parsed_items.portlist, 1); 3726 if (nb_item > 0) { 3727 set_fwd_ports_list(parsed_items.portlist, nb_item); 3728 fwd_config_setup(); 3729 } 3730 } 3731 } 3732 3733 cmdline_parse_token_string_t cmd_set_list_keyword = 3734 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3735 "set"); 3736 cmdline_parse_token_string_t cmd_set_list_name = 3737 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3738 "corelist#portlist"); 3739 cmdline_parse_token_string_t cmd_set_list_of_items = 3740 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3741 NULL); 3742 3743 cmdline_parse_inst_t cmd_set_fwd_list = { 3744 .f = cmd_set_list_parsed, 3745 .data = NULL, 3746 .help_str = "set corelist|portlist <list0[,list1]*>", 3747 .tokens = { 3748 (void *)&cmd_set_list_keyword, 3749 (void *)&cmd_set_list_name, 3750 (void *)&cmd_set_list_of_items, 3751 NULL, 3752 }, 3753 }; 3754 3755 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3756 3757 struct cmd_setmask_result { 3758 cmdline_fixed_string_t set; 3759 cmdline_fixed_string_t mask; 3760 uint64_t hexavalue; 3761 }; 3762 3763 static void cmd_set_mask_parsed(void *parsed_result, 3764 __rte_unused struct cmdline *cl, 3765 __rte_unused void *data) 3766 { 3767 struct cmd_setmask_result *res = parsed_result; 3768 3769 if (test_done == 0) { 3770 fprintf(stderr, "Please stop forwarding first\n"); 3771 return; 3772 } 3773 if (!strcmp(res->mask, "coremask")) { 3774 set_fwd_lcores_mask(res->hexavalue); 3775 fwd_config_setup(); 3776 } else if (!strcmp(res->mask, "portmask")) { 3777 set_fwd_ports_mask(res->hexavalue); 3778 fwd_config_setup(); 3779 } 3780 } 3781 3782 cmdline_parse_token_string_t cmd_setmask_set = 3783 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3784 cmdline_parse_token_string_t cmd_setmask_mask = 3785 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3786 "coremask#portmask"); 3787 cmdline_parse_token_num_t cmd_setmask_value = 3788 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64); 3789 3790 cmdline_parse_inst_t cmd_set_fwd_mask = { 3791 .f = cmd_set_mask_parsed, 3792 .data = NULL, 3793 .help_str = "set coremask|portmask <hexadecimal value>", 3794 .tokens = { 3795 (void *)&cmd_setmask_set, 3796 (void *)&cmd_setmask_mask, 3797 (void *)&cmd_setmask_value, 3798 NULL, 3799 }, 3800 }; 3801 3802 /* 3803 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3804 */ 3805 struct cmd_set_result { 3806 cmdline_fixed_string_t set; 3807 cmdline_fixed_string_t what; 3808 uint16_t value; 3809 }; 3810 3811 static void cmd_set_parsed(void *parsed_result, 3812 __rte_unused struct cmdline *cl, 3813 __rte_unused void *data) 3814 { 3815 struct cmd_set_result *res = parsed_result; 3816 if (!strcmp(res->what, "nbport")) { 3817 set_fwd_ports_number(res->value); 3818 fwd_config_setup(); 3819 } else if (!strcmp(res->what, "nbcore")) { 3820 set_fwd_lcores_number(res->value); 3821 fwd_config_setup(); 3822 } else if (!strcmp(res->what, "burst")) 3823 set_nb_pkt_per_burst(res->value); 3824 else if (!strcmp(res->what, "verbose")) 3825 set_verbose_level(res->value); 3826 } 3827 3828 cmdline_parse_token_string_t cmd_set_set = 3829 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3830 cmdline_parse_token_string_t cmd_set_what = 3831 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3832 "nbport#nbcore#burst#verbose"); 3833 cmdline_parse_token_num_t cmd_set_value = 3834 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16); 3835 3836 cmdline_parse_inst_t cmd_set_numbers = { 3837 .f = cmd_set_parsed, 3838 .data = NULL, 3839 .help_str = "set nbport|nbcore|burst|verbose <value>", 3840 .tokens = { 3841 (void *)&cmd_set_set, 3842 (void *)&cmd_set_what, 3843 (void *)&cmd_set_value, 3844 NULL, 3845 }, 3846 }; 3847 3848 /* *** SET LOG LEVEL CONFIGURATION *** */ 3849 3850 struct cmd_set_log_result { 3851 cmdline_fixed_string_t set; 3852 cmdline_fixed_string_t log; 3853 cmdline_fixed_string_t type; 3854 uint32_t level; 3855 }; 3856 3857 static void 3858 cmd_set_log_parsed(void *parsed_result, 3859 __rte_unused struct cmdline *cl, 3860 __rte_unused void *data) 3861 { 3862 struct cmd_set_log_result *res; 3863 int ret; 3864 3865 res = parsed_result; 3866 if (!strcmp(res->type, "global")) 3867 rte_log_set_global_level(res->level); 3868 else { 3869 ret = rte_log_set_level_regexp(res->type, res->level); 3870 if (ret < 0) 3871 fprintf(stderr, "Unable to set log level\n"); 3872 } 3873 } 3874 3875 cmdline_parse_token_string_t cmd_set_log_set = 3876 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3877 cmdline_parse_token_string_t cmd_set_log_log = 3878 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3879 cmdline_parse_token_string_t cmd_set_log_type = 3880 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3881 cmdline_parse_token_num_t cmd_set_log_level = 3882 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32); 3883 3884 cmdline_parse_inst_t cmd_set_log = { 3885 .f = cmd_set_log_parsed, 3886 .data = NULL, 3887 .help_str = "set log global|<type> <level>", 3888 .tokens = { 3889 (void *)&cmd_set_log_set, 3890 (void *)&cmd_set_log_log, 3891 (void *)&cmd_set_log_type, 3892 (void *)&cmd_set_log_level, 3893 NULL, 3894 }, 3895 }; 3896 3897 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */ 3898 3899 struct cmd_set_rxoffs_result { 3900 cmdline_fixed_string_t cmd_keyword; 3901 cmdline_fixed_string_t rxoffs; 3902 cmdline_fixed_string_t seg_offsets; 3903 }; 3904 3905 static void 3906 cmd_set_rxoffs_parsed(void *parsed_result, 3907 __rte_unused struct cmdline *cl, 3908 __rte_unused void *data) 3909 { 3910 struct cmd_set_rxoffs_result *res; 3911 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT]; 3912 unsigned int nb_segs; 3913 3914 res = parsed_result; 3915 nb_segs = parse_item_list(res->seg_offsets, "segment offsets", 3916 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0); 3917 if (nb_segs > 0) 3918 set_rx_pkt_offsets(seg_offsets, nb_segs); 3919 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1); 3920 } 3921 3922 cmdline_parse_token_string_t cmd_set_rxoffs_keyword = 3923 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3924 cmd_keyword, "set"); 3925 cmdline_parse_token_string_t cmd_set_rxoffs_name = 3926 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3927 rxoffs, "rxoffs"); 3928 cmdline_parse_token_string_t cmd_set_rxoffs_offsets = 3929 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3930 seg_offsets, NULL); 3931 3932 cmdline_parse_inst_t cmd_set_rxoffs = { 3933 .f = cmd_set_rxoffs_parsed, 3934 .data = NULL, 3935 .help_str = "set rxoffs <len0[,len1]*>", 3936 .tokens = { 3937 (void *)&cmd_set_rxoffs_keyword, 3938 (void *)&cmd_set_rxoffs_name, 3939 (void *)&cmd_set_rxoffs_offsets, 3940 NULL, 3941 }, 3942 }; 3943 3944 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */ 3945 3946 struct cmd_set_rxpkts_result { 3947 cmdline_fixed_string_t cmd_keyword; 3948 cmdline_fixed_string_t rxpkts; 3949 cmdline_fixed_string_t seg_lengths; 3950 }; 3951 3952 static void 3953 cmd_set_rxpkts_parsed(void *parsed_result, 3954 __rte_unused struct cmdline *cl, 3955 __rte_unused void *data) 3956 { 3957 struct cmd_set_rxpkts_result *res; 3958 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT]; 3959 unsigned int nb_segs; 3960 3961 res = parsed_result; 3962 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3963 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0); 3964 if (nb_segs > 0) 3965 set_rx_pkt_segments(seg_lengths, nb_segs); 3966 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1); 3967 } 3968 3969 cmdline_parse_token_string_t cmd_set_rxpkts_keyword = 3970 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3971 cmd_keyword, "set"); 3972 cmdline_parse_token_string_t cmd_set_rxpkts_name = 3973 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3974 rxpkts, "rxpkts"); 3975 cmdline_parse_token_string_t cmd_set_rxpkts_lengths = 3976 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3977 seg_lengths, NULL); 3978 3979 cmdline_parse_inst_t cmd_set_rxpkts = { 3980 .f = cmd_set_rxpkts_parsed, 3981 .data = NULL, 3982 .help_str = "set rxpkts <len0[,len1]*>", 3983 .tokens = { 3984 (void *)&cmd_set_rxpkts_keyword, 3985 (void *)&cmd_set_rxpkts_name, 3986 (void *)&cmd_set_rxpkts_lengths, 3987 NULL, 3988 }, 3989 }; 3990 3991 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3992 3993 struct cmd_set_txpkts_result { 3994 cmdline_fixed_string_t cmd_keyword; 3995 cmdline_fixed_string_t txpkts; 3996 cmdline_fixed_string_t seg_lengths; 3997 }; 3998 3999 static void 4000 cmd_set_txpkts_parsed(void *parsed_result, 4001 __rte_unused struct cmdline *cl, 4002 __rte_unused void *data) 4003 { 4004 struct cmd_set_txpkts_result *res; 4005 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 4006 unsigned int nb_segs; 4007 4008 res = parsed_result; 4009 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 4010 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 4011 if (nb_segs > 0) 4012 set_tx_pkt_segments(seg_lengths, nb_segs); 4013 } 4014 4015 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 4016 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 4017 cmd_keyword, "set"); 4018 cmdline_parse_token_string_t cmd_set_txpkts_name = 4019 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 4020 txpkts, "txpkts"); 4021 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 4022 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 4023 seg_lengths, NULL); 4024 4025 cmdline_parse_inst_t cmd_set_txpkts = { 4026 .f = cmd_set_txpkts_parsed, 4027 .data = NULL, 4028 .help_str = "set txpkts <len0[,len1]*>", 4029 .tokens = { 4030 (void *)&cmd_set_txpkts_keyword, 4031 (void *)&cmd_set_txpkts_name, 4032 (void *)&cmd_set_txpkts_lengths, 4033 NULL, 4034 }, 4035 }; 4036 4037 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 4038 4039 struct cmd_set_txsplit_result { 4040 cmdline_fixed_string_t cmd_keyword; 4041 cmdline_fixed_string_t txsplit; 4042 cmdline_fixed_string_t mode; 4043 }; 4044 4045 static void 4046 cmd_set_txsplit_parsed(void *parsed_result, 4047 __rte_unused struct cmdline *cl, 4048 __rte_unused void *data) 4049 { 4050 struct cmd_set_txsplit_result *res; 4051 4052 res = parsed_result; 4053 set_tx_pkt_split(res->mode); 4054 } 4055 4056 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 4057 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 4058 cmd_keyword, "set"); 4059 cmdline_parse_token_string_t cmd_set_txsplit_name = 4060 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 4061 txsplit, "txsplit"); 4062 cmdline_parse_token_string_t cmd_set_txsplit_mode = 4063 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 4064 mode, NULL); 4065 4066 cmdline_parse_inst_t cmd_set_txsplit = { 4067 .f = cmd_set_txsplit_parsed, 4068 .data = NULL, 4069 .help_str = "set txsplit on|off|rand", 4070 .tokens = { 4071 (void *)&cmd_set_txsplit_keyword, 4072 (void *)&cmd_set_txsplit_name, 4073 (void *)&cmd_set_txsplit_mode, 4074 NULL, 4075 }, 4076 }; 4077 4078 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */ 4079 4080 struct cmd_set_txtimes_result { 4081 cmdline_fixed_string_t cmd_keyword; 4082 cmdline_fixed_string_t txtimes; 4083 cmdline_fixed_string_t tx_times; 4084 }; 4085 4086 static void 4087 cmd_set_txtimes_parsed(void *parsed_result, 4088 __rte_unused struct cmdline *cl, 4089 __rte_unused void *data) 4090 { 4091 struct cmd_set_txtimes_result *res; 4092 unsigned int tx_times[2] = {0, 0}; 4093 unsigned int n_times; 4094 4095 res = parsed_result; 4096 n_times = parse_item_list(res->tx_times, "tx times", 4097 2, tx_times, 0); 4098 if (n_times == 2) 4099 set_tx_pkt_times(tx_times); 4100 } 4101 4102 cmdline_parse_token_string_t cmd_set_txtimes_keyword = 4103 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 4104 cmd_keyword, "set"); 4105 cmdline_parse_token_string_t cmd_set_txtimes_name = 4106 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 4107 txtimes, "txtimes"); 4108 cmdline_parse_token_string_t cmd_set_txtimes_value = 4109 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 4110 tx_times, NULL); 4111 4112 cmdline_parse_inst_t cmd_set_txtimes = { 4113 .f = cmd_set_txtimes_parsed, 4114 .data = NULL, 4115 .help_str = "set txtimes <inter_burst>,<intra_burst>", 4116 .tokens = { 4117 (void *)&cmd_set_txtimes_keyword, 4118 (void *)&cmd_set_txtimes_name, 4119 (void *)&cmd_set_txtimes_value, 4120 NULL, 4121 }, 4122 }; 4123 4124 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 4125 struct cmd_rx_vlan_filter_all_result { 4126 cmdline_fixed_string_t rx_vlan; 4127 cmdline_fixed_string_t what; 4128 cmdline_fixed_string_t all; 4129 portid_t port_id; 4130 }; 4131 4132 static void 4133 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 4134 __rte_unused struct cmdline *cl, 4135 __rte_unused void *data) 4136 { 4137 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 4138 4139 if (!strcmp(res->what, "add")) 4140 rx_vlan_all_filter_set(res->port_id, 1); 4141 else 4142 rx_vlan_all_filter_set(res->port_id, 0); 4143 } 4144 4145 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 4146 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4147 rx_vlan, "rx_vlan"); 4148 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 4149 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4150 what, "add#rm"); 4151 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 4152 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4153 all, "all"); 4154 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 4155 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4156 port_id, RTE_UINT16); 4157 4158 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 4159 .f = cmd_rx_vlan_filter_all_parsed, 4160 .data = NULL, 4161 .help_str = "rx_vlan add|rm all <port_id>: " 4162 "Add/Remove all identifiers to/from the set of VLAN " 4163 "identifiers filtered by a port", 4164 .tokens = { 4165 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 4166 (void *)&cmd_rx_vlan_filter_all_what, 4167 (void *)&cmd_rx_vlan_filter_all_all, 4168 (void *)&cmd_rx_vlan_filter_all_portid, 4169 NULL, 4170 }, 4171 }; 4172 4173 /* *** VLAN OFFLOAD SET ON A PORT *** */ 4174 struct cmd_vlan_offload_result { 4175 cmdline_fixed_string_t vlan; 4176 cmdline_fixed_string_t set; 4177 cmdline_fixed_string_t vlan_type; 4178 cmdline_fixed_string_t what; 4179 cmdline_fixed_string_t on; 4180 cmdline_fixed_string_t port_id; 4181 }; 4182 4183 static void 4184 cmd_vlan_offload_parsed(void *parsed_result, 4185 __rte_unused struct cmdline *cl, 4186 __rte_unused void *data) 4187 { 4188 int on; 4189 struct cmd_vlan_offload_result *res = parsed_result; 4190 char *str; 4191 int i, len = 0; 4192 portid_t port_id = 0; 4193 unsigned int tmp; 4194 4195 str = res->port_id; 4196 len = strnlen(str, STR_TOKEN_SIZE); 4197 i = 0; 4198 /* Get port_id first */ 4199 while(i < len){ 4200 if(str[i] == ',') 4201 break; 4202 4203 i++; 4204 } 4205 str[i]='\0'; 4206 tmp = strtoul(str, NULL, 0); 4207 /* If port_id greater that what portid_t can represent, return */ 4208 if(tmp >= RTE_MAX_ETHPORTS) 4209 return; 4210 port_id = (portid_t)tmp; 4211 4212 if (!strcmp(res->on, "on")) 4213 on = 1; 4214 else 4215 on = 0; 4216 4217 if (!strcmp(res->what, "strip")) 4218 rx_vlan_strip_set(port_id, on); 4219 else if(!strcmp(res->what, "stripq")){ 4220 uint16_t queue_id = 0; 4221 4222 /* No queue_id, return */ 4223 if(i + 1 >= len) { 4224 fprintf(stderr, "must specify (port,queue_id)\n"); 4225 return; 4226 } 4227 tmp = strtoul(str + i + 1, NULL, 0); 4228 /* If queue_id greater that what 16-bits can represent, return */ 4229 if(tmp > 0xffff) 4230 return; 4231 4232 queue_id = (uint16_t)tmp; 4233 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 4234 } 4235 else if (!strcmp(res->what, "filter")) 4236 rx_vlan_filter_set(port_id, on); 4237 else if (!strcmp(res->what, "qinq_strip")) 4238 rx_vlan_qinq_strip_set(port_id, on); 4239 else 4240 vlan_extend_set(port_id, on); 4241 4242 return; 4243 } 4244 4245 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 4246 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4247 vlan, "vlan"); 4248 cmdline_parse_token_string_t cmd_vlan_offload_set = 4249 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4250 set, "set"); 4251 cmdline_parse_token_string_t cmd_vlan_offload_what = 4252 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4253 what, "strip#filter#qinq_strip#extend#stripq"); 4254 cmdline_parse_token_string_t cmd_vlan_offload_on = 4255 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4256 on, "on#off"); 4257 cmdline_parse_token_string_t cmd_vlan_offload_portid = 4258 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4259 port_id, NULL); 4260 4261 cmdline_parse_inst_t cmd_vlan_offload = { 4262 .f = cmd_vlan_offload_parsed, 4263 .data = NULL, 4264 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off " 4265 "<port_id[,queue_id]>: " 4266 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides", 4267 .tokens = { 4268 (void *)&cmd_vlan_offload_vlan, 4269 (void *)&cmd_vlan_offload_set, 4270 (void *)&cmd_vlan_offload_what, 4271 (void *)&cmd_vlan_offload_on, 4272 (void *)&cmd_vlan_offload_portid, 4273 NULL, 4274 }, 4275 }; 4276 4277 /* *** VLAN TPID SET ON A PORT *** */ 4278 struct cmd_vlan_tpid_result { 4279 cmdline_fixed_string_t vlan; 4280 cmdline_fixed_string_t set; 4281 cmdline_fixed_string_t vlan_type; 4282 cmdline_fixed_string_t what; 4283 uint16_t tp_id; 4284 portid_t port_id; 4285 }; 4286 4287 static void 4288 cmd_vlan_tpid_parsed(void *parsed_result, 4289 __rte_unused struct cmdline *cl, 4290 __rte_unused void *data) 4291 { 4292 struct cmd_vlan_tpid_result *res = parsed_result; 4293 enum rte_vlan_type vlan_type; 4294 4295 if (!strcmp(res->vlan_type, "inner")) 4296 vlan_type = ETH_VLAN_TYPE_INNER; 4297 else if (!strcmp(res->vlan_type, "outer")) 4298 vlan_type = ETH_VLAN_TYPE_OUTER; 4299 else { 4300 fprintf(stderr, "Unknown vlan type\n"); 4301 return; 4302 } 4303 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 4304 } 4305 4306 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 4307 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4308 vlan, "vlan"); 4309 cmdline_parse_token_string_t cmd_vlan_tpid_set = 4310 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4311 set, "set"); 4312 cmdline_parse_token_string_t cmd_vlan_type = 4313 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4314 vlan_type, "inner#outer"); 4315 cmdline_parse_token_string_t cmd_vlan_tpid_what = 4316 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4317 what, "tpid"); 4318 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 4319 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4320 tp_id, RTE_UINT16); 4321 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 4322 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4323 port_id, RTE_UINT16); 4324 4325 cmdline_parse_inst_t cmd_vlan_tpid = { 4326 .f = cmd_vlan_tpid_parsed, 4327 .data = NULL, 4328 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 4329 "Set the VLAN Ether type", 4330 .tokens = { 4331 (void *)&cmd_vlan_tpid_vlan, 4332 (void *)&cmd_vlan_tpid_set, 4333 (void *)&cmd_vlan_type, 4334 (void *)&cmd_vlan_tpid_what, 4335 (void *)&cmd_vlan_tpid_tpid, 4336 (void *)&cmd_vlan_tpid_portid, 4337 NULL, 4338 }, 4339 }; 4340 4341 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 4342 struct cmd_rx_vlan_filter_result { 4343 cmdline_fixed_string_t rx_vlan; 4344 cmdline_fixed_string_t what; 4345 uint16_t vlan_id; 4346 portid_t port_id; 4347 }; 4348 4349 static void 4350 cmd_rx_vlan_filter_parsed(void *parsed_result, 4351 __rte_unused struct cmdline *cl, 4352 __rte_unused void *data) 4353 { 4354 struct cmd_rx_vlan_filter_result *res = parsed_result; 4355 4356 if (!strcmp(res->what, "add")) 4357 rx_vft_set(res->port_id, res->vlan_id, 1); 4358 else 4359 rx_vft_set(res->port_id, res->vlan_id, 0); 4360 } 4361 4362 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 4363 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4364 rx_vlan, "rx_vlan"); 4365 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 4366 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4367 what, "add#rm"); 4368 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 4369 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4370 vlan_id, RTE_UINT16); 4371 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 4372 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4373 port_id, RTE_UINT16); 4374 4375 cmdline_parse_inst_t cmd_rx_vlan_filter = { 4376 .f = cmd_rx_vlan_filter_parsed, 4377 .data = NULL, 4378 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 4379 "Add/Remove a VLAN identifier to/from the set of VLAN " 4380 "identifiers filtered by a port", 4381 .tokens = { 4382 (void *)&cmd_rx_vlan_filter_rx_vlan, 4383 (void *)&cmd_rx_vlan_filter_what, 4384 (void *)&cmd_rx_vlan_filter_vlanid, 4385 (void *)&cmd_rx_vlan_filter_portid, 4386 NULL, 4387 }, 4388 }; 4389 4390 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4391 struct cmd_tx_vlan_set_result { 4392 cmdline_fixed_string_t tx_vlan; 4393 cmdline_fixed_string_t set; 4394 portid_t port_id; 4395 uint16_t vlan_id; 4396 }; 4397 4398 static void 4399 cmd_tx_vlan_set_parsed(void *parsed_result, 4400 __rte_unused struct cmdline *cl, 4401 __rte_unused void *data) 4402 { 4403 struct cmd_tx_vlan_set_result *res = parsed_result; 4404 4405 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4406 return; 4407 4408 if (!port_is_stopped(res->port_id)) { 4409 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4410 return; 4411 } 4412 4413 tx_vlan_set(res->port_id, res->vlan_id); 4414 4415 cmd_reconfig_device_queue(res->port_id, 1, 1); 4416 } 4417 4418 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 4419 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4420 tx_vlan, "tx_vlan"); 4421 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 4422 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4423 set, "set"); 4424 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 4425 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4426 port_id, RTE_UINT16); 4427 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 4428 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4429 vlan_id, RTE_UINT16); 4430 4431 cmdline_parse_inst_t cmd_tx_vlan_set = { 4432 .f = cmd_tx_vlan_set_parsed, 4433 .data = NULL, 4434 .help_str = "tx_vlan set <port_id> <vlan_id>: " 4435 "Enable hardware insertion of a single VLAN header " 4436 "with a given TAG Identifier in packets sent on a port", 4437 .tokens = { 4438 (void *)&cmd_tx_vlan_set_tx_vlan, 4439 (void *)&cmd_tx_vlan_set_set, 4440 (void *)&cmd_tx_vlan_set_portid, 4441 (void *)&cmd_tx_vlan_set_vlanid, 4442 NULL, 4443 }, 4444 }; 4445 4446 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 4447 struct cmd_tx_vlan_set_qinq_result { 4448 cmdline_fixed_string_t tx_vlan; 4449 cmdline_fixed_string_t set; 4450 portid_t port_id; 4451 uint16_t vlan_id; 4452 uint16_t vlan_id_outer; 4453 }; 4454 4455 static void 4456 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 4457 __rte_unused struct cmdline *cl, 4458 __rte_unused void *data) 4459 { 4460 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 4461 4462 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4463 return; 4464 4465 if (!port_is_stopped(res->port_id)) { 4466 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4467 return; 4468 } 4469 4470 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 4471 4472 cmd_reconfig_device_queue(res->port_id, 1, 1); 4473 } 4474 4475 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 4476 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4477 tx_vlan, "tx_vlan"); 4478 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 4479 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4480 set, "set"); 4481 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 4482 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4483 port_id, RTE_UINT16); 4484 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 4485 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4486 vlan_id, RTE_UINT16); 4487 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 4488 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4489 vlan_id_outer, RTE_UINT16); 4490 4491 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 4492 .f = cmd_tx_vlan_set_qinq_parsed, 4493 .data = NULL, 4494 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 4495 "Enable hardware insertion of double VLAN header " 4496 "with given TAG Identifiers in packets sent on a port", 4497 .tokens = { 4498 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 4499 (void *)&cmd_tx_vlan_set_qinq_set, 4500 (void *)&cmd_tx_vlan_set_qinq_portid, 4501 (void *)&cmd_tx_vlan_set_qinq_vlanid, 4502 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 4503 NULL, 4504 }, 4505 }; 4506 4507 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 4508 struct cmd_tx_vlan_set_pvid_result { 4509 cmdline_fixed_string_t tx_vlan; 4510 cmdline_fixed_string_t set; 4511 cmdline_fixed_string_t pvid; 4512 portid_t port_id; 4513 uint16_t vlan_id; 4514 cmdline_fixed_string_t mode; 4515 }; 4516 4517 static void 4518 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 4519 __rte_unused struct cmdline *cl, 4520 __rte_unused void *data) 4521 { 4522 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 4523 4524 if (strcmp(res->mode, "on") == 0) 4525 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 4526 else 4527 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 4528 } 4529 4530 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 4531 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4532 tx_vlan, "tx_vlan"); 4533 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 4534 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4535 set, "set"); 4536 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 4537 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4538 pvid, "pvid"); 4539 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 4540 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4541 port_id, RTE_UINT16); 4542 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 4543 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4544 vlan_id, RTE_UINT16); 4545 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 4546 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4547 mode, "on#off"); 4548 4549 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 4550 .f = cmd_tx_vlan_set_pvid_parsed, 4551 .data = NULL, 4552 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 4553 .tokens = { 4554 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 4555 (void *)&cmd_tx_vlan_set_pvid_set, 4556 (void *)&cmd_tx_vlan_set_pvid_pvid, 4557 (void *)&cmd_tx_vlan_set_pvid_port_id, 4558 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 4559 (void *)&cmd_tx_vlan_set_pvid_mode, 4560 NULL, 4561 }, 4562 }; 4563 4564 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4565 struct cmd_tx_vlan_reset_result { 4566 cmdline_fixed_string_t tx_vlan; 4567 cmdline_fixed_string_t reset; 4568 portid_t port_id; 4569 }; 4570 4571 static void 4572 cmd_tx_vlan_reset_parsed(void *parsed_result, 4573 __rte_unused struct cmdline *cl, 4574 __rte_unused void *data) 4575 { 4576 struct cmd_tx_vlan_reset_result *res = parsed_result; 4577 4578 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4579 return; 4580 4581 if (!port_is_stopped(res->port_id)) { 4582 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4583 return; 4584 } 4585 4586 tx_vlan_reset(res->port_id); 4587 4588 cmd_reconfig_device_queue(res->port_id, 1, 1); 4589 } 4590 4591 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4592 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4593 tx_vlan, "tx_vlan"); 4594 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4595 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4596 reset, "reset"); 4597 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4598 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4599 port_id, RTE_UINT16); 4600 4601 cmdline_parse_inst_t cmd_tx_vlan_reset = { 4602 .f = cmd_tx_vlan_reset_parsed, 4603 .data = NULL, 4604 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4605 "VLAN header in packets sent on a port", 4606 .tokens = { 4607 (void *)&cmd_tx_vlan_reset_tx_vlan, 4608 (void *)&cmd_tx_vlan_reset_reset, 4609 (void *)&cmd_tx_vlan_reset_portid, 4610 NULL, 4611 }, 4612 }; 4613 4614 4615 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4616 struct cmd_csum_result { 4617 cmdline_fixed_string_t csum; 4618 cmdline_fixed_string_t mode; 4619 cmdline_fixed_string_t proto; 4620 cmdline_fixed_string_t hwsw; 4621 portid_t port_id; 4622 }; 4623 4624 static void 4625 csum_show(int port_id) 4626 { 4627 struct rte_eth_dev_info dev_info; 4628 uint64_t tx_offloads; 4629 int ret; 4630 4631 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4632 printf("Parse tunnel is %s\n", 4633 (ports[port_id].parse_tunnel) ? "on" : "off"); 4634 printf("IP checksum offload is %s\n", 4635 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4636 printf("UDP checksum offload is %s\n", 4637 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4638 printf("TCP checksum offload is %s\n", 4639 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4640 printf("SCTP checksum offload is %s\n", 4641 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4642 printf("Outer-Ip checksum offload is %s\n", 4643 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4644 printf("Outer-Udp checksum offload is %s\n", 4645 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); 4646 4647 /* display warnings if configuration is not supported by the NIC */ 4648 ret = eth_dev_info_get_print_err(port_id, &dev_info); 4649 if (ret != 0) 4650 return; 4651 4652 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 4653 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4654 fprintf(stderr, 4655 "Warning: hardware IP checksum enabled but not supported by port %d\n", 4656 port_id); 4657 } 4658 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 4659 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 4660 fprintf(stderr, 4661 "Warning: hardware UDP checksum enabled but not supported by port %d\n", 4662 port_id); 4663 } 4664 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 4665 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 4666 fprintf(stderr, 4667 "Warning: hardware TCP checksum enabled but not supported by port %d\n", 4668 port_id); 4669 } 4670 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 4671 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4672 fprintf(stderr, 4673 "Warning: hardware SCTP checksum enabled but not supported by port %d\n", 4674 port_id); 4675 } 4676 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4677 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4678 fprintf(stderr, 4679 "Warning: hardware outer IP checksum enabled but not supported by port %d\n", 4680 port_id); 4681 } 4682 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) && 4683 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) 4684 == 0) { 4685 fprintf(stderr, 4686 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n", 4687 port_id); 4688 } 4689 } 4690 4691 static void 4692 cmd_config_queue_tx_offloads(struct rte_port *port) 4693 { 4694 int k; 4695 4696 /* Apply queue tx offloads configuration */ 4697 for (k = 0; k < port->dev_info.max_tx_queues; k++) 4698 port->tx_conf[k].offloads = 4699 port->dev_conf.txmode.offloads; 4700 } 4701 4702 static void 4703 cmd_csum_parsed(void *parsed_result, 4704 __rte_unused struct cmdline *cl, 4705 __rte_unused void *data) 4706 { 4707 struct cmd_csum_result *res = parsed_result; 4708 int hw = 0; 4709 uint64_t csum_offloads = 0; 4710 struct rte_eth_dev_info dev_info; 4711 int ret; 4712 4713 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4714 fprintf(stderr, "invalid port %d\n", res->port_id); 4715 return; 4716 } 4717 if (!port_is_stopped(res->port_id)) { 4718 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4719 return; 4720 } 4721 4722 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4723 if (ret != 0) 4724 return; 4725 4726 if (!strcmp(res->mode, "set")) { 4727 4728 if (!strcmp(res->hwsw, "hw")) 4729 hw = 1; 4730 4731 if (!strcmp(res->proto, "ip")) { 4732 if (hw == 0 || (dev_info.tx_offload_capa & 4733 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 4734 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 4735 } else { 4736 fprintf(stderr, 4737 "IP checksum offload is not supported by port %u\n", 4738 res->port_id); 4739 } 4740 } else if (!strcmp(res->proto, "udp")) { 4741 if (hw == 0 || (dev_info.tx_offload_capa & 4742 DEV_TX_OFFLOAD_UDP_CKSUM)) { 4743 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 4744 } else { 4745 fprintf(stderr, 4746 "UDP checksum offload is not supported by port %u\n", 4747 res->port_id); 4748 } 4749 } else if (!strcmp(res->proto, "tcp")) { 4750 if (hw == 0 || (dev_info.tx_offload_capa & 4751 DEV_TX_OFFLOAD_TCP_CKSUM)) { 4752 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 4753 } else { 4754 fprintf(stderr, 4755 "TCP checksum offload is not supported by port %u\n", 4756 res->port_id); 4757 } 4758 } else if (!strcmp(res->proto, "sctp")) { 4759 if (hw == 0 || (dev_info.tx_offload_capa & 4760 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 4761 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 4762 } else { 4763 fprintf(stderr, 4764 "SCTP checksum offload is not supported by port %u\n", 4765 res->port_id); 4766 } 4767 } else if (!strcmp(res->proto, "outer-ip")) { 4768 if (hw == 0 || (dev_info.tx_offload_capa & 4769 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4770 csum_offloads |= 4771 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4772 } else { 4773 fprintf(stderr, 4774 "Outer IP checksum offload is not supported by port %u\n", 4775 res->port_id); 4776 } 4777 } else if (!strcmp(res->proto, "outer-udp")) { 4778 if (hw == 0 || (dev_info.tx_offload_capa & 4779 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) { 4780 csum_offloads |= 4781 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; 4782 } else { 4783 fprintf(stderr, 4784 "Outer UDP checksum offload is not supported by port %u\n", 4785 res->port_id); 4786 } 4787 } 4788 4789 if (hw) { 4790 ports[res->port_id].dev_conf.txmode.offloads |= 4791 csum_offloads; 4792 } else { 4793 ports[res->port_id].dev_conf.txmode.offloads &= 4794 (~csum_offloads); 4795 } 4796 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4797 } 4798 csum_show(res->port_id); 4799 4800 cmd_reconfig_device_queue(res->port_id, 1, 1); 4801 } 4802 4803 cmdline_parse_token_string_t cmd_csum_csum = 4804 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4805 csum, "csum"); 4806 cmdline_parse_token_string_t cmd_csum_mode = 4807 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4808 mode, "set"); 4809 cmdline_parse_token_string_t cmd_csum_proto = 4810 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4811 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); 4812 cmdline_parse_token_string_t cmd_csum_hwsw = 4813 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4814 hwsw, "hw#sw"); 4815 cmdline_parse_token_num_t cmd_csum_portid = 4816 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4817 port_id, RTE_UINT16); 4818 4819 cmdline_parse_inst_t cmd_csum_set = { 4820 .f = cmd_csum_parsed, 4821 .data = NULL, 4822 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: " 4823 "Enable/Disable hardware calculation of L3/L4 checksum when " 4824 "using csum forward engine", 4825 .tokens = { 4826 (void *)&cmd_csum_csum, 4827 (void *)&cmd_csum_mode, 4828 (void *)&cmd_csum_proto, 4829 (void *)&cmd_csum_hwsw, 4830 (void *)&cmd_csum_portid, 4831 NULL, 4832 }, 4833 }; 4834 4835 cmdline_parse_token_string_t cmd_csum_mode_show = 4836 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4837 mode, "show"); 4838 4839 cmdline_parse_inst_t cmd_csum_show = { 4840 .f = cmd_csum_parsed, 4841 .data = NULL, 4842 .help_str = "csum show <port_id>: Show checksum offload configuration", 4843 .tokens = { 4844 (void *)&cmd_csum_csum, 4845 (void *)&cmd_csum_mode_show, 4846 (void *)&cmd_csum_portid, 4847 NULL, 4848 }, 4849 }; 4850 4851 /* Enable/disable tunnel parsing */ 4852 struct cmd_csum_tunnel_result { 4853 cmdline_fixed_string_t csum; 4854 cmdline_fixed_string_t parse; 4855 cmdline_fixed_string_t onoff; 4856 portid_t port_id; 4857 }; 4858 4859 static void 4860 cmd_csum_tunnel_parsed(void *parsed_result, 4861 __rte_unused struct cmdline *cl, 4862 __rte_unused void *data) 4863 { 4864 struct cmd_csum_tunnel_result *res = parsed_result; 4865 4866 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4867 return; 4868 4869 if (!strcmp(res->onoff, "on")) 4870 ports[res->port_id].parse_tunnel = 1; 4871 else 4872 ports[res->port_id].parse_tunnel = 0; 4873 4874 csum_show(res->port_id); 4875 } 4876 4877 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4878 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4879 csum, "csum"); 4880 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4881 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4882 parse, "parse-tunnel"); 4883 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4884 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4885 onoff, "on#off"); 4886 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4887 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4888 port_id, RTE_UINT16); 4889 4890 cmdline_parse_inst_t cmd_csum_tunnel = { 4891 .f = cmd_csum_tunnel_parsed, 4892 .data = NULL, 4893 .help_str = "csum parse-tunnel on|off <port_id>: " 4894 "Enable/Disable parsing of tunnels for csum engine", 4895 .tokens = { 4896 (void *)&cmd_csum_tunnel_csum, 4897 (void *)&cmd_csum_tunnel_parse, 4898 (void *)&cmd_csum_tunnel_onoff, 4899 (void *)&cmd_csum_tunnel_portid, 4900 NULL, 4901 }, 4902 }; 4903 4904 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4905 struct cmd_tso_set_result { 4906 cmdline_fixed_string_t tso; 4907 cmdline_fixed_string_t mode; 4908 uint16_t tso_segsz; 4909 portid_t port_id; 4910 }; 4911 4912 static void 4913 cmd_tso_set_parsed(void *parsed_result, 4914 __rte_unused struct cmdline *cl, 4915 __rte_unused void *data) 4916 { 4917 struct cmd_tso_set_result *res = parsed_result; 4918 struct rte_eth_dev_info dev_info; 4919 int ret; 4920 4921 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4922 return; 4923 if (!port_is_stopped(res->port_id)) { 4924 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4925 return; 4926 } 4927 4928 if (!strcmp(res->mode, "set")) 4929 ports[res->port_id].tso_segsz = res->tso_segsz; 4930 4931 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4932 if (ret != 0) 4933 return; 4934 4935 if ((ports[res->port_id].tso_segsz != 0) && 4936 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4937 fprintf(stderr, "Error: TSO is not supported by port %d\n", 4938 res->port_id); 4939 return; 4940 } 4941 4942 if (ports[res->port_id].tso_segsz == 0) { 4943 ports[res->port_id].dev_conf.txmode.offloads &= 4944 ~DEV_TX_OFFLOAD_TCP_TSO; 4945 printf("TSO for non-tunneled packets is disabled\n"); 4946 } else { 4947 ports[res->port_id].dev_conf.txmode.offloads |= 4948 DEV_TX_OFFLOAD_TCP_TSO; 4949 printf("TSO segment size for non-tunneled packets is %d\n", 4950 ports[res->port_id].tso_segsz); 4951 } 4952 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4953 4954 /* display warnings if configuration is not supported by the NIC */ 4955 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4956 if (ret != 0) 4957 return; 4958 4959 if ((ports[res->port_id].tso_segsz != 0) && 4960 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4961 fprintf(stderr, 4962 "Warning: TSO enabled but not supported by port %d\n", 4963 res->port_id); 4964 } 4965 4966 cmd_reconfig_device_queue(res->port_id, 1, 1); 4967 } 4968 4969 cmdline_parse_token_string_t cmd_tso_set_tso = 4970 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4971 tso, "tso"); 4972 cmdline_parse_token_string_t cmd_tso_set_mode = 4973 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4974 mode, "set"); 4975 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4976 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4977 tso_segsz, RTE_UINT16); 4978 cmdline_parse_token_num_t cmd_tso_set_portid = 4979 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4980 port_id, RTE_UINT16); 4981 4982 cmdline_parse_inst_t cmd_tso_set = { 4983 .f = cmd_tso_set_parsed, 4984 .data = NULL, 4985 .help_str = "tso set <tso_segsz> <port_id>: " 4986 "Set TSO segment size of non-tunneled packets for csum engine " 4987 "(0 to disable)", 4988 .tokens = { 4989 (void *)&cmd_tso_set_tso, 4990 (void *)&cmd_tso_set_mode, 4991 (void *)&cmd_tso_set_tso_segsz, 4992 (void *)&cmd_tso_set_portid, 4993 NULL, 4994 }, 4995 }; 4996 4997 cmdline_parse_token_string_t cmd_tso_show_mode = 4998 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4999 mode, "show"); 5000 5001 5002 cmdline_parse_inst_t cmd_tso_show = { 5003 .f = cmd_tso_set_parsed, 5004 .data = NULL, 5005 .help_str = "tso show <port_id>: " 5006 "Show TSO segment size of non-tunneled packets for csum engine", 5007 .tokens = { 5008 (void *)&cmd_tso_set_tso, 5009 (void *)&cmd_tso_show_mode, 5010 (void *)&cmd_tso_set_portid, 5011 NULL, 5012 }, 5013 }; 5014 5015 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 5016 struct cmd_tunnel_tso_set_result { 5017 cmdline_fixed_string_t tso; 5018 cmdline_fixed_string_t mode; 5019 uint16_t tso_segsz; 5020 portid_t port_id; 5021 }; 5022 5023 static struct rte_eth_dev_info 5024 check_tunnel_tso_nic_support(portid_t port_id) 5025 { 5026 struct rte_eth_dev_info dev_info; 5027 5028 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0) 5029 return dev_info; 5030 5031 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 5032 fprintf(stderr, 5033 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n", 5034 port_id); 5035 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 5036 fprintf(stderr, 5037 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n", 5038 port_id); 5039 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 5040 fprintf(stderr, 5041 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n", 5042 port_id); 5043 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 5044 fprintf(stderr, 5045 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n", 5046 port_id); 5047 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO)) 5048 fprintf(stderr, 5049 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n", 5050 port_id); 5051 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO)) 5052 fprintf(stderr, 5053 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n", 5054 port_id); 5055 return dev_info; 5056 } 5057 5058 static void 5059 cmd_tunnel_tso_set_parsed(void *parsed_result, 5060 __rte_unused struct cmdline *cl, 5061 __rte_unused void *data) 5062 { 5063 struct cmd_tunnel_tso_set_result *res = parsed_result; 5064 struct rte_eth_dev_info dev_info; 5065 5066 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 5067 return; 5068 if (!port_is_stopped(res->port_id)) { 5069 fprintf(stderr, "Please stop port %d first\n", res->port_id); 5070 return; 5071 } 5072 5073 if (!strcmp(res->mode, "set")) 5074 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 5075 5076 dev_info = check_tunnel_tso_nic_support(res->port_id); 5077 if (ports[res->port_id].tunnel_tso_segsz == 0) { 5078 ports[res->port_id].dev_conf.txmode.offloads &= 5079 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 5080 DEV_TX_OFFLOAD_GRE_TNL_TSO | 5081 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 5082 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 5083 DEV_TX_OFFLOAD_IP_TNL_TSO | 5084 DEV_TX_OFFLOAD_UDP_TNL_TSO); 5085 printf("TSO for tunneled packets is disabled\n"); 5086 } else { 5087 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 5088 DEV_TX_OFFLOAD_GRE_TNL_TSO | 5089 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 5090 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 5091 DEV_TX_OFFLOAD_IP_TNL_TSO | 5092 DEV_TX_OFFLOAD_UDP_TNL_TSO); 5093 5094 ports[res->port_id].dev_conf.txmode.offloads |= 5095 (tso_offloads & dev_info.tx_offload_capa); 5096 printf("TSO segment size for tunneled packets is %d\n", 5097 ports[res->port_id].tunnel_tso_segsz); 5098 5099 /* Below conditions are needed to make it work: 5100 * (1) tunnel TSO is supported by the NIC; 5101 * (2) "csum parse_tunnel" must be set so that tunneled pkts 5102 * are recognized; 5103 * (3) for tunneled pkts with outer L3 of IPv4, 5104 * "csum set outer-ip" must be set to hw, because after tso, 5105 * total_len of outer IP header is changed, and the checksum 5106 * of outer IP header calculated by sw should be wrong; that 5107 * is not necessary for IPv6 tunneled pkts because there's no 5108 * checksum in IP header anymore. 5109 */ 5110 5111 if (!ports[res->port_id].parse_tunnel) 5112 fprintf(stderr, 5113 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n"); 5114 if (!(ports[res->port_id].dev_conf.txmode.offloads & 5115 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 5116 fprintf(stderr, 5117 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n"); 5118 } 5119 5120 cmd_config_queue_tx_offloads(&ports[res->port_id]); 5121 cmd_reconfig_device_queue(res->port_id, 1, 1); 5122 } 5123 5124 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 5125 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5126 tso, "tunnel_tso"); 5127 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 5128 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5129 mode, "set"); 5130 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 5131 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 5132 tso_segsz, RTE_UINT16); 5133 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 5134 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 5135 port_id, RTE_UINT16); 5136 5137 cmdline_parse_inst_t cmd_tunnel_tso_set = { 5138 .f = cmd_tunnel_tso_set_parsed, 5139 .data = NULL, 5140 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 5141 "Set TSO segment size of tunneled packets for csum engine " 5142 "(0 to disable)", 5143 .tokens = { 5144 (void *)&cmd_tunnel_tso_set_tso, 5145 (void *)&cmd_tunnel_tso_set_mode, 5146 (void *)&cmd_tunnel_tso_set_tso_segsz, 5147 (void *)&cmd_tunnel_tso_set_portid, 5148 NULL, 5149 }, 5150 }; 5151 5152 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 5153 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5154 mode, "show"); 5155 5156 5157 cmdline_parse_inst_t cmd_tunnel_tso_show = { 5158 .f = cmd_tunnel_tso_set_parsed, 5159 .data = NULL, 5160 .help_str = "tunnel_tso show <port_id> " 5161 "Show TSO segment size of tunneled packets for csum engine", 5162 .tokens = { 5163 (void *)&cmd_tunnel_tso_set_tso, 5164 (void *)&cmd_tunnel_tso_show_mode, 5165 (void *)&cmd_tunnel_tso_set_portid, 5166 NULL, 5167 }, 5168 }; 5169 5170 /* *** SET GRO FOR A PORT *** */ 5171 struct cmd_gro_enable_result { 5172 cmdline_fixed_string_t cmd_set; 5173 cmdline_fixed_string_t cmd_port; 5174 cmdline_fixed_string_t cmd_keyword; 5175 cmdline_fixed_string_t cmd_onoff; 5176 portid_t cmd_pid; 5177 }; 5178 5179 static void 5180 cmd_gro_enable_parsed(void *parsed_result, 5181 __rte_unused struct cmdline *cl, 5182 __rte_unused void *data) 5183 { 5184 struct cmd_gro_enable_result *res; 5185 5186 res = parsed_result; 5187 if (!strcmp(res->cmd_keyword, "gro")) 5188 setup_gro(res->cmd_onoff, res->cmd_pid); 5189 } 5190 5191 cmdline_parse_token_string_t cmd_gro_enable_set = 5192 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5193 cmd_set, "set"); 5194 cmdline_parse_token_string_t cmd_gro_enable_port = 5195 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5196 cmd_keyword, "port"); 5197 cmdline_parse_token_num_t cmd_gro_enable_pid = 5198 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 5199 cmd_pid, RTE_UINT16); 5200 cmdline_parse_token_string_t cmd_gro_enable_keyword = 5201 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5202 cmd_keyword, "gro"); 5203 cmdline_parse_token_string_t cmd_gro_enable_onoff = 5204 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5205 cmd_onoff, "on#off"); 5206 5207 cmdline_parse_inst_t cmd_gro_enable = { 5208 .f = cmd_gro_enable_parsed, 5209 .data = NULL, 5210 .help_str = "set port <port_id> gro on|off", 5211 .tokens = { 5212 (void *)&cmd_gro_enable_set, 5213 (void *)&cmd_gro_enable_port, 5214 (void *)&cmd_gro_enable_pid, 5215 (void *)&cmd_gro_enable_keyword, 5216 (void *)&cmd_gro_enable_onoff, 5217 NULL, 5218 }, 5219 }; 5220 5221 /* *** DISPLAY GRO CONFIGURATION *** */ 5222 struct cmd_gro_show_result { 5223 cmdline_fixed_string_t cmd_show; 5224 cmdline_fixed_string_t cmd_port; 5225 cmdline_fixed_string_t cmd_keyword; 5226 portid_t cmd_pid; 5227 }; 5228 5229 static void 5230 cmd_gro_show_parsed(void *parsed_result, 5231 __rte_unused struct cmdline *cl, 5232 __rte_unused void *data) 5233 { 5234 struct cmd_gro_show_result *res; 5235 5236 res = parsed_result; 5237 if (!strcmp(res->cmd_keyword, "gro")) 5238 show_gro(res->cmd_pid); 5239 } 5240 5241 cmdline_parse_token_string_t cmd_gro_show_show = 5242 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5243 cmd_show, "show"); 5244 cmdline_parse_token_string_t cmd_gro_show_port = 5245 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5246 cmd_port, "port"); 5247 cmdline_parse_token_num_t cmd_gro_show_pid = 5248 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 5249 cmd_pid, RTE_UINT16); 5250 cmdline_parse_token_string_t cmd_gro_show_keyword = 5251 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5252 cmd_keyword, "gro"); 5253 5254 cmdline_parse_inst_t cmd_gro_show = { 5255 .f = cmd_gro_show_parsed, 5256 .data = NULL, 5257 .help_str = "show port <port_id> gro", 5258 .tokens = { 5259 (void *)&cmd_gro_show_show, 5260 (void *)&cmd_gro_show_port, 5261 (void *)&cmd_gro_show_pid, 5262 (void *)&cmd_gro_show_keyword, 5263 NULL, 5264 }, 5265 }; 5266 5267 /* *** SET FLUSH CYCLES FOR GRO *** */ 5268 struct cmd_gro_flush_result { 5269 cmdline_fixed_string_t cmd_set; 5270 cmdline_fixed_string_t cmd_keyword; 5271 cmdline_fixed_string_t cmd_flush; 5272 uint8_t cmd_cycles; 5273 }; 5274 5275 static void 5276 cmd_gro_flush_parsed(void *parsed_result, 5277 __rte_unused struct cmdline *cl, 5278 __rte_unused void *data) 5279 { 5280 struct cmd_gro_flush_result *res; 5281 5282 res = parsed_result; 5283 if ((!strcmp(res->cmd_keyword, "gro")) && 5284 (!strcmp(res->cmd_flush, "flush"))) 5285 setup_gro_flush_cycles(res->cmd_cycles); 5286 } 5287 5288 cmdline_parse_token_string_t cmd_gro_flush_set = 5289 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5290 cmd_set, "set"); 5291 cmdline_parse_token_string_t cmd_gro_flush_keyword = 5292 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5293 cmd_keyword, "gro"); 5294 cmdline_parse_token_string_t cmd_gro_flush_flush = 5295 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5296 cmd_flush, "flush"); 5297 cmdline_parse_token_num_t cmd_gro_flush_cycles = 5298 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 5299 cmd_cycles, RTE_UINT8); 5300 5301 cmdline_parse_inst_t cmd_gro_flush = { 5302 .f = cmd_gro_flush_parsed, 5303 .data = NULL, 5304 .help_str = "set gro flush <cycles>", 5305 .tokens = { 5306 (void *)&cmd_gro_flush_set, 5307 (void *)&cmd_gro_flush_keyword, 5308 (void *)&cmd_gro_flush_flush, 5309 (void *)&cmd_gro_flush_cycles, 5310 NULL, 5311 }, 5312 }; 5313 5314 /* *** ENABLE/DISABLE GSO *** */ 5315 struct cmd_gso_enable_result { 5316 cmdline_fixed_string_t cmd_set; 5317 cmdline_fixed_string_t cmd_port; 5318 cmdline_fixed_string_t cmd_keyword; 5319 cmdline_fixed_string_t cmd_mode; 5320 portid_t cmd_pid; 5321 }; 5322 5323 static void 5324 cmd_gso_enable_parsed(void *parsed_result, 5325 __rte_unused struct cmdline *cl, 5326 __rte_unused void *data) 5327 { 5328 struct cmd_gso_enable_result *res; 5329 5330 res = parsed_result; 5331 if (!strcmp(res->cmd_keyword, "gso")) 5332 setup_gso(res->cmd_mode, res->cmd_pid); 5333 } 5334 5335 cmdline_parse_token_string_t cmd_gso_enable_set = 5336 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5337 cmd_set, "set"); 5338 cmdline_parse_token_string_t cmd_gso_enable_port = 5339 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5340 cmd_port, "port"); 5341 cmdline_parse_token_string_t cmd_gso_enable_keyword = 5342 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5343 cmd_keyword, "gso"); 5344 cmdline_parse_token_string_t cmd_gso_enable_mode = 5345 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5346 cmd_mode, "on#off"); 5347 cmdline_parse_token_num_t cmd_gso_enable_pid = 5348 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 5349 cmd_pid, RTE_UINT16); 5350 5351 cmdline_parse_inst_t cmd_gso_enable = { 5352 .f = cmd_gso_enable_parsed, 5353 .data = NULL, 5354 .help_str = "set port <port_id> gso on|off", 5355 .tokens = { 5356 (void *)&cmd_gso_enable_set, 5357 (void *)&cmd_gso_enable_port, 5358 (void *)&cmd_gso_enable_pid, 5359 (void *)&cmd_gso_enable_keyword, 5360 (void *)&cmd_gso_enable_mode, 5361 NULL, 5362 }, 5363 }; 5364 5365 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 5366 struct cmd_gso_size_result { 5367 cmdline_fixed_string_t cmd_set; 5368 cmdline_fixed_string_t cmd_keyword; 5369 cmdline_fixed_string_t cmd_segsz; 5370 uint16_t cmd_size; 5371 }; 5372 5373 static void 5374 cmd_gso_size_parsed(void *parsed_result, 5375 __rte_unused struct cmdline *cl, 5376 __rte_unused void *data) 5377 { 5378 struct cmd_gso_size_result *res = parsed_result; 5379 5380 if (test_done == 0) { 5381 fprintf(stderr, 5382 "Before setting GSO segsz, please first stop forwarding\n"); 5383 return; 5384 } 5385 5386 if (!strcmp(res->cmd_keyword, "gso") && 5387 !strcmp(res->cmd_segsz, "segsz")) { 5388 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 5389 fprintf(stderr, 5390 "gso_size should be larger than %zu. Please input a legal value\n", 5391 RTE_GSO_SEG_SIZE_MIN); 5392 else 5393 gso_max_segment_size = res->cmd_size; 5394 } 5395 } 5396 5397 cmdline_parse_token_string_t cmd_gso_size_set = 5398 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5399 cmd_set, "set"); 5400 cmdline_parse_token_string_t cmd_gso_size_keyword = 5401 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5402 cmd_keyword, "gso"); 5403 cmdline_parse_token_string_t cmd_gso_size_segsz = 5404 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5405 cmd_segsz, "segsz"); 5406 cmdline_parse_token_num_t cmd_gso_size_size = 5407 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 5408 cmd_size, RTE_UINT16); 5409 5410 cmdline_parse_inst_t cmd_gso_size = { 5411 .f = cmd_gso_size_parsed, 5412 .data = NULL, 5413 .help_str = "set gso segsz <length>", 5414 .tokens = { 5415 (void *)&cmd_gso_size_set, 5416 (void *)&cmd_gso_size_keyword, 5417 (void *)&cmd_gso_size_segsz, 5418 (void *)&cmd_gso_size_size, 5419 NULL, 5420 }, 5421 }; 5422 5423 /* *** SHOW GSO CONFIGURATION *** */ 5424 struct cmd_gso_show_result { 5425 cmdline_fixed_string_t cmd_show; 5426 cmdline_fixed_string_t cmd_port; 5427 cmdline_fixed_string_t cmd_keyword; 5428 portid_t cmd_pid; 5429 }; 5430 5431 static void 5432 cmd_gso_show_parsed(void *parsed_result, 5433 __rte_unused struct cmdline *cl, 5434 __rte_unused void *data) 5435 { 5436 struct cmd_gso_show_result *res = parsed_result; 5437 5438 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 5439 fprintf(stderr, "invalid port id %u\n", res->cmd_pid); 5440 return; 5441 } 5442 if (!strcmp(res->cmd_keyword, "gso")) { 5443 if (gso_ports[res->cmd_pid].enable) { 5444 printf("Max GSO'd packet size: %uB\n" 5445 "Supported GSO types: TCP/IPv4, " 5446 "UDP/IPv4, VxLAN with inner " 5447 "TCP/IPv4 packet, GRE with inner " 5448 "TCP/IPv4 packet\n", 5449 gso_max_segment_size); 5450 } else 5451 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 5452 } 5453 } 5454 5455 cmdline_parse_token_string_t cmd_gso_show_show = 5456 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5457 cmd_show, "show"); 5458 cmdline_parse_token_string_t cmd_gso_show_port = 5459 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5460 cmd_port, "port"); 5461 cmdline_parse_token_string_t cmd_gso_show_keyword = 5462 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5463 cmd_keyword, "gso"); 5464 cmdline_parse_token_num_t cmd_gso_show_pid = 5465 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 5466 cmd_pid, RTE_UINT16); 5467 5468 cmdline_parse_inst_t cmd_gso_show = { 5469 .f = cmd_gso_show_parsed, 5470 .data = NULL, 5471 .help_str = "show port <port_id> gso", 5472 .tokens = { 5473 (void *)&cmd_gso_show_show, 5474 (void *)&cmd_gso_show_port, 5475 (void *)&cmd_gso_show_pid, 5476 (void *)&cmd_gso_show_keyword, 5477 NULL, 5478 }, 5479 }; 5480 5481 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 5482 struct cmd_set_flush_rx { 5483 cmdline_fixed_string_t set; 5484 cmdline_fixed_string_t flush_rx; 5485 cmdline_fixed_string_t mode; 5486 }; 5487 5488 static void 5489 cmd_set_flush_rx_parsed(void *parsed_result, 5490 __rte_unused struct cmdline *cl, 5491 __rte_unused void *data) 5492 { 5493 struct cmd_set_flush_rx *res = parsed_result; 5494 5495 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) { 5496 printf("multi-process doesn't support to flush Rx queues.\n"); 5497 return; 5498 } 5499 5500 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5501 } 5502 5503 cmdline_parse_token_string_t cmd_setflushrx_set = 5504 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5505 set, "set"); 5506 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 5507 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5508 flush_rx, "flush_rx"); 5509 cmdline_parse_token_string_t cmd_setflushrx_mode = 5510 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5511 mode, "on#off"); 5512 5513 5514 cmdline_parse_inst_t cmd_set_flush_rx = { 5515 .f = cmd_set_flush_rx_parsed, 5516 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 5517 .data = NULL, 5518 .tokens = { 5519 (void *)&cmd_setflushrx_set, 5520 (void *)&cmd_setflushrx_flush_rx, 5521 (void *)&cmd_setflushrx_mode, 5522 NULL, 5523 }, 5524 }; 5525 5526 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 5527 struct cmd_set_link_check { 5528 cmdline_fixed_string_t set; 5529 cmdline_fixed_string_t link_check; 5530 cmdline_fixed_string_t mode; 5531 }; 5532 5533 static void 5534 cmd_set_link_check_parsed(void *parsed_result, 5535 __rte_unused struct cmdline *cl, 5536 __rte_unused void *data) 5537 { 5538 struct cmd_set_link_check *res = parsed_result; 5539 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5540 } 5541 5542 cmdline_parse_token_string_t cmd_setlinkcheck_set = 5543 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5544 set, "set"); 5545 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 5546 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5547 link_check, "link_check"); 5548 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 5549 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5550 mode, "on#off"); 5551 5552 5553 cmdline_parse_inst_t cmd_set_link_check = { 5554 .f = cmd_set_link_check_parsed, 5555 .help_str = "set link_check on|off: Enable/Disable link status check " 5556 "when starting/stopping a port", 5557 .data = NULL, 5558 .tokens = { 5559 (void *)&cmd_setlinkcheck_set, 5560 (void *)&cmd_setlinkcheck_link_check, 5561 (void *)&cmd_setlinkcheck_mode, 5562 NULL, 5563 }, 5564 }; 5565 5566 /* *** SET NIC BYPASS MODE *** */ 5567 struct cmd_set_bypass_mode_result { 5568 cmdline_fixed_string_t set; 5569 cmdline_fixed_string_t bypass; 5570 cmdline_fixed_string_t mode; 5571 cmdline_fixed_string_t value; 5572 portid_t port_id; 5573 }; 5574 5575 static void 5576 cmd_set_bypass_mode_parsed(void *parsed_result, 5577 __rte_unused struct cmdline *cl, 5578 __rte_unused void *data) 5579 { 5580 struct cmd_set_bypass_mode_result *res = parsed_result; 5581 portid_t port_id = res->port_id; 5582 int32_t rc = -EINVAL; 5583 5584 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5585 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5586 5587 if (!strcmp(res->value, "bypass")) 5588 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5589 else if (!strcmp(res->value, "isolate")) 5590 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5591 else 5592 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5593 5594 /* Set the bypass mode for the relevant port. */ 5595 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 5596 #endif 5597 if (rc != 0) 5598 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n", 5599 port_id); 5600 } 5601 5602 cmdline_parse_token_string_t cmd_setbypass_mode_set = 5603 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5604 set, "set"); 5605 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 5606 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5607 bypass, "bypass"); 5608 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 5609 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5610 mode, "mode"); 5611 cmdline_parse_token_string_t cmd_setbypass_mode_value = 5612 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5613 value, "normal#bypass#isolate"); 5614 cmdline_parse_token_num_t cmd_setbypass_mode_port = 5615 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 5616 port_id, RTE_UINT16); 5617 5618 cmdline_parse_inst_t cmd_set_bypass_mode = { 5619 .f = cmd_set_bypass_mode_parsed, 5620 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 5621 "Set the NIC bypass mode for port_id", 5622 .data = NULL, 5623 .tokens = { 5624 (void *)&cmd_setbypass_mode_set, 5625 (void *)&cmd_setbypass_mode_bypass, 5626 (void *)&cmd_setbypass_mode_mode, 5627 (void *)&cmd_setbypass_mode_value, 5628 (void *)&cmd_setbypass_mode_port, 5629 NULL, 5630 }, 5631 }; 5632 5633 /* *** SET NIC BYPASS EVENT *** */ 5634 struct cmd_set_bypass_event_result { 5635 cmdline_fixed_string_t set; 5636 cmdline_fixed_string_t bypass; 5637 cmdline_fixed_string_t event; 5638 cmdline_fixed_string_t event_value; 5639 cmdline_fixed_string_t mode; 5640 cmdline_fixed_string_t mode_value; 5641 portid_t port_id; 5642 }; 5643 5644 static void 5645 cmd_set_bypass_event_parsed(void *parsed_result, 5646 __rte_unused struct cmdline *cl, 5647 __rte_unused void *data) 5648 { 5649 int32_t rc = -EINVAL; 5650 struct cmd_set_bypass_event_result *res = parsed_result; 5651 portid_t port_id = res->port_id; 5652 5653 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5654 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5655 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5656 5657 if (!strcmp(res->event_value, "timeout")) 5658 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 5659 else if (!strcmp(res->event_value, "os_on")) 5660 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 5661 else if (!strcmp(res->event_value, "os_off")) 5662 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 5663 else if (!strcmp(res->event_value, "power_on")) 5664 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 5665 else if (!strcmp(res->event_value, "power_off")) 5666 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 5667 else 5668 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5669 5670 if (!strcmp(res->mode_value, "bypass")) 5671 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5672 else if (!strcmp(res->mode_value, "isolate")) 5673 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5674 else 5675 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5676 5677 /* Set the watchdog timeout. */ 5678 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 5679 5680 rc = -EINVAL; 5681 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 5682 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 5683 bypass_timeout); 5684 } 5685 if (rc != 0) { 5686 fprintf(stderr, 5687 "Failed to set timeout value %u for port %d, errto code: %d.\n", 5688 bypass_timeout, port_id, rc); 5689 } 5690 } 5691 5692 /* Set the bypass event to transition to bypass mode. */ 5693 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 5694 bypass_mode); 5695 #endif 5696 5697 if (rc != 0) 5698 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n", 5699 port_id); 5700 } 5701 5702 cmdline_parse_token_string_t cmd_setbypass_event_set = 5703 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5704 set, "set"); 5705 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 5706 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5707 bypass, "bypass"); 5708 cmdline_parse_token_string_t cmd_setbypass_event_event = 5709 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5710 event, "event"); 5711 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 5712 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5713 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 5714 cmdline_parse_token_string_t cmd_setbypass_event_mode = 5715 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5716 mode, "mode"); 5717 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 5718 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5719 mode_value, "normal#bypass#isolate"); 5720 cmdline_parse_token_num_t cmd_setbypass_event_port = 5721 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 5722 port_id, RTE_UINT16); 5723 5724 cmdline_parse_inst_t cmd_set_bypass_event = { 5725 .f = cmd_set_bypass_event_parsed, 5726 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 5727 "power_off mode normal|bypass|isolate <port_id>: " 5728 "Set the NIC bypass event mode for port_id", 5729 .data = NULL, 5730 .tokens = { 5731 (void *)&cmd_setbypass_event_set, 5732 (void *)&cmd_setbypass_event_bypass, 5733 (void *)&cmd_setbypass_event_event, 5734 (void *)&cmd_setbypass_event_event_value, 5735 (void *)&cmd_setbypass_event_mode, 5736 (void *)&cmd_setbypass_event_mode_value, 5737 (void *)&cmd_setbypass_event_port, 5738 NULL, 5739 }, 5740 }; 5741 5742 5743 /* *** SET NIC BYPASS TIMEOUT *** */ 5744 struct cmd_set_bypass_timeout_result { 5745 cmdline_fixed_string_t set; 5746 cmdline_fixed_string_t bypass; 5747 cmdline_fixed_string_t timeout; 5748 cmdline_fixed_string_t value; 5749 }; 5750 5751 static void 5752 cmd_set_bypass_timeout_parsed(void *parsed_result, 5753 __rte_unused struct cmdline *cl, 5754 __rte_unused void *data) 5755 { 5756 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 5757 5758 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5759 if (!strcmp(res->value, "1.5")) 5760 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 5761 else if (!strcmp(res->value, "2")) 5762 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 5763 else if (!strcmp(res->value, "3")) 5764 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 5765 else if (!strcmp(res->value, "4")) 5766 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 5767 else if (!strcmp(res->value, "8")) 5768 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 5769 else if (!strcmp(res->value, "16")) 5770 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 5771 else if (!strcmp(res->value, "32")) 5772 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 5773 else 5774 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5775 #endif 5776 } 5777 5778 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 5779 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5780 set, "set"); 5781 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 5782 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5783 bypass, "bypass"); 5784 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 5785 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5786 timeout, "timeout"); 5787 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 5788 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5789 value, "0#1.5#2#3#4#8#16#32"); 5790 5791 cmdline_parse_inst_t cmd_set_bypass_timeout = { 5792 .f = cmd_set_bypass_timeout_parsed, 5793 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 5794 "Set the NIC bypass watchdog timeout in seconds", 5795 .data = NULL, 5796 .tokens = { 5797 (void *)&cmd_setbypass_timeout_set, 5798 (void *)&cmd_setbypass_timeout_bypass, 5799 (void *)&cmd_setbypass_timeout_timeout, 5800 (void *)&cmd_setbypass_timeout_value, 5801 NULL, 5802 }, 5803 }; 5804 5805 /* *** SHOW NIC BYPASS MODE *** */ 5806 struct cmd_show_bypass_config_result { 5807 cmdline_fixed_string_t show; 5808 cmdline_fixed_string_t bypass; 5809 cmdline_fixed_string_t config; 5810 portid_t port_id; 5811 }; 5812 5813 static void 5814 cmd_show_bypass_config_parsed(void *parsed_result, 5815 __rte_unused struct cmdline *cl, 5816 __rte_unused void *data) 5817 { 5818 struct cmd_show_bypass_config_result *res = parsed_result; 5819 portid_t port_id = res->port_id; 5820 int rc = -EINVAL; 5821 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5822 uint32_t event_mode; 5823 uint32_t bypass_mode; 5824 uint32_t timeout = bypass_timeout; 5825 unsigned int i; 5826 5827 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 5828 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 5829 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 5830 {"UNKNOWN", "normal", "bypass", "isolate"}; 5831 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 5832 "NONE", 5833 "OS/board on", 5834 "power supply on", 5835 "OS/board off", 5836 "power supply off", 5837 "timeout"}; 5838 5839 /* Display the bypass mode.*/ 5840 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 5841 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n", 5842 port_id); 5843 return; 5844 } 5845 else { 5846 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 5847 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5848 5849 printf("\tbypass mode = %s\n", modes[bypass_mode]); 5850 } 5851 5852 /* Display the bypass timeout.*/ 5853 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 5854 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5855 5856 printf("\tbypass timeout = %s\n", timeouts[timeout]); 5857 5858 /* Display the bypass events and associated modes. */ 5859 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) { 5860 5861 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 5862 fprintf(stderr, 5863 "\tFailed to get bypass mode for event = %s\n", 5864 events[i]); 5865 } else { 5866 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 5867 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5868 5869 printf("\tbypass event: %-16s = %s\n", events[i], 5870 modes[event_mode]); 5871 } 5872 } 5873 #endif 5874 if (rc != 0) 5875 fprintf(stderr, 5876 "\tFailed to get bypass configuration for port = %d\n", 5877 port_id); 5878 } 5879 5880 cmdline_parse_token_string_t cmd_showbypass_config_show = 5881 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5882 show, "show"); 5883 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 5884 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5885 bypass, "bypass"); 5886 cmdline_parse_token_string_t cmd_showbypass_config_config = 5887 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5888 config, "config"); 5889 cmdline_parse_token_num_t cmd_showbypass_config_port = 5890 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 5891 port_id, RTE_UINT16); 5892 5893 cmdline_parse_inst_t cmd_show_bypass_config = { 5894 .f = cmd_show_bypass_config_parsed, 5895 .help_str = "show bypass config <port_id>: " 5896 "Show the NIC bypass config for port_id", 5897 .data = NULL, 5898 .tokens = { 5899 (void *)&cmd_showbypass_config_show, 5900 (void *)&cmd_showbypass_config_bypass, 5901 (void *)&cmd_showbypass_config_config, 5902 (void *)&cmd_showbypass_config_port, 5903 NULL, 5904 }, 5905 }; 5906 5907 #ifdef RTE_NET_BOND 5908 /* *** SET BONDING MODE *** */ 5909 struct cmd_set_bonding_mode_result { 5910 cmdline_fixed_string_t set; 5911 cmdline_fixed_string_t bonding; 5912 cmdline_fixed_string_t mode; 5913 uint8_t value; 5914 portid_t port_id; 5915 }; 5916 5917 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5918 __rte_unused struct cmdline *cl, 5919 __rte_unused void *data) 5920 { 5921 struct cmd_set_bonding_mode_result *res = parsed_result; 5922 portid_t port_id = res->port_id; 5923 5924 /* Set the bonding mode for the relevant port. */ 5925 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5926 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n", 5927 port_id); 5928 } 5929 5930 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5931 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5932 set, "set"); 5933 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5934 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5935 bonding, "bonding"); 5936 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5937 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5938 mode, "mode"); 5939 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5940 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5941 value, RTE_UINT8); 5942 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5943 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5944 port_id, RTE_UINT16); 5945 5946 cmdline_parse_inst_t cmd_set_bonding_mode = { 5947 .f = cmd_set_bonding_mode_parsed, 5948 .help_str = "set bonding mode <mode_value> <port_id>: " 5949 "Set the bonding mode for port_id", 5950 .data = NULL, 5951 .tokens = { 5952 (void *) &cmd_setbonding_mode_set, 5953 (void *) &cmd_setbonding_mode_bonding, 5954 (void *) &cmd_setbonding_mode_mode, 5955 (void *) &cmd_setbonding_mode_value, 5956 (void *) &cmd_setbonding_mode_port, 5957 NULL 5958 } 5959 }; 5960 5961 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5962 struct cmd_set_bonding_lacp_dedicated_queues_result { 5963 cmdline_fixed_string_t set; 5964 cmdline_fixed_string_t bonding; 5965 cmdline_fixed_string_t lacp; 5966 cmdline_fixed_string_t dedicated_queues; 5967 portid_t port_id; 5968 cmdline_fixed_string_t mode; 5969 }; 5970 5971 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5972 __rte_unused struct cmdline *cl, 5973 __rte_unused void *data) 5974 { 5975 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5976 portid_t port_id = res->port_id; 5977 struct rte_port *port; 5978 5979 port = &ports[port_id]; 5980 5981 /** Check if the port is not started **/ 5982 if (port->port_status != RTE_PORT_STOPPED) { 5983 fprintf(stderr, "Please stop port %d first\n", port_id); 5984 return; 5985 } 5986 5987 if (!strcmp(res->mode, "enable")) { 5988 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5989 printf("Dedicate queues for LACP control packets" 5990 " enabled\n"); 5991 else 5992 printf("Enabling dedicate queues for LACP control " 5993 "packets on port %d failed\n", port_id); 5994 } else if (!strcmp(res->mode, "disable")) { 5995 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5996 printf("Dedicated queues for LACP control packets " 5997 "disabled\n"); 5998 else 5999 printf("Disabling dedicated queues for LACP control " 6000 "traffic on port %d failed\n", port_id); 6001 } 6002 } 6003 6004 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 6005 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 6006 set, "set"); 6007 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 6008 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 6009 bonding, "bonding"); 6010 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 6011 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 6012 lacp, "lacp"); 6013 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 6014 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 6015 dedicated_queues, "dedicated_queues"); 6016 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 6017 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 6018 port_id, RTE_UINT16); 6019 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 6020 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 6021 mode, "enable#disable"); 6022 6023 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 6024 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 6025 .help_str = "set bonding lacp dedicated_queues <port_id> " 6026 "enable|disable: " 6027 "Enable/disable dedicated queues for LACP control traffic for port_id", 6028 .data = NULL, 6029 .tokens = { 6030 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 6031 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 6032 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 6033 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 6034 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 6035 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 6036 NULL 6037 } 6038 }; 6039 6040 /* *** SET BALANCE XMIT POLICY *** */ 6041 struct cmd_set_bonding_balance_xmit_policy_result { 6042 cmdline_fixed_string_t set; 6043 cmdline_fixed_string_t bonding; 6044 cmdline_fixed_string_t balance_xmit_policy; 6045 portid_t port_id; 6046 cmdline_fixed_string_t policy; 6047 }; 6048 6049 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 6050 __rte_unused struct cmdline *cl, 6051 __rte_unused void *data) 6052 { 6053 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 6054 portid_t port_id = res->port_id; 6055 uint8_t policy; 6056 6057 if (!strcmp(res->policy, "l2")) { 6058 policy = BALANCE_XMIT_POLICY_LAYER2; 6059 } else if (!strcmp(res->policy, "l23")) { 6060 policy = BALANCE_XMIT_POLICY_LAYER23; 6061 } else if (!strcmp(res->policy, "l34")) { 6062 policy = BALANCE_XMIT_POLICY_LAYER34; 6063 } else { 6064 fprintf(stderr, "\t Invalid xmit policy selection"); 6065 return; 6066 } 6067 6068 /* Set the bonding mode for the relevant port. */ 6069 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 6070 fprintf(stderr, 6071 "\t Failed to set bonding balance xmit policy for port = %d.\n", 6072 port_id); 6073 } 6074 } 6075 6076 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 6077 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6078 set, "set"); 6079 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 6080 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6081 bonding, "bonding"); 6082 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 6083 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6084 balance_xmit_policy, "balance_xmit_policy"); 6085 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 6086 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6087 port_id, RTE_UINT16); 6088 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 6089 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6090 policy, "l2#l23#l34"); 6091 6092 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 6093 .f = cmd_set_bonding_balance_xmit_policy_parsed, 6094 .help_str = "set bonding balance_xmit_policy <port_id> " 6095 "l2|l23|l34: " 6096 "Set the bonding balance_xmit_policy for port_id", 6097 .data = NULL, 6098 .tokens = { 6099 (void *)&cmd_setbonding_balance_xmit_policy_set, 6100 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 6101 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 6102 (void *)&cmd_setbonding_balance_xmit_policy_port, 6103 (void *)&cmd_setbonding_balance_xmit_policy_policy, 6104 NULL 6105 } 6106 }; 6107 6108 /* *** SHOW NIC BONDING CONFIGURATION *** */ 6109 struct cmd_show_bonding_config_result { 6110 cmdline_fixed_string_t show; 6111 cmdline_fixed_string_t bonding; 6112 cmdline_fixed_string_t config; 6113 portid_t port_id; 6114 }; 6115 6116 static void cmd_show_bonding_config_parsed(void *parsed_result, 6117 __rte_unused struct cmdline *cl, 6118 __rte_unused void *data) 6119 { 6120 struct cmd_show_bonding_config_result *res = parsed_result; 6121 int bonding_mode, agg_mode; 6122 portid_t slaves[RTE_MAX_ETHPORTS]; 6123 int num_slaves, num_active_slaves; 6124 int primary_id; 6125 int i; 6126 portid_t port_id = res->port_id; 6127 6128 /* Display the bonding mode.*/ 6129 bonding_mode = rte_eth_bond_mode_get(port_id); 6130 if (bonding_mode < 0) { 6131 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n", 6132 port_id); 6133 return; 6134 } else 6135 printf("\tBonding mode: %d\n", bonding_mode); 6136 6137 if (bonding_mode == BONDING_MODE_BALANCE) { 6138 int balance_xmit_policy; 6139 6140 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 6141 if (balance_xmit_policy < 0) { 6142 fprintf(stderr, 6143 "\tFailed to get balance xmit policy for port = %d\n", 6144 port_id); 6145 return; 6146 } else { 6147 printf("\tBalance Xmit Policy: "); 6148 6149 switch (balance_xmit_policy) { 6150 case BALANCE_XMIT_POLICY_LAYER2: 6151 printf("BALANCE_XMIT_POLICY_LAYER2"); 6152 break; 6153 case BALANCE_XMIT_POLICY_LAYER23: 6154 printf("BALANCE_XMIT_POLICY_LAYER23"); 6155 break; 6156 case BALANCE_XMIT_POLICY_LAYER34: 6157 printf("BALANCE_XMIT_POLICY_LAYER34"); 6158 break; 6159 } 6160 printf("\n"); 6161 } 6162 } 6163 6164 if (bonding_mode == BONDING_MODE_8023AD) { 6165 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 6166 printf("\tIEEE802.3AD Aggregator Mode: "); 6167 switch (agg_mode) { 6168 case AGG_BANDWIDTH: 6169 printf("bandwidth"); 6170 break; 6171 case AGG_STABLE: 6172 printf("stable"); 6173 break; 6174 case AGG_COUNT: 6175 printf("count"); 6176 break; 6177 } 6178 printf("\n"); 6179 } 6180 6181 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 6182 6183 if (num_slaves < 0) { 6184 fprintf(stderr, "\tFailed to get slave list for port = %d\n", 6185 port_id); 6186 return; 6187 } 6188 if (num_slaves > 0) { 6189 printf("\tSlaves (%d): [", num_slaves); 6190 for (i = 0; i < num_slaves - 1; i++) 6191 printf("%d ", slaves[i]); 6192 6193 printf("%d]\n", slaves[num_slaves - 1]); 6194 } else { 6195 printf("\tSlaves: []\n"); 6196 6197 } 6198 6199 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 6200 RTE_MAX_ETHPORTS); 6201 6202 if (num_active_slaves < 0) { 6203 fprintf(stderr, 6204 "\tFailed to get active slave list for port = %d\n", 6205 port_id); 6206 return; 6207 } 6208 if (num_active_slaves > 0) { 6209 printf("\tActive Slaves (%d): [", num_active_slaves); 6210 for (i = 0; i < num_active_slaves - 1; i++) 6211 printf("%d ", slaves[i]); 6212 6213 printf("%d]\n", slaves[num_active_slaves - 1]); 6214 6215 } else { 6216 printf("\tActive Slaves: []\n"); 6217 6218 } 6219 6220 primary_id = rte_eth_bond_primary_get(port_id); 6221 if (primary_id < 0) { 6222 fprintf(stderr, "\tFailed to get primary slave for port = %d\n", 6223 port_id); 6224 return; 6225 } else 6226 printf("\tPrimary: [%d]\n", primary_id); 6227 6228 } 6229 6230 cmdline_parse_token_string_t cmd_showbonding_config_show = 6231 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6232 show, "show"); 6233 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 6234 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6235 bonding, "bonding"); 6236 cmdline_parse_token_string_t cmd_showbonding_config_config = 6237 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6238 config, "config"); 6239 cmdline_parse_token_num_t cmd_showbonding_config_port = 6240 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 6241 port_id, RTE_UINT16); 6242 6243 cmdline_parse_inst_t cmd_show_bonding_config = { 6244 .f = cmd_show_bonding_config_parsed, 6245 .help_str = "show bonding config <port_id>: " 6246 "Show the bonding config for port_id", 6247 .data = NULL, 6248 .tokens = { 6249 (void *)&cmd_showbonding_config_show, 6250 (void *)&cmd_showbonding_config_bonding, 6251 (void *)&cmd_showbonding_config_config, 6252 (void *)&cmd_showbonding_config_port, 6253 NULL 6254 } 6255 }; 6256 6257 /* *** SET BONDING PRIMARY *** */ 6258 struct cmd_set_bonding_primary_result { 6259 cmdline_fixed_string_t set; 6260 cmdline_fixed_string_t bonding; 6261 cmdline_fixed_string_t primary; 6262 portid_t slave_id; 6263 portid_t port_id; 6264 }; 6265 6266 static void cmd_set_bonding_primary_parsed(void *parsed_result, 6267 __rte_unused struct cmdline *cl, 6268 __rte_unused void *data) 6269 { 6270 struct cmd_set_bonding_primary_result *res = parsed_result; 6271 portid_t master_port_id = res->port_id; 6272 portid_t slave_port_id = res->slave_id; 6273 6274 /* Set the primary slave for a bonded device. */ 6275 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 6276 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n", 6277 master_port_id); 6278 return; 6279 } 6280 init_port_config(); 6281 } 6282 6283 cmdline_parse_token_string_t cmd_setbonding_primary_set = 6284 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6285 set, "set"); 6286 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 6287 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6288 bonding, "bonding"); 6289 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 6290 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6291 primary, "primary"); 6292 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 6293 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6294 slave_id, RTE_UINT16); 6295 cmdline_parse_token_num_t cmd_setbonding_primary_port = 6296 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6297 port_id, RTE_UINT16); 6298 6299 cmdline_parse_inst_t cmd_set_bonding_primary = { 6300 .f = cmd_set_bonding_primary_parsed, 6301 .help_str = "set bonding primary <slave_id> <port_id>: " 6302 "Set the primary slave for port_id", 6303 .data = NULL, 6304 .tokens = { 6305 (void *)&cmd_setbonding_primary_set, 6306 (void *)&cmd_setbonding_primary_bonding, 6307 (void *)&cmd_setbonding_primary_primary, 6308 (void *)&cmd_setbonding_primary_slave, 6309 (void *)&cmd_setbonding_primary_port, 6310 NULL 6311 } 6312 }; 6313 6314 /* *** ADD SLAVE *** */ 6315 struct cmd_add_bonding_slave_result { 6316 cmdline_fixed_string_t add; 6317 cmdline_fixed_string_t bonding; 6318 cmdline_fixed_string_t slave; 6319 portid_t slave_id; 6320 portid_t port_id; 6321 }; 6322 6323 static void cmd_add_bonding_slave_parsed(void *parsed_result, 6324 __rte_unused struct cmdline *cl, 6325 __rte_unused void *data) 6326 { 6327 struct cmd_add_bonding_slave_result *res = parsed_result; 6328 portid_t master_port_id = res->port_id; 6329 portid_t slave_port_id = res->slave_id; 6330 6331 /* add the slave for a bonded device. */ 6332 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 6333 fprintf(stderr, 6334 "\t Failed to add slave %d to master port = %d.\n", 6335 slave_port_id, master_port_id); 6336 return; 6337 } 6338 init_port_config(); 6339 set_port_slave_flag(slave_port_id); 6340 } 6341 6342 cmdline_parse_token_string_t cmd_addbonding_slave_add = 6343 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6344 add, "add"); 6345 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 6346 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6347 bonding, "bonding"); 6348 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 6349 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6350 slave, "slave"); 6351 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 6352 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6353 slave_id, RTE_UINT16); 6354 cmdline_parse_token_num_t cmd_addbonding_slave_port = 6355 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6356 port_id, RTE_UINT16); 6357 6358 cmdline_parse_inst_t cmd_add_bonding_slave = { 6359 .f = cmd_add_bonding_slave_parsed, 6360 .help_str = "add bonding slave <slave_id> <port_id>: " 6361 "Add a slave device to a bonded device", 6362 .data = NULL, 6363 .tokens = { 6364 (void *)&cmd_addbonding_slave_add, 6365 (void *)&cmd_addbonding_slave_bonding, 6366 (void *)&cmd_addbonding_slave_slave, 6367 (void *)&cmd_addbonding_slave_slaveid, 6368 (void *)&cmd_addbonding_slave_port, 6369 NULL 6370 } 6371 }; 6372 6373 /* *** REMOVE SLAVE *** */ 6374 struct cmd_remove_bonding_slave_result { 6375 cmdline_fixed_string_t remove; 6376 cmdline_fixed_string_t bonding; 6377 cmdline_fixed_string_t slave; 6378 portid_t slave_id; 6379 portid_t port_id; 6380 }; 6381 6382 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 6383 __rte_unused struct cmdline *cl, 6384 __rte_unused void *data) 6385 { 6386 struct cmd_remove_bonding_slave_result *res = parsed_result; 6387 portid_t master_port_id = res->port_id; 6388 portid_t slave_port_id = res->slave_id; 6389 6390 /* remove the slave from a bonded device. */ 6391 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 6392 fprintf(stderr, 6393 "\t Failed to remove slave %d from master port = %d.\n", 6394 slave_port_id, master_port_id); 6395 return; 6396 } 6397 init_port_config(); 6398 clear_port_slave_flag(slave_port_id); 6399 } 6400 6401 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 6402 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6403 remove, "remove"); 6404 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 6405 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6406 bonding, "bonding"); 6407 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 6408 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6409 slave, "slave"); 6410 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 6411 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6412 slave_id, RTE_UINT16); 6413 cmdline_parse_token_num_t cmd_removebonding_slave_port = 6414 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6415 port_id, RTE_UINT16); 6416 6417 cmdline_parse_inst_t cmd_remove_bonding_slave = { 6418 .f = cmd_remove_bonding_slave_parsed, 6419 .help_str = "remove bonding slave <slave_id> <port_id>: " 6420 "Remove a slave device from a bonded device", 6421 .data = NULL, 6422 .tokens = { 6423 (void *)&cmd_removebonding_slave_remove, 6424 (void *)&cmd_removebonding_slave_bonding, 6425 (void *)&cmd_removebonding_slave_slave, 6426 (void *)&cmd_removebonding_slave_slaveid, 6427 (void *)&cmd_removebonding_slave_port, 6428 NULL 6429 } 6430 }; 6431 6432 /* *** CREATE BONDED DEVICE *** */ 6433 struct cmd_create_bonded_device_result { 6434 cmdline_fixed_string_t create; 6435 cmdline_fixed_string_t bonded; 6436 cmdline_fixed_string_t device; 6437 uint8_t mode; 6438 uint8_t socket; 6439 }; 6440 6441 static int bond_dev_num = 0; 6442 6443 static void cmd_create_bonded_device_parsed(void *parsed_result, 6444 __rte_unused struct cmdline *cl, 6445 __rte_unused void *data) 6446 { 6447 struct cmd_create_bonded_device_result *res = parsed_result; 6448 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 6449 int port_id; 6450 int ret; 6451 6452 if (test_done == 0) { 6453 fprintf(stderr, "Please stop forwarding first\n"); 6454 return; 6455 } 6456 6457 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 6458 bond_dev_num++); 6459 6460 /* Create a new bonded device. */ 6461 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 6462 if (port_id < 0) { 6463 fprintf(stderr, "\t Failed to create bonded device.\n"); 6464 return; 6465 } else { 6466 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 6467 port_id); 6468 6469 /* Update number of ports */ 6470 nb_ports = rte_eth_dev_count_avail(); 6471 reconfig(port_id, res->socket); 6472 ret = rte_eth_promiscuous_enable(port_id); 6473 if (ret != 0) 6474 fprintf(stderr, 6475 "Failed to enable promiscuous mode for port %u: %s - ignore\n", 6476 port_id, rte_strerror(-ret)); 6477 6478 ports[port_id].need_setup = 0; 6479 ports[port_id].port_status = RTE_PORT_STOPPED; 6480 } 6481 6482 } 6483 6484 cmdline_parse_token_string_t cmd_createbonded_device_create = 6485 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6486 create, "create"); 6487 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 6488 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6489 bonded, "bonded"); 6490 cmdline_parse_token_string_t cmd_createbonded_device_device = 6491 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6492 device, "device"); 6493 cmdline_parse_token_num_t cmd_createbonded_device_mode = 6494 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6495 mode, RTE_UINT8); 6496 cmdline_parse_token_num_t cmd_createbonded_device_socket = 6497 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6498 socket, RTE_UINT8); 6499 6500 cmdline_parse_inst_t cmd_create_bonded_device = { 6501 .f = cmd_create_bonded_device_parsed, 6502 .help_str = "create bonded device <mode> <socket>: " 6503 "Create a new bonded device with specific bonding mode and socket", 6504 .data = NULL, 6505 .tokens = { 6506 (void *)&cmd_createbonded_device_create, 6507 (void *)&cmd_createbonded_device_bonded, 6508 (void *)&cmd_createbonded_device_device, 6509 (void *)&cmd_createbonded_device_mode, 6510 (void *)&cmd_createbonded_device_socket, 6511 NULL 6512 } 6513 }; 6514 6515 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 6516 struct cmd_set_bond_mac_addr_result { 6517 cmdline_fixed_string_t set; 6518 cmdline_fixed_string_t bonding; 6519 cmdline_fixed_string_t mac_addr; 6520 uint16_t port_num; 6521 struct rte_ether_addr address; 6522 }; 6523 6524 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 6525 __rte_unused struct cmdline *cl, 6526 __rte_unused void *data) 6527 { 6528 struct cmd_set_bond_mac_addr_result *res = parsed_result; 6529 int ret; 6530 6531 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 6532 return; 6533 6534 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 6535 6536 /* check the return value and print it if is < 0 */ 6537 if (ret < 0) 6538 fprintf(stderr, "set_bond_mac_addr error: (%s)\n", 6539 strerror(-ret)); 6540 } 6541 6542 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 6543 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 6544 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 6545 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 6546 "bonding"); 6547 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 6548 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 6549 "mac_addr"); 6550 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 6551 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 6552 port_num, RTE_UINT16); 6553 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 6554 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 6555 6556 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 6557 .f = cmd_set_bond_mac_addr_parsed, 6558 .data = (void *) 0, 6559 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 6560 .tokens = { 6561 (void *)&cmd_set_bond_mac_addr_set, 6562 (void *)&cmd_set_bond_mac_addr_bonding, 6563 (void *)&cmd_set_bond_mac_addr_mac, 6564 (void *)&cmd_set_bond_mac_addr_portnum, 6565 (void *)&cmd_set_bond_mac_addr_addr, 6566 NULL 6567 } 6568 }; 6569 6570 6571 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 6572 struct cmd_set_bond_mon_period_result { 6573 cmdline_fixed_string_t set; 6574 cmdline_fixed_string_t bonding; 6575 cmdline_fixed_string_t mon_period; 6576 uint16_t port_num; 6577 uint32_t period_ms; 6578 }; 6579 6580 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 6581 __rte_unused struct cmdline *cl, 6582 __rte_unused void *data) 6583 { 6584 struct cmd_set_bond_mon_period_result *res = parsed_result; 6585 int ret; 6586 6587 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 6588 6589 /* check the return value and print it if is < 0 */ 6590 if (ret < 0) 6591 fprintf(stderr, "set_bond_mac_addr error: (%s)\n", 6592 strerror(-ret)); 6593 } 6594 6595 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 6596 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6597 set, "set"); 6598 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 6599 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6600 bonding, "bonding"); 6601 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 6602 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6603 mon_period, "mon_period"); 6604 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 6605 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6606 port_num, RTE_UINT16); 6607 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 6608 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6609 period_ms, RTE_UINT32); 6610 6611 cmdline_parse_inst_t cmd_set_bond_mon_period = { 6612 .f = cmd_set_bond_mon_period_parsed, 6613 .data = (void *) 0, 6614 .help_str = "set bonding mon_period <port_id> <period_ms>", 6615 .tokens = { 6616 (void *)&cmd_set_bond_mon_period_set, 6617 (void *)&cmd_set_bond_mon_period_bonding, 6618 (void *)&cmd_set_bond_mon_period_mon_period, 6619 (void *)&cmd_set_bond_mon_period_portnum, 6620 (void *)&cmd_set_bond_mon_period_period_ms, 6621 NULL 6622 } 6623 }; 6624 6625 6626 6627 struct cmd_set_bonding_agg_mode_policy_result { 6628 cmdline_fixed_string_t set; 6629 cmdline_fixed_string_t bonding; 6630 cmdline_fixed_string_t agg_mode; 6631 uint16_t port_num; 6632 cmdline_fixed_string_t policy; 6633 }; 6634 6635 6636 static void 6637 cmd_set_bonding_agg_mode(void *parsed_result, 6638 __rte_unused struct cmdline *cl, 6639 __rte_unused void *data) 6640 { 6641 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 6642 uint8_t policy = AGG_BANDWIDTH; 6643 6644 if (!strcmp(res->policy, "bandwidth")) 6645 policy = AGG_BANDWIDTH; 6646 else if (!strcmp(res->policy, "stable")) 6647 policy = AGG_STABLE; 6648 else if (!strcmp(res->policy, "count")) 6649 policy = AGG_COUNT; 6650 6651 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 6652 } 6653 6654 6655 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 6656 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6657 set, "set"); 6658 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 6659 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6660 bonding, "bonding"); 6661 6662 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 6663 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6664 agg_mode, "agg_mode"); 6665 6666 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 6667 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6668 port_num, RTE_UINT16); 6669 6670 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 6671 TOKEN_STRING_INITIALIZER( 6672 struct cmd_set_bonding_balance_xmit_policy_result, 6673 policy, "stable#bandwidth#count"); 6674 6675 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 6676 .f = cmd_set_bonding_agg_mode, 6677 .data = (void *) 0, 6678 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 6679 .tokens = { 6680 (void *)&cmd_set_bonding_agg_mode_set, 6681 (void *)&cmd_set_bonding_agg_mode_bonding, 6682 (void *)&cmd_set_bonding_agg_mode_agg_mode, 6683 (void *)&cmd_set_bonding_agg_mode_portnum, 6684 (void *)&cmd_set_bonding_agg_mode_policy_string, 6685 NULL 6686 } 6687 }; 6688 6689 6690 #endif /* RTE_NET_BOND */ 6691 6692 /* *** SET FORWARDING MODE *** */ 6693 struct cmd_set_fwd_mode_result { 6694 cmdline_fixed_string_t set; 6695 cmdline_fixed_string_t fwd; 6696 cmdline_fixed_string_t mode; 6697 }; 6698 6699 static void cmd_set_fwd_mode_parsed(void *parsed_result, 6700 __rte_unused struct cmdline *cl, 6701 __rte_unused void *data) 6702 { 6703 struct cmd_set_fwd_mode_result *res = parsed_result; 6704 6705 retry_enabled = 0; 6706 set_pkt_forwarding_mode(res->mode); 6707 } 6708 6709 cmdline_parse_token_string_t cmd_setfwd_set = 6710 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 6711 cmdline_parse_token_string_t cmd_setfwd_fwd = 6712 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 6713 cmdline_parse_token_string_t cmd_setfwd_mode = 6714 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 6715 "" /* defined at init */); 6716 6717 cmdline_parse_inst_t cmd_set_fwd_mode = { 6718 .f = cmd_set_fwd_mode_parsed, 6719 .data = NULL, 6720 .help_str = NULL, /* defined at init */ 6721 .tokens = { 6722 (void *)&cmd_setfwd_set, 6723 (void *)&cmd_setfwd_fwd, 6724 (void *)&cmd_setfwd_mode, 6725 NULL, 6726 }, 6727 }; 6728 6729 static void cmd_set_fwd_mode_init(void) 6730 { 6731 char *modes, *c; 6732 static char token[128]; 6733 static char help[256]; 6734 cmdline_parse_token_string_t *token_struct; 6735 6736 modes = list_pkt_forwarding_modes(); 6737 snprintf(help, sizeof(help), "set fwd %s: " 6738 "Set packet forwarding mode", modes); 6739 cmd_set_fwd_mode.help_str = help; 6740 6741 /* string token separator is # */ 6742 for (c = token; *modes != '\0'; modes++) 6743 if (*modes == '|') 6744 *c++ = '#'; 6745 else 6746 *c++ = *modes; 6747 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 6748 token_struct->string_data.str = token; 6749 } 6750 6751 /* *** SET RETRY FORWARDING MODE *** */ 6752 struct cmd_set_fwd_retry_mode_result { 6753 cmdline_fixed_string_t set; 6754 cmdline_fixed_string_t fwd; 6755 cmdline_fixed_string_t mode; 6756 cmdline_fixed_string_t retry; 6757 }; 6758 6759 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 6760 __rte_unused struct cmdline *cl, 6761 __rte_unused void *data) 6762 { 6763 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 6764 6765 retry_enabled = 1; 6766 set_pkt_forwarding_mode(res->mode); 6767 } 6768 6769 cmdline_parse_token_string_t cmd_setfwd_retry_set = 6770 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6771 set, "set"); 6772 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 6773 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6774 fwd, "fwd"); 6775 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 6776 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6777 mode, 6778 "" /* defined at init */); 6779 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 6780 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6781 retry, "retry"); 6782 6783 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 6784 .f = cmd_set_fwd_retry_mode_parsed, 6785 .data = NULL, 6786 .help_str = NULL, /* defined at init */ 6787 .tokens = { 6788 (void *)&cmd_setfwd_retry_set, 6789 (void *)&cmd_setfwd_retry_fwd, 6790 (void *)&cmd_setfwd_retry_mode, 6791 (void *)&cmd_setfwd_retry_retry, 6792 NULL, 6793 }, 6794 }; 6795 6796 static void cmd_set_fwd_retry_mode_init(void) 6797 { 6798 char *modes, *c; 6799 static char token[128]; 6800 static char help[256]; 6801 cmdline_parse_token_string_t *token_struct; 6802 6803 modes = list_pkt_forwarding_retry_modes(); 6804 snprintf(help, sizeof(help), "set fwd %s retry: " 6805 "Set packet forwarding mode with retry", modes); 6806 cmd_set_fwd_retry_mode.help_str = help; 6807 6808 /* string token separator is # */ 6809 for (c = token; *modes != '\0'; modes++) 6810 if (*modes == '|') 6811 *c++ = '#'; 6812 else 6813 *c++ = *modes; 6814 token_struct = (cmdline_parse_token_string_t *) 6815 cmd_set_fwd_retry_mode.tokens[2]; 6816 token_struct->string_data.str = token; 6817 } 6818 6819 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 6820 struct cmd_set_burst_tx_retry_result { 6821 cmdline_fixed_string_t set; 6822 cmdline_fixed_string_t burst; 6823 cmdline_fixed_string_t tx; 6824 cmdline_fixed_string_t delay; 6825 uint32_t time; 6826 cmdline_fixed_string_t retry; 6827 uint32_t retry_num; 6828 }; 6829 6830 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 6831 __rte_unused struct cmdline *cl, 6832 __rte_unused void *data) 6833 { 6834 struct cmd_set_burst_tx_retry_result *res = parsed_result; 6835 6836 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 6837 && !strcmp(res->tx, "tx")) { 6838 if (!strcmp(res->delay, "delay")) 6839 burst_tx_delay_time = res->time; 6840 if (!strcmp(res->retry, "retry")) 6841 burst_tx_retry_num = res->retry_num; 6842 } 6843 6844 } 6845 6846 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 6847 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 6848 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 6849 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 6850 "burst"); 6851 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 6852 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 6853 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 6854 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 6855 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 6856 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, 6857 RTE_UINT32); 6858 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 6859 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 6860 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 6861 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, 6862 RTE_UINT32); 6863 6864 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 6865 .f = cmd_set_burst_tx_retry_parsed, 6866 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 6867 .tokens = { 6868 (void *)&cmd_set_burst_tx_retry_set, 6869 (void *)&cmd_set_burst_tx_retry_burst, 6870 (void *)&cmd_set_burst_tx_retry_tx, 6871 (void *)&cmd_set_burst_tx_retry_delay, 6872 (void *)&cmd_set_burst_tx_retry_time, 6873 (void *)&cmd_set_burst_tx_retry_retry, 6874 (void *)&cmd_set_burst_tx_retry_retry_num, 6875 NULL, 6876 }, 6877 }; 6878 6879 /* *** SET PROMISC MODE *** */ 6880 struct cmd_set_promisc_mode_result { 6881 cmdline_fixed_string_t set; 6882 cmdline_fixed_string_t promisc; 6883 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6884 uint16_t port_num; /* valid if "allports" argument == 0 */ 6885 cmdline_fixed_string_t mode; 6886 }; 6887 6888 static void cmd_set_promisc_mode_parsed(void *parsed_result, 6889 __rte_unused struct cmdline *cl, 6890 void *allports) 6891 { 6892 struct cmd_set_promisc_mode_result *res = parsed_result; 6893 int enable; 6894 portid_t i; 6895 6896 if (!strcmp(res->mode, "on")) 6897 enable = 1; 6898 else 6899 enable = 0; 6900 6901 /* all ports */ 6902 if (allports) { 6903 RTE_ETH_FOREACH_DEV(i) 6904 eth_set_promisc_mode(i, enable); 6905 } else { 6906 eth_set_promisc_mode(res->port_num, enable); 6907 } 6908 } 6909 6910 cmdline_parse_token_string_t cmd_setpromisc_set = 6911 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 6912 cmdline_parse_token_string_t cmd_setpromisc_promisc = 6913 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 6914 "promisc"); 6915 cmdline_parse_token_string_t cmd_setpromisc_portall = 6916 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 6917 "all"); 6918 cmdline_parse_token_num_t cmd_setpromisc_portnum = 6919 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 6920 RTE_UINT16); 6921 cmdline_parse_token_string_t cmd_setpromisc_mode = 6922 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 6923 "on#off"); 6924 6925 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 6926 .f = cmd_set_promisc_mode_parsed, 6927 .data = (void *)1, 6928 .help_str = "set promisc all on|off: Set promisc mode for all ports", 6929 .tokens = { 6930 (void *)&cmd_setpromisc_set, 6931 (void *)&cmd_setpromisc_promisc, 6932 (void *)&cmd_setpromisc_portall, 6933 (void *)&cmd_setpromisc_mode, 6934 NULL, 6935 }, 6936 }; 6937 6938 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 6939 .f = cmd_set_promisc_mode_parsed, 6940 .data = (void *)0, 6941 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 6942 .tokens = { 6943 (void *)&cmd_setpromisc_set, 6944 (void *)&cmd_setpromisc_promisc, 6945 (void *)&cmd_setpromisc_portnum, 6946 (void *)&cmd_setpromisc_mode, 6947 NULL, 6948 }, 6949 }; 6950 6951 /* *** SET ALLMULTI MODE *** */ 6952 struct cmd_set_allmulti_mode_result { 6953 cmdline_fixed_string_t set; 6954 cmdline_fixed_string_t allmulti; 6955 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6956 uint16_t port_num; /* valid if "allports" argument == 0 */ 6957 cmdline_fixed_string_t mode; 6958 }; 6959 6960 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 6961 __rte_unused struct cmdline *cl, 6962 void *allports) 6963 { 6964 struct cmd_set_allmulti_mode_result *res = parsed_result; 6965 int enable; 6966 portid_t i; 6967 6968 if (!strcmp(res->mode, "on")) 6969 enable = 1; 6970 else 6971 enable = 0; 6972 6973 /* all ports */ 6974 if (allports) { 6975 RTE_ETH_FOREACH_DEV(i) { 6976 eth_set_allmulticast_mode(i, enable); 6977 } 6978 } 6979 else { 6980 eth_set_allmulticast_mode(res->port_num, enable); 6981 } 6982 } 6983 6984 cmdline_parse_token_string_t cmd_setallmulti_set = 6985 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 6986 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 6987 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 6988 "allmulti"); 6989 cmdline_parse_token_string_t cmd_setallmulti_portall = 6990 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 6991 "all"); 6992 cmdline_parse_token_num_t cmd_setallmulti_portnum = 6993 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 6994 RTE_UINT16); 6995 cmdline_parse_token_string_t cmd_setallmulti_mode = 6996 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 6997 "on#off"); 6998 6999 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 7000 .f = cmd_set_allmulti_mode_parsed, 7001 .data = (void *)1, 7002 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 7003 .tokens = { 7004 (void *)&cmd_setallmulti_set, 7005 (void *)&cmd_setallmulti_allmulti, 7006 (void *)&cmd_setallmulti_portall, 7007 (void *)&cmd_setallmulti_mode, 7008 NULL, 7009 }, 7010 }; 7011 7012 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 7013 .f = cmd_set_allmulti_mode_parsed, 7014 .data = (void *)0, 7015 .help_str = "set allmulti <port_id> on|off: " 7016 "Set allmulti mode on port_id", 7017 .tokens = { 7018 (void *)&cmd_setallmulti_set, 7019 (void *)&cmd_setallmulti_allmulti, 7020 (void *)&cmd_setallmulti_portnum, 7021 (void *)&cmd_setallmulti_mode, 7022 NULL, 7023 }, 7024 }; 7025 7026 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */ 7027 struct cmd_link_flow_ctrl_show { 7028 cmdline_fixed_string_t show; 7029 cmdline_fixed_string_t port; 7030 portid_t port_id; 7031 cmdline_fixed_string_t flow_ctrl; 7032 }; 7033 7034 cmdline_parse_token_string_t cmd_lfc_show_show = 7035 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, 7036 show, "show"); 7037 cmdline_parse_token_string_t cmd_lfc_show_port = 7038 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, 7039 port, "port"); 7040 cmdline_parse_token_num_t cmd_lfc_show_portid = 7041 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show, 7042 port_id, RTE_UINT16); 7043 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl = 7044 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, 7045 flow_ctrl, "flow_ctrl"); 7046 7047 static void 7048 cmd_link_flow_ctrl_show_parsed(void *parsed_result, 7049 __rte_unused struct cmdline *cl, 7050 __rte_unused void *data) 7051 { 7052 struct cmd_link_flow_ctrl_show *res = parsed_result; 7053 static const char *info_border = "*********************"; 7054 struct rte_eth_fc_conf fc_conf; 7055 bool rx_fc_en = false; 7056 bool tx_fc_en = false; 7057 int ret; 7058 7059 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 7060 if (ret != 0) { 7061 fprintf(stderr, 7062 "Failed to get current flow ctrl information: err = %d\n", 7063 ret); 7064 return; 7065 } 7066 7067 if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL) 7068 rx_fc_en = true; 7069 if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL) 7070 tx_fc_en = true; 7071 7072 printf("\n%s Flow control infos for port %-2d %s\n", 7073 info_border, res->port_id, info_border); 7074 printf("FC mode:\n"); 7075 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off"); 7076 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off"); 7077 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off"); 7078 printf("Pause time: 0x%x\n", fc_conf.pause_time); 7079 printf("High waterline: 0x%x\n", fc_conf.high_water); 7080 printf("Low waterline: 0x%x\n", fc_conf.low_water); 7081 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off"); 7082 printf("Forward MAC control frames: %s\n", 7083 fc_conf.mac_ctrl_frame_fwd ? "on" : "off"); 7084 printf("\n%s************** End ***********%s\n", 7085 info_border, info_border); 7086 } 7087 7088 cmdline_parse_inst_t cmd_link_flow_control_show = { 7089 .f = cmd_link_flow_ctrl_show_parsed, 7090 .data = NULL, 7091 .help_str = "show port <port_id> flow_ctrl", 7092 .tokens = { 7093 (void *)&cmd_lfc_show_show, 7094 (void *)&cmd_lfc_show_port, 7095 (void *)&cmd_lfc_show_portid, 7096 (void *)&cmd_lfc_show_flow_ctrl, 7097 NULL, 7098 }, 7099 }; 7100 7101 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 7102 struct cmd_link_flow_ctrl_set_result { 7103 cmdline_fixed_string_t set; 7104 cmdline_fixed_string_t flow_ctrl; 7105 cmdline_fixed_string_t rx; 7106 cmdline_fixed_string_t rx_lfc_mode; 7107 cmdline_fixed_string_t tx; 7108 cmdline_fixed_string_t tx_lfc_mode; 7109 cmdline_fixed_string_t mac_ctrl_frame_fwd; 7110 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 7111 cmdline_fixed_string_t autoneg_str; 7112 cmdline_fixed_string_t autoneg; 7113 cmdline_fixed_string_t hw_str; 7114 uint32_t high_water; 7115 cmdline_fixed_string_t lw_str; 7116 uint32_t low_water; 7117 cmdline_fixed_string_t pt_str; 7118 uint16_t pause_time; 7119 cmdline_fixed_string_t xon_str; 7120 uint16_t send_xon; 7121 portid_t port_id; 7122 }; 7123 7124 cmdline_parse_token_string_t cmd_lfc_set_set = 7125 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7126 set, "set"); 7127 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 7128 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7129 flow_ctrl, "flow_ctrl"); 7130 cmdline_parse_token_string_t cmd_lfc_set_rx = 7131 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7132 rx, "rx"); 7133 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 7134 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7135 rx_lfc_mode, "on#off"); 7136 cmdline_parse_token_string_t cmd_lfc_set_tx = 7137 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7138 tx, "tx"); 7139 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 7140 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7141 tx_lfc_mode, "on#off"); 7142 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 7143 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7144 hw_str, "high_water"); 7145 cmdline_parse_token_num_t cmd_lfc_set_high_water = 7146 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7147 high_water, RTE_UINT32); 7148 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 7149 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7150 lw_str, "low_water"); 7151 cmdline_parse_token_num_t cmd_lfc_set_low_water = 7152 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7153 low_water, RTE_UINT32); 7154 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 7155 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7156 pt_str, "pause_time"); 7157 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 7158 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7159 pause_time, RTE_UINT16); 7160 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 7161 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7162 xon_str, "send_xon"); 7163 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 7164 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7165 send_xon, RTE_UINT16); 7166 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 7167 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7168 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 7169 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 7170 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7171 mac_ctrl_frame_fwd_mode, "on#off"); 7172 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 7173 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7174 autoneg_str, "autoneg"); 7175 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 7176 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7177 autoneg, "on#off"); 7178 cmdline_parse_token_num_t cmd_lfc_set_portid = 7179 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7180 port_id, RTE_UINT16); 7181 7182 /* forward declaration */ 7183 static void 7184 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 7185 void *data); 7186 7187 cmdline_parse_inst_t cmd_link_flow_control_set = { 7188 .f = cmd_link_flow_ctrl_set_parsed, 7189 .data = NULL, 7190 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 7191 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 7192 "autoneg on|off <port_id>: Configure the Ethernet flow control", 7193 .tokens = { 7194 (void *)&cmd_lfc_set_set, 7195 (void *)&cmd_lfc_set_flow_ctrl, 7196 (void *)&cmd_lfc_set_rx, 7197 (void *)&cmd_lfc_set_rx_mode, 7198 (void *)&cmd_lfc_set_tx, 7199 (void *)&cmd_lfc_set_tx_mode, 7200 (void *)&cmd_lfc_set_high_water, 7201 (void *)&cmd_lfc_set_low_water, 7202 (void *)&cmd_lfc_set_pause_time, 7203 (void *)&cmd_lfc_set_send_xon, 7204 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 7205 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 7206 (void *)&cmd_lfc_set_autoneg_str, 7207 (void *)&cmd_lfc_set_autoneg, 7208 (void *)&cmd_lfc_set_portid, 7209 NULL, 7210 }, 7211 }; 7212 7213 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 7214 .f = cmd_link_flow_ctrl_set_parsed, 7215 .data = (void *)&cmd_link_flow_control_set_rx, 7216 .help_str = "set flow_ctrl rx on|off <port_id>: " 7217 "Change rx flow control parameter", 7218 .tokens = { 7219 (void *)&cmd_lfc_set_set, 7220 (void *)&cmd_lfc_set_flow_ctrl, 7221 (void *)&cmd_lfc_set_rx, 7222 (void *)&cmd_lfc_set_rx_mode, 7223 (void *)&cmd_lfc_set_portid, 7224 NULL, 7225 }, 7226 }; 7227 7228 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 7229 .f = cmd_link_flow_ctrl_set_parsed, 7230 .data = (void *)&cmd_link_flow_control_set_tx, 7231 .help_str = "set flow_ctrl tx on|off <port_id>: " 7232 "Change tx flow control parameter", 7233 .tokens = { 7234 (void *)&cmd_lfc_set_set, 7235 (void *)&cmd_lfc_set_flow_ctrl, 7236 (void *)&cmd_lfc_set_tx, 7237 (void *)&cmd_lfc_set_tx_mode, 7238 (void *)&cmd_lfc_set_portid, 7239 NULL, 7240 }, 7241 }; 7242 7243 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 7244 .f = cmd_link_flow_ctrl_set_parsed, 7245 .data = (void *)&cmd_link_flow_control_set_hw, 7246 .help_str = "set flow_ctrl high_water <value> <port_id>: " 7247 "Change high water flow control parameter", 7248 .tokens = { 7249 (void *)&cmd_lfc_set_set, 7250 (void *)&cmd_lfc_set_flow_ctrl, 7251 (void *)&cmd_lfc_set_high_water_str, 7252 (void *)&cmd_lfc_set_high_water, 7253 (void *)&cmd_lfc_set_portid, 7254 NULL, 7255 }, 7256 }; 7257 7258 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 7259 .f = cmd_link_flow_ctrl_set_parsed, 7260 .data = (void *)&cmd_link_flow_control_set_lw, 7261 .help_str = "set flow_ctrl low_water <value> <port_id>: " 7262 "Change low water flow control parameter", 7263 .tokens = { 7264 (void *)&cmd_lfc_set_set, 7265 (void *)&cmd_lfc_set_flow_ctrl, 7266 (void *)&cmd_lfc_set_low_water_str, 7267 (void *)&cmd_lfc_set_low_water, 7268 (void *)&cmd_lfc_set_portid, 7269 NULL, 7270 }, 7271 }; 7272 7273 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 7274 .f = cmd_link_flow_ctrl_set_parsed, 7275 .data = (void *)&cmd_link_flow_control_set_pt, 7276 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 7277 "Change pause time flow control parameter", 7278 .tokens = { 7279 (void *)&cmd_lfc_set_set, 7280 (void *)&cmd_lfc_set_flow_ctrl, 7281 (void *)&cmd_lfc_set_pause_time_str, 7282 (void *)&cmd_lfc_set_pause_time, 7283 (void *)&cmd_lfc_set_portid, 7284 NULL, 7285 }, 7286 }; 7287 7288 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 7289 .f = cmd_link_flow_ctrl_set_parsed, 7290 .data = (void *)&cmd_link_flow_control_set_xon, 7291 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 7292 "Change send_xon flow control parameter", 7293 .tokens = { 7294 (void *)&cmd_lfc_set_set, 7295 (void *)&cmd_lfc_set_flow_ctrl, 7296 (void *)&cmd_lfc_set_send_xon_str, 7297 (void *)&cmd_lfc_set_send_xon, 7298 (void *)&cmd_lfc_set_portid, 7299 NULL, 7300 }, 7301 }; 7302 7303 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 7304 .f = cmd_link_flow_ctrl_set_parsed, 7305 .data = (void *)&cmd_link_flow_control_set_macfwd, 7306 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 7307 "Change mac ctrl fwd flow control parameter", 7308 .tokens = { 7309 (void *)&cmd_lfc_set_set, 7310 (void *)&cmd_lfc_set_flow_ctrl, 7311 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 7312 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 7313 (void *)&cmd_lfc_set_portid, 7314 NULL, 7315 }, 7316 }; 7317 7318 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 7319 .f = cmd_link_flow_ctrl_set_parsed, 7320 .data = (void *)&cmd_link_flow_control_set_autoneg, 7321 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 7322 "Change autoneg flow control parameter", 7323 .tokens = { 7324 (void *)&cmd_lfc_set_set, 7325 (void *)&cmd_lfc_set_flow_ctrl, 7326 (void *)&cmd_lfc_set_autoneg_str, 7327 (void *)&cmd_lfc_set_autoneg, 7328 (void *)&cmd_lfc_set_portid, 7329 NULL, 7330 }, 7331 }; 7332 7333 static void 7334 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 7335 __rte_unused struct cmdline *cl, 7336 void *data) 7337 { 7338 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 7339 cmdline_parse_inst_t *cmd = data; 7340 struct rte_eth_fc_conf fc_conf; 7341 int rx_fc_en = 0; 7342 int tx_fc_en = 0; 7343 int ret; 7344 7345 /* 7346 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 7347 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 7348 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 7349 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 7350 */ 7351 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 7352 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 7353 }; 7354 7355 /* Partial command line, retrieve current configuration */ 7356 if (cmd) { 7357 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 7358 if (ret != 0) { 7359 fprintf(stderr, 7360 "cannot get current flow ctrl parameters, return code = %d\n", 7361 ret); 7362 return; 7363 } 7364 7365 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 7366 (fc_conf.mode == RTE_FC_FULL)) 7367 rx_fc_en = 1; 7368 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 7369 (fc_conf.mode == RTE_FC_FULL)) 7370 tx_fc_en = 1; 7371 } 7372 7373 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 7374 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 7375 7376 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 7377 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 7378 7379 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 7380 7381 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 7382 fc_conf.high_water = res->high_water; 7383 7384 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 7385 fc_conf.low_water = res->low_water; 7386 7387 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 7388 fc_conf.pause_time = res->pause_time; 7389 7390 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 7391 fc_conf.send_xon = res->send_xon; 7392 7393 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 7394 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 7395 fc_conf.mac_ctrl_frame_fwd = 1; 7396 else 7397 fc_conf.mac_ctrl_frame_fwd = 0; 7398 } 7399 7400 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 7401 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 7402 7403 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 7404 if (ret != 0) 7405 fprintf(stderr, 7406 "bad flow control parameter, return code = %d\n", 7407 ret); 7408 } 7409 7410 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 7411 struct cmd_priority_flow_ctrl_set_result { 7412 cmdline_fixed_string_t set; 7413 cmdline_fixed_string_t pfc_ctrl; 7414 cmdline_fixed_string_t rx; 7415 cmdline_fixed_string_t rx_pfc_mode; 7416 cmdline_fixed_string_t tx; 7417 cmdline_fixed_string_t tx_pfc_mode; 7418 uint32_t high_water; 7419 uint32_t low_water; 7420 uint16_t pause_time; 7421 uint8_t priority; 7422 portid_t port_id; 7423 }; 7424 7425 static void 7426 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 7427 __rte_unused struct cmdline *cl, 7428 __rte_unused void *data) 7429 { 7430 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 7431 struct rte_eth_pfc_conf pfc_conf; 7432 int rx_fc_enable, tx_fc_enable; 7433 int ret; 7434 7435 /* 7436 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 7437 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 7438 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 7439 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 7440 */ 7441 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 7442 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 7443 }; 7444 7445 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf)); 7446 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 7447 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 7448 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 7449 pfc_conf.fc.high_water = res->high_water; 7450 pfc_conf.fc.low_water = res->low_water; 7451 pfc_conf.fc.pause_time = res->pause_time; 7452 pfc_conf.priority = res->priority; 7453 7454 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 7455 if (ret != 0) 7456 fprintf(stderr, 7457 "bad priority flow control parameter, return code = %d\n", 7458 ret); 7459 } 7460 7461 cmdline_parse_token_string_t cmd_pfc_set_set = 7462 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7463 set, "set"); 7464 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 7465 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7466 pfc_ctrl, "pfc_ctrl"); 7467 cmdline_parse_token_string_t cmd_pfc_set_rx = 7468 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7469 rx, "rx"); 7470 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 7471 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7472 rx_pfc_mode, "on#off"); 7473 cmdline_parse_token_string_t cmd_pfc_set_tx = 7474 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7475 tx, "tx"); 7476 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 7477 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7478 tx_pfc_mode, "on#off"); 7479 cmdline_parse_token_num_t cmd_pfc_set_high_water = 7480 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7481 high_water, RTE_UINT32); 7482 cmdline_parse_token_num_t cmd_pfc_set_low_water = 7483 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7484 low_water, RTE_UINT32); 7485 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 7486 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7487 pause_time, RTE_UINT16); 7488 cmdline_parse_token_num_t cmd_pfc_set_priority = 7489 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7490 priority, RTE_UINT8); 7491 cmdline_parse_token_num_t cmd_pfc_set_portid = 7492 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7493 port_id, RTE_UINT16); 7494 7495 cmdline_parse_inst_t cmd_priority_flow_control_set = { 7496 .f = cmd_priority_flow_ctrl_set_parsed, 7497 .data = NULL, 7498 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 7499 "<pause_time> <priority> <port_id>: " 7500 "Configure the Ethernet priority flow control", 7501 .tokens = { 7502 (void *)&cmd_pfc_set_set, 7503 (void *)&cmd_pfc_set_flow_ctrl, 7504 (void *)&cmd_pfc_set_rx, 7505 (void *)&cmd_pfc_set_rx_mode, 7506 (void *)&cmd_pfc_set_tx, 7507 (void *)&cmd_pfc_set_tx_mode, 7508 (void *)&cmd_pfc_set_high_water, 7509 (void *)&cmd_pfc_set_low_water, 7510 (void *)&cmd_pfc_set_pause_time, 7511 (void *)&cmd_pfc_set_priority, 7512 (void *)&cmd_pfc_set_portid, 7513 NULL, 7514 }, 7515 }; 7516 7517 /* *** RESET CONFIGURATION *** */ 7518 struct cmd_reset_result { 7519 cmdline_fixed_string_t reset; 7520 cmdline_fixed_string_t def; 7521 }; 7522 7523 static void cmd_reset_parsed(__rte_unused void *parsed_result, 7524 struct cmdline *cl, 7525 __rte_unused void *data) 7526 { 7527 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 7528 set_def_fwd_config(); 7529 } 7530 7531 cmdline_parse_token_string_t cmd_reset_set = 7532 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 7533 cmdline_parse_token_string_t cmd_reset_def = 7534 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 7535 "default"); 7536 7537 cmdline_parse_inst_t cmd_reset = { 7538 .f = cmd_reset_parsed, 7539 .data = NULL, 7540 .help_str = "set default: Reset default forwarding configuration", 7541 .tokens = { 7542 (void *)&cmd_reset_set, 7543 (void *)&cmd_reset_def, 7544 NULL, 7545 }, 7546 }; 7547 7548 /* *** START FORWARDING *** */ 7549 struct cmd_start_result { 7550 cmdline_fixed_string_t start; 7551 }; 7552 7553 cmdline_parse_token_string_t cmd_start_start = 7554 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 7555 7556 static void cmd_start_parsed(__rte_unused void *parsed_result, 7557 __rte_unused struct cmdline *cl, 7558 __rte_unused void *data) 7559 { 7560 start_packet_forwarding(0); 7561 } 7562 7563 cmdline_parse_inst_t cmd_start = { 7564 .f = cmd_start_parsed, 7565 .data = NULL, 7566 .help_str = "start: Start packet forwarding", 7567 .tokens = { 7568 (void *)&cmd_start_start, 7569 NULL, 7570 }, 7571 }; 7572 7573 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 7574 struct cmd_start_tx_first_result { 7575 cmdline_fixed_string_t start; 7576 cmdline_fixed_string_t tx_first; 7577 }; 7578 7579 static void 7580 cmd_start_tx_first_parsed(__rte_unused void *parsed_result, 7581 __rte_unused struct cmdline *cl, 7582 __rte_unused void *data) 7583 { 7584 start_packet_forwarding(1); 7585 } 7586 7587 cmdline_parse_token_string_t cmd_start_tx_first_start = 7588 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 7589 "start"); 7590 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 7591 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 7592 tx_first, "tx_first"); 7593 7594 cmdline_parse_inst_t cmd_start_tx_first = { 7595 .f = cmd_start_tx_first_parsed, 7596 .data = NULL, 7597 .help_str = "start tx_first: Start packet forwarding, " 7598 "after sending 1 burst of packets", 7599 .tokens = { 7600 (void *)&cmd_start_tx_first_start, 7601 (void *)&cmd_start_tx_first_tx_first, 7602 NULL, 7603 }, 7604 }; 7605 7606 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 7607 struct cmd_start_tx_first_n_result { 7608 cmdline_fixed_string_t start; 7609 cmdline_fixed_string_t tx_first; 7610 uint32_t tx_num; 7611 }; 7612 7613 static void 7614 cmd_start_tx_first_n_parsed(void *parsed_result, 7615 __rte_unused struct cmdline *cl, 7616 __rte_unused void *data) 7617 { 7618 struct cmd_start_tx_first_n_result *res = parsed_result; 7619 7620 start_packet_forwarding(res->tx_num); 7621 } 7622 7623 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 7624 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7625 start, "start"); 7626 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 7627 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7628 tx_first, "tx_first"); 7629 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 7630 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 7631 tx_num, RTE_UINT32); 7632 7633 cmdline_parse_inst_t cmd_start_tx_first_n = { 7634 .f = cmd_start_tx_first_n_parsed, 7635 .data = NULL, 7636 .help_str = "start tx_first <num>: " 7637 "packet forwarding, after sending <num> bursts of packets", 7638 .tokens = { 7639 (void *)&cmd_start_tx_first_n_start, 7640 (void *)&cmd_start_tx_first_n_tx_first, 7641 (void *)&cmd_start_tx_first_n_tx_num, 7642 NULL, 7643 }, 7644 }; 7645 7646 /* *** SET LINK UP *** */ 7647 struct cmd_set_link_up_result { 7648 cmdline_fixed_string_t set; 7649 cmdline_fixed_string_t link_up; 7650 cmdline_fixed_string_t port; 7651 portid_t port_id; 7652 }; 7653 7654 cmdline_parse_token_string_t cmd_set_link_up_set = 7655 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 7656 cmdline_parse_token_string_t cmd_set_link_up_link_up = 7657 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 7658 "link-up"); 7659 cmdline_parse_token_string_t cmd_set_link_up_port = 7660 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 7661 cmdline_parse_token_num_t cmd_set_link_up_port_id = 7662 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, 7663 RTE_UINT16); 7664 7665 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result, 7666 __rte_unused struct cmdline *cl, 7667 __rte_unused void *data) 7668 { 7669 struct cmd_set_link_up_result *res = parsed_result; 7670 dev_set_link_up(res->port_id); 7671 } 7672 7673 cmdline_parse_inst_t cmd_set_link_up = { 7674 .f = cmd_set_link_up_parsed, 7675 .data = NULL, 7676 .help_str = "set link-up port <port id>", 7677 .tokens = { 7678 (void *)&cmd_set_link_up_set, 7679 (void *)&cmd_set_link_up_link_up, 7680 (void *)&cmd_set_link_up_port, 7681 (void *)&cmd_set_link_up_port_id, 7682 NULL, 7683 }, 7684 }; 7685 7686 /* *** SET LINK DOWN *** */ 7687 struct cmd_set_link_down_result { 7688 cmdline_fixed_string_t set; 7689 cmdline_fixed_string_t link_down; 7690 cmdline_fixed_string_t port; 7691 portid_t port_id; 7692 }; 7693 7694 cmdline_parse_token_string_t cmd_set_link_down_set = 7695 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 7696 cmdline_parse_token_string_t cmd_set_link_down_link_down = 7697 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 7698 "link-down"); 7699 cmdline_parse_token_string_t cmd_set_link_down_port = 7700 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 7701 cmdline_parse_token_num_t cmd_set_link_down_port_id = 7702 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, 7703 RTE_UINT16); 7704 7705 static void cmd_set_link_down_parsed( 7706 __rte_unused void *parsed_result, 7707 __rte_unused struct cmdline *cl, 7708 __rte_unused void *data) 7709 { 7710 struct cmd_set_link_down_result *res = parsed_result; 7711 dev_set_link_down(res->port_id); 7712 } 7713 7714 cmdline_parse_inst_t cmd_set_link_down = { 7715 .f = cmd_set_link_down_parsed, 7716 .data = NULL, 7717 .help_str = "set link-down port <port id>", 7718 .tokens = { 7719 (void *)&cmd_set_link_down_set, 7720 (void *)&cmd_set_link_down_link_down, 7721 (void *)&cmd_set_link_down_port, 7722 (void *)&cmd_set_link_down_port_id, 7723 NULL, 7724 }, 7725 }; 7726 7727 /* *** SHOW CFG *** */ 7728 struct cmd_showcfg_result { 7729 cmdline_fixed_string_t show; 7730 cmdline_fixed_string_t cfg; 7731 cmdline_fixed_string_t what; 7732 }; 7733 7734 static void cmd_showcfg_parsed(void *parsed_result, 7735 __rte_unused struct cmdline *cl, 7736 __rte_unused void *data) 7737 { 7738 struct cmd_showcfg_result *res = parsed_result; 7739 if (!strcmp(res->what, "rxtx")) 7740 rxtx_config_display(); 7741 else if (!strcmp(res->what, "cores")) 7742 fwd_lcores_config_display(); 7743 else if (!strcmp(res->what, "fwd")) 7744 pkt_fwd_config_display(&cur_fwd_config); 7745 else if (!strcmp(res->what, "rxoffs")) 7746 show_rx_pkt_offsets(); 7747 else if (!strcmp(res->what, "rxpkts")) 7748 show_rx_pkt_segments(); 7749 else if (!strcmp(res->what, "txpkts")) 7750 show_tx_pkt_segments(); 7751 else if (!strcmp(res->what, "txtimes")) 7752 show_tx_pkt_times(); 7753 } 7754 7755 cmdline_parse_token_string_t cmd_showcfg_show = 7756 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 7757 cmdline_parse_token_string_t cmd_showcfg_port = 7758 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7759 cmdline_parse_token_string_t cmd_showcfg_what = 7760 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7761 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes"); 7762 7763 cmdline_parse_inst_t cmd_showcfg = { 7764 .f = cmd_showcfg_parsed, 7765 .data = NULL, 7766 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes", 7767 .tokens = { 7768 (void *)&cmd_showcfg_show, 7769 (void *)&cmd_showcfg_port, 7770 (void *)&cmd_showcfg_what, 7771 NULL, 7772 }, 7773 }; 7774 7775 /* *** SHOW ALL PORT INFO *** */ 7776 struct cmd_showportall_result { 7777 cmdline_fixed_string_t show; 7778 cmdline_fixed_string_t port; 7779 cmdline_fixed_string_t what; 7780 cmdline_fixed_string_t all; 7781 }; 7782 7783 static void cmd_showportall_parsed(void *parsed_result, 7784 __rte_unused struct cmdline *cl, 7785 __rte_unused void *data) 7786 { 7787 portid_t i; 7788 7789 struct cmd_showportall_result *res = parsed_result; 7790 if (!strcmp(res->show, "clear")) { 7791 if (!strcmp(res->what, "stats")) 7792 RTE_ETH_FOREACH_DEV(i) 7793 nic_stats_clear(i); 7794 else if (!strcmp(res->what, "xstats")) 7795 RTE_ETH_FOREACH_DEV(i) 7796 nic_xstats_clear(i); 7797 } else if (!strcmp(res->what, "info")) 7798 RTE_ETH_FOREACH_DEV(i) 7799 port_infos_display(i); 7800 else if (!strcmp(res->what, "summary")) { 7801 port_summary_header_display(); 7802 RTE_ETH_FOREACH_DEV(i) 7803 port_summary_display(i); 7804 } 7805 else if (!strcmp(res->what, "stats")) 7806 RTE_ETH_FOREACH_DEV(i) 7807 nic_stats_display(i); 7808 else if (!strcmp(res->what, "xstats")) 7809 RTE_ETH_FOREACH_DEV(i) 7810 nic_xstats_display(i); 7811 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) 7812 else if (!strcmp(res->what, "fdir")) 7813 RTE_ETH_FOREACH_DEV(i) 7814 fdir_get_infos(i); 7815 #endif 7816 else if (!strcmp(res->what, "dcb_tc")) 7817 RTE_ETH_FOREACH_DEV(i) 7818 port_dcb_info_display(i); 7819 } 7820 7821 cmdline_parse_token_string_t cmd_showportall_show = 7822 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7823 "show#clear"); 7824 cmdline_parse_token_string_t cmd_showportall_port = 7825 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7826 cmdline_parse_token_string_t cmd_showportall_what = 7827 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7828 "info#summary#stats#xstats#fdir#dcb_tc"); 7829 cmdline_parse_token_string_t cmd_showportall_all = 7830 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 7831 cmdline_parse_inst_t cmd_showportall = { 7832 .f = cmd_showportall_parsed, 7833 .data = NULL, 7834 .help_str = "show|clear port " 7835 "info|summary|stats|xstats|fdir|dcb_tc all", 7836 .tokens = { 7837 (void *)&cmd_showportall_show, 7838 (void *)&cmd_showportall_port, 7839 (void *)&cmd_showportall_what, 7840 (void *)&cmd_showportall_all, 7841 NULL, 7842 }, 7843 }; 7844 7845 /* *** SHOW PORT INFO *** */ 7846 struct cmd_showport_result { 7847 cmdline_fixed_string_t show; 7848 cmdline_fixed_string_t port; 7849 cmdline_fixed_string_t what; 7850 uint16_t portnum; 7851 }; 7852 7853 static void cmd_showport_parsed(void *parsed_result, 7854 __rte_unused struct cmdline *cl, 7855 __rte_unused void *data) 7856 { 7857 struct cmd_showport_result *res = parsed_result; 7858 if (!strcmp(res->show, "clear")) { 7859 if (!strcmp(res->what, "stats")) 7860 nic_stats_clear(res->portnum); 7861 else if (!strcmp(res->what, "xstats")) 7862 nic_xstats_clear(res->portnum); 7863 } else if (!strcmp(res->what, "info")) 7864 port_infos_display(res->portnum); 7865 else if (!strcmp(res->what, "summary")) { 7866 port_summary_header_display(); 7867 port_summary_display(res->portnum); 7868 } 7869 else if (!strcmp(res->what, "stats")) 7870 nic_stats_display(res->portnum); 7871 else if (!strcmp(res->what, "xstats")) 7872 nic_xstats_display(res->portnum); 7873 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) 7874 else if (!strcmp(res->what, "fdir")) 7875 fdir_get_infos(res->portnum); 7876 #endif 7877 else if (!strcmp(res->what, "dcb_tc")) 7878 port_dcb_info_display(res->portnum); 7879 } 7880 7881 cmdline_parse_token_string_t cmd_showport_show = 7882 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 7883 "show#clear"); 7884 cmdline_parse_token_string_t cmd_showport_port = 7885 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 7886 cmdline_parse_token_string_t cmd_showport_what = 7887 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 7888 "info#summary#stats#xstats#fdir#dcb_tc"); 7889 cmdline_parse_token_num_t cmd_showport_portnum = 7890 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16); 7891 7892 cmdline_parse_inst_t cmd_showport = { 7893 .f = cmd_showport_parsed, 7894 .data = NULL, 7895 .help_str = "show|clear port " 7896 "info|summary|stats|xstats|fdir|dcb_tc " 7897 "<port_id>", 7898 .tokens = { 7899 (void *)&cmd_showport_show, 7900 (void *)&cmd_showport_port, 7901 (void *)&cmd_showport_what, 7902 (void *)&cmd_showport_portnum, 7903 NULL, 7904 }, 7905 }; 7906 7907 /* *** SHOW DEVICE INFO *** */ 7908 struct cmd_showdevice_result { 7909 cmdline_fixed_string_t show; 7910 cmdline_fixed_string_t device; 7911 cmdline_fixed_string_t what; 7912 cmdline_fixed_string_t identifier; 7913 }; 7914 7915 static void cmd_showdevice_parsed(void *parsed_result, 7916 __rte_unused struct cmdline *cl, 7917 __rte_unused void *data) 7918 { 7919 struct cmd_showdevice_result *res = parsed_result; 7920 if (!strcmp(res->what, "info")) { 7921 if (!strcmp(res->identifier, "all")) 7922 device_infos_display(NULL); 7923 else 7924 device_infos_display(res->identifier); 7925 } 7926 } 7927 7928 cmdline_parse_token_string_t cmd_showdevice_show = 7929 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show, 7930 "show"); 7931 cmdline_parse_token_string_t cmd_showdevice_device = 7932 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device"); 7933 cmdline_parse_token_string_t cmd_showdevice_what = 7934 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what, 7935 "info"); 7936 cmdline_parse_token_string_t cmd_showdevice_identifier = 7937 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, 7938 identifier, NULL); 7939 7940 cmdline_parse_inst_t cmd_showdevice = { 7941 .f = cmd_showdevice_parsed, 7942 .data = NULL, 7943 .help_str = "show device info <identifier>|all", 7944 .tokens = { 7945 (void *)&cmd_showdevice_show, 7946 (void *)&cmd_showdevice_device, 7947 (void *)&cmd_showdevice_what, 7948 (void *)&cmd_showdevice_identifier, 7949 NULL, 7950 }, 7951 }; 7952 7953 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */ 7954 struct cmd_showeeprom_result { 7955 cmdline_fixed_string_t show; 7956 cmdline_fixed_string_t port; 7957 uint16_t portnum; 7958 cmdline_fixed_string_t type; 7959 }; 7960 7961 static void cmd_showeeprom_parsed(void *parsed_result, 7962 __rte_unused struct cmdline *cl, 7963 __rte_unused void *data) 7964 { 7965 struct cmd_showeeprom_result *res = parsed_result; 7966 7967 if (!strcmp(res->type, "eeprom")) 7968 port_eeprom_display(res->portnum); 7969 else if (!strcmp(res->type, "module_eeprom")) 7970 port_module_eeprom_display(res->portnum); 7971 else 7972 fprintf(stderr, "Unknown argument\n"); 7973 } 7974 7975 cmdline_parse_token_string_t cmd_showeeprom_show = 7976 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show"); 7977 cmdline_parse_token_string_t cmd_showeeprom_port = 7978 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port"); 7979 cmdline_parse_token_num_t cmd_showeeprom_portnum = 7980 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, 7981 RTE_UINT16); 7982 cmdline_parse_token_string_t cmd_showeeprom_type = 7983 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom"); 7984 7985 cmdline_parse_inst_t cmd_showeeprom = { 7986 .f = cmd_showeeprom_parsed, 7987 .data = NULL, 7988 .help_str = "show port <port_id> module_eeprom|eeprom", 7989 .tokens = { 7990 (void *)&cmd_showeeprom_show, 7991 (void *)&cmd_showeeprom_port, 7992 (void *)&cmd_showeeprom_portnum, 7993 (void *)&cmd_showeeprom_type, 7994 NULL, 7995 }, 7996 }; 7997 7998 /* *** SHOW QUEUE INFO *** */ 7999 struct cmd_showqueue_result { 8000 cmdline_fixed_string_t show; 8001 cmdline_fixed_string_t type; 8002 cmdline_fixed_string_t what; 8003 uint16_t portnum; 8004 uint16_t queuenum; 8005 }; 8006 8007 static void 8008 cmd_showqueue_parsed(void *parsed_result, 8009 __rte_unused struct cmdline *cl, 8010 __rte_unused void *data) 8011 { 8012 struct cmd_showqueue_result *res = parsed_result; 8013 8014 if (!strcmp(res->type, "rxq")) 8015 rx_queue_infos_display(res->portnum, res->queuenum); 8016 else if (!strcmp(res->type, "txq")) 8017 tx_queue_infos_display(res->portnum, res->queuenum); 8018 } 8019 8020 cmdline_parse_token_string_t cmd_showqueue_show = 8021 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 8022 cmdline_parse_token_string_t cmd_showqueue_type = 8023 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 8024 cmdline_parse_token_string_t cmd_showqueue_what = 8025 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 8026 cmdline_parse_token_num_t cmd_showqueue_portnum = 8027 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, 8028 RTE_UINT16); 8029 cmdline_parse_token_num_t cmd_showqueue_queuenum = 8030 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, 8031 RTE_UINT16); 8032 8033 cmdline_parse_inst_t cmd_showqueue = { 8034 .f = cmd_showqueue_parsed, 8035 .data = NULL, 8036 .help_str = "show rxq|txq info <port_id> <queue_id>", 8037 .tokens = { 8038 (void *)&cmd_showqueue_show, 8039 (void *)&cmd_showqueue_type, 8040 (void *)&cmd_showqueue_what, 8041 (void *)&cmd_showqueue_portnum, 8042 (void *)&cmd_showqueue_queuenum, 8043 NULL, 8044 }, 8045 }; 8046 8047 /* show/clear fwd engine statistics */ 8048 struct fwd_result { 8049 cmdline_fixed_string_t action; 8050 cmdline_fixed_string_t fwd; 8051 cmdline_fixed_string_t stats; 8052 cmdline_fixed_string_t all; 8053 }; 8054 8055 cmdline_parse_token_string_t cmd_fwd_action = 8056 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear"); 8057 cmdline_parse_token_string_t cmd_fwd_fwd = 8058 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd"); 8059 cmdline_parse_token_string_t cmd_fwd_stats = 8060 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats"); 8061 cmdline_parse_token_string_t cmd_fwd_all = 8062 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all"); 8063 8064 static void 8065 cmd_showfwdall_parsed(void *parsed_result, 8066 __rte_unused struct cmdline *cl, 8067 __rte_unused void *data) 8068 { 8069 struct fwd_result *res = parsed_result; 8070 8071 if (!strcmp(res->action, "show")) 8072 fwd_stats_display(); 8073 else 8074 fwd_stats_reset(); 8075 } 8076 8077 static cmdline_parse_inst_t cmd_showfwdall = { 8078 .f = cmd_showfwdall_parsed, 8079 .data = NULL, 8080 .help_str = "show|clear fwd stats all", 8081 .tokens = { 8082 (void *)&cmd_fwd_action, 8083 (void *)&cmd_fwd_fwd, 8084 (void *)&cmd_fwd_stats, 8085 (void *)&cmd_fwd_all, 8086 NULL, 8087 }, 8088 }; 8089 8090 /* *** READ PORT REGISTER *** */ 8091 struct cmd_read_reg_result { 8092 cmdline_fixed_string_t read; 8093 cmdline_fixed_string_t reg; 8094 portid_t port_id; 8095 uint32_t reg_off; 8096 }; 8097 8098 static void 8099 cmd_read_reg_parsed(void *parsed_result, 8100 __rte_unused struct cmdline *cl, 8101 __rte_unused void *data) 8102 { 8103 struct cmd_read_reg_result *res = parsed_result; 8104 port_reg_display(res->port_id, res->reg_off); 8105 } 8106 8107 cmdline_parse_token_string_t cmd_read_reg_read = 8108 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 8109 cmdline_parse_token_string_t cmd_read_reg_reg = 8110 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 8111 cmdline_parse_token_num_t cmd_read_reg_port_id = 8112 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16); 8113 cmdline_parse_token_num_t cmd_read_reg_reg_off = 8114 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32); 8115 8116 cmdline_parse_inst_t cmd_read_reg = { 8117 .f = cmd_read_reg_parsed, 8118 .data = NULL, 8119 .help_str = "read reg <port_id> <reg_off>", 8120 .tokens = { 8121 (void *)&cmd_read_reg_read, 8122 (void *)&cmd_read_reg_reg, 8123 (void *)&cmd_read_reg_port_id, 8124 (void *)&cmd_read_reg_reg_off, 8125 NULL, 8126 }, 8127 }; 8128 8129 /* *** READ PORT REGISTER BIT FIELD *** */ 8130 struct cmd_read_reg_bit_field_result { 8131 cmdline_fixed_string_t read; 8132 cmdline_fixed_string_t regfield; 8133 portid_t port_id; 8134 uint32_t reg_off; 8135 uint8_t bit1_pos; 8136 uint8_t bit2_pos; 8137 }; 8138 8139 static void 8140 cmd_read_reg_bit_field_parsed(void *parsed_result, 8141 __rte_unused struct cmdline *cl, 8142 __rte_unused void *data) 8143 { 8144 struct cmd_read_reg_bit_field_result *res = parsed_result; 8145 port_reg_bit_field_display(res->port_id, res->reg_off, 8146 res->bit1_pos, res->bit2_pos); 8147 } 8148 8149 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 8150 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 8151 "read"); 8152 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 8153 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 8154 regfield, "regfield"); 8155 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 8156 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 8157 RTE_UINT16); 8158 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 8159 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 8160 RTE_UINT32); 8161 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 8162 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 8163 RTE_UINT8); 8164 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 8165 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 8166 RTE_UINT8); 8167 8168 cmdline_parse_inst_t cmd_read_reg_bit_field = { 8169 .f = cmd_read_reg_bit_field_parsed, 8170 .data = NULL, 8171 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 8172 "Read register bit field between bit_x and bit_y included", 8173 .tokens = { 8174 (void *)&cmd_read_reg_bit_field_read, 8175 (void *)&cmd_read_reg_bit_field_regfield, 8176 (void *)&cmd_read_reg_bit_field_port_id, 8177 (void *)&cmd_read_reg_bit_field_reg_off, 8178 (void *)&cmd_read_reg_bit_field_bit1_pos, 8179 (void *)&cmd_read_reg_bit_field_bit2_pos, 8180 NULL, 8181 }, 8182 }; 8183 8184 /* *** READ PORT REGISTER BIT *** */ 8185 struct cmd_read_reg_bit_result { 8186 cmdline_fixed_string_t read; 8187 cmdline_fixed_string_t regbit; 8188 portid_t port_id; 8189 uint32_t reg_off; 8190 uint8_t bit_pos; 8191 }; 8192 8193 static void 8194 cmd_read_reg_bit_parsed(void *parsed_result, 8195 __rte_unused struct cmdline *cl, 8196 __rte_unused void *data) 8197 { 8198 struct cmd_read_reg_bit_result *res = parsed_result; 8199 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 8200 } 8201 8202 cmdline_parse_token_string_t cmd_read_reg_bit_read = 8203 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 8204 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 8205 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 8206 regbit, "regbit"); 8207 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 8208 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, 8209 RTE_UINT16); 8210 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 8211 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, 8212 RTE_UINT32); 8213 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 8214 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, 8215 RTE_UINT8); 8216 8217 cmdline_parse_inst_t cmd_read_reg_bit = { 8218 .f = cmd_read_reg_bit_parsed, 8219 .data = NULL, 8220 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 8221 .tokens = { 8222 (void *)&cmd_read_reg_bit_read, 8223 (void *)&cmd_read_reg_bit_regbit, 8224 (void *)&cmd_read_reg_bit_port_id, 8225 (void *)&cmd_read_reg_bit_reg_off, 8226 (void *)&cmd_read_reg_bit_bit_pos, 8227 NULL, 8228 }, 8229 }; 8230 8231 /* *** WRITE PORT REGISTER *** */ 8232 struct cmd_write_reg_result { 8233 cmdline_fixed_string_t write; 8234 cmdline_fixed_string_t reg; 8235 portid_t port_id; 8236 uint32_t reg_off; 8237 uint32_t value; 8238 }; 8239 8240 static void 8241 cmd_write_reg_parsed(void *parsed_result, 8242 __rte_unused struct cmdline *cl, 8243 __rte_unused void *data) 8244 { 8245 struct cmd_write_reg_result *res = parsed_result; 8246 port_reg_set(res->port_id, res->reg_off, res->value); 8247 } 8248 8249 cmdline_parse_token_string_t cmd_write_reg_write = 8250 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 8251 cmdline_parse_token_string_t cmd_write_reg_reg = 8252 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 8253 cmdline_parse_token_num_t cmd_write_reg_port_id = 8254 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16); 8255 cmdline_parse_token_num_t cmd_write_reg_reg_off = 8256 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32); 8257 cmdline_parse_token_num_t cmd_write_reg_value = 8258 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32); 8259 8260 cmdline_parse_inst_t cmd_write_reg = { 8261 .f = cmd_write_reg_parsed, 8262 .data = NULL, 8263 .help_str = "write reg <port_id> <reg_off> <reg_value>", 8264 .tokens = { 8265 (void *)&cmd_write_reg_write, 8266 (void *)&cmd_write_reg_reg, 8267 (void *)&cmd_write_reg_port_id, 8268 (void *)&cmd_write_reg_reg_off, 8269 (void *)&cmd_write_reg_value, 8270 NULL, 8271 }, 8272 }; 8273 8274 /* *** WRITE PORT REGISTER BIT FIELD *** */ 8275 struct cmd_write_reg_bit_field_result { 8276 cmdline_fixed_string_t write; 8277 cmdline_fixed_string_t regfield; 8278 portid_t port_id; 8279 uint32_t reg_off; 8280 uint8_t bit1_pos; 8281 uint8_t bit2_pos; 8282 uint32_t value; 8283 }; 8284 8285 static void 8286 cmd_write_reg_bit_field_parsed(void *parsed_result, 8287 __rte_unused struct cmdline *cl, 8288 __rte_unused void *data) 8289 { 8290 struct cmd_write_reg_bit_field_result *res = parsed_result; 8291 port_reg_bit_field_set(res->port_id, res->reg_off, 8292 res->bit1_pos, res->bit2_pos, res->value); 8293 } 8294 8295 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 8296 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 8297 "write"); 8298 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 8299 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 8300 regfield, "regfield"); 8301 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 8302 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 8303 RTE_UINT16); 8304 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 8305 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 8306 RTE_UINT32); 8307 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 8308 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 8309 RTE_UINT8); 8310 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 8311 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 8312 RTE_UINT8); 8313 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 8314 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 8315 RTE_UINT32); 8316 8317 cmdline_parse_inst_t cmd_write_reg_bit_field = { 8318 .f = cmd_write_reg_bit_field_parsed, 8319 .data = NULL, 8320 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 8321 "<reg_value>: " 8322 "Set register bit field between bit_x and bit_y included", 8323 .tokens = { 8324 (void *)&cmd_write_reg_bit_field_write, 8325 (void *)&cmd_write_reg_bit_field_regfield, 8326 (void *)&cmd_write_reg_bit_field_port_id, 8327 (void *)&cmd_write_reg_bit_field_reg_off, 8328 (void *)&cmd_write_reg_bit_field_bit1_pos, 8329 (void *)&cmd_write_reg_bit_field_bit2_pos, 8330 (void *)&cmd_write_reg_bit_field_value, 8331 NULL, 8332 }, 8333 }; 8334 8335 /* *** WRITE PORT REGISTER BIT *** */ 8336 struct cmd_write_reg_bit_result { 8337 cmdline_fixed_string_t write; 8338 cmdline_fixed_string_t regbit; 8339 portid_t port_id; 8340 uint32_t reg_off; 8341 uint8_t bit_pos; 8342 uint8_t value; 8343 }; 8344 8345 static void 8346 cmd_write_reg_bit_parsed(void *parsed_result, 8347 __rte_unused struct cmdline *cl, 8348 __rte_unused void *data) 8349 { 8350 struct cmd_write_reg_bit_result *res = parsed_result; 8351 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 8352 } 8353 8354 cmdline_parse_token_string_t cmd_write_reg_bit_write = 8355 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 8356 "write"); 8357 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 8358 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 8359 regbit, "regbit"); 8360 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 8361 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, 8362 RTE_UINT16); 8363 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 8364 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, 8365 RTE_UINT32); 8366 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 8367 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, 8368 RTE_UINT8); 8369 cmdline_parse_token_num_t cmd_write_reg_bit_value = 8370 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, 8371 RTE_UINT8); 8372 8373 cmdline_parse_inst_t cmd_write_reg_bit = { 8374 .f = cmd_write_reg_bit_parsed, 8375 .data = NULL, 8376 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 8377 "0 <= bit_x <= 31", 8378 .tokens = { 8379 (void *)&cmd_write_reg_bit_write, 8380 (void *)&cmd_write_reg_bit_regbit, 8381 (void *)&cmd_write_reg_bit_port_id, 8382 (void *)&cmd_write_reg_bit_reg_off, 8383 (void *)&cmd_write_reg_bit_bit_pos, 8384 (void *)&cmd_write_reg_bit_value, 8385 NULL, 8386 }, 8387 }; 8388 8389 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 8390 struct cmd_read_rxd_txd_result { 8391 cmdline_fixed_string_t read; 8392 cmdline_fixed_string_t rxd_txd; 8393 portid_t port_id; 8394 uint16_t queue_id; 8395 uint16_t desc_id; 8396 }; 8397 8398 static void 8399 cmd_read_rxd_txd_parsed(void *parsed_result, 8400 __rte_unused struct cmdline *cl, 8401 __rte_unused void *data) 8402 { 8403 struct cmd_read_rxd_txd_result *res = parsed_result; 8404 8405 if (!strcmp(res->rxd_txd, "rxd")) 8406 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 8407 else if (!strcmp(res->rxd_txd, "txd")) 8408 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 8409 } 8410 8411 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 8412 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 8413 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 8414 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 8415 "rxd#txd"); 8416 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 8417 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, 8418 RTE_UINT16); 8419 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 8420 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, 8421 RTE_UINT16); 8422 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 8423 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, 8424 RTE_UINT16); 8425 8426 cmdline_parse_inst_t cmd_read_rxd_txd = { 8427 .f = cmd_read_rxd_txd_parsed, 8428 .data = NULL, 8429 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 8430 .tokens = { 8431 (void *)&cmd_read_rxd_txd_read, 8432 (void *)&cmd_read_rxd_txd_rxd_txd, 8433 (void *)&cmd_read_rxd_txd_port_id, 8434 (void *)&cmd_read_rxd_txd_queue_id, 8435 (void *)&cmd_read_rxd_txd_desc_id, 8436 NULL, 8437 }, 8438 }; 8439 8440 /* *** QUIT *** */ 8441 struct cmd_quit_result { 8442 cmdline_fixed_string_t quit; 8443 }; 8444 8445 static void cmd_quit_parsed(__rte_unused void *parsed_result, 8446 struct cmdline *cl, 8447 __rte_unused void *data) 8448 { 8449 cmdline_quit(cl); 8450 } 8451 8452 cmdline_parse_token_string_t cmd_quit_quit = 8453 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 8454 8455 cmdline_parse_inst_t cmd_quit = { 8456 .f = cmd_quit_parsed, 8457 .data = NULL, 8458 .help_str = "quit: Exit application", 8459 .tokens = { 8460 (void *)&cmd_quit_quit, 8461 NULL, 8462 }, 8463 }; 8464 8465 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 8466 struct cmd_mac_addr_result { 8467 cmdline_fixed_string_t mac_addr_cmd; 8468 cmdline_fixed_string_t what; 8469 uint16_t port_num; 8470 struct rte_ether_addr address; 8471 }; 8472 8473 static void cmd_mac_addr_parsed(void *parsed_result, 8474 __rte_unused struct cmdline *cl, 8475 __rte_unused void *data) 8476 { 8477 struct cmd_mac_addr_result *res = parsed_result; 8478 int ret; 8479 8480 if (strcmp(res->what, "add") == 0) 8481 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 8482 else if (strcmp(res->what, "set") == 0) 8483 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 8484 &res->address); 8485 else 8486 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 8487 8488 /* check the return value and print it if is < 0 */ 8489 if(ret < 0) 8490 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret)); 8491 8492 } 8493 8494 cmdline_parse_token_string_t cmd_mac_addr_cmd = 8495 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 8496 "mac_addr"); 8497 cmdline_parse_token_string_t cmd_mac_addr_what = 8498 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 8499 "add#remove#set"); 8500 cmdline_parse_token_num_t cmd_mac_addr_portnum = 8501 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 8502 RTE_UINT16); 8503 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 8504 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 8505 8506 cmdline_parse_inst_t cmd_mac_addr = { 8507 .f = cmd_mac_addr_parsed, 8508 .data = (void *)0, 8509 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 8510 "Add/Remove/Set MAC address on port_id", 8511 .tokens = { 8512 (void *)&cmd_mac_addr_cmd, 8513 (void *)&cmd_mac_addr_what, 8514 (void *)&cmd_mac_addr_portnum, 8515 (void *)&cmd_mac_addr_addr, 8516 NULL, 8517 }, 8518 }; 8519 8520 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 8521 struct cmd_eth_peer_result { 8522 cmdline_fixed_string_t set; 8523 cmdline_fixed_string_t eth_peer; 8524 portid_t port_id; 8525 cmdline_fixed_string_t peer_addr; 8526 }; 8527 8528 static void cmd_set_eth_peer_parsed(void *parsed_result, 8529 __rte_unused struct cmdline *cl, 8530 __rte_unused void *data) 8531 { 8532 struct cmd_eth_peer_result *res = parsed_result; 8533 8534 if (test_done == 0) { 8535 fprintf(stderr, "Please stop forwarding first\n"); 8536 return; 8537 } 8538 if (!strcmp(res->eth_peer, "eth-peer")) { 8539 set_fwd_eth_peer(res->port_id, res->peer_addr); 8540 fwd_config_setup(); 8541 } 8542 } 8543 cmdline_parse_token_string_t cmd_eth_peer_set = 8544 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 8545 cmdline_parse_token_string_t cmd_eth_peer = 8546 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 8547 cmdline_parse_token_num_t cmd_eth_peer_port_id = 8548 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, 8549 RTE_UINT16); 8550 cmdline_parse_token_string_t cmd_eth_peer_addr = 8551 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 8552 8553 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 8554 .f = cmd_set_eth_peer_parsed, 8555 .data = NULL, 8556 .help_str = "set eth-peer <port_id> <peer_mac>", 8557 .tokens = { 8558 (void *)&cmd_eth_peer_set, 8559 (void *)&cmd_eth_peer, 8560 (void *)&cmd_eth_peer_port_id, 8561 (void *)&cmd_eth_peer_addr, 8562 NULL, 8563 }, 8564 }; 8565 8566 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 8567 struct cmd_set_qmap_result { 8568 cmdline_fixed_string_t set; 8569 cmdline_fixed_string_t qmap; 8570 cmdline_fixed_string_t what; 8571 portid_t port_id; 8572 uint16_t queue_id; 8573 uint8_t map_value; 8574 }; 8575 8576 static void 8577 cmd_set_qmap_parsed(void *parsed_result, 8578 __rte_unused struct cmdline *cl, 8579 __rte_unused void *data) 8580 { 8581 struct cmd_set_qmap_result *res = parsed_result; 8582 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 8583 8584 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 8585 } 8586 8587 cmdline_parse_token_string_t cmd_setqmap_set = 8588 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8589 set, "set"); 8590 cmdline_parse_token_string_t cmd_setqmap_qmap = 8591 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8592 qmap, "stat_qmap"); 8593 cmdline_parse_token_string_t cmd_setqmap_what = 8594 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8595 what, "tx#rx"); 8596 cmdline_parse_token_num_t cmd_setqmap_portid = 8597 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8598 port_id, RTE_UINT16); 8599 cmdline_parse_token_num_t cmd_setqmap_queueid = 8600 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8601 queue_id, RTE_UINT16); 8602 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 8603 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8604 map_value, RTE_UINT8); 8605 8606 cmdline_parse_inst_t cmd_set_qmap = { 8607 .f = cmd_set_qmap_parsed, 8608 .data = NULL, 8609 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 8610 "Set statistics mapping value on tx|rx queue_id of port_id", 8611 .tokens = { 8612 (void *)&cmd_setqmap_set, 8613 (void *)&cmd_setqmap_qmap, 8614 (void *)&cmd_setqmap_what, 8615 (void *)&cmd_setqmap_portid, 8616 (void *)&cmd_setqmap_queueid, 8617 (void *)&cmd_setqmap_mapvalue, 8618 NULL, 8619 }, 8620 }; 8621 8622 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 8623 struct cmd_set_xstats_hide_zero_result { 8624 cmdline_fixed_string_t keyword; 8625 cmdline_fixed_string_t name; 8626 cmdline_fixed_string_t on_off; 8627 }; 8628 8629 static void 8630 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 8631 __rte_unused struct cmdline *cl, 8632 __rte_unused void *data) 8633 { 8634 struct cmd_set_xstats_hide_zero_result *res; 8635 uint16_t on_off = 0; 8636 8637 res = parsed_result; 8638 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8639 set_xstats_hide_zero(on_off); 8640 } 8641 8642 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 8643 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8644 keyword, "set"); 8645 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 8646 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8647 name, "xstats-hide-zero"); 8648 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 8649 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8650 on_off, "on#off"); 8651 8652 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 8653 .f = cmd_set_xstats_hide_zero_parsed, 8654 .data = NULL, 8655 .help_str = "set xstats-hide-zero on|off", 8656 .tokens = { 8657 (void *)&cmd_set_xstats_hide_zero_keyword, 8658 (void *)&cmd_set_xstats_hide_zero_name, 8659 (void *)&cmd_set_xstats_hide_zero_on_off, 8660 NULL, 8661 }, 8662 }; 8663 8664 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */ 8665 struct cmd_set_record_core_cycles_result { 8666 cmdline_fixed_string_t keyword; 8667 cmdline_fixed_string_t name; 8668 cmdline_fixed_string_t on_off; 8669 }; 8670 8671 static void 8672 cmd_set_record_core_cycles_parsed(void *parsed_result, 8673 __rte_unused struct cmdline *cl, 8674 __rte_unused void *data) 8675 { 8676 struct cmd_set_record_core_cycles_result *res; 8677 uint16_t on_off = 0; 8678 8679 res = parsed_result; 8680 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8681 set_record_core_cycles(on_off); 8682 } 8683 8684 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword = 8685 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8686 keyword, "set"); 8687 cmdline_parse_token_string_t cmd_set_record_core_cycles_name = 8688 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8689 name, "record-core-cycles"); 8690 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off = 8691 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8692 on_off, "on#off"); 8693 8694 cmdline_parse_inst_t cmd_set_record_core_cycles = { 8695 .f = cmd_set_record_core_cycles_parsed, 8696 .data = NULL, 8697 .help_str = "set record-core-cycles on|off", 8698 .tokens = { 8699 (void *)&cmd_set_record_core_cycles_keyword, 8700 (void *)&cmd_set_record_core_cycles_name, 8701 (void *)&cmd_set_record_core_cycles_on_off, 8702 NULL, 8703 }, 8704 }; 8705 8706 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */ 8707 struct cmd_set_record_burst_stats_result { 8708 cmdline_fixed_string_t keyword; 8709 cmdline_fixed_string_t name; 8710 cmdline_fixed_string_t on_off; 8711 }; 8712 8713 static void 8714 cmd_set_record_burst_stats_parsed(void *parsed_result, 8715 __rte_unused struct cmdline *cl, 8716 __rte_unused void *data) 8717 { 8718 struct cmd_set_record_burst_stats_result *res; 8719 uint16_t on_off = 0; 8720 8721 res = parsed_result; 8722 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8723 set_record_burst_stats(on_off); 8724 } 8725 8726 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword = 8727 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8728 keyword, "set"); 8729 cmdline_parse_token_string_t cmd_set_record_burst_stats_name = 8730 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8731 name, "record-burst-stats"); 8732 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off = 8733 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8734 on_off, "on#off"); 8735 8736 cmdline_parse_inst_t cmd_set_record_burst_stats = { 8737 .f = cmd_set_record_burst_stats_parsed, 8738 .data = NULL, 8739 .help_str = "set record-burst-stats on|off", 8740 .tokens = { 8741 (void *)&cmd_set_record_burst_stats_keyword, 8742 (void *)&cmd_set_record_burst_stats_name, 8743 (void *)&cmd_set_record_burst_stats_on_off, 8744 NULL, 8745 }, 8746 }; 8747 8748 /* *** CONFIGURE UNICAST HASH TABLE *** */ 8749 struct cmd_set_uc_hash_table { 8750 cmdline_fixed_string_t set; 8751 cmdline_fixed_string_t port; 8752 portid_t port_id; 8753 cmdline_fixed_string_t what; 8754 struct rte_ether_addr address; 8755 cmdline_fixed_string_t mode; 8756 }; 8757 8758 static void 8759 cmd_set_uc_hash_parsed(void *parsed_result, 8760 __rte_unused struct cmdline *cl, 8761 __rte_unused void *data) 8762 { 8763 int ret=0; 8764 struct cmd_set_uc_hash_table *res = parsed_result; 8765 8766 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8767 8768 if (strcmp(res->what, "uta") == 0) 8769 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 8770 &res->address,(uint8_t)is_on); 8771 if (ret < 0) 8772 fprintf(stderr, 8773 "bad unicast hash table parameter, return code = %d\n", 8774 ret); 8775 8776 } 8777 8778 cmdline_parse_token_string_t cmd_set_uc_hash_set = 8779 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8780 set, "set"); 8781 cmdline_parse_token_string_t cmd_set_uc_hash_port = 8782 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8783 port, "port"); 8784 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 8785 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 8786 port_id, RTE_UINT16); 8787 cmdline_parse_token_string_t cmd_set_uc_hash_what = 8788 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8789 what, "uta"); 8790 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 8791 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 8792 address); 8793 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 8794 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8795 mode, "on#off"); 8796 8797 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 8798 .f = cmd_set_uc_hash_parsed, 8799 .data = NULL, 8800 .help_str = "set port <port_id> uta <mac_addr> on|off)", 8801 .tokens = { 8802 (void *)&cmd_set_uc_hash_set, 8803 (void *)&cmd_set_uc_hash_port, 8804 (void *)&cmd_set_uc_hash_portid, 8805 (void *)&cmd_set_uc_hash_what, 8806 (void *)&cmd_set_uc_hash_mac, 8807 (void *)&cmd_set_uc_hash_mode, 8808 NULL, 8809 }, 8810 }; 8811 8812 struct cmd_set_uc_all_hash_table { 8813 cmdline_fixed_string_t set; 8814 cmdline_fixed_string_t port; 8815 portid_t port_id; 8816 cmdline_fixed_string_t what; 8817 cmdline_fixed_string_t value; 8818 cmdline_fixed_string_t mode; 8819 }; 8820 8821 static void 8822 cmd_set_uc_all_hash_parsed(void *parsed_result, 8823 __rte_unused struct cmdline *cl, 8824 __rte_unused void *data) 8825 { 8826 int ret=0; 8827 struct cmd_set_uc_all_hash_table *res = parsed_result; 8828 8829 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8830 8831 if ((strcmp(res->what, "uta") == 0) && 8832 (strcmp(res->value, "all") == 0)) 8833 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 8834 if (ret < 0) 8835 fprintf(stderr, 8836 "bad unicast hash table parameter, return code = %d\n", 8837 ret); 8838 } 8839 8840 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 8841 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8842 set, "set"); 8843 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 8844 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8845 port, "port"); 8846 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 8847 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 8848 port_id, RTE_UINT16); 8849 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 8850 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8851 what, "uta"); 8852 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 8853 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8854 value,"all"); 8855 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 8856 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8857 mode, "on#off"); 8858 8859 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 8860 .f = cmd_set_uc_all_hash_parsed, 8861 .data = NULL, 8862 .help_str = "set port <port_id> uta all on|off", 8863 .tokens = { 8864 (void *)&cmd_set_uc_all_hash_set, 8865 (void *)&cmd_set_uc_all_hash_port, 8866 (void *)&cmd_set_uc_all_hash_portid, 8867 (void *)&cmd_set_uc_all_hash_what, 8868 (void *)&cmd_set_uc_all_hash_value, 8869 (void *)&cmd_set_uc_all_hash_mode, 8870 NULL, 8871 }, 8872 }; 8873 8874 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 8875 struct cmd_set_vf_traffic { 8876 cmdline_fixed_string_t set; 8877 cmdline_fixed_string_t port; 8878 portid_t port_id; 8879 cmdline_fixed_string_t vf; 8880 uint8_t vf_id; 8881 cmdline_fixed_string_t what; 8882 cmdline_fixed_string_t mode; 8883 }; 8884 8885 static void 8886 cmd_set_vf_traffic_parsed(void *parsed_result, 8887 __rte_unused struct cmdline *cl, 8888 __rte_unused void *data) 8889 { 8890 struct cmd_set_vf_traffic *res = parsed_result; 8891 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 8892 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8893 8894 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 8895 } 8896 8897 cmdline_parse_token_string_t cmd_setvf_traffic_set = 8898 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8899 set, "set"); 8900 cmdline_parse_token_string_t cmd_setvf_traffic_port = 8901 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8902 port, "port"); 8903 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 8904 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8905 port_id, RTE_UINT16); 8906 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 8907 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8908 vf, "vf"); 8909 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 8910 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8911 vf_id, RTE_UINT8); 8912 cmdline_parse_token_string_t cmd_setvf_traffic_what = 8913 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8914 what, "tx#rx"); 8915 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 8916 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8917 mode, "on#off"); 8918 8919 cmdline_parse_inst_t cmd_set_vf_traffic = { 8920 .f = cmd_set_vf_traffic_parsed, 8921 .data = NULL, 8922 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 8923 .tokens = { 8924 (void *)&cmd_setvf_traffic_set, 8925 (void *)&cmd_setvf_traffic_port, 8926 (void *)&cmd_setvf_traffic_portid, 8927 (void *)&cmd_setvf_traffic_vf, 8928 (void *)&cmd_setvf_traffic_vfid, 8929 (void *)&cmd_setvf_traffic_what, 8930 (void *)&cmd_setvf_traffic_mode, 8931 NULL, 8932 }, 8933 }; 8934 8935 /* *** CONFIGURE VF RECEIVE MODE *** */ 8936 struct cmd_set_vf_rxmode { 8937 cmdline_fixed_string_t set; 8938 cmdline_fixed_string_t port; 8939 portid_t port_id; 8940 cmdline_fixed_string_t vf; 8941 uint8_t vf_id; 8942 cmdline_fixed_string_t what; 8943 cmdline_fixed_string_t mode; 8944 cmdline_fixed_string_t on; 8945 }; 8946 8947 static void 8948 cmd_set_vf_rxmode_parsed(void *parsed_result, 8949 __rte_unused struct cmdline *cl, 8950 __rte_unused void *data) 8951 { 8952 int ret = -ENOTSUP; 8953 uint16_t vf_rxmode = 0; 8954 struct cmd_set_vf_rxmode *res = parsed_result; 8955 8956 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 8957 if (!strcmp(res->what,"rxmode")) { 8958 if (!strcmp(res->mode, "AUPE")) 8959 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG; 8960 else if (!strcmp(res->mode, "ROPE")) 8961 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC; 8962 else if (!strcmp(res->mode, "BAM")) 8963 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST; 8964 else if (!strncmp(res->mode, "MPE",3)) 8965 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST; 8966 } 8967 8968 RTE_SET_USED(is_on); 8969 8970 #ifdef RTE_NET_IXGBE 8971 if (ret == -ENOTSUP) 8972 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 8973 vf_rxmode, (uint8_t)is_on); 8974 #endif 8975 #ifdef RTE_NET_BNXT 8976 if (ret == -ENOTSUP) 8977 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 8978 vf_rxmode, (uint8_t)is_on); 8979 #endif 8980 if (ret < 0) 8981 fprintf(stderr, 8982 "bad VF receive mode parameter, return code = %d\n", 8983 ret); 8984 } 8985 8986 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 8987 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8988 set, "set"); 8989 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 8990 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8991 port, "port"); 8992 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 8993 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8994 port_id, RTE_UINT16); 8995 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 8996 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8997 vf, "vf"); 8998 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 8999 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 9000 vf_id, RTE_UINT8); 9001 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 9002 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 9003 what, "rxmode"); 9004 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 9005 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 9006 mode, "AUPE#ROPE#BAM#MPE"); 9007 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 9008 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 9009 on, "on#off"); 9010 9011 cmdline_parse_inst_t cmd_set_vf_rxmode = { 9012 .f = cmd_set_vf_rxmode_parsed, 9013 .data = NULL, 9014 .help_str = "set port <port_id> vf <vf_id> rxmode " 9015 "AUPE|ROPE|BAM|MPE on|off", 9016 .tokens = { 9017 (void *)&cmd_set_vf_rxmode_set, 9018 (void *)&cmd_set_vf_rxmode_port, 9019 (void *)&cmd_set_vf_rxmode_portid, 9020 (void *)&cmd_set_vf_rxmode_vf, 9021 (void *)&cmd_set_vf_rxmode_vfid, 9022 (void *)&cmd_set_vf_rxmode_what, 9023 (void *)&cmd_set_vf_rxmode_mode, 9024 (void *)&cmd_set_vf_rxmode_on, 9025 NULL, 9026 }, 9027 }; 9028 9029 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 9030 struct cmd_vf_mac_addr_result { 9031 cmdline_fixed_string_t mac_addr_cmd; 9032 cmdline_fixed_string_t what; 9033 cmdline_fixed_string_t port; 9034 uint16_t port_num; 9035 cmdline_fixed_string_t vf; 9036 uint8_t vf_num; 9037 struct rte_ether_addr address; 9038 }; 9039 9040 static void cmd_vf_mac_addr_parsed(void *parsed_result, 9041 __rte_unused struct cmdline *cl, 9042 __rte_unused void *data) 9043 { 9044 struct cmd_vf_mac_addr_result *res = parsed_result; 9045 int ret = -ENOTSUP; 9046 9047 if (strcmp(res->what, "add") != 0) 9048 return; 9049 9050 #ifdef RTE_NET_I40E 9051 if (ret == -ENOTSUP) 9052 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 9053 &res->address); 9054 #endif 9055 #ifdef RTE_NET_BNXT 9056 if (ret == -ENOTSUP) 9057 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 9058 res->vf_num); 9059 #endif 9060 9061 if(ret < 0) 9062 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 9063 9064 } 9065 9066 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 9067 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 9068 mac_addr_cmd,"mac_addr"); 9069 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 9070 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 9071 what,"add"); 9072 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 9073 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 9074 port,"port"); 9075 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 9076 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 9077 port_num, RTE_UINT16); 9078 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 9079 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 9080 vf,"vf"); 9081 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 9082 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 9083 vf_num, RTE_UINT8); 9084 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 9085 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 9086 address); 9087 9088 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 9089 .f = cmd_vf_mac_addr_parsed, 9090 .data = (void *)0, 9091 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 9092 "Add MAC address filtering for a VF on port_id", 9093 .tokens = { 9094 (void *)&cmd_vf_mac_addr_cmd, 9095 (void *)&cmd_vf_mac_addr_what, 9096 (void *)&cmd_vf_mac_addr_port, 9097 (void *)&cmd_vf_mac_addr_portnum, 9098 (void *)&cmd_vf_mac_addr_vf, 9099 (void *)&cmd_vf_mac_addr_vfnum, 9100 (void *)&cmd_vf_mac_addr_addr, 9101 NULL, 9102 }, 9103 }; 9104 9105 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 9106 struct cmd_vf_rx_vlan_filter { 9107 cmdline_fixed_string_t rx_vlan; 9108 cmdline_fixed_string_t what; 9109 uint16_t vlan_id; 9110 cmdline_fixed_string_t port; 9111 portid_t port_id; 9112 cmdline_fixed_string_t vf; 9113 uint64_t vf_mask; 9114 }; 9115 9116 static void 9117 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 9118 __rte_unused struct cmdline *cl, 9119 __rte_unused void *data) 9120 { 9121 struct cmd_vf_rx_vlan_filter *res = parsed_result; 9122 int ret = -ENOTSUP; 9123 9124 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 9125 9126 #ifdef RTE_NET_IXGBE 9127 if (ret == -ENOTSUP) 9128 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 9129 res->vlan_id, res->vf_mask, is_add); 9130 #endif 9131 #ifdef RTE_NET_I40E 9132 if (ret == -ENOTSUP) 9133 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 9134 res->vlan_id, res->vf_mask, is_add); 9135 #endif 9136 #ifdef RTE_NET_BNXT 9137 if (ret == -ENOTSUP) 9138 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 9139 res->vlan_id, res->vf_mask, is_add); 9140 #endif 9141 9142 switch (ret) { 9143 case 0: 9144 break; 9145 case -EINVAL: 9146 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n", 9147 res->vlan_id, res->vf_mask); 9148 break; 9149 case -ENODEV: 9150 fprintf(stderr, "invalid port_id %d\n", res->port_id); 9151 break; 9152 case -ENOTSUP: 9153 fprintf(stderr, "function not implemented or supported\n"); 9154 break; 9155 default: 9156 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 9157 } 9158 } 9159 9160 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 9161 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9162 rx_vlan, "rx_vlan"); 9163 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 9164 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9165 what, "add#rm"); 9166 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 9167 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9168 vlan_id, RTE_UINT16); 9169 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 9170 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9171 port, "port"); 9172 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 9173 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9174 port_id, RTE_UINT16); 9175 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 9176 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9177 vf, "vf"); 9178 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 9179 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9180 vf_mask, RTE_UINT64); 9181 9182 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 9183 .f = cmd_vf_rx_vlan_filter_parsed, 9184 .data = NULL, 9185 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 9186 "(vf_mask = hexadecimal VF mask)", 9187 .tokens = { 9188 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 9189 (void *)&cmd_vf_rx_vlan_filter_what, 9190 (void *)&cmd_vf_rx_vlan_filter_vlanid, 9191 (void *)&cmd_vf_rx_vlan_filter_port, 9192 (void *)&cmd_vf_rx_vlan_filter_portid, 9193 (void *)&cmd_vf_rx_vlan_filter_vf, 9194 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 9195 NULL, 9196 }, 9197 }; 9198 9199 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 9200 struct cmd_queue_rate_limit_result { 9201 cmdline_fixed_string_t set; 9202 cmdline_fixed_string_t port; 9203 uint16_t port_num; 9204 cmdline_fixed_string_t queue; 9205 uint8_t queue_num; 9206 cmdline_fixed_string_t rate; 9207 uint16_t rate_num; 9208 }; 9209 9210 static void cmd_queue_rate_limit_parsed(void *parsed_result, 9211 __rte_unused struct cmdline *cl, 9212 __rte_unused void *data) 9213 { 9214 struct cmd_queue_rate_limit_result *res = parsed_result; 9215 int ret = 0; 9216 9217 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 9218 && (strcmp(res->queue, "queue") == 0) 9219 && (strcmp(res->rate, "rate") == 0)) 9220 ret = set_queue_rate_limit(res->port_num, res->queue_num, 9221 res->rate_num); 9222 if (ret < 0) 9223 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n", 9224 strerror(-ret)); 9225 9226 } 9227 9228 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 9229 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9230 set, "set"); 9231 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 9232 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9233 port, "port"); 9234 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 9235 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9236 port_num, RTE_UINT16); 9237 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 9238 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9239 queue, "queue"); 9240 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 9241 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9242 queue_num, RTE_UINT8); 9243 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 9244 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9245 rate, "rate"); 9246 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 9247 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9248 rate_num, RTE_UINT16); 9249 9250 cmdline_parse_inst_t cmd_queue_rate_limit = { 9251 .f = cmd_queue_rate_limit_parsed, 9252 .data = (void *)0, 9253 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 9254 "Set rate limit for a queue on port_id", 9255 .tokens = { 9256 (void *)&cmd_queue_rate_limit_set, 9257 (void *)&cmd_queue_rate_limit_port, 9258 (void *)&cmd_queue_rate_limit_portnum, 9259 (void *)&cmd_queue_rate_limit_queue, 9260 (void *)&cmd_queue_rate_limit_queuenum, 9261 (void *)&cmd_queue_rate_limit_rate, 9262 (void *)&cmd_queue_rate_limit_ratenum, 9263 NULL, 9264 }, 9265 }; 9266 9267 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 9268 struct cmd_vf_rate_limit_result { 9269 cmdline_fixed_string_t set; 9270 cmdline_fixed_string_t port; 9271 uint16_t port_num; 9272 cmdline_fixed_string_t vf; 9273 uint8_t vf_num; 9274 cmdline_fixed_string_t rate; 9275 uint16_t rate_num; 9276 cmdline_fixed_string_t q_msk; 9277 uint64_t q_msk_val; 9278 }; 9279 9280 static void cmd_vf_rate_limit_parsed(void *parsed_result, 9281 __rte_unused struct cmdline *cl, 9282 __rte_unused void *data) 9283 { 9284 struct cmd_vf_rate_limit_result *res = parsed_result; 9285 int ret = 0; 9286 9287 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 9288 && (strcmp(res->vf, "vf") == 0) 9289 && (strcmp(res->rate, "rate") == 0) 9290 && (strcmp(res->q_msk, "queue_mask") == 0)) 9291 ret = set_vf_rate_limit(res->port_num, res->vf_num, 9292 res->rate_num, res->q_msk_val); 9293 if (ret < 0) 9294 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n", 9295 strerror(-ret)); 9296 9297 } 9298 9299 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 9300 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9301 set, "set"); 9302 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 9303 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9304 port, "port"); 9305 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 9306 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9307 port_num, RTE_UINT16); 9308 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 9309 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9310 vf, "vf"); 9311 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 9312 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9313 vf_num, RTE_UINT8); 9314 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 9315 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9316 rate, "rate"); 9317 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 9318 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9319 rate_num, RTE_UINT16); 9320 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 9321 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9322 q_msk, "queue_mask"); 9323 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 9324 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9325 q_msk_val, RTE_UINT64); 9326 9327 cmdline_parse_inst_t cmd_vf_rate_limit = { 9328 .f = cmd_vf_rate_limit_parsed, 9329 .data = (void *)0, 9330 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 9331 "queue_mask <queue_mask_value>: " 9332 "Set rate limit for queues of VF on port_id", 9333 .tokens = { 9334 (void *)&cmd_vf_rate_limit_set, 9335 (void *)&cmd_vf_rate_limit_port, 9336 (void *)&cmd_vf_rate_limit_portnum, 9337 (void *)&cmd_vf_rate_limit_vf, 9338 (void *)&cmd_vf_rate_limit_vfnum, 9339 (void *)&cmd_vf_rate_limit_rate, 9340 (void *)&cmd_vf_rate_limit_ratenum, 9341 (void *)&cmd_vf_rate_limit_q_msk, 9342 (void *)&cmd_vf_rate_limit_q_msk_val, 9343 NULL, 9344 }, 9345 }; 9346 9347 /* *** CONFIGURE TUNNEL UDP PORT *** */ 9348 struct cmd_tunnel_udp_config { 9349 cmdline_fixed_string_t rx_vxlan_port; 9350 cmdline_fixed_string_t what; 9351 uint16_t udp_port; 9352 portid_t port_id; 9353 }; 9354 9355 static void 9356 cmd_tunnel_udp_config_parsed(void *parsed_result, 9357 __rte_unused struct cmdline *cl, 9358 __rte_unused void *data) 9359 { 9360 struct cmd_tunnel_udp_config *res = parsed_result; 9361 struct rte_eth_udp_tunnel tunnel_udp; 9362 int ret; 9363 9364 tunnel_udp.udp_port = res->udp_port; 9365 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9366 9367 if (!strcmp(res->what, "add")) 9368 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9369 &tunnel_udp); 9370 else 9371 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9372 &tunnel_udp); 9373 9374 if (ret < 0) 9375 fprintf(stderr, "udp tunneling add error: (%s)\n", 9376 strerror(-ret)); 9377 } 9378 9379 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port = 9380 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9381 rx_vxlan_port, "rx_vxlan_port"); 9382 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 9383 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9384 what, "add#rm"); 9385 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 9386 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9387 udp_port, RTE_UINT16); 9388 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 9389 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9390 port_id, RTE_UINT16); 9391 9392 cmdline_parse_inst_t cmd_tunnel_udp_config = { 9393 .f = cmd_tunnel_udp_config_parsed, 9394 .data = (void *)0, 9395 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 9396 "Add/Remove a tunneling UDP port filter", 9397 .tokens = { 9398 (void *)&cmd_tunnel_udp_config_rx_vxlan_port, 9399 (void *)&cmd_tunnel_udp_config_what, 9400 (void *)&cmd_tunnel_udp_config_udp_port, 9401 (void *)&cmd_tunnel_udp_config_port_id, 9402 NULL, 9403 }, 9404 }; 9405 9406 struct cmd_config_tunnel_udp_port { 9407 cmdline_fixed_string_t port; 9408 cmdline_fixed_string_t config; 9409 portid_t port_id; 9410 cmdline_fixed_string_t udp_tunnel_port; 9411 cmdline_fixed_string_t action; 9412 cmdline_fixed_string_t tunnel_type; 9413 uint16_t udp_port; 9414 }; 9415 9416 static void 9417 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 9418 __rte_unused struct cmdline *cl, 9419 __rte_unused void *data) 9420 { 9421 struct cmd_config_tunnel_udp_port *res = parsed_result; 9422 struct rte_eth_udp_tunnel tunnel_udp; 9423 int ret = 0; 9424 9425 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9426 return; 9427 9428 tunnel_udp.udp_port = res->udp_port; 9429 9430 if (!strcmp(res->tunnel_type, "vxlan")) { 9431 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9432 } else if (!strcmp(res->tunnel_type, "geneve")) { 9433 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 9434 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) { 9435 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 9436 } else if (!strcmp(res->tunnel_type, "ecpri")) { 9437 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI; 9438 } else { 9439 fprintf(stderr, "Invalid tunnel type\n"); 9440 return; 9441 } 9442 9443 if (!strcmp(res->action, "add")) 9444 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9445 &tunnel_udp); 9446 else 9447 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9448 &tunnel_udp); 9449 9450 if (ret < 0) 9451 fprintf(stderr, "udp tunneling port add error: (%s)\n", 9452 strerror(-ret)); 9453 } 9454 9455 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 9456 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 9457 "port"); 9458 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 9459 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 9460 "config"); 9461 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 9462 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 9463 RTE_UINT16); 9464 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 9465 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 9466 udp_tunnel_port, 9467 "udp_tunnel_port"); 9468 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 9469 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 9470 "add#rm"); 9471 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 9472 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 9473 "vxlan#geneve#vxlan-gpe#ecpri"); 9474 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 9475 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 9476 RTE_UINT16); 9477 9478 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 9479 .f = cmd_cfg_tunnel_udp_port_parsed, 9480 .data = NULL, 9481 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|" 9482 "geneve|vxlan-gpe|ecpri <udp_port>", 9483 .tokens = { 9484 (void *)&cmd_config_tunnel_udp_port_port, 9485 (void *)&cmd_config_tunnel_udp_port_config, 9486 (void *)&cmd_config_tunnel_udp_port_port_id, 9487 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 9488 (void *)&cmd_config_tunnel_udp_port_action, 9489 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 9490 (void *)&cmd_config_tunnel_udp_port_value, 9491 NULL, 9492 }, 9493 }; 9494 9495 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 9496 struct cmd_set_mirror_mask_result { 9497 cmdline_fixed_string_t set; 9498 cmdline_fixed_string_t port; 9499 portid_t port_id; 9500 cmdline_fixed_string_t mirror; 9501 uint8_t rule_id; 9502 cmdline_fixed_string_t what; 9503 cmdline_fixed_string_t value; 9504 cmdline_fixed_string_t dstpool; 9505 uint8_t dstpool_id; 9506 cmdline_fixed_string_t on; 9507 }; 9508 9509 cmdline_parse_token_string_t cmd_mirror_mask_set = 9510 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9511 set, "set"); 9512 cmdline_parse_token_string_t cmd_mirror_mask_port = 9513 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9514 port, "port"); 9515 cmdline_parse_token_num_t cmd_mirror_mask_portid = 9516 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9517 port_id, RTE_UINT16); 9518 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 9519 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9520 mirror, "mirror-rule"); 9521 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 9522 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9523 rule_id, RTE_UINT8); 9524 cmdline_parse_token_string_t cmd_mirror_mask_what = 9525 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9526 what, "pool-mirror-up#pool-mirror-down" 9527 "#vlan-mirror"); 9528 cmdline_parse_token_string_t cmd_mirror_mask_value = 9529 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9530 value, NULL); 9531 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 9532 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9533 dstpool, "dst-pool"); 9534 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 9535 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9536 dstpool_id, RTE_UINT8); 9537 cmdline_parse_token_string_t cmd_mirror_mask_on = 9538 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9539 on, "on#off"); 9540 9541 static void 9542 cmd_set_mirror_mask_parsed(void *parsed_result, 9543 __rte_unused struct cmdline *cl, 9544 __rte_unused void *data) 9545 { 9546 int ret,nb_item,i; 9547 struct cmd_set_mirror_mask_result *res = parsed_result; 9548 struct rte_eth_mirror_conf mr_conf; 9549 9550 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9551 9552 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 9553 9554 mr_conf.dst_pool = res->dstpool_id; 9555 9556 if (!strcmp(res->what, "pool-mirror-up")) { 9557 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9558 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 9559 } else if (!strcmp(res->what, "pool-mirror-down")) { 9560 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9561 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 9562 } else if (!strcmp(res->what, "vlan-mirror")) { 9563 mr_conf.rule_type = ETH_MIRROR_VLAN; 9564 nb_item = parse_item_list(res->value, "vlan", 9565 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 9566 if (nb_item <= 0) 9567 return; 9568 9569 for (i = 0; i < nb_item; i++) { 9570 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) { 9571 fprintf(stderr, 9572 "Invalid vlan_id: must be < 4096\n"); 9573 return; 9574 } 9575 9576 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 9577 mr_conf.vlan.vlan_mask |= 1ULL << i; 9578 } 9579 } 9580 9581 if (!strcmp(res->on, "on")) 9582 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9583 res->rule_id, 1); 9584 else 9585 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9586 res->rule_id, 0); 9587 if (ret < 0) 9588 fprintf(stderr, "mirror rule add error: (%s)\n", 9589 strerror(-ret)); 9590 } 9591 9592 cmdline_parse_inst_t cmd_set_mirror_mask = { 9593 .f = cmd_set_mirror_mask_parsed, 9594 .data = NULL, 9595 .help_str = "set port <port_id> mirror-rule <rule_id> " 9596 "pool-mirror-up|pool-mirror-down|vlan-mirror " 9597 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 9598 .tokens = { 9599 (void *)&cmd_mirror_mask_set, 9600 (void *)&cmd_mirror_mask_port, 9601 (void *)&cmd_mirror_mask_portid, 9602 (void *)&cmd_mirror_mask_mirror, 9603 (void *)&cmd_mirror_mask_ruleid, 9604 (void *)&cmd_mirror_mask_what, 9605 (void *)&cmd_mirror_mask_value, 9606 (void *)&cmd_mirror_mask_dstpool, 9607 (void *)&cmd_mirror_mask_poolid, 9608 (void *)&cmd_mirror_mask_on, 9609 NULL, 9610 }, 9611 }; 9612 9613 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 9614 struct cmd_set_mirror_link_result { 9615 cmdline_fixed_string_t set; 9616 cmdline_fixed_string_t port; 9617 portid_t port_id; 9618 cmdline_fixed_string_t mirror; 9619 uint8_t rule_id; 9620 cmdline_fixed_string_t what; 9621 cmdline_fixed_string_t dstpool; 9622 uint8_t dstpool_id; 9623 cmdline_fixed_string_t on; 9624 }; 9625 9626 cmdline_parse_token_string_t cmd_mirror_link_set = 9627 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9628 set, "set"); 9629 cmdline_parse_token_string_t cmd_mirror_link_port = 9630 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9631 port, "port"); 9632 cmdline_parse_token_num_t cmd_mirror_link_portid = 9633 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9634 port_id, RTE_UINT16); 9635 cmdline_parse_token_string_t cmd_mirror_link_mirror = 9636 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9637 mirror, "mirror-rule"); 9638 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 9639 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9640 rule_id, RTE_UINT8); 9641 cmdline_parse_token_string_t cmd_mirror_link_what = 9642 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9643 what, "uplink-mirror#downlink-mirror"); 9644 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 9645 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9646 dstpool, "dst-pool"); 9647 cmdline_parse_token_num_t cmd_mirror_link_poolid = 9648 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9649 dstpool_id, RTE_UINT8); 9650 cmdline_parse_token_string_t cmd_mirror_link_on = 9651 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9652 on, "on#off"); 9653 9654 static void 9655 cmd_set_mirror_link_parsed(void *parsed_result, 9656 __rte_unused struct cmdline *cl, 9657 __rte_unused void *data) 9658 { 9659 int ret; 9660 struct cmd_set_mirror_link_result *res = parsed_result; 9661 struct rte_eth_mirror_conf mr_conf; 9662 9663 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9664 if (!strcmp(res->what, "uplink-mirror")) 9665 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 9666 else 9667 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 9668 9669 mr_conf.dst_pool = res->dstpool_id; 9670 9671 if (!strcmp(res->on, "on")) 9672 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9673 res->rule_id, 1); 9674 else 9675 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9676 res->rule_id, 0); 9677 9678 /* check the return value and print it if is < 0 */ 9679 if (ret < 0) 9680 fprintf(stderr, "mirror rule add error: (%s)\n", 9681 strerror(-ret)); 9682 9683 } 9684 9685 cmdline_parse_inst_t cmd_set_mirror_link = { 9686 .f = cmd_set_mirror_link_parsed, 9687 .data = NULL, 9688 .help_str = "set port <port_id> mirror-rule <rule_id> " 9689 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 9690 .tokens = { 9691 (void *)&cmd_mirror_link_set, 9692 (void *)&cmd_mirror_link_port, 9693 (void *)&cmd_mirror_link_portid, 9694 (void *)&cmd_mirror_link_mirror, 9695 (void *)&cmd_mirror_link_ruleid, 9696 (void *)&cmd_mirror_link_what, 9697 (void *)&cmd_mirror_link_dstpool, 9698 (void *)&cmd_mirror_link_poolid, 9699 (void *)&cmd_mirror_link_on, 9700 NULL, 9701 }, 9702 }; 9703 9704 /* *** RESET VM MIRROR RULE *** */ 9705 struct cmd_rm_mirror_rule_result { 9706 cmdline_fixed_string_t reset; 9707 cmdline_fixed_string_t port; 9708 portid_t port_id; 9709 cmdline_fixed_string_t mirror; 9710 uint8_t rule_id; 9711 }; 9712 9713 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 9714 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9715 reset, "reset"); 9716 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 9717 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9718 port, "port"); 9719 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 9720 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9721 port_id, RTE_UINT16); 9722 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 9723 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9724 mirror, "mirror-rule"); 9725 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 9726 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9727 rule_id, RTE_UINT8); 9728 9729 static void 9730 cmd_reset_mirror_rule_parsed(void *parsed_result, 9731 __rte_unused struct cmdline *cl, 9732 __rte_unused void *data) 9733 { 9734 int ret; 9735 struct cmd_set_mirror_link_result *res = parsed_result; 9736 /* check rule_id */ 9737 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 9738 if(ret < 0) 9739 fprintf(stderr, "mirror rule remove error: (%s)\n", 9740 strerror(-ret)); 9741 } 9742 9743 cmdline_parse_inst_t cmd_reset_mirror_rule = { 9744 .f = cmd_reset_mirror_rule_parsed, 9745 .data = NULL, 9746 .help_str = "reset port <port_id> mirror-rule <rule_id>", 9747 .tokens = { 9748 (void *)&cmd_rm_mirror_rule_reset, 9749 (void *)&cmd_rm_mirror_rule_port, 9750 (void *)&cmd_rm_mirror_rule_portid, 9751 (void *)&cmd_rm_mirror_rule_mirror, 9752 (void *)&cmd_rm_mirror_rule_ruleid, 9753 NULL, 9754 }, 9755 }; 9756 9757 /* ******************************************************************************** */ 9758 9759 struct cmd_dump_result { 9760 cmdline_fixed_string_t dump; 9761 }; 9762 9763 static void 9764 dump_struct_sizes(void) 9765 { 9766 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9767 DUMP_SIZE(struct rte_mbuf); 9768 DUMP_SIZE(struct rte_mempool); 9769 DUMP_SIZE(struct rte_ring); 9770 #undef DUMP_SIZE 9771 } 9772 9773 9774 /* Dump the socket memory statistics on console */ 9775 static void 9776 dump_socket_mem(FILE *f) 9777 { 9778 struct rte_malloc_socket_stats socket_stats; 9779 unsigned int i; 9780 size_t total = 0; 9781 size_t alloc = 0; 9782 size_t free = 0; 9783 unsigned int n_alloc = 0; 9784 unsigned int n_free = 0; 9785 static size_t last_allocs; 9786 static size_t last_total; 9787 9788 9789 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) { 9790 if (rte_malloc_get_socket_stats(i, &socket_stats) || 9791 !socket_stats.heap_totalsz_bytes) 9792 continue; 9793 total += socket_stats.heap_totalsz_bytes; 9794 alloc += socket_stats.heap_allocsz_bytes; 9795 free += socket_stats.heap_freesz_bytes; 9796 n_alloc += socket_stats.alloc_count; 9797 n_free += socket_stats.free_count; 9798 fprintf(f, 9799 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 9800 i, 9801 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024), 9802 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024), 9803 (double)socket_stats.heap_allocsz_bytes * 100 / 9804 (double)socket_stats.heap_totalsz_bytes, 9805 (double)socket_stats.heap_freesz_bytes / (1024 * 1024), 9806 socket_stats.alloc_count, 9807 socket_stats.free_count); 9808 } 9809 fprintf(f, 9810 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 9811 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024), 9812 total ? ((double)alloc * 100 / (double)total) : 0, 9813 (double)free / (1024 * 1024), 9814 n_alloc, n_free); 9815 if (last_allocs) 9816 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n", 9817 ((double)total - (double)last_total) / (1024 * 1024), 9818 (double)(alloc - (double)last_allocs) / 1024 / 1024); 9819 last_allocs = alloc; 9820 last_total = total; 9821 } 9822 9823 static void cmd_dump_parsed(void *parsed_result, 9824 __rte_unused struct cmdline *cl, 9825 __rte_unused void *data) 9826 { 9827 struct cmd_dump_result *res = parsed_result; 9828 9829 if (!strcmp(res->dump, "dump_physmem")) 9830 rte_dump_physmem_layout(stdout); 9831 else if (!strcmp(res->dump, "dump_socket_mem")) 9832 dump_socket_mem(stdout); 9833 else if (!strcmp(res->dump, "dump_memzone")) 9834 rte_memzone_dump(stdout); 9835 else if (!strcmp(res->dump, "dump_struct_sizes")) 9836 dump_struct_sizes(); 9837 else if (!strcmp(res->dump, "dump_ring")) 9838 rte_ring_list_dump(stdout); 9839 else if (!strcmp(res->dump, "dump_mempool")) 9840 rte_mempool_list_dump(stdout); 9841 else if (!strcmp(res->dump, "dump_devargs")) 9842 rte_devargs_dump(stdout); 9843 else if (!strcmp(res->dump, "dump_log_types")) 9844 rte_log_dump(stdout); 9845 } 9846 9847 cmdline_parse_token_string_t cmd_dump_dump = 9848 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9849 "dump_physmem#" 9850 "dump_memzone#" 9851 "dump_socket_mem#" 9852 "dump_struct_sizes#" 9853 "dump_ring#" 9854 "dump_mempool#" 9855 "dump_devargs#" 9856 "dump_log_types"); 9857 9858 cmdline_parse_inst_t cmd_dump = { 9859 .f = cmd_dump_parsed, /* function to call */ 9860 .data = NULL, /* 2nd arg of func */ 9861 .help_str = "Dump status", 9862 .tokens = { /* token list, NULL terminated */ 9863 (void *)&cmd_dump_dump, 9864 NULL, 9865 }, 9866 }; 9867 9868 /* ******************************************************************************** */ 9869 9870 struct cmd_dump_one_result { 9871 cmdline_fixed_string_t dump; 9872 cmdline_fixed_string_t name; 9873 }; 9874 9875 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9876 __rte_unused void *data) 9877 { 9878 struct cmd_dump_one_result *res = parsed_result; 9879 9880 if (!strcmp(res->dump, "dump_ring")) { 9881 struct rte_ring *r; 9882 r = rte_ring_lookup(res->name); 9883 if (r == NULL) { 9884 cmdline_printf(cl, "Cannot find ring\n"); 9885 return; 9886 } 9887 rte_ring_dump(stdout, r); 9888 } else if (!strcmp(res->dump, "dump_mempool")) { 9889 struct rte_mempool *mp; 9890 mp = rte_mempool_lookup(res->name); 9891 if (mp == NULL) { 9892 cmdline_printf(cl, "Cannot find mempool\n"); 9893 return; 9894 } 9895 rte_mempool_dump(stdout, mp); 9896 } 9897 } 9898 9899 cmdline_parse_token_string_t cmd_dump_one_dump = 9900 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9901 "dump_ring#dump_mempool"); 9902 9903 cmdline_parse_token_string_t cmd_dump_one_name = 9904 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9905 9906 cmdline_parse_inst_t cmd_dump_one = { 9907 .f = cmd_dump_one_parsed, /* function to call */ 9908 .data = NULL, /* 2nd arg of func */ 9909 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9910 .tokens = { /* token list, NULL terminated */ 9911 (void *)&cmd_dump_one_dump, 9912 (void *)&cmd_dump_one_name, 9913 NULL, 9914 }, 9915 }; 9916 9917 /* *** queue region set *** */ 9918 struct cmd_queue_region_result { 9919 cmdline_fixed_string_t set; 9920 cmdline_fixed_string_t port; 9921 portid_t port_id; 9922 cmdline_fixed_string_t cmd; 9923 cmdline_fixed_string_t region; 9924 uint8_t region_id; 9925 cmdline_fixed_string_t queue_start_index; 9926 uint8_t queue_id; 9927 cmdline_fixed_string_t queue_num; 9928 uint8_t queue_num_value; 9929 }; 9930 9931 static void 9932 cmd_queue_region_parsed(void *parsed_result, 9933 __rte_unused struct cmdline *cl, 9934 __rte_unused void *data) 9935 { 9936 struct cmd_queue_region_result *res = parsed_result; 9937 int ret = -ENOTSUP; 9938 #ifdef RTE_NET_I40E 9939 struct rte_pmd_i40e_queue_region_conf region_conf; 9940 enum rte_pmd_i40e_queue_region_op op_type; 9941 #endif 9942 9943 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9944 return; 9945 9946 #ifdef RTE_NET_I40E 9947 memset(®ion_conf, 0, sizeof(region_conf)); 9948 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 9949 region_conf.region_id = res->region_id; 9950 region_conf.queue_num = res->queue_num_value; 9951 region_conf.queue_start_index = res->queue_id; 9952 9953 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9954 op_type, ®ion_conf); 9955 #endif 9956 9957 switch (ret) { 9958 case 0: 9959 break; 9960 case -ENOTSUP: 9961 fprintf(stderr, "function not implemented or supported\n"); 9962 break; 9963 default: 9964 fprintf(stderr, "queue region config error: (%s)\n", 9965 strerror(-ret)); 9966 } 9967 } 9968 9969 cmdline_parse_token_string_t cmd_queue_region_set = 9970 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9971 set, "set"); 9972 cmdline_parse_token_string_t cmd_queue_region_port = 9973 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 9974 cmdline_parse_token_num_t cmd_queue_region_port_id = 9975 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9976 port_id, RTE_UINT16); 9977 cmdline_parse_token_string_t cmd_queue_region_cmd = 9978 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9979 cmd, "queue-region"); 9980 cmdline_parse_token_string_t cmd_queue_region_id = 9981 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9982 region, "region_id"); 9983 cmdline_parse_token_num_t cmd_queue_region_index = 9984 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9985 region_id, RTE_UINT8); 9986 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 9987 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9988 queue_start_index, "queue_start_index"); 9989 cmdline_parse_token_num_t cmd_queue_region_queue_id = 9990 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9991 queue_id, RTE_UINT8); 9992 cmdline_parse_token_string_t cmd_queue_region_queue_num = 9993 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9994 queue_num, "queue_num"); 9995 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 9996 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9997 queue_num_value, RTE_UINT8); 9998 9999 cmdline_parse_inst_t cmd_queue_region = { 10000 .f = cmd_queue_region_parsed, 10001 .data = NULL, 10002 .help_str = "set port <port_id> queue-region region_id <value> " 10003 "queue_start_index <value> queue_num <value>: Set a queue region", 10004 .tokens = { 10005 (void *)&cmd_queue_region_set, 10006 (void *)&cmd_queue_region_port, 10007 (void *)&cmd_queue_region_port_id, 10008 (void *)&cmd_queue_region_cmd, 10009 (void *)&cmd_queue_region_id, 10010 (void *)&cmd_queue_region_index, 10011 (void *)&cmd_queue_region_queue_start_index, 10012 (void *)&cmd_queue_region_queue_id, 10013 (void *)&cmd_queue_region_queue_num, 10014 (void *)&cmd_queue_region_queue_num_value, 10015 NULL, 10016 }, 10017 }; 10018 10019 /* *** queue region and flowtype set *** */ 10020 struct cmd_region_flowtype_result { 10021 cmdline_fixed_string_t set; 10022 cmdline_fixed_string_t port; 10023 portid_t port_id; 10024 cmdline_fixed_string_t cmd; 10025 cmdline_fixed_string_t region; 10026 uint8_t region_id; 10027 cmdline_fixed_string_t flowtype; 10028 uint8_t flowtype_id; 10029 }; 10030 10031 static void 10032 cmd_region_flowtype_parsed(void *parsed_result, 10033 __rte_unused struct cmdline *cl, 10034 __rte_unused void *data) 10035 { 10036 struct cmd_region_flowtype_result *res = parsed_result; 10037 int ret = -ENOTSUP; 10038 #ifdef RTE_NET_I40E 10039 struct rte_pmd_i40e_queue_region_conf region_conf; 10040 enum rte_pmd_i40e_queue_region_op op_type; 10041 #endif 10042 10043 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10044 return; 10045 10046 #ifdef RTE_NET_I40E 10047 memset(®ion_conf, 0, sizeof(region_conf)); 10048 10049 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 10050 region_conf.region_id = res->region_id; 10051 region_conf.hw_flowtype = res->flowtype_id; 10052 10053 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10054 op_type, ®ion_conf); 10055 #endif 10056 10057 switch (ret) { 10058 case 0: 10059 break; 10060 case -ENOTSUP: 10061 fprintf(stderr, "function not implemented or supported\n"); 10062 break; 10063 default: 10064 fprintf(stderr, "region flowtype config error: (%s)\n", 10065 strerror(-ret)); 10066 } 10067 } 10068 10069 cmdline_parse_token_string_t cmd_region_flowtype_set = 10070 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 10071 set, "set"); 10072 cmdline_parse_token_string_t cmd_region_flowtype_port = 10073 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 10074 port, "port"); 10075 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 10076 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 10077 port_id, RTE_UINT16); 10078 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 10079 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 10080 cmd, "queue-region"); 10081 cmdline_parse_token_string_t cmd_region_flowtype_index = 10082 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 10083 region, "region_id"); 10084 cmdline_parse_token_num_t cmd_region_flowtype_id = 10085 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 10086 region_id, RTE_UINT8); 10087 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 10088 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 10089 flowtype, "flowtype"); 10090 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 10091 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 10092 flowtype_id, RTE_UINT8); 10093 cmdline_parse_inst_t cmd_region_flowtype = { 10094 .f = cmd_region_flowtype_parsed, 10095 .data = NULL, 10096 .help_str = "set port <port_id> queue-region region_id <value> " 10097 "flowtype <value>: Set a flowtype region index", 10098 .tokens = { 10099 (void *)&cmd_region_flowtype_set, 10100 (void *)&cmd_region_flowtype_port, 10101 (void *)&cmd_region_flowtype_port_index, 10102 (void *)&cmd_region_flowtype_cmd, 10103 (void *)&cmd_region_flowtype_index, 10104 (void *)&cmd_region_flowtype_id, 10105 (void *)&cmd_region_flowtype_flow_index, 10106 (void *)&cmd_region_flowtype_flow_id, 10107 NULL, 10108 }, 10109 }; 10110 10111 /* *** User Priority (UP) to queue region (region_id) set *** */ 10112 struct cmd_user_priority_region_result { 10113 cmdline_fixed_string_t set; 10114 cmdline_fixed_string_t port; 10115 portid_t port_id; 10116 cmdline_fixed_string_t cmd; 10117 cmdline_fixed_string_t user_priority; 10118 uint8_t user_priority_id; 10119 cmdline_fixed_string_t region; 10120 uint8_t region_id; 10121 }; 10122 10123 static void 10124 cmd_user_priority_region_parsed(void *parsed_result, 10125 __rte_unused struct cmdline *cl, 10126 __rte_unused void *data) 10127 { 10128 struct cmd_user_priority_region_result *res = parsed_result; 10129 int ret = -ENOTSUP; 10130 #ifdef RTE_NET_I40E 10131 struct rte_pmd_i40e_queue_region_conf region_conf; 10132 enum rte_pmd_i40e_queue_region_op op_type; 10133 #endif 10134 10135 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10136 return; 10137 10138 #ifdef RTE_NET_I40E 10139 memset(®ion_conf, 0, sizeof(region_conf)); 10140 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 10141 region_conf.user_priority = res->user_priority_id; 10142 region_conf.region_id = res->region_id; 10143 10144 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10145 op_type, ®ion_conf); 10146 #endif 10147 10148 switch (ret) { 10149 case 0: 10150 break; 10151 case -ENOTSUP: 10152 fprintf(stderr, "function not implemented or supported\n"); 10153 break; 10154 default: 10155 fprintf(stderr, "user_priority region config error: (%s)\n", 10156 strerror(-ret)); 10157 } 10158 } 10159 10160 cmdline_parse_token_string_t cmd_user_priority_region_set = 10161 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10162 set, "set"); 10163 cmdline_parse_token_string_t cmd_user_priority_region_port = 10164 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10165 port, "port"); 10166 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 10167 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10168 port_id, RTE_UINT16); 10169 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 10170 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10171 cmd, "queue-region"); 10172 cmdline_parse_token_string_t cmd_user_priority_region_UP = 10173 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10174 user_priority, "UP"); 10175 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 10176 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10177 user_priority_id, RTE_UINT8); 10178 cmdline_parse_token_string_t cmd_user_priority_region_region = 10179 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10180 region, "region_id"); 10181 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 10182 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10183 region_id, RTE_UINT8); 10184 10185 cmdline_parse_inst_t cmd_user_priority_region = { 10186 .f = cmd_user_priority_region_parsed, 10187 .data = NULL, 10188 .help_str = "set port <port_id> queue-region UP <value> " 10189 "region_id <value>: Set the mapping of User Priority (UP) " 10190 "to queue region (region_id) ", 10191 .tokens = { 10192 (void *)&cmd_user_priority_region_set, 10193 (void *)&cmd_user_priority_region_port, 10194 (void *)&cmd_user_priority_region_port_index, 10195 (void *)&cmd_user_priority_region_cmd, 10196 (void *)&cmd_user_priority_region_UP, 10197 (void *)&cmd_user_priority_region_UP_id, 10198 (void *)&cmd_user_priority_region_region, 10199 (void *)&cmd_user_priority_region_region_id, 10200 NULL, 10201 }, 10202 }; 10203 10204 /* *** flush all queue region related configuration *** */ 10205 struct cmd_flush_queue_region_result { 10206 cmdline_fixed_string_t set; 10207 cmdline_fixed_string_t port; 10208 portid_t port_id; 10209 cmdline_fixed_string_t cmd; 10210 cmdline_fixed_string_t flush; 10211 cmdline_fixed_string_t what; 10212 }; 10213 10214 static void 10215 cmd_flush_queue_region_parsed(void *parsed_result, 10216 __rte_unused struct cmdline *cl, 10217 __rte_unused void *data) 10218 { 10219 struct cmd_flush_queue_region_result *res = parsed_result; 10220 int ret = -ENOTSUP; 10221 #ifdef RTE_NET_I40E 10222 struct rte_pmd_i40e_queue_region_conf region_conf; 10223 enum rte_pmd_i40e_queue_region_op op_type; 10224 #endif 10225 10226 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10227 return; 10228 10229 #ifdef RTE_NET_I40E 10230 memset(®ion_conf, 0, sizeof(region_conf)); 10231 10232 if (strcmp(res->what, "on") == 0) 10233 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 10234 else 10235 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 10236 10237 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10238 op_type, ®ion_conf); 10239 #endif 10240 10241 switch (ret) { 10242 case 0: 10243 break; 10244 case -ENOTSUP: 10245 fprintf(stderr, "function not implemented or supported\n"); 10246 break; 10247 default: 10248 fprintf(stderr, "queue region config flush error: (%s)\n", 10249 strerror(-ret)); 10250 } 10251 } 10252 10253 cmdline_parse_token_string_t cmd_flush_queue_region_set = 10254 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10255 set, "set"); 10256 cmdline_parse_token_string_t cmd_flush_queue_region_port = 10257 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10258 port, "port"); 10259 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 10260 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 10261 port_id, RTE_UINT16); 10262 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 10263 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10264 cmd, "queue-region"); 10265 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 10266 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10267 flush, "flush"); 10268 cmdline_parse_token_string_t cmd_flush_queue_region_what = 10269 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10270 what, "on#off"); 10271 10272 cmdline_parse_inst_t cmd_flush_queue_region = { 10273 .f = cmd_flush_queue_region_parsed, 10274 .data = NULL, 10275 .help_str = "set port <port_id> queue-region flush on|off" 10276 ": flush all queue region related configuration", 10277 .tokens = { 10278 (void *)&cmd_flush_queue_region_set, 10279 (void *)&cmd_flush_queue_region_port, 10280 (void *)&cmd_flush_queue_region_port_index, 10281 (void *)&cmd_flush_queue_region_cmd, 10282 (void *)&cmd_flush_queue_region_flush, 10283 (void *)&cmd_flush_queue_region_what, 10284 NULL, 10285 }, 10286 }; 10287 10288 /* *** get all queue region related configuration info *** */ 10289 struct cmd_show_queue_region_info { 10290 cmdline_fixed_string_t show; 10291 cmdline_fixed_string_t port; 10292 portid_t port_id; 10293 cmdline_fixed_string_t cmd; 10294 }; 10295 10296 static void 10297 cmd_show_queue_region_info_parsed(void *parsed_result, 10298 __rte_unused struct cmdline *cl, 10299 __rte_unused void *data) 10300 { 10301 struct cmd_show_queue_region_info *res = parsed_result; 10302 int ret = -ENOTSUP; 10303 #ifdef RTE_NET_I40E 10304 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 10305 enum rte_pmd_i40e_queue_region_op op_type; 10306 #endif 10307 10308 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10309 return; 10310 10311 #ifdef RTE_NET_I40E 10312 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 10313 10314 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 10315 10316 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10317 op_type, &rte_pmd_regions); 10318 10319 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 10320 #endif 10321 10322 switch (ret) { 10323 case 0: 10324 break; 10325 case -ENOTSUP: 10326 fprintf(stderr, "function not implemented or supported\n"); 10327 break; 10328 default: 10329 fprintf(stderr, "queue region config info show error: (%s)\n", 10330 strerror(-ret)); 10331 } 10332 } 10333 10334 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 10335 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10336 show, "show"); 10337 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 10338 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10339 port, "port"); 10340 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 10341 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 10342 port_id, RTE_UINT16); 10343 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 10344 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10345 cmd, "queue-region"); 10346 10347 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 10348 .f = cmd_show_queue_region_info_parsed, 10349 .data = NULL, 10350 .help_str = "show port <port_id> queue-region" 10351 ": show all queue region related configuration info", 10352 .tokens = { 10353 (void *)&cmd_show_queue_region_info_get, 10354 (void *)&cmd_show_queue_region_info_port, 10355 (void *)&cmd_show_queue_region_info_port_index, 10356 (void *)&cmd_show_queue_region_info_cmd, 10357 NULL, 10358 }, 10359 }; 10360 10361 /* *** Filters Control *** */ 10362 10363 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10364 do { \ 10365 if ((ip_addr).family == AF_INET) \ 10366 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10367 else { \ 10368 fprintf(stderr, "invalid parameter.\n"); \ 10369 return; \ 10370 } \ 10371 } while (0) 10372 10373 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10374 do { \ 10375 if ((ip_addr).family == AF_INET6) \ 10376 rte_memcpy(&(ip), \ 10377 &((ip_addr).addr.ipv6), \ 10378 sizeof(struct in6_addr)); \ 10379 else { \ 10380 fprintf(stderr, "invalid parameter.\n"); \ 10381 return; \ 10382 } \ 10383 } while (0) 10384 10385 #ifdef RTE_NET_I40E 10386 10387 static uint16_t 10388 str2flowtype(char *string) 10389 { 10390 uint8_t i = 0; 10391 static const struct { 10392 char str[32]; 10393 uint16_t type; 10394 } flowtype_str[] = { 10395 {"raw", RTE_ETH_FLOW_RAW}, 10396 {"ipv4", RTE_ETH_FLOW_IPV4}, 10397 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10398 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10399 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10400 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10401 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10402 {"ipv6", RTE_ETH_FLOW_IPV6}, 10403 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10404 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10405 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10406 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10407 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10408 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10409 }; 10410 10411 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10412 if (!strcmp(flowtype_str[i].str, string)) 10413 return flowtype_str[i].type; 10414 } 10415 10416 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10417 return (uint16_t)atoi(string); 10418 10419 return RTE_ETH_FLOW_UNKNOWN; 10420 } 10421 10422 /* *** deal with flow director filter *** */ 10423 struct cmd_flow_director_result { 10424 cmdline_fixed_string_t flow_director_filter; 10425 portid_t port_id; 10426 cmdline_fixed_string_t mode; 10427 cmdline_fixed_string_t mode_value; 10428 cmdline_fixed_string_t ops; 10429 cmdline_fixed_string_t flow; 10430 cmdline_fixed_string_t flow_type; 10431 cmdline_fixed_string_t drop; 10432 cmdline_fixed_string_t queue; 10433 uint16_t queue_id; 10434 cmdline_fixed_string_t fd_id; 10435 uint32_t fd_id_value; 10436 cmdline_fixed_string_t packet; 10437 char filepath[]; 10438 }; 10439 10440 static void 10441 cmd_flow_director_filter_parsed(void *parsed_result, 10442 __rte_unused struct cmdline *cl, 10443 __rte_unused void *data) 10444 { 10445 struct cmd_flow_director_result *res = parsed_result; 10446 int ret = 0; 10447 struct rte_pmd_i40e_flow_type_mapping 10448 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 10449 struct rte_pmd_i40e_pkt_template_conf conf; 10450 uint16_t flow_type = str2flowtype(res->flow_type); 10451 uint16_t i, port = res->port_id; 10452 uint8_t add; 10453 10454 memset(&conf, 0, sizeof(conf)); 10455 10456 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 10457 fprintf(stderr, "Invalid flow type specified.\n"); 10458 return; 10459 } 10460 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 10461 mapping); 10462 if (ret) 10463 return; 10464 if (mapping[flow_type].pctype == 0ULL) { 10465 fprintf(stderr, "Invalid flow type specified.\n"); 10466 return; 10467 } 10468 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 10469 if (mapping[flow_type].pctype & (1ULL << i)) { 10470 conf.input.pctype = i; 10471 break; 10472 } 10473 } 10474 10475 conf.input.packet = open_file(res->filepath, 10476 &conf.input.length); 10477 if (!conf.input.packet) 10478 return; 10479 if (!strcmp(res->drop, "drop")) 10480 conf.action.behavior = 10481 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 10482 else 10483 conf.action.behavior = 10484 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 10485 conf.action.report_status = 10486 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 10487 conf.action.rx_queue = res->queue_id; 10488 conf.soft_id = res->fd_id_value; 10489 add = strcmp(res->ops, "del") ? 1 : 0; 10490 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 10491 &conf, 10492 add); 10493 if (ret < 0) 10494 fprintf(stderr, "flow director config error: (%s)\n", 10495 strerror(-ret)); 10496 close_file(conf.input.packet); 10497 } 10498 10499 cmdline_parse_token_string_t cmd_flow_director_filter = 10500 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10501 flow_director_filter, "flow_director_filter"); 10502 cmdline_parse_token_num_t cmd_flow_director_port_id = 10503 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10504 port_id, RTE_UINT16); 10505 cmdline_parse_token_string_t cmd_flow_director_ops = 10506 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10507 ops, "add#del#update"); 10508 cmdline_parse_token_string_t cmd_flow_director_flow = 10509 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10510 flow, "flow"); 10511 cmdline_parse_token_string_t cmd_flow_director_flow_type = 10512 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10513 flow_type, NULL); 10514 cmdline_parse_token_string_t cmd_flow_director_drop = 10515 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10516 drop, "drop#fwd"); 10517 cmdline_parse_token_string_t cmd_flow_director_queue = 10518 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10519 queue, "queue"); 10520 cmdline_parse_token_num_t cmd_flow_director_queue_id = 10521 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10522 queue_id, RTE_UINT16); 10523 cmdline_parse_token_string_t cmd_flow_director_fd_id = 10524 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10525 fd_id, "fd_id"); 10526 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 10527 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10528 fd_id_value, RTE_UINT32); 10529 10530 cmdline_parse_token_string_t cmd_flow_director_mode = 10531 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10532 mode, "mode"); 10533 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 10534 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10535 mode_value, "raw"); 10536 cmdline_parse_token_string_t cmd_flow_director_packet = 10537 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10538 packet, "packet"); 10539 cmdline_parse_token_string_t cmd_flow_director_filepath = 10540 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10541 filepath, NULL); 10542 10543 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 10544 .f = cmd_flow_director_filter_parsed, 10545 .data = NULL, 10546 .help_str = "flow_director_filter ... : Add or delete a raw flow " 10547 "director entry on NIC", 10548 .tokens = { 10549 (void *)&cmd_flow_director_filter, 10550 (void *)&cmd_flow_director_port_id, 10551 (void *)&cmd_flow_director_mode, 10552 (void *)&cmd_flow_director_mode_raw, 10553 (void *)&cmd_flow_director_ops, 10554 (void *)&cmd_flow_director_flow, 10555 (void *)&cmd_flow_director_flow_type, 10556 (void *)&cmd_flow_director_drop, 10557 (void *)&cmd_flow_director_queue, 10558 (void *)&cmd_flow_director_queue_id, 10559 (void *)&cmd_flow_director_fd_id, 10560 (void *)&cmd_flow_director_fd_id_value, 10561 (void *)&cmd_flow_director_packet, 10562 (void *)&cmd_flow_director_filepath, 10563 NULL, 10564 }, 10565 }; 10566 10567 #endif /* RTE_NET_I40E */ 10568 10569 /* *** deal with flow director mask *** */ 10570 struct cmd_flow_director_mask_result { 10571 cmdline_fixed_string_t flow_director_mask; 10572 portid_t port_id; 10573 cmdline_fixed_string_t mode; 10574 cmdline_fixed_string_t mode_value; 10575 cmdline_fixed_string_t vlan; 10576 uint16_t vlan_mask; 10577 cmdline_fixed_string_t src_mask; 10578 cmdline_ipaddr_t ipv4_src; 10579 cmdline_ipaddr_t ipv6_src; 10580 uint16_t port_src; 10581 cmdline_fixed_string_t dst_mask; 10582 cmdline_ipaddr_t ipv4_dst; 10583 cmdline_ipaddr_t ipv6_dst; 10584 uint16_t port_dst; 10585 cmdline_fixed_string_t mac; 10586 uint8_t mac_addr_byte_mask; 10587 cmdline_fixed_string_t tunnel_id; 10588 uint32_t tunnel_id_mask; 10589 cmdline_fixed_string_t tunnel_type; 10590 uint8_t tunnel_type_mask; 10591 }; 10592 10593 static void 10594 cmd_flow_director_mask_parsed(void *parsed_result, 10595 __rte_unused struct cmdline *cl, 10596 __rte_unused void *data) 10597 { 10598 struct cmd_flow_director_mask_result *res = parsed_result; 10599 struct rte_eth_fdir_masks *mask; 10600 struct rte_port *port; 10601 10602 port = &ports[res->port_id]; 10603 /** Check if the port is not started **/ 10604 if (port->port_status != RTE_PORT_STOPPED) { 10605 fprintf(stderr, "Please stop port %d first\n", res->port_id); 10606 return; 10607 } 10608 10609 mask = &port->dev_conf.fdir_conf.mask; 10610 10611 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10612 if (strcmp(res->mode_value, "MAC-VLAN")) { 10613 fprintf(stderr, "Please set mode to MAC-VLAN.\n"); 10614 return; 10615 } 10616 10617 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10618 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10619 if (strcmp(res->mode_value, "Tunnel")) { 10620 fprintf(stderr, "Please set mode to Tunnel.\n"); 10621 return; 10622 } 10623 10624 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10625 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 10626 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 10627 mask->tunnel_type_mask = res->tunnel_type_mask; 10628 } else { 10629 if (strcmp(res->mode_value, "IP")) { 10630 fprintf(stderr, "Please set mode to IP.\n"); 10631 return; 10632 } 10633 10634 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10635 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 10636 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 10637 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 10638 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 10639 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 10640 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 10641 } 10642 10643 cmd_reconfig_device_queue(res->port_id, 1, 1); 10644 } 10645 10646 cmdline_parse_token_string_t cmd_flow_director_mask = 10647 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10648 flow_director_mask, "flow_director_mask"); 10649 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 10650 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10651 port_id, RTE_UINT16); 10652 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 10653 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10654 vlan, "vlan"); 10655 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 10656 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10657 vlan_mask, RTE_UINT16); 10658 cmdline_parse_token_string_t cmd_flow_director_mask_src = 10659 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10660 src_mask, "src_mask"); 10661 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 10662 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10663 ipv4_src); 10664 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 10665 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10666 ipv6_src); 10667 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 10668 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10669 port_src, RTE_UINT16); 10670 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 10671 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10672 dst_mask, "dst_mask"); 10673 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 10674 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10675 ipv4_dst); 10676 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 10677 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10678 ipv6_dst); 10679 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 10680 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10681 port_dst, RTE_UINT16); 10682 10683 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 10684 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10685 mode, "mode"); 10686 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 10687 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10688 mode_value, "IP"); 10689 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 10690 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10691 mode_value, "MAC-VLAN"); 10692 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 10693 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10694 mode_value, "Tunnel"); 10695 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 10696 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10697 mac, "mac"); 10698 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 10699 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10700 mac_addr_byte_mask, RTE_UINT8); 10701 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 10702 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10703 tunnel_type, "tunnel-type"); 10704 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 10705 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10706 tunnel_type_mask, RTE_UINT8); 10707 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 10708 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10709 tunnel_id, "tunnel-id"); 10710 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 10711 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10712 tunnel_id_mask, RTE_UINT32); 10713 10714 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 10715 .f = cmd_flow_director_mask_parsed, 10716 .data = NULL, 10717 .help_str = "flow_director_mask ... : " 10718 "Set IP mode flow director's mask on NIC", 10719 .tokens = { 10720 (void *)&cmd_flow_director_mask, 10721 (void *)&cmd_flow_director_mask_port_id, 10722 (void *)&cmd_flow_director_mask_mode, 10723 (void *)&cmd_flow_director_mask_mode_ip, 10724 (void *)&cmd_flow_director_mask_vlan, 10725 (void *)&cmd_flow_director_mask_vlan_value, 10726 (void *)&cmd_flow_director_mask_src, 10727 (void *)&cmd_flow_director_mask_ipv4_src, 10728 (void *)&cmd_flow_director_mask_ipv6_src, 10729 (void *)&cmd_flow_director_mask_port_src, 10730 (void *)&cmd_flow_director_mask_dst, 10731 (void *)&cmd_flow_director_mask_ipv4_dst, 10732 (void *)&cmd_flow_director_mask_ipv6_dst, 10733 (void *)&cmd_flow_director_mask_port_dst, 10734 NULL, 10735 }, 10736 }; 10737 10738 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 10739 .f = cmd_flow_director_mask_parsed, 10740 .data = NULL, 10741 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 10742 "flow director's mask on NIC", 10743 .tokens = { 10744 (void *)&cmd_flow_director_mask, 10745 (void *)&cmd_flow_director_mask_port_id, 10746 (void *)&cmd_flow_director_mask_mode, 10747 (void *)&cmd_flow_director_mask_mode_mac_vlan, 10748 (void *)&cmd_flow_director_mask_vlan, 10749 (void *)&cmd_flow_director_mask_vlan_value, 10750 NULL, 10751 }, 10752 }; 10753 10754 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 10755 .f = cmd_flow_director_mask_parsed, 10756 .data = NULL, 10757 .help_str = "flow_director_mask ... : Set tunnel mode " 10758 "flow director's mask on NIC", 10759 .tokens = { 10760 (void *)&cmd_flow_director_mask, 10761 (void *)&cmd_flow_director_mask_port_id, 10762 (void *)&cmd_flow_director_mask_mode, 10763 (void *)&cmd_flow_director_mask_mode_tunnel, 10764 (void *)&cmd_flow_director_mask_vlan, 10765 (void *)&cmd_flow_director_mask_vlan_value, 10766 (void *)&cmd_flow_director_mask_mac, 10767 (void *)&cmd_flow_director_mask_mac_value, 10768 (void *)&cmd_flow_director_mask_tunnel_type, 10769 (void *)&cmd_flow_director_mask_tunnel_type_value, 10770 (void *)&cmd_flow_director_mask_tunnel_id, 10771 (void *)&cmd_flow_director_mask_tunnel_id_value, 10772 NULL, 10773 }, 10774 }; 10775 10776 /* *** deal with flow director flexible payload configuration *** */ 10777 struct cmd_flow_director_flexpayload_result { 10778 cmdline_fixed_string_t flow_director_flexpayload; 10779 portid_t port_id; 10780 cmdline_fixed_string_t payload_layer; 10781 cmdline_fixed_string_t payload_cfg; 10782 }; 10783 10784 static inline int 10785 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 10786 { 10787 char s[256]; 10788 const char *p, *p0 = q_arg; 10789 char *end; 10790 unsigned long int_fld; 10791 char *str_fld[max_num]; 10792 int i; 10793 unsigned size; 10794 int ret = -1; 10795 10796 p = strchr(p0, '('); 10797 if (p == NULL) 10798 return -1; 10799 ++p; 10800 p0 = strchr(p, ')'); 10801 if (p0 == NULL) 10802 return -1; 10803 10804 size = p0 - p; 10805 if (size >= sizeof(s)) 10806 return -1; 10807 10808 snprintf(s, sizeof(s), "%.*s", size, p); 10809 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10810 if (ret < 0 || ret > max_num) 10811 return -1; 10812 for (i = 0; i < ret; i++) { 10813 errno = 0; 10814 int_fld = strtoul(str_fld[i], &end, 0); 10815 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 10816 return -1; 10817 offsets[i] = (uint16_t)int_fld; 10818 } 10819 return ret; 10820 } 10821 10822 static void 10823 cmd_flow_director_flxpld_parsed(void *parsed_result, 10824 __rte_unused struct cmdline *cl, 10825 __rte_unused void *data) 10826 { 10827 struct cmd_flow_director_flexpayload_result *res = parsed_result; 10828 struct rte_eth_flex_payload_cfg flex_cfg; 10829 struct rte_port *port; 10830 int ret = 0; 10831 10832 port = &ports[res->port_id]; 10833 /** Check if the port is not started **/ 10834 if (port->port_status != RTE_PORT_STOPPED) { 10835 fprintf(stderr, "Please stop port %d first\n", res->port_id); 10836 return; 10837 } 10838 10839 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 10840 10841 if (!strcmp(res->payload_layer, "raw")) 10842 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 10843 else if (!strcmp(res->payload_layer, "l2")) 10844 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 10845 else if (!strcmp(res->payload_layer, "l3")) 10846 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 10847 else if (!strcmp(res->payload_layer, "l4")) 10848 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 10849 10850 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 10851 RTE_ETH_FDIR_MAX_FLEXLEN); 10852 if (ret < 0) { 10853 fprintf(stderr, "error: Cannot parse flex payload input.\n"); 10854 return; 10855 } 10856 10857 fdir_set_flex_payload(res->port_id, &flex_cfg); 10858 cmd_reconfig_device_queue(res->port_id, 1, 1); 10859 } 10860 10861 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 10862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10863 flow_director_flexpayload, 10864 "flow_director_flex_payload"); 10865 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 10866 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10867 port_id, RTE_UINT16); 10868 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 10869 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10870 payload_layer, "raw#l2#l3#l4"); 10871 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 10872 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10873 payload_cfg, NULL); 10874 10875 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 10876 .f = cmd_flow_director_flxpld_parsed, 10877 .data = NULL, 10878 .help_str = "flow_director_flexpayload ... : " 10879 "Set flow director's flex payload on NIC", 10880 .tokens = { 10881 (void *)&cmd_flow_director_flexpayload, 10882 (void *)&cmd_flow_director_flexpayload_port_id, 10883 (void *)&cmd_flow_director_flexpayload_payload_layer, 10884 (void *)&cmd_flow_director_flexpayload_payload_cfg, 10885 NULL, 10886 }, 10887 }; 10888 10889 /* Generic flow interface command. */ 10890 extern cmdline_parse_inst_t cmd_flow; 10891 10892 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 10893 struct cmd_mcast_addr_result { 10894 cmdline_fixed_string_t mcast_addr_cmd; 10895 cmdline_fixed_string_t what; 10896 uint16_t port_num; 10897 struct rte_ether_addr mc_addr; 10898 }; 10899 10900 static void cmd_mcast_addr_parsed(void *parsed_result, 10901 __rte_unused struct cmdline *cl, 10902 __rte_unused void *data) 10903 { 10904 struct cmd_mcast_addr_result *res = parsed_result; 10905 10906 if (!rte_is_multicast_ether_addr(&res->mc_addr)) { 10907 fprintf(stderr, 10908 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n", 10909 RTE_ETHER_ADDR_BYTES(&res->mc_addr)); 10910 return; 10911 } 10912 if (strcmp(res->what, "add") == 0) 10913 mcast_addr_add(res->port_num, &res->mc_addr); 10914 else 10915 mcast_addr_remove(res->port_num, &res->mc_addr); 10916 } 10917 10918 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 10919 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 10920 mcast_addr_cmd, "mcast_addr"); 10921 cmdline_parse_token_string_t cmd_mcast_addr_what = 10922 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 10923 "add#remove"); 10924 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 10925 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, 10926 RTE_UINT16); 10927 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 10928 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 10929 10930 cmdline_parse_inst_t cmd_mcast_addr = { 10931 .f = cmd_mcast_addr_parsed, 10932 .data = (void *)0, 10933 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 10934 "Add/Remove multicast MAC address on port_id", 10935 .tokens = { 10936 (void *)&cmd_mcast_addr_cmd, 10937 (void *)&cmd_mcast_addr_what, 10938 (void *)&cmd_mcast_addr_portnum, 10939 (void *)&cmd_mcast_addr_addr, 10940 NULL, 10941 }, 10942 }; 10943 10944 /* vf vlan anti spoof configuration */ 10945 10946 /* Common result structure for vf vlan anti spoof */ 10947 struct cmd_vf_vlan_anti_spoof_result { 10948 cmdline_fixed_string_t set; 10949 cmdline_fixed_string_t vf; 10950 cmdline_fixed_string_t vlan; 10951 cmdline_fixed_string_t antispoof; 10952 portid_t port_id; 10953 uint32_t vf_id; 10954 cmdline_fixed_string_t on_off; 10955 }; 10956 10957 /* Common CLI fields for vf vlan anti spoof enable disable */ 10958 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 10959 TOKEN_STRING_INITIALIZER 10960 (struct cmd_vf_vlan_anti_spoof_result, 10961 set, "set"); 10962 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 10963 TOKEN_STRING_INITIALIZER 10964 (struct cmd_vf_vlan_anti_spoof_result, 10965 vf, "vf"); 10966 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 10967 TOKEN_STRING_INITIALIZER 10968 (struct cmd_vf_vlan_anti_spoof_result, 10969 vlan, "vlan"); 10970 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 10971 TOKEN_STRING_INITIALIZER 10972 (struct cmd_vf_vlan_anti_spoof_result, 10973 antispoof, "antispoof"); 10974 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 10975 TOKEN_NUM_INITIALIZER 10976 (struct cmd_vf_vlan_anti_spoof_result, 10977 port_id, RTE_UINT16); 10978 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 10979 TOKEN_NUM_INITIALIZER 10980 (struct cmd_vf_vlan_anti_spoof_result, 10981 vf_id, RTE_UINT32); 10982 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 10983 TOKEN_STRING_INITIALIZER 10984 (struct cmd_vf_vlan_anti_spoof_result, 10985 on_off, "on#off"); 10986 10987 static void 10988 cmd_set_vf_vlan_anti_spoof_parsed( 10989 void *parsed_result, 10990 __rte_unused struct cmdline *cl, 10991 __rte_unused void *data) 10992 { 10993 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 10994 int ret = -ENOTSUP; 10995 10996 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 10997 10998 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10999 return; 11000 11001 #ifdef RTE_NET_IXGBE 11002 if (ret == -ENOTSUP) 11003 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 11004 res->vf_id, is_on); 11005 #endif 11006 #ifdef RTE_NET_I40E 11007 if (ret == -ENOTSUP) 11008 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 11009 res->vf_id, is_on); 11010 #endif 11011 #ifdef RTE_NET_BNXT 11012 if (ret == -ENOTSUP) 11013 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 11014 res->vf_id, is_on); 11015 #endif 11016 11017 switch (ret) { 11018 case 0: 11019 break; 11020 case -EINVAL: 11021 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 11022 break; 11023 case -ENODEV: 11024 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11025 break; 11026 case -ENOTSUP: 11027 fprintf(stderr, "function not implemented\n"); 11028 break; 11029 default: 11030 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11031 } 11032 } 11033 11034 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 11035 .f = cmd_set_vf_vlan_anti_spoof_parsed, 11036 .data = NULL, 11037 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 11038 .tokens = { 11039 (void *)&cmd_vf_vlan_anti_spoof_set, 11040 (void *)&cmd_vf_vlan_anti_spoof_vf, 11041 (void *)&cmd_vf_vlan_anti_spoof_vlan, 11042 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 11043 (void *)&cmd_vf_vlan_anti_spoof_port_id, 11044 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 11045 (void *)&cmd_vf_vlan_anti_spoof_on_off, 11046 NULL, 11047 }, 11048 }; 11049 11050 /* vf mac anti spoof configuration */ 11051 11052 /* Common result structure for vf mac anti spoof */ 11053 struct cmd_vf_mac_anti_spoof_result { 11054 cmdline_fixed_string_t set; 11055 cmdline_fixed_string_t vf; 11056 cmdline_fixed_string_t mac; 11057 cmdline_fixed_string_t antispoof; 11058 portid_t port_id; 11059 uint32_t vf_id; 11060 cmdline_fixed_string_t on_off; 11061 }; 11062 11063 /* Common CLI fields for vf mac anti spoof enable disable */ 11064 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 11065 TOKEN_STRING_INITIALIZER 11066 (struct cmd_vf_mac_anti_spoof_result, 11067 set, "set"); 11068 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 11069 TOKEN_STRING_INITIALIZER 11070 (struct cmd_vf_mac_anti_spoof_result, 11071 vf, "vf"); 11072 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 11073 TOKEN_STRING_INITIALIZER 11074 (struct cmd_vf_mac_anti_spoof_result, 11075 mac, "mac"); 11076 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 11077 TOKEN_STRING_INITIALIZER 11078 (struct cmd_vf_mac_anti_spoof_result, 11079 antispoof, "antispoof"); 11080 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 11081 TOKEN_NUM_INITIALIZER 11082 (struct cmd_vf_mac_anti_spoof_result, 11083 port_id, RTE_UINT16); 11084 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 11085 TOKEN_NUM_INITIALIZER 11086 (struct cmd_vf_mac_anti_spoof_result, 11087 vf_id, RTE_UINT32); 11088 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 11089 TOKEN_STRING_INITIALIZER 11090 (struct cmd_vf_mac_anti_spoof_result, 11091 on_off, "on#off"); 11092 11093 static void 11094 cmd_set_vf_mac_anti_spoof_parsed( 11095 void *parsed_result, 11096 __rte_unused struct cmdline *cl, 11097 __rte_unused void *data) 11098 { 11099 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 11100 int ret = -ENOTSUP; 11101 11102 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11103 11104 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11105 return; 11106 11107 #ifdef RTE_NET_IXGBE 11108 if (ret == -ENOTSUP) 11109 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 11110 res->vf_id, is_on); 11111 #endif 11112 #ifdef RTE_NET_I40E 11113 if (ret == -ENOTSUP) 11114 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 11115 res->vf_id, is_on); 11116 #endif 11117 #ifdef RTE_NET_BNXT 11118 if (ret == -ENOTSUP) 11119 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 11120 res->vf_id, is_on); 11121 #endif 11122 11123 switch (ret) { 11124 case 0: 11125 break; 11126 case -EINVAL: 11127 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 11128 res->vf_id, is_on); 11129 break; 11130 case -ENODEV: 11131 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11132 break; 11133 case -ENOTSUP: 11134 fprintf(stderr, "function not implemented\n"); 11135 break; 11136 default: 11137 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11138 } 11139 } 11140 11141 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 11142 .f = cmd_set_vf_mac_anti_spoof_parsed, 11143 .data = NULL, 11144 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 11145 .tokens = { 11146 (void *)&cmd_vf_mac_anti_spoof_set, 11147 (void *)&cmd_vf_mac_anti_spoof_vf, 11148 (void *)&cmd_vf_mac_anti_spoof_mac, 11149 (void *)&cmd_vf_mac_anti_spoof_antispoof, 11150 (void *)&cmd_vf_mac_anti_spoof_port_id, 11151 (void *)&cmd_vf_mac_anti_spoof_vf_id, 11152 (void *)&cmd_vf_mac_anti_spoof_on_off, 11153 NULL, 11154 }, 11155 }; 11156 11157 /* vf vlan strip queue configuration */ 11158 11159 /* Common result structure for vf mac anti spoof */ 11160 struct cmd_vf_vlan_stripq_result { 11161 cmdline_fixed_string_t set; 11162 cmdline_fixed_string_t vf; 11163 cmdline_fixed_string_t vlan; 11164 cmdline_fixed_string_t stripq; 11165 portid_t port_id; 11166 uint16_t vf_id; 11167 cmdline_fixed_string_t on_off; 11168 }; 11169 11170 /* Common CLI fields for vf vlan strip enable disable */ 11171 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 11172 TOKEN_STRING_INITIALIZER 11173 (struct cmd_vf_vlan_stripq_result, 11174 set, "set"); 11175 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 11176 TOKEN_STRING_INITIALIZER 11177 (struct cmd_vf_vlan_stripq_result, 11178 vf, "vf"); 11179 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 11180 TOKEN_STRING_INITIALIZER 11181 (struct cmd_vf_vlan_stripq_result, 11182 vlan, "vlan"); 11183 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 11184 TOKEN_STRING_INITIALIZER 11185 (struct cmd_vf_vlan_stripq_result, 11186 stripq, "stripq"); 11187 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 11188 TOKEN_NUM_INITIALIZER 11189 (struct cmd_vf_vlan_stripq_result, 11190 port_id, RTE_UINT16); 11191 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 11192 TOKEN_NUM_INITIALIZER 11193 (struct cmd_vf_vlan_stripq_result, 11194 vf_id, RTE_UINT16); 11195 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 11196 TOKEN_STRING_INITIALIZER 11197 (struct cmd_vf_vlan_stripq_result, 11198 on_off, "on#off"); 11199 11200 static void 11201 cmd_set_vf_vlan_stripq_parsed( 11202 void *parsed_result, 11203 __rte_unused struct cmdline *cl, 11204 __rte_unused void *data) 11205 { 11206 struct cmd_vf_vlan_stripq_result *res = parsed_result; 11207 int ret = -ENOTSUP; 11208 11209 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11210 11211 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11212 return; 11213 11214 #ifdef RTE_NET_IXGBE 11215 if (ret == -ENOTSUP) 11216 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 11217 res->vf_id, is_on); 11218 #endif 11219 #ifdef RTE_NET_I40E 11220 if (ret == -ENOTSUP) 11221 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 11222 res->vf_id, is_on); 11223 #endif 11224 #ifdef RTE_NET_BNXT 11225 if (ret == -ENOTSUP) 11226 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 11227 res->vf_id, is_on); 11228 #endif 11229 11230 switch (ret) { 11231 case 0: 11232 break; 11233 case -EINVAL: 11234 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 11235 res->vf_id, is_on); 11236 break; 11237 case -ENODEV: 11238 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11239 break; 11240 case -ENOTSUP: 11241 fprintf(stderr, "function not implemented\n"); 11242 break; 11243 default: 11244 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11245 } 11246 } 11247 11248 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 11249 .f = cmd_set_vf_vlan_stripq_parsed, 11250 .data = NULL, 11251 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 11252 .tokens = { 11253 (void *)&cmd_vf_vlan_stripq_set, 11254 (void *)&cmd_vf_vlan_stripq_vf, 11255 (void *)&cmd_vf_vlan_stripq_vlan, 11256 (void *)&cmd_vf_vlan_stripq_stripq, 11257 (void *)&cmd_vf_vlan_stripq_port_id, 11258 (void *)&cmd_vf_vlan_stripq_vf_id, 11259 (void *)&cmd_vf_vlan_stripq_on_off, 11260 NULL, 11261 }, 11262 }; 11263 11264 /* vf vlan insert configuration */ 11265 11266 /* Common result structure for vf vlan insert */ 11267 struct cmd_vf_vlan_insert_result { 11268 cmdline_fixed_string_t set; 11269 cmdline_fixed_string_t vf; 11270 cmdline_fixed_string_t vlan; 11271 cmdline_fixed_string_t insert; 11272 portid_t port_id; 11273 uint16_t vf_id; 11274 uint16_t vlan_id; 11275 }; 11276 11277 /* Common CLI fields for vf vlan insert enable disable */ 11278 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 11279 TOKEN_STRING_INITIALIZER 11280 (struct cmd_vf_vlan_insert_result, 11281 set, "set"); 11282 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 11283 TOKEN_STRING_INITIALIZER 11284 (struct cmd_vf_vlan_insert_result, 11285 vf, "vf"); 11286 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 11287 TOKEN_STRING_INITIALIZER 11288 (struct cmd_vf_vlan_insert_result, 11289 vlan, "vlan"); 11290 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 11291 TOKEN_STRING_INITIALIZER 11292 (struct cmd_vf_vlan_insert_result, 11293 insert, "insert"); 11294 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 11295 TOKEN_NUM_INITIALIZER 11296 (struct cmd_vf_vlan_insert_result, 11297 port_id, RTE_UINT16); 11298 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 11299 TOKEN_NUM_INITIALIZER 11300 (struct cmd_vf_vlan_insert_result, 11301 vf_id, RTE_UINT16); 11302 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 11303 TOKEN_NUM_INITIALIZER 11304 (struct cmd_vf_vlan_insert_result, 11305 vlan_id, RTE_UINT16); 11306 11307 static void 11308 cmd_set_vf_vlan_insert_parsed( 11309 void *parsed_result, 11310 __rte_unused struct cmdline *cl, 11311 __rte_unused void *data) 11312 { 11313 struct cmd_vf_vlan_insert_result *res = parsed_result; 11314 int ret = -ENOTSUP; 11315 11316 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11317 return; 11318 11319 #ifdef RTE_NET_IXGBE 11320 if (ret == -ENOTSUP) 11321 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 11322 res->vlan_id); 11323 #endif 11324 #ifdef RTE_NET_I40E 11325 if (ret == -ENOTSUP) 11326 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 11327 res->vlan_id); 11328 #endif 11329 #ifdef RTE_NET_BNXT 11330 if (ret == -ENOTSUP) 11331 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 11332 res->vlan_id); 11333 #endif 11334 11335 switch (ret) { 11336 case 0: 11337 break; 11338 case -EINVAL: 11339 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n", 11340 res->vf_id, res->vlan_id); 11341 break; 11342 case -ENODEV: 11343 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11344 break; 11345 case -ENOTSUP: 11346 fprintf(stderr, "function not implemented\n"); 11347 break; 11348 default: 11349 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11350 } 11351 } 11352 11353 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 11354 .f = cmd_set_vf_vlan_insert_parsed, 11355 .data = NULL, 11356 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 11357 .tokens = { 11358 (void *)&cmd_vf_vlan_insert_set, 11359 (void *)&cmd_vf_vlan_insert_vf, 11360 (void *)&cmd_vf_vlan_insert_vlan, 11361 (void *)&cmd_vf_vlan_insert_insert, 11362 (void *)&cmd_vf_vlan_insert_port_id, 11363 (void *)&cmd_vf_vlan_insert_vf_id, 11364 (void *)&cmd_vf_vlan_insert_vlan_id, 11365 NULL, 11366 }, 11367 }; 11368 11369 /* tx loopback configuration */ 11370 11371 /* Common result structure for tx loopback */ 11372 struct cmd_tx_loopback_result { 11373 cmdline_fixed_string_t set; 11374 cmdline_fixed_string_t tx; 11375 cmdline_fixed_string_t loopback; 11376 portid_t port_id; 11377 cmdline_fixed_string_t on_off; 11378 }; 11379 11380 /* Common CLI fields for tx loopback enable disable */ 11381 cmdline_parse_token_string_t cmd_tx_loopback_set = 11382 TOKEN_STRING_INITIALIZER 11383 (struct cmd_tx_loopback_result, 11384 set, "set"); 11385 cmdline_parse_token_string_t cmd_tx_loopback_tx = 11386 TOKEN_STRING_INITIALIZER 11387 (struct cmd_tx_loopback_result, 11388 tx, "tx"); 11389 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 11390 TOKEN_STRING_INITIALIZER 11391 (struct cmd_tx_loopback_result, 11392 loopback, "loopback"); 11393 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 11394 TOKEN_NUM_INITIALIZER 11395 (struct cmd_tx_loopback_result, 11396 port_id, RTE_UINT16); 11397 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 11398 TOKEN_STRING_INITIALIZER 11399 (struct cmd_tx_loopback_result, 11400 on_off, "on#off"); 11401 11402 static void 11403 cmd_set_tx_loopback_parsed( 11404 void *parsed_result, 11405 __rte_unused struct cmdline *cl, 11406 __rte_unused void *data) 11407 { 11408 struct cmd_tx_loopback_result *res = parsed_result; 11409 int ret = -ENOTSUP; 11410 11411 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11412 11413 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11414 return; 11415 11416 #ifdef RTE_NET_IXGBE 11417 if (ret == -ENOTSUP) 11418 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 11419 #endif 11420 #ifdef RTE_NET_I40E 11421 if (ret == -ENOTSUP) 11422 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 11423 #endif 11424 #ifdef RTE_NET_BNXT 11425 if (ret == -ENOTSUP) 11426 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 11427 #endif 11428 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA 11429 if (ret == -ENOTSUP) 11430 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 11431 #endif 11432 11433 switch (ret) { 11434 case 0: 11435 break; 11436 case -EINVAL: 11437 fprintf(stderr, "invalid is_on %d\n", is_on); 11438 break; 11439 case -ENODEV: 11440 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11441 break; 11442 case -ENOTSUP: 11443 fprintf(stderr, "function not implemented\n"); 11444 break; 11445 default: 11446 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11447 } 11448 } 11449 11450 cmdline_parse_inst_t cmd_set_tx_loopback = { 11451 .f = cmd_set_tx_loopback_parsed, 11452 .data = NULL, 11453 .help_str = "set tx loopback <port_id> on|off", 11454 .tokens = { 11455 (void *)&cmd_tx_loopback_set, 11456 (void *)&cmd_tx_loopback_tx, 11457 (void *)&cmd_tx_loopback_loopback, 11458 (void *)&cmd_tx_loopback_port_id, 11459 (void *)&cmd_tx_loopback_on_off, 11460 NULL, 11461 }, 11462 }; 11463 11464 /* all queues drop enable configuration */ 11465 11466 /* Common result structure for all queues drop enable */ 11467 struct cmd_all_queues_drop_en_result { 11468 cmdline_fixed_string_t set; 11469 cmdline_fixed_string_t all; 11470 cmdline_fixed_string_t queues; 11471 cmdline_fixed_string_t drop; 11472 portid_t port_id; 11473 cmdline_fixed_string_t on_off; 11474 }; 11475 11476 /* Common CLI fields for tx loopback enable disable */ 11477 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 11478 TOKEN_STRING_INITIALIZER 11479 (struct cmd_all_queues_drop_en_result, 11480 set, "set"); 11481 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 11482 TOKEN_STRING_INITIALIZER 11483 (struct cmd_all_queues_drop_en_result, 11484 all, "all"); 11485 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 11486 TOKEN_STRING_INITIALIZER 11487 (struct cmd_all_queues_drop_en_result, 11488 queues, "queues"); 11489 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 11490 TOKEN_STRING_INITIALIZER 11491 (struct cmd_all_queues_drop_en_result, 11492 drop, "drop"); 11493 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 11494 TOKEN_NUM_INITIALIZER 11495 (struct cmd_all_queues_drop_en_result, 11496 port_id, RTE_UINT16); 11497 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 11498 TOKEN_STRING_INITIALIZER 11499 (struct cmd_all_queues_drop_en_result, 11500 on_off, "on#off"); 11501 11502 static void 11503 cmd_set_all_queues_drop_en_parsed( 11504 void *parsed_result, 11505 __rte_unused struct cmdline *cl, 11506 __rte_unused void *data) 11507 { 11508 struct cmd_all_queues_drop_en_result *res = parsed_result; 11509 int ret = -ENOTSUP; 11510 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11511 11512 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11513 return; 11514 11515 #ifdef RTE_NET_IXGBE 11516 if (ret == -ENOTSUP) 11517 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 11518 #endif 11519 #ifdef RTE_NET_BNXT 11520 if (ret == -ENOTSUP) 11521 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 11522 #endif 11523 switch (ret) { 11524 case 0: 11525 break; 11526 case -EINVAL: 11527 fprintf(stderr, "invalid is_on %d\n", is_on); 11528 break; 11529 case -ENODEV: 11530 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11531 break; 11532 case -ENOTSUP: 11533 fprintf(stderr, "function not implemented\n"); 11534 break; 11535 default: 11536 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11537 } 11538 } 11539 11540 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 11541 .f = cmd_set_all_queues_drop_en_parsed, 11542 .data = NULL, 11543 .help_str = "set all queues drop <port_id> on|off", 11544 .tokens = { 11545 (void *)&cmd_all_queues_drop_en_set, 11546 (void *)&cmd_all_queues_drop_en_all, 11547 (void *)&cmd_all_queues_drop_en_queues, 11548 (void *)&cmd_all_queues_drop_en_drop, 11549 (void *)&cmd_all_queues_drop_en_port_id, 11550 (void *)&cmd_all_queues_drop_en_on_off, 11551 NULL, 11552 }, 11553 }; 11554 11555 /* vf split drop enable configuration */ 11556 11557 /* Common result structure for vf split drop enable */ 11558 struct cmd_vf_split_drop_en_result { 11559 cmdline_fixed_string_t set; 11560 cmdline_fixed_string_t vf; 11561 cmdline_fixed_string_t split; 11562 cmdline_fixed_string_t drop; 11563 portid_t port_id; 11564 uint16_t vf_id; 11565 cmdline_fixed_string_t on_off; 11566 }; 11567 11568 /* Common CLI fields for vf split drop enable disable */ 11569 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 11570 TOKEN_STRING_INITIALIZER 11571 (struct cmd_vf_split_drop_en_result, 11572 set, "set"); 11573 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 11574 TOKEN_STRING_INITIALIZER 11575 (struct cmd_vf_split_drop_en_result, 11576 vf, "vf"); 11577 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 11578 TOKEN_STRING_INITIALIZER 11579 (struct cmd_vf_split_drop_en_result, 11580 split, "split"); 11581 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 11582 TOKEN_STRING_INITIALIZER 11583 (struct cmd_vf_split_drop_en_result, 11584 drop, "drop"); 11585 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 11586 TOKEN_NUM_INITIALIZER 11587 (struct cmd_vf_split_drop_en_result, 11588 port_id, RTE_UINT16); 11589 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 11590 TOKEN_NUM_INITIALIZER 11591 (struct cmd_vf_split_drop_en_result, 11592 vf_id, RTE_UINT16); 11593 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 11594 TOKEN_STRING_INITIALIZER 11595 (struct cmd_vf_split_drop_en_result, 11596 on_off, "on#off"); 11597 11598 static void 11599 cmd_set_vf_split_drop_en_parsed( 11600 void *parsed_result, 11601 __rte_unused struct cmdline *cl, 11602 __rte_unused void *data) 11603 { 11604 struct cmd_vf_split_drop_en_result *res = parsed_result; 11605 int ret = -ENOTSUP; 11606 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11607 11608 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11609 return; 11610 11611 #ifdef RTE_NET_IXGBE 11612 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 11613 is_on); 11614 #endif 11615 switch (ret) { 11616 case 0: 11617 break; 11618 case -EINVAL: 11619 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 11620 res->vf_id, is_on); 11621 break; 11622 case -ENODEV: 11623 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11624 break; 11625 case -ENOTSUP: 11626 fprintf(stderr, "not supported on port %d\n", res->port_id); 11627 break; 11628 default: 11629 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11630 } 11631 } 11632 11633 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 11634 .f = cmd_set_vf_split_drop_en_parsed, 11635 .data = NULL, 11636 .help_str = "set vf split drop <port_id> <vf_id> on|off", 11637 .tokens = { 11638 (void *)&cmd_vf_split_drop_en_set, 11639 (void *)&cmd_vf_split_drop_en_vf, 11640 (void *)&cmd_vf_split_drop_en_split, 11641 (void *)&cmd_vf_split_drop_en_drop, 11642 (void *)&cmd_vf_split_drop_en_port_id, 11643 (void *)&cmd_vf_split_drop_en_vf_id, 11644 (void *)&cmd_vf_split_drop_en_on_off, 11645 NULL, 11646 }, 11647 }; 11648 11649 /* vf mac address configuration */ 11650 11651 /* Common result structure for vf mac address */ 11652 struct cmd_set_vf_mac_addr_result { 11653 cmdline_fixed_string_t set; 11654 cmdline_fixed_string_t vf; 11655 cmdline_fixed_string_t mac; 11656 cmdline_fixed_string_t addr; 11657 portid_t port_id; 11658 uint16_t vf_id; 11659 struct rte_ether_addr mac_addr; 11660 11661 }; 11662 11663 /* Common CLI fields for vf split drop enable disable */ 11664 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 11665 TOKEN_STRING_INITIALIZER 11666 (struct cmd_set_vf_mac_addr_result, 11667 set, "set"); 11668 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 11669 TOKEN_STRING_INITIALIZER 11670 (struct cmd_set_vf_mac_addr_result, 11671 vf, "vf"); 11672 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 11673 TOKEN_STRING_INITIALIZER 11674 (struct cmd_set_vf_mac_addr_result, 11675 mac, "mac"); 11676 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 11677 TOKEN_STRING_INITIALIZER 11678 (struct cmd_set_vf_mac_addr_result, 11679 addr, "addr"); 11680 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 11681 TOKEN_NUM_INITIALIZER 11682 (struct cmd_set_vf_mac_addr_result, 11683 port_id, RTE_UINT16); 11684 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 11685 TOKEN_NUM_INITIALIZER 11686 (struct cmd_set_vf_mac_addr_result, 11687 vf_id, RTE_UINT16); 11688 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 11689 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 11690 mac_addr); 11691 11692 static void 11693 cmd_set_vf_mac_addr_parsed( 11694 void *parsed_result, 11695 __rte_unused struct cmdline *cl, 11696 __rte_unused void *data) 11697 { 11698 struct cmd_set_vf_mac_addr_result *res = parsed_result; 11699 int ret = -ENOTSUP; 11700 11701 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11702 return; 11703 11704 #ifdef RTE_NET_IXGBE 11705 if (ret == -ENOTSUP) 11706 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 11707 &res->mac_addr); 11708 #endif 11709 #ifdef RTE_NET_I40E 11710 if (ret == -ENOTSUP) 11711 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 11712 &res->mac_addr); 11713 #endif 11714 #ifdef RTE_NET_BNXT 11715 if (ret == -ENOTSUP) 11716 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 11717 &res->mac_addr); 11718 #endif 11719 11720 switch (ret) { 11721 case 0: 11722 break; 11723 case -EINVAL: 11724 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id); 11725 break; 11726 case -ENODEV: 11727 fprintf(stderr, "invalid port_id %d\n", res->port_id); 11728 break; 11729 case -ENOTSUP: 11730 fprintf(stderr, "function not implemented\n"); 11731 break; 11732 default: 11733 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11734 } 11735 } 11736 11737 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 11738 .f = cmd_set_vf_mac_addr_parsed, 11739 .data = NULL, 11740 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 11741 .tokens = { 11742 (void *)&cmd_set_vf_mac_addr_set, 11743 (void *)&cmd_set_vf_mac_addr_vf, 11744 (void *)&cmd_set_vf_mac_addr_mac, 11745 (void *)&cmd_set_vf_mac_addr_addr, 11746 (void *)&cmd_set_vf_mac_addr_port_id, 11747 (void *)&cmd_set_vf_mac_addr_vf_id, 11748 (void *)&cmd_set_vf_mac_addr_mac_addr, 11749 NULL, 11750 }, 11751 }; 11752 11753 /* MACsec configuration */ 11754 11755 /* Common result structure for MACsec offload enable */ 11756 struct cmd_macsec_offload_on_result { 11757 cmdline_fixed_string_t set; 11758 cmdline_fixed_string_t macsec; 11759 cmdline_fixed_string_t offload; 11760 portid_t port_id; 11761 cmdline_fixed_string_t on; 11762 cmdline_fixed_string_t encrypt; 11763 cmdline_fixed_string_t en_on_off; 11764 cmdline_fixed_string_t replay_protect; 11765 cmdline_fixed_string_t rp_on_off; 11766 }; 11767 11768 /* Common CLI fields for MACsec offload disable */ 11769 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 11770 TOKEN_STRING_INITIALIZER 11771 (struct cmd_macsec_offload_on_result, 11772 set, "set"); 11773 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 11774 TOKEN_STRING_INITIALIZER 11775 (struct cmd_macsec_offload_on_result, 11776 macsec, "macsec"); 11777 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 11778 TOKEN_STRING_INITIALIZER 11779 (struct cmd_macsec_offload_on_result, 11780 offload, "offload"); 11781 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 11782 TOKEN_NUM_INITIALIZER 11783 (struct cmd_macsec_offload_on_result, 11784 port_id, RTE_UINT16); 11785 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 11786 TOKEN_STRING_INITIALIZER 11787 (struct cmd_macsec_offload_on_result, 11788 on, "on"); 11789 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 11790 TOKEN_STRING_INITIALIZER 11791 (struct cmd_macsec_offload_on_result, 11792 encrypt, "encrypt"); 11793 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 11794 TOKEN_STRING_INITIALIZER 11795 (struct cmd_macsec_offload_on_result, 11796 en_on_off, "on#off"); 11797 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 11798 TOKEN_STRING_INITIALIZER 11799 (struct cmd_macsec_offload_on_result, 11800 replay_protect, "replay-protect"); 11801 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 11802 TOKEN_STRING_INITIALIZER 11803 (struct cmd_macsec_offload_on_result, 11804 rp_on_off, "on#off"); 11805 11806 static void 11807 cmd_set_macsec_offload_on_parsed( 11808 void *parsed_result, 11809 __rte_unused struct cmdline *cl, 11810 __rte_unused void *data) 11811 { 11812 struct cmd_macsec_offload_on_result *res = parsed_result; 11813 int ret = -ENOTSUP; 11814 portid_t port_id = res->port_id; 11815 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 11816 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 11817 struct rte_eth_dev_info dev_info; 11818 11819 if (port_id_is_invalid(port_id, ENABLED_WARN)) 11820 return; 11821 if (!port_is_stopped(port_id)) { 11822 fprintf(stderr, "Please stop port %d first\n", port_id); 11823 return; 11824 } 11825 11826 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11827 if (ret != 0) 11828 return; 11829 11830 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 11831 #ifdef RTE_NET_IXGBE 11832 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 11833 #endif 11834 } 11835 RTE_SET_USED(en); 11836 RTE_SET_USED(rp); 11837 11838 switch (ret) { 11839 case 0: 11840 ports[port_id].dev_conf.txmode.offloads |= 11841 DEV_TX_OFFLOAD_MACSEC_INSERT; 11842 cmd_reconfig_device_queue(port_id, 1, 1); 11843 break; 11844 case -ENODEV: 11845 fprintf(stderr, "invalid port_id %d\n", port_id); 11846 break; 11847 case -ENOTSUP: 11848 fprintf(stderr, "not supported on port %d\n", port_id); 11849 break; 11850 default: 11851 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11852 } 11853 } 11854 11855 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 11856 .f = cmd_set_macsec_offload_on_parsed, 11857 .data = NULL, 11858 .help_str = "set macsec offload <port_id> on " 11859 "encrypt on|off replay-protect on|off", 11860 .tokens = { 11861 (void *)&cmd_macsec_offload_on_set, 11862 (void *)&cmd_macsec_offload_on_macsec, 11863 (void *)&cmd_macsec_offload_on_offload, 11864 (void *)&cmd_macsec_offload_on_port_id, 11865 (void *)&cmd_macsec_offload_on_on, 11866 (void *)&cmd_macsec_offload_on_encrypt, 11867 (void *)&cmd_macsec_offload_on_en_on_off, 11868 (void *)&cmd_macsec_offload_on_replay_protect, 11869 (void *)&cmd_macsec_offload_on_rp_on_off, 11870 NULL, 11871 }, 11872 }; 11873 11874 /* Common result structure for MACsec offload disable */ 11875 struct cmd_macsec_offload_off_result { 11876 cmdline_fixed_string_t set; 11877 cmdline_fixed_string_t macsec; 11878 cmdline_fixed_string_t offload; 11879 portid_t port_id; 11880 cmdline_fixed_string_t off; 11881 }; 11882 11883 /* Common CLI fields for MACsec offload disable */ 11884 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 11885 TOKEN_STRING_INITIALIZER 11886 (struct cmd_macsec_offload_off_result, 11887 set, "set"); 11888 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 11889 TOKEN_STRING_INITIALIZER 11890 (struct cmd_macsec_offload_off_result, 11891 macsec, "macsec"); 11892 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 11893 TOKEN_STRING_INITIALIZER 11894 (struct cmd_macsec_offload_off_result, 11895 offload, "offload"); 11896 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 11897 TOKEN_NUM_INITIALIZER 11898 (struct cmd_macsec_offload_off_result, 11899 port_id, RTE_UINT16); 11900 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 11901 TOKEN_STRING_INITIALIZER 11902 (struct cmd_macsec_offload_off_result, 11903 off, "off"); 11904 11905 static void 11906 cmd_set_macsec_offload_off_parsed( 11907 void *parsed_result, 11908 __rte_unused struct cmdline *cl, 11909 __rte_unused void *data) 11910 { 11911 struct cmd_macsec_offload_off_result *res = parsed_result; 11912 int ret = -ENOTSUP; 11913 struct rte_eth_dev_info dev_info; 11914 portid_t port_id = res->port_id; 11915 11916 if (port_id_is_invalid(port_id, ENABLED_WARN)) 11917 return; 11918 if (!port_is_stopped(port_id)) { 11919 fprintf(stderr, "Please stop port %d first\n", port_id); 11920 return; 11921 } 11922 11923 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11924 if (ret != 0) 11925 return; 11926 11927 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 11928 #ifdef RTE_NET_IXGBE 11929 ret = rte_pmd_ixgbe_macsec_disable(port_id); 11930 #endif 11931 } 11932 switch (ret) { 11933 case 0: 11934 ports[port_id].dev_conf.txmode.offloads &= 11935 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 11936 cmd_reconfig_device_queue(port_id, 1, 1); 11937 break; 11938 case -ENODEV: 11939 fprintf(stderr, "invalid port_id %d\n", port_id); 11940 break; 11941 case -ENOTSUP: 11942 fprintf(stderr, "not supported on port %d\n", port_id); 11943 break; 11944 default: 11945 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 11946 } 11947 } 11948 11949 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 11950 .f = cmd_set_macsec_offload_off_parsed, 11951 .data = NULL, 11952 .help_str = "set macsec offload <port_id> off", 11953 .tokens = { 11954 (void *)&cmd_macsec_offload_off_set, 11955 (void *)&cmd_macsec_offload_off_macsec, 11956 (void *)&cmd_macsec_offload_off_offload, 11957 (void *)&cmd_macsec_offload_off_port_id, 11958 (void *)&cmd_macsec_offload_off_off, 11959 NULL, 11960 }, 11961 }; 11962 11963 /* Common result structure for MACsec secure connection configure */ 11964 struct cmd_macsec_sc_result { 11965 cmdline_fixed_string_t set; 11966 cmdline_fixed_string_t macsec; 11967 cmdline_fixed_string_t sc; 11968 cmdline_fixed_string_t tx_rx; 11969 portid_t port_id; 11970 struct rte_ether_addr mac; 11971 uint16_t pi; 11972 }; 11973 11974 /* Common CLI fields for MACsec secure connection configure */ 11975 cmdline_parse_token_string_t cmd_macsec_sc_set = 11976 TOKEN_STRING_INITIALIZER 11977 (struct cmd_macsec_sc_result, 11978 set, "set"); 11979 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 11980 TOKEN_STRING_INITIALIZER 11981 (struct cmd_macsec_sc_result, 11982 macsec, "macsec"); 11983 cmdline_parse_token_string_t cmd_macsec_sc_sc = 11984 TOKEN_STRING_INITIALIZER 11985 (struct cmd_macsec_sc_result, 11986 sc, "sc"); 11987 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 11988 TOKEN_STRING_INITIALIZER 11989 (struct cmd_macsec_sc_result, 11990 tx_rx, "tx#rx"); 11991 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 11992 TOKEN_NUM_INITIALIZER 11993 (struct cmd_macsec_sc_result, 11994 port_id, RTE_UINT16); 11995 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 11996 TOKEN_ETHERADDR_INITIALIZER 11997 (struct cmd_macsec_sc_result, 11998 mac); 11999 cmdline_parse_token_num_t cmd_macsec_sc_pi = 12000 TOKEN_NUM_INITIALIZER 12001 (struct cmd_macsec_sc_result, 12002 pi, RTE_UINT16); 12003 12004 static void 12005 cmd_set_macsec_sc_parsed( 12006 void *parsed_result, 12007 __rte_unused struct cmdline *cl, 12008 __rte_unused void *data) 12009 { 12010 struct cmd_macsec_sc_result *res = parsed_result; 12011 int ret = -ENOTSUP; 12012 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 12013 12014 #ifdef RTE_NET_IXGBE 12015 ret = is_tx ? 12016 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 12017 res->mac.addr_bytes) : 12018 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 12019 res->mac.addr_bytes, res->pi); 12020 #endif 12021 RTE_SET_USED(is_tx); 12022 12023 switch (ret) { 12024 case 0: 12025 break; 12026 case -ENODEV: 12027 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12028 break; 12029 case -ENOTSUP: 12030 fprintf(stderr, "not supported on port %d\n", res->port_id); 12031 break; 12032 default: 12033 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12034 } 12035 } 12036 12037 cmdline_parse_inst_t cmd_set_macsec_sc = { 12038 .f = cmd_set_macsec_sc_parsed, 12039 .data = NULL, 12040 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 12041 .tokens = { 12042 (void *)&cmd_macsec_sc_set, 12043 (void *)&cmd_macsec_sc_macsec, 12044 (void *)&cmd_macsec_sc_sc, 12045 (void *)&cmd_macsec_sc_tx_rx, 12046 (void *)&cmd_macsec_sc_port_id, 12047 (void *)&cmd_macsec_sc_mac, 12048 (void *)&cmd_macsec_sc_pi, 12049 NULL, 12050 }, 12051 }; 12052 12053 /* Common result structure for MACsec secure connection configure */ 12054 struct cmd_macsec_sa_result { 12055 cmdline_fixed_string_t set; 12056 cmdline_fixed_string_t macsec; 12057 cmdline_fixed_string_t sa; 12058 cmdline_fixed_string_t tx_rx; 12059 portid_t port_id; 12060 uint8_t idx; 12061 uint8_t an; 12062 uint32_t pn; 12063 cmdline_fixed_string_t key; 12064 }; 12065 12066 /* Common CLI fields for MACsec secure connection configure */ 12067 cmdline_parse_token_string_t cmd_macsec_sa_set = 12068 TOKEN_STRING_INITIALIZER 12069 (struct cmd_macsec_sa_result, 12070 set, "set"); 12071 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 12072 TOKEN_STRING_INITIALIZER 12073 (struct cmd_macsec_sa_result, 12074 macsec, "macsec"); 12075 cmdline_parse_token_string_t cmd_macsec_sa_sa = 12076 TOKEN_STRING_INITIALIZER 12077 (struct cmd_macsec_sa_result, 12078 sa, "sa"); 12079 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 12080 TOKEN_STRING_INITIALIZER 12081 (struct cmd_macsec_sa_result, 12082 tx_rx, "tx#rx"); 12083 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 12084 TOKEN_NUM_INITIALIZER 12085 (struct cmd_macsec_sa_result, 12086 port_id, RTE_UINT16); 12087 cmdline_parse_token_num_t cmd_macsec_sa_idx = 12088 TOKEN_NUM_INITIALIZER 12089 (struct cmd_macsec_sa_result, 12090 idx, RTE_UINT8); 12091 cmdline_parse_token_num_t cmd_macsec_sa_an = 12092 TOKEN_NUM_INITIALIZER 12093 (struct cmd_macsec_sa_result, 12094 an, RTE_UINT8); 12095 cmdline_parse_token_num_t cmd_macsec_sa_pn = 12096 TOKEN_NUM_INITIALIZER 12097 (struct cmd_macsec_sa_result, 12098 pn, RTE_UINT32); 12099 cmdline_parse_token_string_t cmd_macsec_sa_key = 12100 TOKEN_STRING_INITIALIZER 12101 (struct cmd_macsec_sa_result, 12102 key, NULL); 12103 12104 static void 12105 cmd_set_macsec_sa_parsed( 12106 void *parsed_result, 12107 __rte_unused struct cmdline *cl, 12108 __rte_unused void *data) 12109 { 12110 struct cmd_macsec_sa_result *res = parsed_result; 12111 int ret = -ENOTSUP; 12112 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 12113 uint8_t key[16] = { 0 }; 12114 uint8_t xdgt0; 12115 uint8_t xdgt1; 12116 int key_len; 12117 int i; 12118 12119 key_len = strlen(res->key) / 2; 12120 if (key_len > 16) 12121 key_len = 16; 12122 12123 for (i = 0; i < key_len; i++) { 12124 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 12125 if (xdgt0 == 0xFF) 12126 return; 12127 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 12128 if (xdgt1 == 0xFF) 12129 return; 12130 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 12131 } 12132 12133 #ifdef RTE_NET_IXGBE 12134 ret = is_tx ? 12135 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 12136 res->idx, res->an, res->pn, key) : 12137 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 12138 res->idx, res->an, res->pn, key); 12139 #endif 12140 RTE_SET_USED(is_tx); 12141 RTE_SET_USED(key); 12142 12143 switch (ret) { 12144 case 0: 12145 break; 12146 case -EINVAL: 12147 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an); 12148 break; 12149 case -ENODEV: 12150 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12151 break; 12152 case -ENOTSUP: 12153 fprintf(stderr, "not supported on port %d\n", res->port_id); 12154 break; 12155 default: 12156 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12157 } 12158 } 12159 12160 cmdline_parse_inst_t cmd_set_macsec_sa = { 12161 .f = cmd_set_macsec_sa_parsed, 12162 .data = NULL, 12163 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 12164 .tokens = { 12165 (void *)&cmd_macsec_sa_set, 12166 (void *)&cmd_macsec_sa_macsec, 12167 (void *)&cmd_macsec_sa_sa, 12168 (void *)&cmd_macsec_sa_tx_rx, 12169 (void *)&cmd_macsec_sa_port_id, 12170 (void *)&cmd_macsec_sa_idx, 12171 (void *)&cmd_macsec_sa_an, 12172 (void *)&cmd_macsec_sa_pn, 12173 (void *)&cmd_macsec_sa_key, 12174 NULL, 12175 }, 12176 }; 12177 12178 /* VF unicast promiscuous mode configuration */ 12179 12180 /* Common result structure for VF unicast promiscuous mode */ 12181 struct cmd_vf_promisc_result { 12182 cmdline_fixed_string_t set; 12183 cmdline_fixed_string_t vf; 12184 cmdline_fixed_string_t promisc; 12185 portid_t port_id; 12186 uint32_t vf_id; 12187 cmdline_fixed_string_t on_off; 12188 }; 12189 12190 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 12191 cmdline_parse_token_string_t cmd_vf_promisc_set = 12192 TOKEN_STRING_INITIALIZER 12193 (struct cmd_vf_promisc_result, 12194 set, "set"); 12195 cmdline_parse_token_string_t cmd_vf_promisc_vf = 12196 TOKEN_STRING_INITIALIZER 12197 (struct cmd_vf_promisc_result, 12198 vf, "vf"); 12199 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 12200 TOKEN_STRING_INITIALIZER 12201 (struct cmd_vf_promisc_result, 12202 promisc, "promisc"); 12203 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 12204 TOKEN_NUM_INITIALIZER 12205 (struct cmd_vf_promisc_result, 12206 port_id, RTE_UINT16); 12207 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 12208 TOKEN_NUM_INITIALIZER 12209 (struct cmd_vf_promisc_result, 12210 vf_id, RTE_UINT32); 12211 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 12212 TOKEN_STRING_INITIALIZER 12213 (struct cmd_vf_promisc_result, 12214 on_off, "on#off"); 12215 12216 static void 12217 cmd_set_vf_promisc_parsed( 12218 void *parsed_result, 12219 __rte_unused struct cmdline *cl, 12220 __rte_unused void *data) 12221 { 12222 struct cmd_vf_promisc_result *res = parsed_result; 12223 int ret = -ENOTSUP; 12224 12225 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12226 12227 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12228 return; 12229 12230 #ifdef RTE_NET_I40E 12231 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 12232 res->vf_id, is_on); 12233 #endif 12234 12235 switch (ret) { 12236 case 0: 12237 break; 12238 case -EINVAL: 12239 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 12240 break; 12241 case -ENODEV: 12242 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12243 break; 12244 case -ENOTSUP: 12245 fprintf(stderr, "function not implemented\n"); 12246 break; 12247 default: 12248 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12249 } 12250 } 12251 12252 cmdline_parse_inst_t cmd_set_vf_promisc = { 12253 .f = cmd_set_vf_promisc_parsed, 12254 .data = NULL, 12255 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 12256 "Set unicast promiscuous mode for a VF from the PF", 12257 .tokens = { 12258 (void *)&cmd_vf_promisc_set, 12259 (void *)&cmd_vf_promisc_vf, 12260 (void *)&cmd_vf_promisc_promisc, 12261 (void *)&cmd_vf_promisc_port_id, 12262 (void *)&cmd_vf_promisc_vf_id, 12263 (void *)&cmd_vf_promisc_on_off, 12264 NULL, 12265 }, 12266 }; 12267 12268 /* VF multicast promiscuous mode configuration */ 12269 12270 /* Common result structure for VF multicast promiscuous mode */ 12271 struct cmd_vf_allmulti_result { 12272 cmdline_fixed_string_t set; 12273 cmdline_fixed_string_t vf; 12274 cmdline_fixed_string_t allmulti; 12275 portid_t port_id; 12276 uint32_t vf_id; 12277 cmdline_fixed_string_t on_off; 12278 }; 12279 12280 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 12281 cmdline_parse_token_string_t cmd_vf_allmulti_set = 12282 TOKEN_STRING_INITIALIZER 12283 (struct cmd_vf_allmulti_result, 12284 set, "set"); 12285 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 12286 TOKEN_STRING_INITIALIZER 12287 (struct cmd_vf_allmulti_result, 12288 vf, "vf"); 12289 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 12290 TOKEN_STRING_INITIALIZER 12291 (struct cmd_vf_allmulti_result, 12292 allmulti, "allmulti"); 12293 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 12294 TOKEN_NUM_INITIALIZER 12295 (struct cmd_vf_allmulti_result, 12296 port_id, RTE_UINT16); 12297 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 12298 TOKEN_NUM_INITIALIZER 12299 (struct cmd_vf_allmulti_result, 12300 vf_id, RTE_UINT32); 12301 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 12302 TOKEN_STRING_INITIALIZER 12303 (struct cmd_vf_allmulti_result, 12304 on_off, "on#off"); 12305 12306 static void 12307 cmd_set_vf_allmulti_parsed( 12308 void *parsed_result, 12309 __rte_unused struct cmdline *cl, 12310 __rte_unused void *data) 12311 { 12312 struct cmd_vf_allmulti_result *res = parsed_result; 12313 int ret = -ENOTSUP; 12314 12315 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12316 12317 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12318 return; 12319 12320 #ifdef RTE_NET_I40E 12321 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 12322 res->vf_id, is_on); 12323 #endif 12324 12325 switch (ret) { 12326 case 0: 12327 break; 12328 case -EINVAL: 12329 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 12330 break; 12331 case -ENODEV: 12332 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12333 break; 12334 case -ENOTSUP: 12335 fprintf(stderr, "function not implemented\n"); 12336 break; 12337 default: 12338 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12339 } 12340 } 12341 12342 cmdline_parse_inst_t cmd_set_vf_allmulti = { 12343 .f = cmd_set_vf_allmulti_parsed, 12344 .data = NULL, 12345 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 12346 "Set multicast promiscuous mode for a VF from the PF", 12347 .tokens = { 12348 (void *)&cmd_vf_allmulti_set, 12349 (void *)&cmd_vf_allmulti_vf, 12350 (void *)&cmd_vf_allmulti_allmulti, 12351 (void *)&cmd_vf_allmulti_port_id, 12352 (void *)&cmd_vf_allmulti_vf_id, 12353 (void *)&cmd_vf_allmulti_on_off, 12354 NULL, 12355 }, 12356 }; 12357 12358 /* vf broadcast mode configuration */ 12359 12360 /* Common result structure for vf broadcast */ 12361 struct cmd_set_vf_broadcast_result { 12362 cmdline_fixed_string_t set; 12363 cmdline_fixed_string_t vf; 12364 cmdline_fixed_string_t broadcast; 12365 portid_t port_id; 12366 uint16_t vf_id; 12367 cmdline_fixed_string_t on_off; 12368 }; 12369 12370 /* Common CLI fields for vf broadcast enable disable */ 12371 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 12372 TOKEN_STRING_INITIALIZER 12373 (struct cmd_set_vf_broadcast_result, 12374 set, "set"); 12375 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 12376 TOKEN_STRING_INITIALIZER 12377 (struct cmd_set_vf_broadcast_result, 12378 vf, "vf"); 12379 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 12380 TOKEN_STRING_INITIALIZER 12381 (struct cmd_set_vf_broadcast_result, 12382 broadcast, "broadcast"); 12383 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 12384 TOKEN_NUM_INITIALIZER 12385 (struct cmd_set_vf_broadcast_result, 12386 port_id, RTE_UINT16); 12387 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 12388 TOKEN_NUM_INITIALIZER 12389 (struct cmd_set_vf_broadcast_result, 12390 vf_id, RTE_UINT16); 12391 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 12392 TOKEN_STRING_INITIALIZER 12393 (struct cmd_set_vf_broadcast_result, 12394 on_off, "on#off"); 12395 12396 static void 12397 cmd_set_vf_broadcast_parsed( 12398 void *parsed_result, 12399 __rte_unused struct cmdline *cl, 12400 __rte_unused void *data) 12401 { 12402 struct cmd_set_vf_broadcast_result *res = parsed_result; 12403 int ret = -ENOTSUP; 12404 12405 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12406 12407 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12408 return; 12409 12410 #ifdef RTE_NET_I40E 12411 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 12412 res->vf_id, is_on); 12413 #endif 12414 12415 switch (ret) { 12416 case 0: 12417 break; 12418 case -EINVAL: 12419 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 12420 res->vf_id, is_on); 12421 break; 12422 case -ENODEV: 12423 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12424 break; 12425 case -ENOTSUP: 12426 fprintf(stderr, "function not implemented\n"); 12427 break; 12428 default: 12429 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12430 } 12431 } 12432 12433 cmdline_parse_inst_t cmd_set_vf_broadcast = { 12434 .f = cmd_set_vf_broadcast_parsed, 12435 .data = NULL, 12436 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 12437 .tokens = { 12438 (void *)&cmd_set_vf_broadcast_set, 12439 (void *)&cmd_set_vf_broadcast_vf, 12440 (void *)&cmd_set_vf_broadcast_broadcast, 12441 (void *)&cmd_set_vf_broadcast_port_id, 12442 (void *)&cmd_set_vf_broadcast_vf_id, 12443 (void *)&cmd_set_vf_broadcast_on_off, 12444 NULL, 12445 }, 12446 }; 12447 12448 /* vf vlan tag configuration */ 12449 12450 /* Common result structure for vf vlan tag */ 12451 struct cmd_set_vf_vlan_tag_result { 12452 cmdline_fixed_string_t set; 12453 cmdline_fixed_string_t vf; 12454 cmdline_fixed_string_t vlan; 12455 cmdline_fixed_string_t tag; 12456 portid_t port_id; 12457 uint16_t vf_id; 12458 cmdline_fixed_string_t on_off; 12459 }; 12460 12461 /* Common CLI fields for vf vlan tag enable disable */ 12462 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 12463 TOKEN_STRING_INITIALIZER 12464 (struct cmd_set_vf_vlan_tag_result, 12465 set, "set"); 12466 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 12467 TOKEN_STRING_INITIALIZER 12468 (struct cmd_set_vf_vlan_tag_result, 12469 vf, "vf"); 12470 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 12471 TOKEN_STRING_INITIALIZER 12472 (struct cmd_set_vf_vlan_tag_result, 12473 vlan, "vlan"); 12474 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 12475 TOKEN_STRING_INITIALIZER 12476 (struct cmd_set_vf_vlan_tag_result, 12477 tag, "tag"); 12478 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 12479 TOKEN_NUM_INITIALIZER 12480 (struct cmd_set_vf_vlan_tag_result, 12481 port_id, RTE_UINT16); 12482 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 12483 TOKEN_NUM_INITIALIZER 12484 (struct cmd_set_vf_vlan_tag_result, 12485 vf_id, RTE_UINT16); 12486 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 12487 TOKEN_STRING_INITIALIZER 12488 (struct cmd_set_vf_vlan_tag_result, 12489 on_off, "on#off"); 12490 12491 static void 12492 cmd_set_vf_vlan_tag_parsed( 12493 void *parsed_result, 12494 __rte_unused struct cmdline *cl, 12495 __rte_unused void *data) 12496 { 12497 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 12498 int ret = -ENOTSUP; 12499 12500 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12501 12502 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12503 return; 12504 12505 #ifdef RTE_NET_I40E 12506 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 12507 res->vf_id, is_on); 12508 #endif 12509 12510 switch (ret) { 12511 case 0: 12512 break; 12513 case -EINVAL: 12514 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 12515 res->vf_id, is_on); 12516 break; 12517 case -ENODEV: 12518 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12519 break; 12520 case -ENOTSUP: 12521 fprintf(stderr, "function not implemented\n"); 12522 break; 12523 default: 12524 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12525 } 12526 } 12527 12528 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 12529 .f = cmd_set_vf_vlan_tag_parsed, 12530 .data = NULL, 12531 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 12532 .tokens = { 12533 (void *)&cmd_set_vf_vlan_tag_set, 12534 (void *)&cmd_set_vf_vlan_tag_vf, 12535 (void *)&cmd_set_vf_vlan_tag_vlan, 12536 (void *)&cmd_set_vf_vlan_tag_tag, 12537 (void *)&cmd_set_vf_vlan_tag_port_id, 12538 (void *)&cmd_set_vf_vlan_tag_vf_id, 12539 (void *)&cmd_set_vf_vlan_tag_on_off, 12540 NULL, 12541 }, 12542 }; 12543 12544 /* Common definition of VF and TC TX bandwidth configuration */ 12545 struct cmd_vf_tc_bw_result { 12546 cmdline_fixed_string_t set; 12547 cmdline_fixed_string_t vf; 12548 cmdline_fixed_string_t tc; 12549 cmdline_fixed_string_t tx; 12550 cmdline_fixed_string_t min_bw; 12551 cmdline_fixed_string_t max_bw; 12552 cmdline_fixed_string_t strict_link_prio; 12553 portid_t port_id; 12554 uint16_t vf_id; 12555 uint8_t tc_no; 12556 uint32_t bw; 12557 cmdline_fixed_string_t bw_list; 12558 uint8_t tc_map; 12559 }; 12560 12561 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 12562 TOKEN_STRING_INITIALIZER 12563 (struct cmd_vf_tc_bw_result, 12564 set, "set"); 12565 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 12566 TOKEN_STRING_INITIALIZER 12567 (struct cmd_vf_tc_bw_result, 12568 vf, "vf"); 12569 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 12570 TOKEN_STRING_INITIALIZER 12571 (struct cmd_vf_tc_bw_result, 12572 tc, "tc"); 12573 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 12574 TOKEN_STRING_INITIALIZER 12575 (struct cmd_vf_tc_bw_result, 12576 tx, "tx"); 12577 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 12578 TOKEN_STRING_INITIALIZER 12579 (struct cmd_vf_tc_bw_result, 12580 strict_link_prio, "strict-link-priority"); 12581 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 12582 TOKEN_STRING_INITIALIZER 12583 (struct cmd_vf_tc_bw_result, 12584 min_bw, "min-bandwidth"); 12585 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 12586 TOKEN_STRING_INITIALIZER 12587 (struct cmd_vf_tc_bw_result, 12588 max_bw, "max-bandwidth"); 12589 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 12590 TOKEN_NUM_INITIALIZER 12591 (struct cmd_vf_tc_bw_result, 12592 port_id, RTE_UINT16); 12593 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 12594 TOKEN_NUM_INITIALIZER 12595 (struct cmd_vf_tc_bw_result, 12596 vf_id, RTE_UINT16); 12597 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 12598 TOKEN_NUM_INITIALIZER 12599 (struct cmd_vf_tc_bw_result, 12600 tc_no, RTE_UINT8); 12601 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 12602 TOKEN_NUM_INITIALIZER 12603 (struct cmd_vf_tc_bw_result, 12604 bw, RTE_UINT32); 12605 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 12606 TOKEN_STRING_INITIALIZER 12607 (struct cmd_vf_tc_bw_result, 12608 bw_list, NULL); 12609 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 12610 TOKEN_NUM_INITIALIZER 12611 (struct cmd_vf_tc_bw_result, 12612 tc_map, RTE_UINT8); 12613 12614 /* VF max bandwidth setting */ 12615 static void 12616 cmd_vf_max_bw_parsed( 12617 void *parsed_result, 12618 __rte_unused struct cmdline *cl, 12619 __rte_unused void *data) 12620 { 12621 struct cmd_vf_tc_bw_result *res = parsed_result; 12622 int ret = -ENOTSUP; 12623 12624 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12625 return; 12626 12627 #ifdef RTE_NET_I40E 12628 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 12629 res->vf_id, res->bw); 12630 #endif 12631 12632 switch (ret) { 12633 case 0: 12634 break; 12635 case -EINVAL: 12636 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n", 12637 res->vf_id, res->bw); 12638 break; 12639 case -ENODEV: 12640 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12641 break; 12642 case -ENOTSUP: 12643 fprintf(stderr, "function not implemented\n"); 12644 break; 12645 default: 12646 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12647 } 12648 } 12649 12650 cmdline_parse_inst_t cmd_vf_max_bw = { 12651 .f = cmd_vf_max_bw_parsed, 12652 .data = NULL, 12653 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 12654 .tokens = { 12655 (void *)&cmd_vf_tc_bw_set, 12656 (void *)&cmd_vf_tc_bw_vf, 12657 (void *)&cmd_vf_tc_bw_tx, 12658 (void *)&cmd_vf_tc_bw_max_bw, 12659 (void *)&cmd_vf_tc_bw_port_id, 12660 (void *)&cmd_vf_tc_bw_vf_id, 12661 (void *)&cmd_vf_tc_bw_bw, 12662 NULL, 12663 }, 12664 }; 12665 12666 static int 12667 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 12668 uint8_t *tc_num, 12669 char *str) 12670 { 12671 uint32_t size; 12672 const char *p, *p0 = str; 12673 char s[256]; 12674 char *end; 12675 char *str_fld[16]; 12676 uint16_t i; 12677 int ret; 12678 12679 p = strchr(p0, '('); 12680 if (p == NULL) { 12681 fprintf(stderr, 12682 "The bandwidth-list should be '(bw1, bw2, ...)'\n"); 12683 return -1; 12684 } 12685 p++; 12686 p0 = strchr(p, ')'); 12687 if (p0 == NULL) { 12688 fprintf(stderr, 12689 "The bandwidth-list should be '(bw1, bw2, ...)'\n"); 12690 return -1; 12691 } 12692 size = p0 - p; 12693 if (size >= sizeof(s)) { 12694 fprintf(stderr, 12695 "The string size exceeds the internal buffer size\n"); 12696 return -1; 12697 } 12698 snprintf(s, sizeof(s), "%.*s", size, p); 12699 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 12700 if (ret <= 0) { 12701 fprintf(stderr, "Failed to get the bandwidth list.\n"); 12702 return -1; 12703 } 12704 *tc_num = ret; 12705 for (i = 0; i < ret; i++) 12706 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 12707 12708 return 0; 12709 } 12710 12711 /* TC min bandwidth setting */ 12712 static void 12713 cmd_vf_tc_min_bw_parsed( 12714 void *parsed_result, 12715 __rte_unused struct cmdline *cl, 12716 __rte_unused void *data) 12717 { 12718 struct cmd_vf_tc_bw_result *res = parsed_result; 12719 uint8_t tc_num; 12720 uint8_t bw[16]; 12721 int ret = -ENOTSUP; 12722 12723 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12724 return; 12725 12726 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 12727 if (ret) 12728 return; 12729 12730 #ifdef RTE_NET_I40E 12731 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 12732 tc_num, bw); 12733 #endif 12734 12735 switch (ret) { 12736 case 0: 12737 break; 12738 case -EINVAL: 12739 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id); 12740 break; 12741 case -ENODEV: 12742 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12743 break; 12744 case -ENOTSUP: 12745 fprintf(stderr, "function not implemented\n"); 12746 break; 12747 default: 12748 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12749 } 12750 } 12751 12752 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 12753 .f = cmd_vf_tc_min_bw_parsed, 12754 .data = NULL, 12755 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 12756 " <bw1, bw2, ...>", 12757 .tokens = { 12758 (void *)&cmd_vf_tc_bw_set, 12759 (void *)&cmd_vf_tc_bw_vf, 12760 (void *)&cmd_vf_tc_bw_tc, 12761 (void *)&cmd_vf_tc_bw_tx, 12762 (void *)&cmd_vf_tc_bw_min_bw, 12763 (void *)&cmd_vf_tc_bw_port_id, 12764 (void *)&cmd_vf_tc_bw_vf_id, 12765 (void *)&cmd_vf_tc_bw_bw_list, 12766 NULL, 12767 }, 12768 }; 12769 12770 static void 12771 cmd_tc_min_bw_parsed( 12772 void *parsed_result, 12773 __rte_unused struct cmdline *cl, 12774 __rte_unused void *data) 12775 { 12776 struct cmd_vf_tc_bw_result *res = parsed_result; 12777 struct rte_port *port; 12778 uint8_t tc_num; 12779 uint8_t bw[16]; 12780 int ret = -ENOTSUP; 12781 12782 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12783 return; 12784 12785 port = &ports[res->port_id]; 12786 /** Check if the port is not started **/ 12787 if (port->port_status != RTE_PORT_STOPPED) { 12788 fprintf(stderr, "Please stop port %d first\n", res->port_id); 12789 return; 12790 } 12791 12792 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 12793 if (ret) 12794 return; 12795 12796 #ifdef RTE_NET_IXGBE 12797 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 12798 #endif 12799 12800 switch (ret) { 12801 case 0: 12802 break; 12803 case -EINVAL: 12804 fprintf(stderr, "invalid bandwidth\n"); 12805 break; 12806 case -ENODEV: 12807 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12808 break; 12809 case -ENOTSUP: 12810 fprintf(stderr, "function not implemented\n"); 12811 break; 12812 default: 12813 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12814 } 12815 } 12816 12817 cmdline_parse_inst_t cmd_tc_min_bw = { 12818 .f = cmd_tc_min_bw_parsed, 12819 .data = NULL, 12820 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 12821 .tokens = { 12822 (void *)&cmd_vf_tc_bw_set, 12823 (void *)&cmd_vf_tc_bw_tc, 12824 (void *)&cmd_vf_tc_bw_tx, 12825 (void *)&cmd_vf_tc_bw_min_bw, 12826 (void *)&cmd_vf_tc_bw_port_id, 12827 (void *)&cmd_vf_tc_bw_bw_list, 12828 NULL, 12829 }, 12830 }; 12831 12832 /* TC max bandwidth setting */ 12833 static void 12834 cmd_vf_tc_max_bw_parsed( 12835 void *parsed_result, 12836 __rte_unused struct cmdline *cl, 12837 __rte_unused void *data) 12838 { 12839 struct cmd_vf_tc_bw_result *res = parsed_result; 12840 int ret = -ENOTSUP; 12841 12842 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12843 return; 12844 12845 #ifdef RTE_NET_I40E 12846 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 12847 res->tc_no, res->bw); 12848 #endif 12849 12850 switch (ret) { 12851 case 0: 12852 break; 12853 case -EINVAL: 12854 fprintf(stderr, 12855 "invalid vf_id %d, tc_no %d or bandwidth %d\n", 12856 res->vf_id, res->tc_no, res->bw); 12857 break; 12858 case -ENODEV: 12859 fprintf(stderr, "invalid port_id %d\n", res->port_id); 12860 break; 12861 case -ENOTSUP: 12862 fprintf(stderr, "function not implemented\n"); 12863 break; 12864 default: 12865 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 12866 } 12867 } 12868 12869 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 12870 .f = cmd_vf_tc_max_bw_parsed, 12871 .data = NULL, 12872 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 12873 " <bandwidth>", 12874 .tokens = { 12875 (void *)&cmd_vf_tc_bw_set, 12876 (void *)&cmd_vf_tc_bw_vf, 12877 (void *)&cmd_vf_tc_bw_tc, 12878 (void *)&cmd_vf_tc_bw_tx, 12879 (void *)&cmd_vf_tc_bw_max_bw, 12880 (void *)&cmd_vf_tc_bw_port_id, 12881 (void *)&cmd_vf_tc_bw_vf_id, 12882 (void *)&cmd_vf_tc_bw_tc_no, 12883 (void *)&cmd_vf_tc_bw_bw, 12884 NULL, 12885 }, 12886 }; 12887 12888 /** Set VXLAN encapsulation details */ 12889 struct cmd_set_vxlan_result { 12890 cmdline_fixed_string_t set; 12891 cmdline_fixed_string_t vxlan; 12892 cmdline_fixed_string_t pos_token; 12893 cmdline_fixed_string_t ip_version; 12894 uint32_t vlan_present:1; 12895 uint32_t vni; 12896 uint16_t udp_src; 12897 uint16_t udp_dst; 12898 cmdline_ipaddr_t ip_src; 12899 cmdline_ipaddr_t ip_dst; 12900 uint16_t tci; 12901 uint8_t tos; 12902 uint8_t ttl; 12903 struct rte_ether_addr eth_src; 12904 struct rte_ether_addr eth_dst; 12905 }; 12906 12907 cmdline_parse_token_string_t cmd_set_vxlan_set = 12908 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 12909 cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 12910 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 12911 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl = 12912 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 12913 "vxlan-tos-ttl"); 12914 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 12915 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 12916 "vxlan-with-vlan"); 12917 cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 12918 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12919 "ip-version"); 12920 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 12921 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 12922 "ipv4#ipv6"); 12923 cmdline_parse_token_string_t cmd_set_vxlan_vni = 12924 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12925 "vni"); 12926 cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 12927 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32); 12928 cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 12929 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12930 "udp-src"); 12931 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 12932 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16); 12933 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 12934 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12935 "udp-dst"); 12936 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 12937 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16); 12938 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos = 12939 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12940 "ip-tos"); 12941 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value = 12942 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8); 12943 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl = 12944 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12945 "ip-ttl"); 12946 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value = 12947 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8); 12948 cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 12949 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12950 "ip-src"); 12951 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 12952 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 12953 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 12954 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12955 "ip-dst"); 12956 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 12957 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 12958 cmdline_parse_token_string_t cmd_set_vxlan_vlan = 12959 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12960 "vlan-tci"); 12961 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 12962 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16); 12963 cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 12964 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12965 "eth-src"); 12966 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 12967 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 12968 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 12969 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12970 "eth-dst"); 12971 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 12972 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 12973 12974 static void cmd_set_vxlan_parsed(void *parsed_result, 12975 __rte_unused struct cmdline *cl, 12976 __rte_unused void *data) 12977 { 12978 struct cmd_set_vxlan_result *res = parsed_result; 12979 union { 12980 uint32_t vxlan_id; 12981 uint8_t vni[4]; 12982 } id = { 12983 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 12984 }; 12985 12986 vxlan_encap_conf.select_tos_ttl = 0; 12987 if (strcmp(res->vxlan, "vxlan") == 0) 12988 vxlan_encap_conf.select_vlan = 0; 12989 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 12990 vxlan_encap_conf.select_vlan = 1; 12991 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) { 12992 vxlan_encap_conf.select_vlan = 0; 12993 vxlan_encap_conf.select_tos_ttl = 1; 12994 } 12995 if (strcmp(res->ip_version, "ipv4") == 0) 12996 vxlan_encap_conf.select_ipv4 = 1; 12997 else if (strcmp(res->ip_version, "ipv6") == 0) 12998 vxlan_encap_conf.select_ipv4 = 0; 12999 else 13000 return; 13001 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 13002 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 13003 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 13004 vxlan_encap_conf.ip_tos = res->tos; 13005 vxlan_encap_conf.ip_ttl = res->ttl; 13006 if (vxlan_encap_conf.select_ipv4) { 13007 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 13008 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 13009 } else { 13010 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 13011 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 13012 } 13013 if (vxlan_encap_conf.select_vlan) 13014 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13015 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 13016 RTE_ETHER_ADDR_LEN); 13017 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13018 RTE_ETHER_ADDR_LEN); 13019 } 13020 13021 cmdline_parse_inst_t cmd_set_vxlan = { 13022 .f = cmd_set_vxlan_parsed, 13023 .data = NULL, 13024 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 13025 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 13026 " eth-src <eth-src> eth-dst <eth-dst>", 13027 .tokens = { 13028 (void *)&cmd_set_vxlan_set, 13029 (void *)&cmd_set_vxlan_vxlan, 13030 (void *)&cmd_set_vxlan_ip_version, 13031 (void *)&cmd_set_vxlan_ip_version_value, 13032 (void *)&cmd_set_vxlan_vni, 13033 (void *)&cmd_set_vxlan_vni_value, 13034 (void *)&cmd_set_vxlan_udp_src, 13035 (void *)&cmd_set_vxlan_udp_src_value, 13036 (void *)&cmd_set_vxlan_udp_dst, 13037 (void *)&cmd_set_vxlan_udp_dst_value, 13038 (void *)&cmd_set_vxlan_ip_src, 13039 (void *)&cmd_set_vxlan_ip_src_value, 13040 (void *)&cmd_set_vxlan_ip_dst, 13041 (void *)&cmd_set_vxlan_ip_dst_value, 13042 (void *)&cmd_set_vxlan_eth_src, 13043 (void *)&cmd_set_vxlan_eth_src_value, 13044 (void *)&cmd_set_vxlan_eth_dst, 13045 (void *)&cmd_set_vxlan_eth_dst_value, 13046 NULL, 13047 }, 13048 }; 13049 13050 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = { 13051 .f = cmd_set_vxlan_parsed, 13052 .data = NULL, 13053 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src" 13054 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>" 13055 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 13056 " eth-dst <eth-dst>", 13057 .tokens = { 13058 (void *)&cmd_set_vxlan_set, 13059 (void *)&cmd_set_vxlan_vxlan_tos_ttl, 13060 (void *)&cmd_set_vxlan_ip_version, 13061 (void *)&cmd_set_vxlan_ip_version_value, 13062 (void *)&cmd_set_vxlan_vni, 13063 (void *)&cmd_set_vxlan_vni_value, 13064 (void *)&cmd_set_vxlan_udp_src, 13065 (void *)&cmd_set_vxlan_udp_src_value, 13066 (void *)&cmd_set_vxlan_udp_dst, 13067 (void *)&cmd_set_vxlan_udp_dst_value, 13068 (void *)&cmd_set_vxlan_ip_tos, 13069 (void *)&cmd_set_vxlan_ip_tos_value, 13070 (void *)&cmd_set_vxlan_ip_ttl, 13071 (void *)&cmd_set_vxlan_ip_ttl_value, 13072 (void *)&cmd_set_vxlan_ip_src, 13073 (void *)&cmd_set_vxlan_ip_src_value, 13074 (void *)&cmd_set_vxlan_ip_dst, 13075 (void *)&cmd_set_vxlan_ip_dst_value, 13076 (void *)&cmd_set_vxlan_eth_src, 13077 (void *)&cmd_set_vxlan_eth_src_value, 13078 (void *)&cmd_set_vxlan_eth_dst, 13079 (void *)&cmd_set_vxlan_eth_dst_value, 13080 NULL, 13081 }, 13082 }; 13083 13084 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 13085 .f = cmd_set_vxlan_parsed, 13086 .data = NULL, 13087 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 13088 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 13089 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 13090 " <eth-dst>", 13091 .tokens = { 13092 (void *)&cmd_set_vxlan_set, 13093 (void *)&cmd_set_vxlan_vxlan_with_vlan, 13094 (void *)&cmd_set_vxlan_ip_version, 13095 (void *)&cmd_set_vxlan_ip_version_value, 13096 (void *)&cmd_set_vxlan_vni, 13097 (void *)&cmd_set_vxlan_vni_value, 13098 (void *)&cmd_set_vxlan_udp_src, 13099 (void *)&cmd_set_vxlan_udp_src_value, 13100 (void *)&cmd_set_vxlan_udp_dst, 13101 (void *)&cmd_set_vxlan_udp_dst_value, 13102 (void *)&cmd_set_vxlan_ip_src, 13103 (void *)&cmd_set_vxlan_ip_src_value, 13104 (void *)&cmd_set_vxlan_ip_dst, 13105 (void *)&cmd_set_vxlan_ip_dst_value, 13106 (void *)&cmd_set_vxlan_vlan, 13107 (void *)&cmd_set_vxlan_vlan_value, 13108 (void *)&cmd_set_vxlan_eth_src, 13109 (void *)&cmd_set_vxlan_eth_src_value, 13110 (void *)&cmd_set_vxlan_eth_dst, 13111 (void *)&cmd_set_vxlan_eth_dst_value, 13112 NULL, 13113 }, 13114 }; 13115 13116 /** Set NVGRE encapsulation details */ 13117 struct cmd_set_nvgre_result { 13118 cmdline_fixed_string_t set; 13119 cmdline_fixed_string_t nvgre; 13120 cmdline_fixed_string_t pos_token; 13121 cmdline_fixed_string_t ip_version; 13122 uint32_t tni; 13123 cmdline_ipaddr_t ip_src; 13124 cmdline_ipaddr_t ip_dst; 13125 uint16_t tci; 13126 struct rte_ether_addr eth_src; 13127 struct rte_ether_addr eth_dst; 13128 }; 13129 13130 cmdline_parse_token_string_t cmd_set_nvgre_set = 13131 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 13132 cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 13133 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 13134 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 13135 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 13136 "nvgre-with-vlan"); 13137 cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 13138 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 13139 "ip-version"); 13140 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 13141 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 13142 "ipv4#ipv6"); 13143 cmdline_parse_token_string_t cmd_set_nvgre_tni = 13144 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 13145 "tni"); 13146 cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 13147 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32); 13148 cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 13149 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 13150 "ip-src"); 13151 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 13152 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 13153 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 13154 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 13155 "ip-dst"); 13156 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 13157 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 13158 cmdline_parse_token_string_t cmd_set_nvgre_vlan = 13159 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 13160 "vlan-tci"); 13161 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 13162 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16); 13163 cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 13164 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 13165 "eth-src"); 13166 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 13167 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 13168 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 13169 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 13170 "eth-dst"); 13171 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 13172 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 13173 13174 static void cmd_set_nvgre_parsed(void *parsed_result, 13175 __rte_unused struct cmdline *cl, 13176 __rte_unused void *data) 13177 { 13178 struct cmd_set_nvgre_result *res = parsed_result; 13179 union { 13180 uint32_t nvgre_tni; 13181 uint8_t tni[4]; 13182 } id = { 13183 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 13184 }; 13185 13186 if (strcmp(res->nvgre, "nvgre") == 0) 13187 nvgre_encap_conf.select_vlan = 0; 13188 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 13189 nvgre_encap_conf.select_vlan = 1; 13190 if (strcmp(res->ip_version, "ipv4") == 0) 13191 nvgre_encap_conf.select_ipv4 = 1; 13192 else if (strcmp(res->ip_version, "ipv6") == 0) 13193 nvgre_encap_conf.select_ipv4 = 0; 13194 else 13195 return; 13196 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 13197 if (nvgre_encap_conf.select_ipv4) { 13198 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 13199 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 13200 } else { 13201 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 13202 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 13203 } 13204 if (nvgre_encap_conf.select_vlan) 13205 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13206 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 13207 RTE_ETHER_ADDR_LEN); 13208 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13209 RTE_ETHER_ADDR_LEN); 13210 } 13211 13212 cmdline_parse_inst_t cmd_set_nvgre = { 13213 .f = cmd_set_nvgre_parsed, 13214 .data = NULL, 13215 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 13216 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 13217 " eth-dst <eth-dst>", 13218 .tokens = { 13219 (void *)&cmd_set_nvgre_set, 13220 (void *)&cmd_set_nvgre_nvgre, 13221 (void *)&cmd_set_nvgre_ip_version, 13222 (void *)&cmd_set_nvgre_ip_version_value, 13223 (void *)&cmd_set_nvgre_tni, 13224 (void *)&cmd_set_nvgre_tni_value, 13225 (void *)&cmd_set_nvgre_ip_src, 13226 (void *)&cmd_set_nvgre_ip_src_value, 13227 (void *)&cmd_set_nvgre_ip_dst, 13228 (void *)&cmd_set_nvgre_ip_dst_value, 13229 (void *)&cmd_set_nvgre_eth_src, 13230 (void *)&cmd_set_nvgre_eth_src_value, 13231 (void *)&cmd_set_nvgre_eth_dst, 13232 (void *)&cmd_set_nvgre_eth_dst_value, 13233 NULL, 13234 }, 13235 }; 13236 13237 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 13238 .f = cmd_set_nvgre_parsed, 13239 .data = NULL, 13240 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 13241 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 13242 " eth-src <eth-src> eth-dst <eth-dst>", 13243 .tokens = { 13244 (void *)&cmd_set_nvgre_set, 13245 (void *)&cmd_set_nvgre_nvgre_with_vlan, 13246 (void *)&cmd_set_nvgre_ip_version, 13247 (void *)&cmd_set_nvgre_ip_version_value, 13248 (void *)&cmd_set_nvgre_tni, 13249 (void *)&cmd_set_nvgre_tni_value, 13250 (void *)&cmd_set_nvgre_ip_src, 13251 (void *)&cmd_set_nvgre_ip_src_value, 13252 (void *)&cmd_set_nvgre_ip_dst, 13253 (void *)&cmd_set_nvgre_ip_dst_value, 13254 (void *)&cmd_set_nvgre_vlan, 13255 (void *)&cmd_set_nvgre_vlan_value, 13256 (void *)&cmd_set_nvgre_eth_src, 13257 (void *)&cmd_set_nvgre_eth_src_value, 13258 (void *)&cmd_set_nvgre_eth_dst, 13259 (void *)&cmd_set_nvgre_eth_dst_value, 13260 NULL, 13261 }, 13262 }; 13263 13264 /** Set L2 encapsulation details */ 13265 struct cmd_set_l2_encap_result { 13266 cmdline_fixed_string_t set; 13267 cmdline_fixed_string_t l2_encap; 13268 cmdline_fixed_string_t pos_token; 13269 cmdline_fixed_string_t ip_version; 13270 uint32_t vlan_present:1; 13271 uint16_t tci; 13272 struct rte_ether_addr eth_src; 13273 struct rte_ether_addr eth_dst; 13274 }; 13275 13276 cmdline_parse_token_string_t cmd_set_l2_encap_set = 13277 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); 13278 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = 13279 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); 13280 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = 13281 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, 13282 "l2_encap-with-vlan"); 13283 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = 13284 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13285 "ip-version"); 13286 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = 13287 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, 13288 "ipv4#ipv6"); 13289 cmdline_parse_token_string_t cmd_set_l2_encap_vlan = 13290 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13291 "vlan-tci"); 13292 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = 13293 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16); 13294 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = 13295 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13296 "eth-src"); 13297 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = 13298 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); 13299 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = 13300 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13301 "eth-dst"); 13302 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = 13303 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); 13304 13305 static void cmd_set_l2_encap_parsed(void *parsed_result, 13306 __rte_unused struct cmdline *cl, 13307 __rte_unused void *data) 13308 { 13309 struct cmd_set_l2_encap_result *res = parsed_result; 13310 13311 if (strcmp(res->l2_encap, "l2_encap") == 0) 13312 l2_encap_conf.select_vlan = 0; 13313 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) 13314 l2_encap_conf.select_vlan = 1; 13315 if (strcmp(res->ip_version, "ipv4") == 0) 13316 l2_encap_conf.select_ipv4 = 1; 13317 else if (strcmp(res->ip_version, "ipv6") == 0) 13318 l2_encap_conf.select_ipv4 = 0; 13319 else 13320 return; 13321 if (l2_encap_conf.select_vlan) 13322 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13323 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, 13324 RTE_ETHER_ADDR_LEN); 13325 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13326 RTE_ETHER_ADDR_LEN); 13327 } 13328 13329 cmdline_parse_inst_t cmd_set_l2_encap = { 13330 .f = cmd_set_l2_encap_parsed, 13331 .data = NULL, 13332 .help_str = "set l2_encap ip-version ipv4|ipv6" 13333 " eth-src <eth-src> eth-dst <eth-dst>", 13334 .tokens = { 13335 (void *)&cmd_set_l2_encap_set, 13336 (void *)&cmd_set_l2_encap_l2_encap, 13337 (void *)&cmd_set_l2_encap_ip_version, 13338 (void *)&cmd_set_l2_encap_ip_version_value, 13339 (void *)&cmd_set_l2_encap_eth_src, 13340 (void *)&cmd_set_l2_encap_eth_src_value, 13341 (void *)&cmd_set_l2_encap_eth_dst, 13342 (void *)&cmd_set_l2_encap_eth_dst_value, 13343 NULL, 13344 }, 13345 }; 13346 13347 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { 13348 .f = cmd_set_l2_encap_parsed, 13349 .data = NULL, 13350 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" 13351 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 13352 .tokens = { 13353 (void *)&cmd_set_l2_encap_set, 13354 (void *)&cmd_set_l2_encap_l2_encap_with_vlan, 13355 (void *)&cmd_set_l2_encap_ip_version, 13356 (void *)&cmd_set_l2_encap_ip_version_value, 13357 (void *)&cmd_set_l2_encap_vlan, 13358 (void *)&cmd_set_l2_encap_vlan_value, 13359 (void *)&cmd_set_l2_encap_eth_src, 13360 (void *)&cmd_set_l2_encap_eth_src_value, 13361 (void *)&cmd_set_l2_encap_eth_dst, 13362 (void *)&cmd_set_l2_encap_eth_dst_value, 13363 NULL, 13364 }, 13365 }; 13366 13367 /** Set L2 decapsulation details */ 13368 struct cmd_set_l2_decap_result { 13369 cmdline_fixed_string_t set; 13370 cmdline_fixed_string_t l2_decap; 13371 cmdline_fixed_string_t pos_token; 13372 uint32_t vlan_present:1; 13373 }; 13374 13375 cmdline_parse_token_string_t cmd_set_l2_decap_set = 13376 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); 13377 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = 13378 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 13379 "l2_decap"); 13380 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = 13381 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 13382 "l2_decap-with-vlan"); 13383 13384 static void cmd_set_l2_decap_parsed(void *parsed_result, 13385 __rte_unused struct cmdline *cl, 13386 __rte_unused void *data) 13387 { 13388 struct cmd_set_l2_decap_result *res = parsed_result; 13389 13390 if (strcmp(res->l2_decap, "l2_decap") == 0) 13391 l2_decap_conf.select_vlan = 0; 13392 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) 13393 l2_decap_conf.select_vlan = 1; 13394 } 13395 13396 cmdline_parse_inst_t cmd_set_l2_decap = { 13397 .f = cmd_set_l2_decap_parsed, 13398 .data = NULL, 13399 .help_str = "set l2_decap", 13400 .tokens = { 13401 (void *)&cmd_set_l2_decap_set, 13402 (void *)&cmd_set_l2_decap_l2_decap, 13403 NULL, 13404 }, 13405 }; 13406 13407 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { 13408 .f = cmd_set_l2_decap_parsed, 13409 .data = NULL, 13410 .help_str = "set l2_decap-with-vlan", 13411 .tokens = { 13412 (void *)&cmd_set_l2_decap_set, 13413 (void *)&cmd_set_l2_decap_l2_decap_with_vlan, 13414 NULL, 13415 }, 13416 }; 13417 13418 /** Set MPLSoGRE encapsulation details */ 13419 struct cmd_set_mplsogre_encap_result { 13420 cmdline_fixed_string_t set; 13421 cmdline_fixed_string_t mplsogre; 13422 cmdline_fixed_string_t pos_token; 13423 cmdline_fixed_string_t ip_version; 13424 uint32_t vlan_present:1; 13425 uint32_t label; 13426 cmdline_ipaddr_t ip_src; 13427 cmdline_ipaddr_t ip_dst; 13428 uint16_t tci; 13429 struct rte_ether_addr eth_src; 13430 struct rte_ether_addr eth_dst; 13431 }; 13432 13433 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = 13434 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, 13435 "set"); 13436 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = 13437 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, 13438 "mplsogre_encap"); 13439 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = 13440 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13441 mplsogre, "mplsogre_encap-with-vlan"); 13442 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = 13443 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13444 pos_token, "ip-version"); 13445 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = 13446 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13447 ip_version, "ipv4#ipv6"); 13448 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = 13449 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13450 pos_token, "label"); 13451 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = 13452 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, 13453 RTE_UINT32); 13454 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = 13455 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13456 pos_token, "ip-src"); 13457 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = 13458 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); 13459 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = 13460 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13461 pos_token, "ip-dst"); 13462 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = 13463 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); 13464 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = 13465 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13466 pos_token, "vlan-tci"); 13467 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = 13468 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, 13469 RTE_UINT16); 13470 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = 13471 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13472 pos_token, "eth-src"); 13473 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = 13474 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13475 eth_src); 13476 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = 13477 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13478 pos_token, "eth-dst"); 13479 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = 13480 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13481 eth_dst); 13482 13483 static void cmd_set_mplsogre_encap_parsed(void *parsed_result, 13484 __rte_unused struct cmdline *cl, 13485 __rte_unused void *data) 13486 { 13487 struct cmd_set_mplsogre_encap_result *res = parsed_result; 13488 union { 13489 uint32_t mplsogre_label; 13490 uint8_t label[4]; 13491 } id = { 13492 .mplsogre_label = rte_cpu_to_be_32(res->label<<12), 13493 }; 13494 13495 if (strcmp(res->mplsogre, "mplsogre_encap") == 0) 13496 mplsogre_encap_conf.select_vlan = 0; 13497 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) 13498 mplsogre_encap_conf.select_vlan = 1; 13499 if (strcmp(res->ip_version, "ipv4") == 0) 13500 mplsogre_encap_conf.select_ipv4 = 1; 13501 else if (strcmp(res->ip_version, "ipv6") == 0) 13502 mplsogre_encap_conf.select_ipv4 = 0; 13503 else 13504 return; 13505 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3); 13506 if (mplsogre_encap_conf.select_ipv4) { 13507 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); 13508 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); 13509 } else { 13510 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); 13511 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); 13512 } 13513 if (mplsogre_encap_conf.select_vlan) 13514 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13515 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, 13516 RTE_ETHER_ADDR_LEN); 13517 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13518 RTE_ETHER_ADDR_LEN); 13519 } 13520 13521 cmdline_parse_inst_t cmd_set_mplsogre_encap = { 13522 .f = cmd_set_mplsogre_encap_parsed, 13523 .data = NULL, 13524 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" 13525 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 13526 " eth-dst <eth-dst>", 13527 .tokens = { 13528 (void *)&cmd_set_mplsogre_encap_set, 13529 (void *)&cmd_set_mplsogre_encap_mplsogre_encap, 13530 (void *)&cmd_set_mplsogre_encap_ip_version, 13531 (void *)&cmd_set_mplsogre_encap_ip_version_value, 13532 (void *)&cmd_set_mplsogre_encap_label, 13533 (void *)&cmd_set_mplsogre_encap_label_value, 13534 (void *)&cmd_set_mplsogre_encap_ip_src, 13535 (void *)&cmd_set_mplsogre_encap_ip_src_value, 13536 (void *)&cmd_set_mplsogre_encap_ip_dst, 13537 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 13538 (void *)&cmd_set_mplsogre_encap_eth_src, 13539 (void *)&cmd_set_mplsogre_encap_eth_src_value, 13540 (void *)&cmd_set_mplsogre_encap_eth_dst, 13541 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 13542 NULL, 13543 }, 13544 }; 13545 13546 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { 13547 .f = cmd_set_mplsogre_encap_parsed, 13548 .data = NULL, 13549 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" 13550 " label <label> ip-src <ip-src> ip-dst <ip-dst>" 13551 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 13552 .tokens = { 13553 (void *)&cmd_set_mplsogre_encap_set, 13554 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, 13555 (void *)&cmd_set_mplsogre_encap_ip_version, 13556 (void *)&cmd_set_mplsogre_encap_ip_version_value, 13557 (void *)&cmd_set_mplsogre_encap_label, 13558 (void *)&cmd_set_mplsogre_encap_label_value, 13559 (void *)&cmd_set_mplsogre_encap_ip_src, 13560 (void *)&cmd_set_mplsogre_encap_ip_src_value, 13561 (void *)&cmd_set_mplsogre_encap_ip_dst, 13562 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 13563 (void *)&cmd_set_mplsogre_encap_vlan, 13564 (void *)&cmd_set_mplsogre_encap_vlan_value, 13565 (void *)&cmd_set_mplsogre_encap_eth_src, 13566 (void *)&cmd_set_mplsogre_encap_eth_src_value, 13567 (void *)&cmd_set_mplsogre_encap_eth_dst, 13568 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 13569 NULL, 13570 }, 13571 }; 13572 13573 /** Set MPLSoGRE decapsulation details */ 13574 struct cmd_set_mplsogre_decap_result { 13575 cmdline_fixed_string_t set; 13576 cmdline_fixed_string_t mplsogre; 13577 cmdline_fixed_string_t pos_token; 13578 cmdline_fixed_string_t ip_version; 13579 uint32_t vlan_present:1; 13580 }; 13581 13582 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = 13583 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, 13584 "set"); 13585 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = 13586 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, 13587 "mplsogre_decap"); 13588 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = 13589 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 13590 mplsogre, "mplsogre_decap-with-vlan"); 13591 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = 13592 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 13593 pos_token, "ip-version"); 13594 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = 13595 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 13596 ip_version, "ipv4#ipv6"); 13597 13598 static void cmd_set_mplsogre_decap_parsed(void *parsed_result, 13599 __rte_unused struct cmdline *cl, 13600 __rte_unused void *data) 13601 { 13602 struct cmd_set_mplsogre_decap_result *res = parsed_result; 13603 13604 if (strcmp(res->mplsogre, "mplsogre_decap") == 0) 13605 mplsogre_decap_conf.select_vlan = 0; 13606 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) 13607 mplsogre_decap_conf.select_vlan = 1; 13608 if (strcmp(res->ip_version, "ipv4") == 0) 13609 mplsogre_decap_conf.select_ipv4 = 1; 13610 else if (strcmp(res->ip_version, "ipv6") == 0) 13611 mplsogre_decap_conf.select_ipv4 = 0; 13612 } 13613 13614 cmdline_parse_inst_t cmd_set_mplsogre_decap = { 13615 .f = cmd_set_mplsogre_decap_parsed, 13616 .data = NULL, 13617 .help_str = "set mplsogre_decap ip-version ipv4|ipv6", 13618 .tokens = { 13619 (void *)&cmd_set_mplsogre_decap_set, 13620 (void *)&cmd_set_mplsogre_decap_mplsogre_decap, 13621 (void *)&cmd_set_mplsogre_decap_ip_version, 13622 (void *)&cmd_set_mplsogre_decap_ip_version_value, 13623 NULL, 13624 }, 13625 }; 13626 13627 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { 13628 .f = cmd_set_mplsogre_decap_parsed, 13629 .data = NULL, 13630 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", 13631 .tokens = { 13632 (void *)&cmd_set_mplsogre_decap_set, 13633 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, 13634 (void *)&cmd_set_mplsogre_decap_ip_version, 13635 (void *)&cmd_set_mplsogre_decap_ip_version_value, 13636 NULL, 13637 }, 13638 }; 13639 13640 /** Set MPLSoUDP encapsulation details */ 13641 struct cmd_set_mplsoudp_encap_result { 13642 cmdline_fixed_string_t set; 13643 cmdline_fixed_string_t mplsoudp; 13644 cmdline_fixed_string_t pos_token; 13645 cmdline_fixed_string_t ip_version; 13646 uint32_t vlan_present:1; 13647 uint32_t label; 13648 uint16_t udp_src; 13649 uint16_t udp_dst; 13650 cmdline_ipaddr_t ip_src; 13651 cmdline_ipaddr_t ip_dst; 13652 uint16_t tci; 13653 struct rte_ether_addr eth_src; 13654 struct rte_ether_addr eth_dst; 13655 }; 13656 13657 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = 13658 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, 13659 "set"); 13660 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = 13661 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, 13662 "mplsoudp_encap"); 13663 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = 13664 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13665 mplsoudp, "mplsoudp_encap-with-vlan"); 13666 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = 13667 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13668 pos_token, "ip-version"); 13669 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = 13670 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13671 ip_version, "ipv4#ipv6"); 13672 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = 13673 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13674 pos_token, "label"); 13675 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = 13676 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, 13677 RTE_UINT32); 13678 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = 13679 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13680 pos_token, "udp-src"); 13681 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = 13682 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, 13683 RTE_UINT16); 13684 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = 13685 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13686 pos_token, "udp-dst"); 13687 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = 13688 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, 13689 RTE_UINT16); 13690 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = 13691 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13692 pos_token, "ip-src"); 13693 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = 13694 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); 13695 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = 13696 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13697 pos_token, "ip-dst"); 13698 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = 13699 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); 13700 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = 13701 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13702 pos_token, "vlan-tci"); 13703 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = 13704 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, 13705 RTE_UINT16); 13706 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = 13707 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13708 pos_token, "eth-src"); 13709 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = 13710 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13711 eth_src); 13712 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = 13713 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13714 pos_token, "eth-dst"); 13715 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = 13716 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13717 eth_dst); 13718 13719 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, 13720 __rte_unused struct cmdline *cl, 13721 __rte_unused void *data) 13722 { 13723 struct cmd_set_mplsoudp_encap_result *res = parsed_result; 13724 union { 13725 uint32_t mplsoudp_label; 13726 uint8_t label[4]; 13727 } id = { 13728 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12), 13729 }; 13730 13731 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) 13732 mplsoudp_encap_conf.select_vlan = 0; 13733 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) 13734 mplsoudp_encap_conf.select_vlan = 1; 13735 if (strcmp(res->ip_version, "ipv4") == 0) 13736 mplsoudp_encap_conf.select_ipv4 = 1; 13737 else if (strcmp(res->ip_version, "ipv6") == 0) 13738 mplsoudp_encap_conf.select_ipv4 = 0; 13739 else 13740 return; 13741 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3); 13742 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 13743 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 13744 if (mplsoudp_encap_conf.select_ipv4) { 13745 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); 13746 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); 13747 } else { 13748 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); 13749 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); 13750 } 13751 if (mplsoudp_encap_conf.select_vlan) 13752 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13753 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, 13754 RTE_ETHER_ADDR_LEN); 13755 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13756 RTE_ETHER_ADDR_LEN); 13757 } 13758 13759 cmdline_parse_inst_t cmd_set_mplsoudp_encap = { 13760 .f = cmd_set_mplsoudp_encap_parsed, 13761 .data = NULL, 13762 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" 13763 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" 13764 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", 13765 .tokens = { 13766 (void *)&cmd_set_mplsoudp_encap_set, 13767 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, 13768 (void *)&cmd_set_mplsoudp_encap_ip_version, 13769 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 13770 (void *)&cmd_set_mplsoudp_encap_label, 13771 (void *)&cmd_set_mplsoudp_encap_label_value, 13772 (void *)&cmd_set_mplsoudp_encap_udp_src, 13773 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 13774 (void *)&cmd_set_mplsoudp_encap_udp_dst, 13775 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 13776 (void *)&cmd_set_mplsoudp_encap_ip_src, 13777 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 13778 (void *)&cmd_set_mplsoudp_encap_ip_dst, 13779 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 13780 (void *)&cmd_set_mplsoudp_encap_eth_src, 13781 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 13782 (void *)&cmd_set_mplsoudp_encap_eth_dst, 13783 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 13784 NULL, 13785 }, 13786 }; 13787 13788 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { 13789 .f = cmd_set_mplsoudp_encap_parsed, 13790 .data = NULL, 13791 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" 13792 " label <label> udp-src <udp-src> udp-dst <udp-dst>" 13793 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 13794 " eth-src <eth-src> eth-dst <eth-dst>", 13795 .tokens = { 13796 (void *)&cmd_set_mplsoudp_encap_set, 13797 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, 13798 (void *)&cmd_set_mplsoudp_encap_ip_version, 13799 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 13800 (void *)&cmd_set_mplsoudp_encap_label, 13801 (void *)&cmd_set_mplsoudp_encap_label_value, 13802 (void *)&cmd_set_mplsoudp_encap_udp_src, 13803 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 13804 (void *)&cmd_set_mplsoudp_encap_udp_dst, 13805 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 13806 (void *)&cmd_set_mplsoudp_encap_ip_src, 13807 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 13808 (void *)&cmd_set_mplsoudp_encap_ip_dst, 13809 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 13810 (void *)&cmd_set_mplsoudp_encap_vlan, 13811 (void *)&cmd_set_mplsoudp_encap_vlan_value, 13812 (void *)&cmd_set_mplsoudp_encap_eth_src, 13813 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 13814 (void *)&cmd_set_mplsoudp_encap_eth_dst, 13815 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 13816 NULL, 13817 }, 13818 }; 13819 13820 /** Set MPLSoUDP decapsulation details */ 13821 struct cmd_set_mplsoudp_decap_result { 13822 cmdline_fixed_string_t set; 13823 cmdline_fixed_string_t mplsoudp; 13824 cmdline_fixed_string_t pos_token; 13825 cmdline_fixed_string_t ip_version; 13826 uint32_t vlan_present:1; 13827 }; 13828 13829 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = 13830 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, 13831 "set"); 13832 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = 13833 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, 13834 "mplsoudp_decap"); 13835 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = 13836 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 13837 mplsoudp, "mplsoudp_decap-with-vlan"); 13838 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = 13839 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 13840 pos_token, "ip-version"); 13841 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = 13842 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 13843 ip_version, "ipv4#ipv6"); 13844 13845 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, 13846 __rte_unused struct cmdline *cl, 13847 __rte_unused void *data) 13848 { 13849 struct cmd_set_mplsoudp_decap_result *res = parsed_result; 13850 13851 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) 13852 mplsoudp_decap_conf.select_vlan = 0; 13853 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) 13854 mplsoudp_decap_conf.select_vlan = 1; 13855 if (strcmp(res->ip_version, "ipv4") == 0) 13856 mplsoudp_decap_conf.select_ipv4 = 1; 13857 else if (strcmp(res->ip_version, "ipv6") == 0) 13858 mplsoudp_decap_conf.select_ipv4 = 0; 13859 } 13860 13861 cmdline_parse_inst_t cmd_set_mplsoudp_decap = { 13862 .f = cmd_set_mplsoudp_decap_parsed, 13863 .data = NULL, 13864 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", 13865 .tokens = { 13866 (void *)&cmd_set_mplsoudp_decap_set, 13867 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, 13868 (void *)&cmd_set_mplsoudp_decap_ip_version, 13869 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 13870 NULL, 13871 }, 13872 }; 13873 13874 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { 13875 .f = cmd_set_mplsoudp_decap_parsed, 13876 .data = NULL, 13877 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", 13878 .tokens = { 13879 (void *)&cmd_set_mplsoudp_decap_set, 13880 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, 13881 (void *)&cmd_set_mplsoudp_decap_ip_version, 13882 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 13883 NULL, 13884 }, 13885 }; 13886 13887 /** Set connection tracking object common details */ 13888 struct cmd_set_conntrack_common_result { 13889 cmdline_fixed_string_t set; 13890 cmdline_fixed_string_t conntrack; 13891 cmdline_fixed_string_t common; 13892 cmdline_fixed_string_t peer; 13893 cmdline_fixed_string_t is_orig; 13894 cmdline_fixed_string_t enable; 13895 cmdline_fixed_string_t live; 13896 cmdline_fixed_string_t sack; 13897 cmdline_fixed_string_t cack; 13898 cmdline_fixed_string_t last_dir; 13899 cmdline_fixed_string_t liberal; 13900 cmdline_fixed_string_t state; 13901 cmdline_fixed_string_t max_ack_win; 13902 cmdline_fixed_string_t retrans; 13903 cmdline_fixed_string_t last_win; 13904 cmdline_fixed_string_t last_seq; 13905 cmdline_fixed_string_t last_ack; 13906 cmdline_fixed_string_t last_end; 13907 cmdline_fixed_string_t last_index; 13908 uint8_t stat; 13909 uint8_t factor; 13910 uint16_t peer_port; 13911 uint32_t is_original; 13912 uint32_t en; 13913 uint32_t is_live; 13914 uint32_t s_ack; 13915 uint32_t c_ack; 13916 uint32_t ld; 13917 uint32_t lb; 13918 uint8_t re_num; 13919 uint8_t li; 13920 uint16_t lw; 13921 uint32_t ls; 13922 uint32_t la; 13923 uint32_t le; 13924 }; 13925 13926 cmdline_parse_token_string_t cmd_set_conntrack_set = 13927 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13928 set, "set"); 13929 cmdline_parse_token_string_t cmd_set_conntrack_conntrack = 13930 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13931 conntrack, "conntrack"); 13932 cmdline_parse_token_string_t cmd_set_conntrack_common_com = 13933 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13934 common, "com"); 13935 cmdline_parse_token_string_t cmd_set_conntrack_common_peer = 13936 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13937 peer, "peer"); 13938 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value = 13939 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13940 peer_port, RTE_UINT16); 13941 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig = 13942 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13943 is_orig, "is_orig"); 13944 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value = 13945 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13946 is_original, RTE_UINT32); 13947 cmdline_parse_token_string_t cmd_set_conntrack_common_enable = 13948 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13949 enable, "enable"); 13950 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value = 13951 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13952 en, RTE_UINT32); 13953 cmdline_parse_token_string_t cmd_set_conntrack_common_live = 13954 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13955 live, "live"); 13956 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value = 13957 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13958 is_live, RTE_UINT32); 13959 cmdline_parse_token_string_t cmd_set_conntrack_common_sack = 13960 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13961 sack, "sack"); 13962 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value = 13963 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13964 s_ack, RTE_UINT32); 13965 cmdline_parse_token_string_t cmd_set_conntrack_common_cack = 13966 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13967 cack, "cack"); 13968 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value = 13969 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13970 c_ack, RTE_UINT32); 13971 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir = 13972 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13973 last_dir, "last_dir"); 13974 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value = 13975 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13976 ld, RTE_UINT32); 13977 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal = 13978 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13979 liberal, "liberal"); 13980 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value = 13981 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13982 lb, RTE_UINT32); 13983 cmdline_parse_token_string_t cmd_set_conntrack_common_state = 13984 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13985 state, "state"); 13986 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value = 13987 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13988 stat, RTE_UINT8); 13989 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin = 13990 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13991 max_ack_win, "max_ack_win"); 13992 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value = 13993 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 13994 factor, RTE_UINT8); 13995 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans = 13996 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 13997 retrans, "r_lim"); 13998 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value = 13999 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14000 re_num, RTE_UINT8); 14001 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win = 14002 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14003 last_win, "last_win"); 14004 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value = 14005 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14006 lw, RTE_UINT16); 14007 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq = 14008 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14009 last_seq, "last_seq"); 14010 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value = 14011 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14012 ls, RTE_UINT32); 14013 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack = 14014 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14015 last_ack, "last_ack"); 14016 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value = 14017 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14018 la, RTE_UINT32); 14019 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end = 14020 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14021 last_end, "last_end"); 14022 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value = 14023 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14024 le, RTE_UINT32); 14025 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index = 14026 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 14027 last_index, "last_index"); 14028 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value = 14029 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 14030 li, RTE_UINT8); 14031 14032 static void cmd_set_conntrack_common_parsed(void *parsed_result, 14033 __rte_unused struct cmdline *cl, 14034 __rte_unused void *data) 14035 { 14036 struct cmd_set_conntrack_common_result *res = parsed_result; 14037 14038 /* No need to swap to big endian. */ 14039 conntrack_context.peer_port = res->peer_port; 14040 conntrack_context.is_original_dir = res->is_original; 14041 conntrack_context.enable = res->en; 14042 conntrack_context.live_connection = res->is_live; 14043 conntrack_context.selective_ack = res->s_ack; 14044 conntrack_context.challenge_ack_passed = res->c_ack; 14045 conntrack_context.last_direction = res->ld; 14046 conntrack_context.liberal_mode = res->lb; 14047 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat; 14048 conntrack_context.max_ack_window = res->factor; 14049 conntrack_context.retransmission_limit = res->re_num; 14050 conntrack_context.last_window = res->lw; 14051 conntrack_context.last_index = 14052 (enum rte_flow_conntrack_tcp_last_index)res->li; 14053 conntrack_context.last_seq = res->ls; 14054 conntrack_context.last_ack = res->la; 14055 conntrack_context.last_end = res->le; 14056 } 14057 14058 cmdline_parse_inst_t cmd_set_conntrack_common = { 14059 .f = cmd_set_conntrack_common_parsed, 14060 .data = NULL, 14061 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>" 14062 " live <ack_seen> sack <en> cack <passed> last_dir <dir>" 14063 " liberal <en> state <s> max_ack_win <factor> r_lim <num>" 14064 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>" 14065 " last_index <flag>", 14066 .tokens = { 14067 (void *)&cmd_set_conntrack_set, 14068 (void *)&cmd_set_conntrack_conntrack, 14069 (void *)&cmd_set_conntrack_common_com, 14070 (void *)&cmd_set_conntrack_common_peer, 14071 (void *)&cmd_set_conntrack_common_peer_value, 14072 (void *)&cmd_set_conntrack_common_is_orig, 14073 (void *)&cmd_set_conntrack_common_is_orig_value, 14074 (void *)&cmd_set_conntrack_common_enable, 14075 (void *)&cmd_set_conntrack_common_enable_value, 14076 (void *)&cmd_set_conntrack_common_live, 14077 (void *)&cmd_set_conntrack_common_live_value, 14078 (void *)&cmd_set_conntrack_common_sack, 14079 (void *)&cmd_set_conntrack_common_sack_value, 14080 (void *)&cmd_set_conntrack_common_cack, 14081 (void *)&cmd_set_conntrack_common_cack_value, 14082 (void *)&cmd_set_conntrack_common_last_dir, 14083 (void *)&cmd_set_conntrack_common_last_dir_value, 14084 (void *)&cmd_set_conntrack_common_liberal, 14085 (void *)&cmd_set_conntrack_common_liberal_value, 14086 (void *)&cmd_set_conntrack_common_state, 14087 (void *)&cmd_set_conntrack_common_state_value, 14088 (void *)&cmd_set_conntrack_common_max_ackwin, 14089 (void *)&cmd_set_conntrack_common_max_ackwin_value, 14090 (void *)&cmd_set_conntrack_common_retrans, 14091 (void *)&cmd_set_conntrack_common_retrans_value, 14092 (void *)&cmd_set_conntrack_common_last_win, 14093 (void *)&cmd_set_conntrack_common_last_win_value, 14094 (void *)&cmd_set_conntrack_common_last_seq, 14095 (void *)&cmd_set_conntrack_common_last_seq_value, 14096 (void *)&cmd_set_conntrack_common_last_ack, 14097 (void *)&cmd_set_conntrack_common_last_ack_value, 14098 (void *)&cmd_set_conntrack_common_last_end, 14099 (void *)&cmd_set_conntrack_common_last_end_value, 14100 (void *)&cmd_set_conntrack_common_last_index, 14101 (void *)&cmd_set_conntrack_common_last_index_value, 14102 NULL, 14103 }, 14104 }; 14105 14106 /** Set connection tracking object both directions' details */ 14107 struct cmd_set_conntrack_dir_result { 14108 cmdline_fixed_string_t set; 14109 cmdline_fixed_string_t conntrack; 14110 cmdline_fixed_string_t dir; 14111 cmdline_fixed_string_t scale; 14112 cmdline_fixed_string_t fin; 14113 cmdline_fixed_string_t ack_seen; 14114 cmdline_fixed_string_t unack; 14115 cmdline_fixed_string_t sent_end; 14116 cmdline_fixed_string_t reply_end; 14117 cmdline_fixed_string_t max_win; 14118 cmdline_fixed_string_t max_ack; 14119 uint32_t factor; 14120 uint32_t f; 14121 uint32_t as; 14122 uint32_t un; 14123 uint32_t se; 14124 uint32_t re; 14125 uint32_t mw; 14126 uint32_t ma; 14127 }; 14128 14129 cmdline_parse_token_string_t cmd_set_conntrack_dir_set = 14130 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14131 set, "set"); 14132 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack = 14133 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14134 conntrack, "conntrack"); 14135 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir = 14136 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14137 dir, "orig#rply"); 14138 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale = 14139 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14140 scale, "scale"); 14141 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value = 14142 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14143 factor, RTE_UINT32); 14144 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin = 14145 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14146 fin, "fin"); 14147 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value = 14148 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14149 f, RTE_UINT32); 14150 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack = 14151 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14152 ack_seen, "acked"); 14153 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value = 14154 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14155 as, RTE_UINT32); 14156 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data = 14157 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14158 unack, "unack_data"); 14159 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value = 14160 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14161 un, RTE_UINT32); 14162 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end = 14163 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14164 sent_end, "sent_end"); 14165 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value = 14166 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14167 se, RTE_UINT32); 14168 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end = 14169 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14170 reply_end, "reply_end"); 14171 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value = 14172 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14173 re, RTE_UINT32); 14174 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win = 14175 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14176 max_win, "max_win"); 14177 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value = 14178 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14179 mw, RTE_UINT32); 14180 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack = 14181 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 14182 max_ack, "max_ack"); 14183 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value = 14184 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 14185 ma, RTE_UINT32); 14186 14187 static void cmd_set_conntrack_dir_parsed(void *parsed_result, 14188 __rte_unused struct cmdline *cl, 14189 __rte_unused void *data) 14190 { 14191 struct cmd_set_conntrack_dir_result *res = parsed_result; 14192 struct rte_flow_tcp_dir_param *dir = NULL; 14193 14194 if (strcmp(res->dir, "orig") == 0) 14195 dir = &conntrack_context.original_dir; 14196 else if (strcmp(res->dir, "rply") == 0) 14197 dir = &conntrack_context.reply_dir; 14198 else 14199 return; 14200 dir->scale = res->factor; 14201 dir->close_initiated = res->f; 14202 dir->last_ack_seen = res->as; 14203 dir->data_unacked = res->un; 14204 dir->sent_end = res->se; 14205 dir->reply_end = res->re; 14206 dir->max_ack = res->ma; 14207 dir->max_win = res->mw; 14208 } 14209 14210 cmdline_parse_inst_t cmd_set_conntrack_dir = { 14211 .f = cmd_set_conntrack_dir_parsed, 14212 .data = NULL, 14213 .help_str = "set conntrack orig|rply scale <factor> fin <sent>" 14214 " acked <seen> unack_data <unack> sent_end <sent>" 14215 " reply_end <reply> max_win <win> max_ack <ack>", 14216 .tokens = { 14217 (void *)&cmd_set_conntrack_set, 14218 (void *)&cmd_set_conntrack_conntrack, 14219 (void *)&cmd_set_conntrack_dir_dir, 14220 (void *)&cmd_set_conntrack_dir_scale, 14221 (void *)&cmd_set_conntrack_dir_scale_value, 14222 (void *)&cmd_set_conntrack_dir_fin, 14223 (void *)&cmd_set_conntrack_dir_fin_value, 14224 (void *)&cmd_set_conntrack_dir_ack, 14225 (void *)&cmd_set_conntrack_dir_ack_value, 14226 (void *)&cmd_set_conntrack_dir_unack_data, 14227 (void *)&cmd_set_conntrack_dir_unack_data_value, 14228 (void *)&cmd_set_conntrack_dir_sent_end, 14229 (void *)&cmd_set_conntrack_dir_sent_end_value, 14230 (void *)&cmd_set_conntrack_dir_reply_end, 14231 (void *)&cmd_set_conntrack_dir_reply_end_value, 14232 (void *)&cmd_set_conntrack_dir_max_win, 14233 (void *)&cmd_set_conntrack_dir_max_win_value, 14234 (void *)&cmd_set_conntrack_dir_max_ack, 14235 (void *)&cmd_set_conntrack_dir_max_ack_value, 14236 NULL, 14237 }, 14238 }; 14239 14240 /* Strict link priority scheduling mode setting */ 14241 static void 14242 cmd_strict_link_prio_parsed( 14243 void *parsed_result, 14244 __rte_unused struct cmdline *cl, 14245 __rte_unused void *data) 14246 { 14247 struct cmd_vf_tc_bw_result *res = parsed_result; 14248 int ret = -ENOTSUP; 14249 14250 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14251 return; 14252 14253 #ifdef RTE_NET_I40E 14254 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 14255 #endif 14256 14257 switch (ret) { 14258 case 0: 14259 break; 14260 case -EINVAL: 14261 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map); 14262 break; 14263 case -ENODEV: 14264 fprintf(stderr, "invalid port_id %d\n", res->port_id); 14265 break; 14266 case -ENOTSUP: 14267 fprintf(stderr, "function not implemented\n"); 14268 break; 14269 default: 14270 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 14271 } 14272 } 14273 14274 cmdline_parse_inst_t cmd_strict_link_prio = { 14275 .f = cmd_strict_link_prio_parsed, 14276 .data = NULL, 14277 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 14278 .tokens = { 14279 (void *)&cmd_vf_tc_bw_set, 14280 (void *)&cmd_vf_tc_bw_tx, 14281 (void *)&cmd_vf_tc_bw_strict_link_prio, 14282 (void *)&cmd_vf_tc_bw_port_id, 14283 (void *)&cmd_vf_tc_bw_tc_map, 14284 NULL, 14285 }, 14286 }; 14287 14288 /* Load dynamic device personalization*/ 14289 struct cmd_ddp_add_result { 14290 cmdline_fixed_string_t ddp; 14291 cmdline_fixed_string_t add; 14292 portid_t port_id; 14293 char filepath[]; 14294 }; 14295 14296 cmdline_parse_token_string_t cmd_ddp_add_ddp = 14297 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 14298 cmdline_parse_token_string_t cmd_ddp_add_add = 14299 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 14300 cmdline_parse_token_num_t cmd_ddp_add_port_id = 14301 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, 14302 RTE_UINT16); 14303 cmdline_parse_token_string_t cmd_ddp_add_filepath = 14304 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 14305 14306 static void 14307 cmd_ddp_add_parsed( 14308 void *parsed_result, 14309 __rte_unused struct cmdline *cl, 14310 __rte_unused void *data) 14311 { 14312 struct cmd_ddp_add_result *res = parsed_result; 14313 uint8_t *buff; 14314 uint32_t size; 14315 char *filepath; 14316 char *file_fld[2]; 14317 int file_num; 14318 int ret = -ENOTSUP; 14319 14320 if (!all_ports_stopped()) { 14321 fprintf(stderr, "Please stop all ports first\n"); 14322 return; 14323 } 14324 14325 filepath = strdup(res->filepath); 14326 if (filepath == NULL) { 14327 fprintf(stderr, "Failed to allocate memory\n"); 14328 return; 14329 } 14330 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 14331 14332 buff = open_file(file_fld[0], &size); 14333 if (!buff) { 14334 free((void *)filepath); 14335 return; 14336 } 14337 14338 #ifdef RTE_NET_I40E 14339 if (ret == -ENOTSUP) 14340 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 14341 buff, size, 14342 RTE_PMD_I40E_PKG_OP_WR_ADD); 14343 #endif 14344 14345 if (ret == -EEXIST) 14346 fprintf(stderr, "Profile has already existed.\n"); 14347 else if (ret < 0) 14348 fprintf(stderr, "Failed to load profile.\n"); 14349 else if (file_num == 2) 14350 save_file(file_fld[1], buff, size); 14351 14352 close_file(buff); 14353 free((void *)filepath); 14354 } 14355 14356 cmdline_parse_inst_t cmd_ddp_add = { 14357 .f = cmd_ddp_add_parsed, 14358 .data = NULL, 14359 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 14360 .tokens = { 14361 (void *)&cmd_ddp_add_ddp, 14362 (void *)&cmd_ddp_add_add, 14363 (void *)&cmd_ddp_add_port_id, 14364 (void *)&cmd_ddp_add_filepath, 14365 NULL, 14366 }, 14367 }; 14368 14369 /* Delete dynamic device personalization*/ 14370 struct cmd_ddp_del_result { 14371 cmdline_fixed_string_t ddp; 14372 cmdline_fixed_string_t del; 14373 portid_t port_id; 14374 char filepath[]; 14375 }; 14376 14377 cmdline_parse_token_string_t cmd_ddp_del_ddp = 14378 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 14379 cmdline_parse_token_string_t cmd_ddp_del_del = 14380 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 14381 cmdline_parse_token_num_t cmd_ddp_del_port_id = 14382 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16); 14383 cmdline_parse_token_string_t cmd_ddp_del_filepath = 14384 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 14385 14386 static void 14387 cmd_ddp_del_parsed( 14388 void *parsed_result, 14389 __rte_unused struct cmdline *cl, 14390 __rte_unused void *data) 14391 { 14392 struct cmd_ddp_del_result *res = parsed_result; 14393 uint8_t *buff; 14394 uint32_t size; 14395 int ret = -ENOTSUP; 14396 14397 if (!all_ports_stopped()) { 14398 fprintf(stderr, "Please stop all ports first\n"); 14399 return; 14400 } 14401 14402 buff = open_file(res->filepath, &size); 14403 if (!buff) 14404 return; 14405 14406 #ifdef RTE_NET_I40E 14407 if (ret == -ENOTSUP) 14408 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 14409 buff, size, 14410 RTE_PMD_I40E_PKG_OP_WR_DEL); 14411 #endif 14412 14413 if (ret == -EACCES) 14414 fprintf(stderr, "Profile does not exist.\n"); 14415 else if (ret < 0) 14416 fprintf(stderr, "Failed to delete profile.\n"); 14417 14418 close_file(buff); 14419 } 14420 14421 cmdline_parse_inst_t cmd_ddp_del = { 14422 .f = cmd_ddp_del_parsed, 14423 .data = NULL, 14424 .help_str = "ddp del <port_id> <backup_profile_path>", 14425 .tokens = { 14426 (void *)&cmd_ddp_del_ddp, 14427 (void *)&cmd_ddp_del_del, 14428 (void *)&cmd_ddp_del_port_id, 14429 (void *)&cmd_ddp_del_filepath, 14430 NULL, 14431 }, 14432 }; 14433 14434 /* Get dynamic device personalization profile info */ 14435 struct cmd_ddp_info_result { 14436 cmdline_fixed_string_t ddp; 14437 cmdline_fixed_string_t get; 14438 cmdline_fixed_string_t info; 14439 char filepath[]; 14440 }; 14441 14442 cmdline_parse_token_string_t cmd_ddp_info_ddp = 14443 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 14444 cmdline_parse_token_string_t cmd_ddp_info_get = 14445 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 14446 cmdline_parse_token_string_t cmd_ddp_info_info = 14447 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 14448 cmdline_parse_token_string_t cmd_ddp_info_filepath = 14449 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 14450 14451 static void 14452 cmd_ddp_info_parsed( 14453 void *parsed_result, 14454 __rte_unused struct cmdline *cl, 14455 __rte_unused void *data) 14456 { 14457 struct cmd_ddp_info_result *res = parsed_result; 14458 uint8_t *pkg; 14459 uint32_t pkg_size; 14460 int ret = -ENOTSUP; 14461 #ifdef RTE_NET_I40E 14462 uint32_t i, j, n; 14463 uint8_t *buff; 14464 uint32_t buff_size = 0; 14465 struct rte_pmd_i40e_profile_info info; 14466 uint32_t dev_num = 0; 14467 struct rte_pmd_i40e_ddp_device_id *devs; 14468 uint32_t proto_num = 0; 14469 struct rte_pmd_i40e_proto_info *proto = NULL; 14470 uint32_t pctype_num = 0; 14471 struct rte_pmd_i40e_ptype_info *pctype; 14472 uint32_t ptype_num = 0; 14473 struct rte_pmd_i40e_ptype_info *ptype; 14474 uint8_t proto_id; 14475 14476 #endif 14477 14478 pkg = open_file(res->filepath, &pkg_size); 14479 if (!pkg) 14480 return; 14481 14482 #ifdef RTE_NET_I40E 14483 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14484 (uint8_t *)&info, sizeof(info), 14485 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 14486 if (!ret) { 14487 printf("Global Track id: 0x%x\n", info.track_id); 14488 printf("Global Version: %d.%d.%d.%d\n", 14489 info.version.major, 14490 info.version.minor, 14491 info.version.update, 14492 info.version.draft); 14493 printf("Global Package name: %s\n\n", info.name); 14494 } 14495 14496 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14497 (uint8_t *)&info, sizeof(info), 14498 RTE_PMD_I40E_PKG_INFO_HEADER); 14499 if (!ret) { 14500 printf("i40e Profile Track id: 0x%x\n", info.track_id); 14501 printf("i40e Profile Version: %d.%d.%d.%d\n", 14502 info.version.major, 14503 info.version.minor, 14504 info.version.update, 14505 info.version.draft); 14506 printf("i40e Profile name: %s\n\n", info.name); 14507 } 14508 14509 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14510 (uint8_t *)&buff_size, sizeof(buff_size), 14511 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 14512 if (!ret && buff_size) { 14513 buff = (uint8_t *)malloc(buff_size); 14514 if (buff) { 14515 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14516 buff, buff_size, 14517 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 14518 if (!ret) 14519 printf("Package Notes:\n%s\n\n", buff); 14520 free(buff); 14521 } 14522 } 14523 14524 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14525 (uint8_t *)&dev_num, sizeof(dev_num), 14526 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 14527 if (!ret && dev_num) { 14528 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 14529 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 14530 if (devs) { 14531 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14532 (uint8_t *)devs, buff_size, 14533 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 14534 if (!ret) { 14535 printf("List of supported devices:\n"); 14536 for (i = 0; i < dev_num; i++) { 14537 printf(" %04X:%04X %04X:%04X\n", 14538 devs[i].vendor_dev_id >> 16, 14539 devs[i].vendor_dev_id & 0xFFFF, 14540 devs[i].sub_vendor_dev_id >> 16, 14541 devs[i].sub_vendor_dev_id & 0xFFFF); 14542 } 14543 printf("\n"); 14544 } 14545 free(devs); 14546 } 14547 } 14548 14549 /* get information about protocols and packet types */ 14550 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14551 (uint8_t *)&proto_num, sizeof(proto_num), 14552 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 14553 if (ret || !proto_num) 14554 goto no_print_return; 14555 14556 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 14557 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 14558 if (!proto) 14559 goto no_print_return; 14560 14561 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 14562 buff_size, 14563 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 14564 if (!ret) { 14565 printf("List of used protocols:\n"); 14566 for (i = 0; i < proto_num; i++) 14567 printf(" %2u: %s\n", proto[i].proto_id, 14568 proto[i].name); 14569 printf("\n"); 14570 } 14571 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14572 (uint8_t *)&pctype_num, sizeof(pctype_num), 14573 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 14574 if (ret || !pctype_num) 14575 goto no_print_pctypes; 14576 14577 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 14578 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 14579 if (!pctype) 14580 goto no_print_pctypes; 14581 14582 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 14583 buff_size, 14584 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 14585 if (ret) { 14586 free(pctype); 14587 goto no_print_pctypes; 14588 } 14589 14590 printf("List of defined packet classification types:\n"); 14591 for (i = 0; i < pctype_num; i++) { 14592 printf(" %2u:", pctype[i].ptype_id); 14593 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 14594 proto_id = pctype[i].protocols[j]; 14595 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 14596 for (n = 0; n < proto_num; n++) { 14597 if (proto[n].proto_id == proto_id) { 14598 printf(" %s", proto[n].name); 14599 break; 14600 } 14601 } 14602 } 14603 } 14604 printf("\n"); 14605 } 14606 printf("\n"); 14607 free(pctype); 14608 14609 no_print_pctypes: 14610 14611 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 14612 sizeof(ptype_num), 14613 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 14614 if (ret || !ptype_num) 14615 goto no_print_return; 14616 14617 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 14618 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 14619 if (!ptype) 14620 goto no_print_return; 14621 14622 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 14623 buff_size, 14624 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 14625 if (ret) { 14626 free(ptype); 14627 goto no_print_return; 14628 } 14629 printf("List of defined packet types:\n"); 14630 for (i = 0; i < ptype_num; i++) { 14631 printf(" %2u:", ptype[i].ptype_id); 14632 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 14633 proto_id = ptype[i].protocols[j]; 14634 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 14635 for (n = 0; n < proto_num; n++) { 14636 if (proto[n].proto_id == proto_id) { 14637 printf(" %s", proto[n].name); 14638 break; 14639 } 14640 } 14641 } 14642 } 14643 printf("\n"); 14644 } 14645 free(ptype); 14646 printf("\n"); 14647 14648 ret = 0; 14649 no_print_return: 14650 if (proto) 14651 free(proto); 14652 #endif 14653 if (ret == -ENOTSUP) 14654 fprintf(stderr, "Function not supported in PMD driver\n"); 14655 close_file(pkg); 14656 } 14657 14658 cmdline_parse_inst_t cmd_ddp_get_info = { 14659 .f = cmd_ddp_info_parsed, 14660 .data = NULL, 14661 .help_str = "ddp get info <profile_path>", 14662 .tokens = { 14663 (void *)&cmd_ddp_info_ddp, 14664 (void *)&cmd_ddp_info_get, 14665 (void *)&cmd_ddp_info_info, 14666 (void *)&cmd_ddp_info_filepath, 14667 NULL, 14668 }, 14669 }; 14670 14671 /* Get dynamic device personalization profile info list*/ 14672 #define PROFILE_INFO_SIZE 48 14673 #define MAX_PROFILE_NUM 16 14674 14675 struct cmd_ddp_get_list_result { 14676 cmdline_fixed_string_t ddp; 14677 cmdline_fixed_string_t get; 14678 cmdline_fixed_string_t list; 14679 portid_t port_id; 14680 }; 14681 14682 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 14683 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 14684 cmdline_parse_token_string_t cmd_ddp_get_list_get = 14685 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 14686 cmdline_parse_token_string_t cmd_ddp_get_list_list = 14687 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 14688 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 14689 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, 14690 RTE_UINT16); 14691 14692 static void 14693 cmd_ddp_get_list_parsed( 14694 __rte_unused void *parsed_result, 14695 __rte_unused struct cmdline *cl, 14696 __rte_unused void *data) 14697 { 14698 #ifdef RTE_NET_I40E 14699 struct cmd_ddp_get_list_result *res = parsed_result; 14700 struct rte_pmd_i40e_profile_list *p_list; 14701 struct rte_pmd_i40e_profile_info *p_info; 14702 uint32_t p_num; 14703 uint32_t size; 14704 uint32_t i; 14705 #endif 14706 int ret = -ENOTSUP; 14707 14708 #ifdef RTE_NET_I40E 14709 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 14710 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 14711 if (!p_list) { 14712 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__); 14713 return; 14714 } 14715 14716 if (ret == -ENOTSUP) 14717 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 14718 (uint8_t *)p_list, size); 14719 14720 if (!ret) { 14721 p_num = p_list->p_count; 14722 printf("Profile number is: %d\n\n", p_num); 14723 14724 for (i = 0; i < p_num; i++) { 14725 p_info = &p_list->p_info[i]; 14726 printf("Profile %d:\n", i); 14727 printf("Track id: 0x%x\n", p_info->track_id); 14728 printf("Version: %d.%d.%d.%d\n", 14729 p_info->version.major, 14730 p_info->version.minor, 14731 p_info->version.update, 14732 p_info->version.draft); 14733 printf("Profile name: %s\n\n", p_info->name); 14734 } 14735 } 14736 14737 free(p_list); 14738 #endif 14739 14740 if (ret < 0) 14741 fprintf(stderr, "Failed to get ddp list\n"); 14742 } 14743 14744 cmdline_parse_inst_t cmd_ddp_get_list = { 14745 .f = cmd_ddp_get_list_parsed, 14746 .data = NULL, 14747 .help_str = "ddp get list <port_id>", 14748 .tokens = { 14749 (void *)&cmd_ddp_get_list_ddp, 14750 (void *)&cmd_ddp_get_list_get, 14751 (void *)&cmd_ddp_get_list_list, 14752 (void *)&cmd_ddp_get_list_port_id, 14753 NULL, 14754 }, 14755 }; 14756 14757 /* Configure input set */ 14758 struct cmd_cfg_input_set_result { 14759 cmdline_fixed_string_t port; 14760 cmdline_fixed_string_t cfg; 14761 portid_t port_id; 14762 cmdline_fixed_string_t pctype; 14763 uint8_t pctype_id; 14764 cmdline_fixed_string_t inset_type; 14765 cmdline_fixed_string_t opt; 14766 cmdline_fixed_string_t field; 14767 uint8_t field_idx; 14768 }; 14769 14770 static void 14771 cmd_cfg_input_set_parsed( 14772 __rte_unused void *parsed_result, 14773 __rte_unused struct cmdline *cl, 14774 __rte_unused void *data) 14775 { 14776 #ifdef RTE_NET_I40E 14777 struct cmd_cfg_input_set_result *res = parsed_result; 14778 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 14779 struct rte_pmd_i40e_inset inset; 14780 #endif 14781 int ret = -ENOTSUP; 14782 14783 if (!all_ports_stopped()) { 14784 fprintf(stderr, "Please stop all ports first\n"); 14785 return; 14786 } 14787 14788 #ifdef RTE_NET_I40E 14789 if (!strcmp(res->inset_type, "hash_inset")) 14790 inset_type = INSET_HASH; 14791 else if (!strcmp(res->inset_type, "fdir_inset")) 14792 inset_type = INSET_FDIR; 14793 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 14794 inset_type = INSET_FDIR_FLX; 14795 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 14796 &inset, inset_type); 14797 if (ret) { 14798 fprintf(stderr, "Failed to get input set.\n"); 14799 return; 14800 } 14801 14802 if (!strcmp(res->opt, "get")) { 14803 ret = rte_pmd_i40e_inset_field_get(inset.inset, 14804 res->field_idx); 14805 if (ret) 14806 printf("Field index %d is enabled.\n", res->field_idx); 14807 else 14808 printf("Field index %d is disabled.\n", res->field_idx); 14809 return; 14810 } else if (!strcmp(res->opt, "set")) 14811 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 14812 res->field_idx); 14813 else if (!strcmp(res->opt, "clear")) 14814 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 14815 res->field_idx); 14816 if (ret) { 14817 fprintf(stderr, "Failed to configure input set field.\n"); 14818 return; 14819 } 14820 14821 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 14822 &inset, inset_type); 14823 if (ret) { 14824 fprintf(stderr, "Failed to set input set.\n"); 14825 return; 14826 } 14827 #endif 14828 14829 if (ret == -ENOTSUP) 14830 fprintf(stderr, "Function not supported\n"); 14831 } 14832 14833 cmdline_parse_token_string_t cmd_cfg_input_set_port = 14834 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14835 port, "port"); 14836 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 14837 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14838 cfg, "config"); 14839 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 14840 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 14841 port_id, RTE_UINT16); 14842 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 14843 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14844 pctype, "pctype"); 14845 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 14846 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 14847 pctype_id, RTE_UINT8); 14848 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 14849 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14850 inset_type, 14851 "hash_inset#fdir_inset#fdir_flx_inset"); 14852 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 14853 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14854 opt, "get#set#clear"); 14855 cmdline_parse_token_string_t cmd_cfg_input_set_field = 14856 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14857 field, "field"); 14858 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 14859 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 14860 field_idx, RTE_UINT8); 14861 14862 cmdline_parse_inst_t cmd_cfg_input_set = { 14863 .f = cmd_cfg_input_set_parsed, 14864 .data = NULL, 14865 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 14866 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 14867 .tokens = { 14868 (void *)&cmd_cfg_input_set_port, 14869 (void *)&cmd_cfg_input_set_cfg, 14870 (void *)&cmd_cfg_input_set_port_id, 14871 (void *)&cmd_cfg_input_set_pctype, 14872 (void *)&cmd_cfg_input_set_pctype_id, 14873 (void *)&cmd_cfg_input_set_inset_type, 14874 (void *)&cmd_cfg_input_set_opt, 14875 (void *)&cmd_cfg_input_set_field, 14876 (void *)&cmd_cfg_input_set_field_idx, 14877 NULL, 14878 }, 14879 }; 14880 14881 /* Clear input set */ 14882 struct cmd_clear_input_set_result { 14883 cmdline_fixed_string_t port; 14884 cmdline_fixed_string_t cfg; 14885 portid_t port_id; 14886 cmdline_fixed_string_t pctype; 14887 uint8_t pctype_id; 14888 cmdline_fixed_string_t inset_type; 14889 cmdline_fixed_string_t clear; 14890 cmdline_fixed_string_t all; 14891 }; 14892 14893 static void 14894 cmd_clear_input_set_parsed( 14895 __rte_unused void *parsed_result, 14896 __rte_unused struct cmdline *cl, 14897 __rte_unused void *data) 14898 { 14899 #ifdef RTE_NET_I40E 14900 struct cmd_clear_input_set_result *res = parsed_result; 14901 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 14902 struct rte_pmd_i40e_inset inset; 14903 #endif 14904 int ret = -ENOTSUP; 14905 14906 if (!all_ports_stopped()) { 14907 fprintf(stderr, "Please stop all ports first\n"); 14908 return; 14909 } 14910 14911 #ifdef RTE_NET_I40E 14912 if (!strcmp(res->inset_type, "hash_inset")) 14913 inset_type = INSET_HASH; 14914 else if (!strcmp(res->inset_type, "fdir_inset")) 14915 inset_type = INSET_FDIR; 14916 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 14917 inset_type = INSET_FDIR_FLX; 14918 14919 memset(&inset, 0, sizeof(inset)); 14920 14921 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 14922 &inset, inset_type); 14923 if (ret) { 14924 fprintf(stderr, "Failed to clear input set.\n"); 14925 return; 14926 } 14927 14928 #endif 14929 14930 if (ret == -ENOTSUP) 14931 fprintf(stderr, "Function not supported\n"); 14932 } 14933 14934 cmdline_parse_token_string_t cmd_clear_input_set_port = 14935 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14936 port, "port"); 14937 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 14938 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14939 cfg, "config"); 14940 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 14941 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 14942 port_id, RTE_UINT16); 14943 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 14944 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14945 pctype, "pctype"); 14946 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 14947 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 14948 pctype_id, RTE_UINT8); 14949 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 14950 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14951 inset_type, 14952 "hash_inset#fdir_inset#fdir_flx_inset"); 14953 cmdline_parse_token_string_t cmd_clear_input_set_clear = 14954 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14955 clear, "clear"); 14956 cmdline_parse_token_string_t cmd_clear_input_set_all = 14957 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14958 all, "all"); 14959 14960 cmdline_parse_inst_t cmd_clear_input_set = { 14961 .f = cmd_clear_input_set_parsed, 14962 .data = NULL, 14963 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 14964 "fdir_inset|fdir_flx_inset clear all", 14965 .tokens = { 14966 (void *)&cmd_clear_input_set_port, 14967 (void *)&cmd_clear_input_set_cfg, 14968 (void *)&cmd_clear_input_set_port_id, 14969 (void *)&cmd_clear_input_set_pctype, 14970 (void *)&cmd_clear_input_set_pctype_id, 14971 (void *)&cmd_clear_input_set_inset_type, 14972 (void *)&cmd_clear_input_set_clear, 14973 (void *)&cmd_clear_input_set_all, 14974 NULL, 14975 }, 14976 }; 14977 14978 /* show vf stats */ 14979 14980 /* Common result structure for show vf stats */ 14981 struct cmd_show_vf_stats_result { 14982 cmdline_fixed_string_t show; 14983 cmdline_fixed_string_t vf; 14984 cmdline_fixed_string_t stats; 14985 portid_t port_id; 14986 uint16_t vf_id; 14987 }; 14988 14989 /* Common CLI fields show vf stats*/ 14990 cmdline_parse_token_string_t cmd_show_vf_stats_show = 14991 TOKEN_STRING_INITIALIZER 14992 (struct cmd_show_vf_stats_result, 14993 show, "show"); 14994 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 14995 TOKEN_STRING_INITIALIZER 14996 (struct cmd_show_vf_stats_result, 14997 vf, "vf"); 14998 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 14999 TOKEN_STRING_INITIALIZER 15000 (struct cmd_show_vf_stats_result, 15001 stats, "stats"); 15002 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 15003 TOKEN_NUM_INITIALIZER 15004 (struct cmd_show_vf_stats_result, 15005 port_id, RTE_UINT16); 15006 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 15007 TOKEN_NUM_INITIALIZER 15008 (struct cmd_show_vf_stats_result, 15009 vf_id, RTE_UINT16); 15010 15011 static void 15012 cmd_show_vf_stats_parsed( 15013 void *parsed_result, 15014 __rte_unused struct cmdline *cl, 15015 __rte_unused void *data) 15016 { 15017 struct cmd_show_vf_stats_result *res = parsed_result; 15018 struct rte_eth_stats stats; 15019 int ret = -ENOTSUP; 15020 static const char *nic_stats_border = "########################"; 15021 15022 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15023 return; 15024 15025 memset(&stats, 0, sizeof(stats)); 15026 15027 #ifdef RTE_NET_I40E 15028 if (ret == -ENOTSUP) 15029 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 15030 res->vf_id, 15031 &stats); 15032 #endif 15033 #ifdef RTE_NET_BNXT 15034 if (ret == -ENOTSUP) 15035 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 15036 res->vf_id, 15037 &stats); 15038 #endif 15039 15040 switch (ret) { 15041 case 0: 15042 break; 15043 case -EINVAL: 15044 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 15045 break; 15046 case -ENODEV: 15047 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15048 break; 15049 case -ENOTSUP: 15050 fprintf(stderr, "function not implemented\n"); 15051 break; 15052 default: 15053 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15054 } 15055 15056 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 15057 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 15058 15059 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 15060 "%-"PRIu64"\n", 15061 stats.ipackets, stats.imissed, stats.ibytes); 15062 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 15063 printf(" RX-nombuf: %-10"PRIu64"\n", 15064 stats.rx_nombuf); 15065 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 15066 "%-"PRIu64"\n", 15067 stats.opackets, stats.oerrors, stats.obytes); 15068 15069 printf(" %s############################%s\n", 15070 nic_stats_border, nic_stats_border); 15071 } 15072 15073 cmdline_parse_inst_t cmd_show_vf_stats = { 15074 .f = cmd_show_vf_stats_parsed, 15075 .data = NULL, 15076 .help_str = "show vf stats <port_id> <vf_id>", 15077 .tokens = { 15078 (void *)&cmd_show_vf_stats_show, 15079 (void *)&cmd_show_vf_stats_vf, 15080 (void *)&cmd_show_vf_stats_stats, 15081 (void *)&cmd_show_vf_stats_port_id, 15082 (void *)&cmd_show_vf_stats_vf_id, 15083 NULL, 15084 }, 15085 }; 15086 15087 /* clear vf stats */ 15088 15089 /* Common result structure for clear vf stats */ 15090 struct cmd_clear_vf_stats_result { 15091 cmdline_fixed_string_t clear; 15092 cmdline_fixed_string_t vf; 15093 cmdline_fixed_string_t stats; 15094 portid_t port_id; 15095 uint16_t vf_id; 15096 }; 15097 15098 /* Common CLI fields clear vf stats*/ 15099 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 15100 TOKEN_STRING_INITIALIZER 15101 (struct cmd_clear_vf_stats_result, 15102 clear, "clear"); 15103 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 15104 TOKEN_STRING_INITIALIZER 15105 (struct cmd_clear_vf_stats_result, 15106 vf, "vf"); 15107 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 15108 TOKEN_STRING_INITIALIZER 15109 (struct cmd_clear_vf_stats_result, 15110 stats, "stats"); 15111 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 15112 TOKEN_NUM_INITIALIZER 15113 (struct cmd_clear_vf_stats_result, 15114 port_id, RTE_UINT16); 15115 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 15116 TOKEN_NUM_INITIALIZER 15117 (struct cmd_clear_vf_stats_result, 15118 vf_id, RTE_UINT16); 15119 15120 static void 15121 cmd_clear_vf_stats_parsed( 15122 void *parsed_result, 15123 __rte_unused struct cmdline *cl, 15124 __rte_unused void *data) 15125 { 15126 struct cmd_clear_vf_stats_result *res = parsed_result; 15127 int ret = -ENOTSUP; 15128 15129 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15130 return; 15131 15132 #ifdef RTE_NET_I40E 15133 if (ret == -ENOTSUP) 15134 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 15135 res->vf_id); 15136 #endif 15137 #ifdef RTE_NET_BNXT 15138 if (ret == -ENOTSUP) 15139 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 15140 res->vf_id); 15141 #endif 15142 15143 switch (ret) { 15144 case 0: 15145 break; 15146 case -EINVAL: 15147 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 15148 break; 15149 case -ENODEV: 15150 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15151 break; 15152 case -ENOTSUP: 15153 fprintf(stderr, "function not implemented\n"); 15154 break; 15155 default: 15156 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15157 } 15158 } 15159 15160 cmdline_parse_inst_t cmd_clear_vf_stats = { 15161 .f = cmd_clear_vf_stats_parsed, 15162 .data = NULL, 15163 .help_str = "clear vf stats <port_id> <vf_id>", 15164 .tokens = { 15165 (void *)&cmd_clear_vf_stats_clear, 15166 (void *)&cmd_clear_vf_stats_vf, 15167 (void *)&cmd_clear_vf_stats_stats, 15168 (void *)&cmd_clear_vf_stats_port_id, 15169 (void *)&cmd_clear_vf_stats_vf_id, 15170 NULL, 15171 }, 15172 }; 15173 15174 /* port config pctype mapping reset */ 15175 15176 /* Common result structure for port config pctype mapping reset */ 15177 struct cmd_pctype_mapping_reset_result { 15178 cmdline_fixed_string_t port; 15179 cmdline_fixed_string_t config; 15180 portid_t port_id; 15181 cmdline_fixed_string_t pctype; 15182 cmdline_fixed_string_t mapping; 15183 cmdline_fixed_string_t reset; 15184 }; 15185 15186 /* Common CLI fields for port config pctype mapping reset*/ 15187 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 15188 TOKEN_STRING_INITIALIZER 15189 (struct cmd_pctype_mapping_reset_result, 15190 port, "port"); 15191 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 15192 TOKEN_STRING_INITIALIZER 15193 (struct cmd_pctype_mapping_reset_result, 15194 config, "config"); 15195 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 15196 TOKEN_NUM_INITIALIZER 15197 (struct cmd_pctype_mapping_reset_result, 15198 port_id, RTE_UINT16); 15199 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 15200 TOKEN_STRING_INITIALIZER 15201 (struct cmd_pctype_mapping_reset_result, 15202 pctype, "pctype"); 15203 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 15204 TOKEN_STRING_INITIALIZER 15205 (struct cmd_pctype_mapping_reset_result, 15206 mapping, "mapping"); 15207 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 15208 TOKEN_STRING_INITIALIZER 15209 (struct cmd_pctype_mapping_reset_result, 15210 reset, "reset"); 15211 15212 static void 15213 cmd_pctype_mapping_reset_parsed( 15214 void *parsed_result, 15215 __rte_unused struct cmdline *cl, 15216 __rte_unused void *data) 15217 { 15218 struct cmd_pctype_mapping_reset_result *res = parsed_result; 15219 int ret = -ENOTSUP; 15220 15221 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15222 return; 15223 15224 #ifdef RTE_NET_I40E 15225 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 15226 #endif 15227 15228 switch (ret) { 15229 case 0: 15230 break; 15231 case -ENODEV: 15232 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15233 break; 15234 case -ENOTSUP: 15235 fprintf(stderr, "function not implemented\n"); 15236 break; 15237 default: 15238 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15239 } 15240 } 15241 15242 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 15243 .f = cmd_pctype_mapping_reset_parsed, 15244 .data = NULL, 15245 .help_str = "port config <port_id> pctype mapping reset", 15246 .tokens = { 15247 (void *)&cmd_pctype_mapping_reset_port, 15248 (void *)&cmd_pctype_mapping_reset_config, 15249 (void *)&cmd_pctype_mapping_reset_port_id, 15250 (void *)&cmd_pctype_mapping_reset_pctype, 15251 (void *)&cmd_pctype_mapping_reset_mapping, 15252 (void *)&cmd_pctype_mapping_reset_reset, 15253 NULL, 15254 }, 15255 }; 15256 15257 /* show port pctype mapping */ 15258 15259 /* Common result structure for show port pctype mapping */ 15260 struct cmd_pctype_mapping_get_result { 15261 cmdline_fixed_string_t show; 15262 cmdline_fixed_string_t port; 15263 portid_t port_id; 15264 cmdline_fixed_string_t pctype; 15265 cmdline_fixed_string_t mapping; 15266 }; 15267 15268 /* Common CLI fields for pctype mapping get */ 15269 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 15270 TOKEN_STRING_INITIALIZER 15271 (struct cmd_pctype_mapping_get_result, 15272 show, "show"); 15273 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 15274 TOKEN_STRING_INITIALIZER 15275 (struct cmd_pctype_mapping_get_result, 15276 port, "port"); 15277 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 15278 TOKEN_NUM_INITIALIZER 15279 (struct cmd_pctype_mapping_get_result, 15280 port_id, RTE_UINT16); 15281 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 15282 TOKEN_STRING_INITIALIZER 15283 (struct cmd_pctype_mapping_get_result, 15284 pctype, "pctype"); 15285 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 15286 TOKEN_STRING_INITIALIZER 15287 (struct cmd_pctype_mapping_get_result, 15288 mapping, "mapping"); 15289 15290 static void 15291 cmd_pctype_mapping_get_parsed( 15292 void *parsed_result, 15293 __rte_unused struct cmdline *cl, 15294 __rte_unused void *data) 15295 { 15296 struct cmd_pctype_mapping_get_result *res = parsed_result; 15297 int ret = -ENOTSUP; 15298 #ifdef RTE_NET_I40E 15299 struct rte_pmd_i40e_flow_type_mapping 15300 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 15301 int i, j, first_pctype; 15302 #endif 15303 15304 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15305 return; 15306 15307 #ifdef RTE_NET_I40E 15308 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 15309 #endif 15310 15311 switch (ret) { 15312 case 0: 15313 break; 15314 case -ENODEV: 15315 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15316 return; 15317 case -ENOTSUP: 15318 fprintf(stderr, "function not implemented\n"); 15319 return; 15320 default: 15321 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15322 return; 15323 } 15324 15325 #ifdef RTE_NET_I40E 15326 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 15327 if (mapping[i].pctype != 0ULL) { 15328 first_pctype = 1; 15329 15330 printf("pctype: "); 15331 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 15332 if (mapping[i].pctype & (1ULL << j)) { 15333 printf(first_pctype ? 15334 "%02d" : ",%02d", j); 15335 first_pctype = 0; 15336 } 15337 } 15338 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 15339 } 15340 } 15341 #endif 15342 } 15343 15344 cmdline_parse_inst_t cmd_pctype_mapping_get = { 15345 .f = cmd_pctype_mapping_get_parsed, 15346 .data = NULL, 15347 .help_str = "show port <port_id> pctype mapping", 15348 .tokens = { 15349 (void *)&cmd_pctype_mapping_get_show, 15350 (void *)&cmd_pctype_mapping_get_port, 15351 (void *)&cmd_pctype_mapping_get_port_id, 15352 (void *)&cmd_pctype_mapping_get_pctype, 15353 (void *)&cmd_pctype_mapping_get_mapping, 15354 NULL, 15355 }, 15356 }; 15357 15358 /* port config pctype mapping update */ 15359 15360 /* Common result structure for port config pctype mapping update */ 15361 struct cmd_pctype_mapping_update_result { 15362 cmdline_fixed_string_t port; 15363 cmdline_fixed_string_t config; 15364 portid_t port_id; 15365 cmdline_fixed_string_t pctype; 15366 cmdline_fixed_string_t mapping; 15367 cmdline_fixed_string_t update; 15368 cmdline_fixed_string_t pctype_list; 15369 uint16_t flow_type; 15370 }; 15371 15372 /* Common CLI fields for pctype mapping update*/ 15373 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 15374 TOKEN_STRING_INITIALIZER 15375 (struct cmd_pctype_mapping_update_result, 15376 port, "port"); 15377 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 15378 TOKEN_STRING_INITIALIZER 15379 (struct cmd_pctype_mapping_update_result, 15380 config, "config"); 15381 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 15382 TOKEN_NUM_INITIALIZER 15383 (struct cmd_pctype_mapping_update_result, 15384 port_id, RTE_UINT16); 15385 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 15386 TOKEN_STRING_INITIALIZER 15387 (struct cmd_pctype_mapping_update_result, 15388 pctype, "pctype"); 15389 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 15390 TOKEN_STRING_INITIALIZER 15391 (struct cmd_pctype_mapping_update_result, 15392 mapping, "mapping"); 15393 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 15394 TOKEN_STRING_INITIALIZER 15395 (struct cmd_pctype_mapping_update_result, 15396 update, "update"); 15397 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 15398 TOKEN_STRING_INITIALIZER 15399 (struct cmd_pctype_mapping_update_result, 15400 pctype_list, NULL); 15401 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 15402 TOKEN_NUM_INITIALIZER 15403 (struct cmd_pctype_mapping_update_result, 15404 flow_type, RTE_UINT16); 15405 15406 static void 15407 cmd_pctype_mapping_update_parsed( 15408 void *parsed_result, 15409 __rte_unused struct cmdline *cl, 15410 __rte_unused void *data) 15411 { 15412 struct cmd_pctype_mapping_update_result *res = parsed_result; 15413 int ret = -ENOTSUP; 15414 #ifdef RTE_NET_I40E 15415 struct rte_pmd_i40e_flow_type_mapping mapping; 15416 unsigned int i; 15417 unsigned int nb_item; 15418 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 15419 #endif 15420 15421 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15422 return; 15423 15424 #ifdef RTE_NET_I40E 15425 nb_item = parse_item_list(res->pctype_list, "pctypes", 15426 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 15427 mapping.flow_type = res->flow_type; 15428 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 15429 mapping.pctype |= (1ULL << pctype_list[i]); 15430 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 15431 &mapping, 15432 1, 15433 0); 15434 #endif 15435 15436 switch (ret) { 15437 case 0: 15438 break; 15439 case -EINVAL: 15440 fprintf(stderr, "invalid pctype or flow type\n"); 15441 break; 15442 case -ENODEV: 15443 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15444 break; 15445 case -ENOTSUP: 15446 fprintf(stderr, "function not implemented\n"); 15447 break; 15448 default: 15449 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15450 } 15451 } 15452 15453 cmdline_parse_inst_t cmd_pctype_mapping_update = { 15454 .f = cmd_pctype_mapping_update_parsed, 15455 .data = NULL, 15456 .help_str = "port config <port_id> pctype mapping update" 15457 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 15458 .tokens = { 15459 (void *)&cmd_pctype_mapping_update_port, 15460 (void *)&cmd_pctype_mapping_update_config, 15461 (void *)&cmd_pctype_mapping_update_port_id, 15462 (void *)&cmd_pctype_mapping_update_pctype, 15463 (void *)&cmd_pctype_mapping_update_mapping, 15464 (void *)&cmd_pctype_mapping_update_update, 15465 (void *)&cmd_pctype_mapping_update_pc_type, 15466 (void *)&cmd_pctype_mapping_update_flow_type, 15467 NULL, 15468 }, 15469 }; 15470 15471 /* ptype mapping get */ 15472 15473 /* Common result structure for ptype mapping get */ 15474 struct cmd_ptype_mapping_get_result { 15475 cmdline_fixed_string_t ptype; 15476 cmdline_fixed_string_t mapping; 15477 cmdline_fixed_string_t get; 15478 portid_t port_id; 15479 uint8_t valid_only; 15480 }; 15481 15482 /* Common CLI fields for ptype mapping get */ 15483 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 15484 TOKEN_STRING_INITIALIZER 15485 (struct cmd_ptype_mapping_get_result, 15486 ptype, "ptype"); 15487 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 15488 TOKEN_STRING_INITIALIZER 15489 (struct cmd_ptype_mapping_get_result, 15490 mapping, "mapping"); 15491 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 15492 TOKEN_STRING_INITIALIZER 15493 (struct cmd_ptype_mapping_get_result, 15494 get, "get"); 15495 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 15496 TOKEN_NUM_INITIALIZER 15497 (struct cmd_ptype_mapping_get_result, 15498 port_id, RTE_UINT16); 15499 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 15500 TOKEN_NUM_INITIALIZER 15501 (struct cmd_ptype_mapping_get_result, 15502 valid_only, RTE_UINT8); 15503 15504 static void 15505 cmd_ptype_mapping_get_parsed( 15506 void *parsed_result, 15507 __rte_unused struct cmdline *cl, 15508 __rte_unused void *data) 15509 { 15510 struct cmd_ptype_mapping_get_result *res = parsed_result; 15511 int ret = -ENOTSUP; 15512 #ifdef RTE_NET_I40E 15513 int max_ptype_num = 256; 15514 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 15515 uint16_t count; 15516 int i; 15517 #endif 15518 15519 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15520 return; 15521 15522 #ifdef RTE_NET_I40E 15523 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 15524 mapping, 15525 max_ptype_num, 15526 &count, 15527 res->valid_only); 15528 #endif 15529 15530 switch (ret) { 15531 case 0: 15532 break; 15533 case -ENODEV: 15534 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15535 break; 15536 case -ENOTSUP: 15537 fprintf(stderr, "function not implemented\n"); 15538 break; 15539 default: 15540 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15541 } 15542 15543 #ifdef RTE_NET_I40E 15544 if (!ret) { 15545 for (i = 0; i < count; i++) 15546 printf("%3d\t0x%08x\n", 15547 mapping[i].hw_ptype, mapping[i].sw_ptype); 15548 } 15549 #endif 15550 } 15551 15552 cmdline_parse_inst_t cmd_ptype_mapping_get = { 15553 .f = cmd_ptype_mapping_get_parsed, 15554 .data = NULL, 15555 .help_str = "ptype mapping get <port_id> <valid_only>", 15556 .tokens = { 15557 (void *)&cmd_ptype_mapping_get_ptype, 15558 (void *)&cmd_ptype_mapping_get_mapping, 15559 (void *)&cmd_ptype_mapping_get_get, 15560 (void *)&cmd_ptype_mapping_get_port_id, 15561 (void *)&cmd_ptype_mapping_get_valid_only, 15562 NULL, 15563 }, 15564 }; 15565 15566 /* ptype mapping replace */ 15567 15568 /* Common result structure for ptype mapping replace */ 15569 struct cmd_ptype_mapping_replace_result { 15570 cmdline_fixed_string_t ptype; 15571 cmdline_fixed_string_t mapping; 15572 cmdline_fixed_string_t replace; 15573 portid_t port_id; 15574 uint32_t target; 15575 uint8_t mask; 15576 uint32_t pkt_type; 15577 }; 15578 15579 /* Common CLI fields for ptype mapping replace */ 15580 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 15581 TOKEN_STRING_INITIALIZER 15582 (struct cmd_ptype_mapping_replace_result, 15583 ptype, "ptype"); 15584 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 15585 TOKEN_STRING_INITIALIZER 15586 (struct cmd_ptype_mapping_replace_result, 15587 mapping, "mapping"); 15588 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 15589 TOKEN_STRING_INITIALIZER 15590 (struct cmd_ptype_mapping_replace_result, 15591 replace, "replace"); 15592 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 15593 TOKEN_NUM_INITIALIZER 15594 (struct cmd_ptype_mapping_replace_result, 15595 port_id, RTE_UINT16); 15596 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 15597 TOKEN_NUM_INITIALIZER 15598 (struct cmd_ptype_mapping_replace_result, 15599 target, RTE_UINT32); 15600 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 15601 TOKEN_NUM_INITIALIZER 15602 (struct cmd_ptype_mapping_replace_result, 15603 mask, RTE_UINT8); 15604 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 15605 TOKEN_NUM_INITIALIZER 15606 (struct cmd_ptype_mapping_replace_result, 15607 pkt_type, RTE_UINT32); 15608 15609 static void 15610 cmd_ptype_mapping_replace_parsed( 15611 void *parsed_result, 15612 __rte_unused struct cmdline *cl, 15613 __rte_unused void *data) 15614 { 15615 struct cmd_ptype_mapping_replace_result *res = parsed_result; 15616 int ret = -ENOTSUP; 15617 15618 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15619 return; 15620 15621 #ifdef RTE_NET_I40E 15622 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 15623 res->target, 15624 res->mask, 15625 res->pkt_type); 15626 #endif 15627 15628 switch (ret) { 15629 case 0: 15630 break; 15631 case -EINVAL: 15632 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n", 15633 res->target, res->pkt_type); 15634 break; 15635 case -ENODEV: 15636 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15637 break; 15638 case -ENOTSUP: 15639 fprintf(stderr, "function not implemented\n"); 15640 break; 15641 default: 15642 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15643 } 15644 } 15645 15646 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 15647 .f = cmd_ptype_mapping_replace_parsed, 15648 .data = NULL, 15649 .help_str = 15650 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 15651 .tokens = { 15652 (void *)&cmd_ptype_mapping_replace_ptype, 15653 (void *)&cmd_ptype_mapping_replace_mapping, 15654 (void *)&cmd_ptype_mapping_replace_replace, 15655 (void *)&cmd_ptype_mapping_replace_port_id, 15656 (void *)&cmd_ptype_mapping_replace_target, 15657 (void *)&cmd_ptype_mapping_replace_mask, 15658 (void *)&cmd_ptype_mapping_replace_pkt_type, 15659 NULL, 15660 }, 15661 }; 15662 15663 /* ptype mapping reset */ 15664 15665 /* Common result structure for ptype mapping reset */ 15666 struct cmd_ptype_mapping_reset_result { 15667 cmdline_fixed_string_t ptype; 15668 cmdline_fixed_string_t mapping; 15669 cmdline_fixed_string_t reset; 15670 portid_t port_id; 15671 }; 15672 15673 /* Common CLI fields for ptype mapping reset*/ 15674 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 15675 TOKEN_STRING_INITIALIZER 15676 (struct cmd_ptype_mapping_reset_result, 15677 ptype, "ptype"); 15678 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 15679 TOKEN_STRING_INITIALIZER 15680 (struct cmd_ptype_mapping_reset_result, 15681 mapping, "mapping"); 15682 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 15683 TOKEN_STRING_INITIALIZER 15684 (struct cmd_ptype_mapping_reset_result, 15685 reset, "reset"); 15686 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 15687 TOKEN_NUM_INITIALIZER 15688 (struct cmd_ptype_mapping_reset_result, 15689 port_id, RTE_UINT16); 15690 15691 static void 15692 cmd_ptype_mapping_reset_parsed( 15693 void *parsed_result, 15694 __rte_unused struct cmdline *cl, 15695 __rte_unused void *data) 15696 { 15697 struct cmd_ptype_mapping_reset_result *res = parsed_result; 15698 int ret = -ENOTSUP; 15699 15700 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15701 return; 15702 15703 #ifdef RTE_NET_I40E 15704 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 15705 #endif 15706 15707 switch (ret) { 15708 case 0: 15709 break; 15710 case -ENODEV: 15711 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15712 break; 15713 case -ENOTSUP: 15714 fprintf(stderr, "function not implemented\n"); 15715 break; 15716 default: 15717 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15718 } 15719 } 15720 15721 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 15722 .f = cmd_ptype_mapping_reset_parsed, 15723 .data = NULL, 15724 .help_str = "ptype mapping reset <port_id>", 15725 .tokens = { 15726 (void *)&cmd_ptype_mapping_reset_ptype, 15727 (void *)&cmd_ptype_mapping_reset_mapping, 15728 (void *)&cmd_ptype_mapping_reset_reset, 15729 (void *)&cmd_ptype_mapping_reset_port_id, 15730 NULL, 15731 }, 15732 }; 15733 15734 /* ptype mapping update */ 15735 15736 /* Common result structure for ptype mapping update */ 15737 struct cmd_ptype_mapping_update_result { 15738 cmdline_fixed_string_t ptype; 15739 cmdline_fixed_string_t mapping; 15740 cmdline_fixed_string_t reset; 15741 portid_t port_id; 15742 uint8_t hw_ptype; 15743 uint32_t sw_ptype; 15744 }; 15745 15746 /* Common CLI fields for ptype mapping update*/ 15747 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 15748 TOKEN_STRING_INITIALIZER 15749 (struct cmd_ptype_mapping_update_result, 15750 ptype, "ptype"); 15751 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 15752 TOKEN_STRING_INITIALIZER 15753 (struct cmd_ptype_mapping_update_result, 15754 mapping, "mapping"); 15755 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 15756 TOKEN_STRING_INITIALIZER 15757 (struct cmd_ptype_mapping_update_result, 15758 reset, "update"); 15759 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 15760 TOKEN_NUM_INITIALIZER 15761 (struct cmd_ptype_mapping_update_result, 15762 port_id, RTE_UINT16); 15763 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 15764 TOKEN_NUM_INITIALIZER 15765 (struct cmd_ptype_mapping_update_result, 15766 hw_ptype, RTE_UINT8); 15767 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 15768 TOKEN_NUM_INITIALIZER 15769 (struct cmd_ptype_mapping_update_result, 15770 sw_ptype, RTE_UINT32); 15771 15772 static void 15773 cmd_ptype_mapping_update_parsed( 15774 void *parsed_result, 15775 __rte_unused struct cmdline *cl, 15776 __rte_unused void *data) 15777 { 15778 struct cmd_ptype_mapping_update_result *res = parsed_result; 15779 int ret = -ENOTSUP; 15780 #ifdef RTE_NET_I40E 15781 struct rte_pmd_i40e_ptype_mapping mapping; 15782 #endif 15783 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15784 return; 15785 15786 #ifdef RTE_NET_I40E 15787 mapping.hw_ptype = res->hw_ptype; 15788 mapping.sw_ptype = res->sw_ptype; 15789 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 15790 &mapping, 15791 1, 15792 0); 15793 #endif 15794 15795 switch (ret) { 15796 case 0: 15797 break; 15798 case -EINVAL: 15799 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype); 15800 break; 15801 case -ENODEV: 15802 fprintf(stderr, "invalid port_id %d\n", res->port_id); 15803 break; 15804 case -ENOTSUP: 15805 fprintf(stderr, "function not implemented\n"); 15806 break; 15807 default: 15808 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 15809 } 15810 } 15811 15812 cmdline_parse_inst_t cmd_ptype_mapping_update = { 15813 .f = cmd_ptype_mapping_update_parsed, 15814 .data = NULL, 15815 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 15816 .tokens = { 15817 (void *)&cmd_ptype_mapping_update_ptype, 15818 (void *)&cmd_ptype_mapping_update_mapping, 15819 (void *)&cmd_ptype_mapping_update_update, 15820 (void *)&cmd_ptype_mapping_update_port_id, 15821 (void *)&cmd_ptype_mapping_update_hw_ptype, 15822 (void *)&cmd_ptype_mapping_update_sw_ptype, 15823 NULL, 15824 }, 15825 }; 15826 15827 /* Common result structure for file commands */ 15828 struct cmd_cmdfile_result { 15829 cmdline_fixed_string_t load; 15830 cmdline_fixed_string_t filename; 15831 }; 15832 15833 /* Common CLI fields for file commands */ 15834 cmdline_parse_token_string_t cmd_load_cmdfile = 15835 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 15836 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 15837 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 15838 15839 static void 15840 cmd_load_from_file_parsed( 15841 void *parsed_result, 15842 __rte_unused struct cmdline *cl, 15843 __rte_unused void *data) 15844 { 15845 struct cmd_cmdfile_result *res = parsed_result; 15846 15847 cmdline_read_from_file(res->filename); 15848 } 15849 15850 cmdline_parse_inst_t cmd_load_from_file = { 15851 .f = cmd_load_from_file_parsed, 15852 .data = NULL, 15853 .help_str = "load <filename>", 15854 .tokens = { 15855 (void *)&cmd_load_cmdfile, 15856 (void *)&cmd_load_cmdfile_filename, 15857 NULL, 15858 }, 15859 }; 15860 15861 /* Get Rx offloads capabilities */ 15862 struct cmd_rx_offload_get_capa_result { 15863 cmdline_fixed_string_t show; 15864 cmdline_fixed_string_t port; 15865 portid_t port_id; 15866 cmdline_fixed_string_t rx_offload; 15867 cmdline_fixed_string_t capabilities; 15868 }; 15869 15870 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 15871 TOKEN_STRING_INITIALIZER 15872 (struct cmd_rx_offload_get_capa_result, 15873 show, "show"); 15874 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 15875 TOKEN_STRING_INITIALIZER 15876 (struct cmd_rx_offload_get_capa_result, 15877 port, "port"); 15878 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 15879 TOKEN_NUM_INITIALIZER 15880 (struct cmd_rx_offload_get_capa_result, 15881 port_id, RTE_UINT16); 15882 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 15883 TOKEN_STRING_INITIALIZER 15884 (struct cmd_rx_offload_get_capa_result, 15885 rx_offload, "rx_offload"); 15886 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 15887 TOKEN_STRING_INITIALIZER 15888 (struct cmd_rx_offload_get_capa_result, 15889 capabilities, "capabilities"); 15890 15891 static void 15892 print_rx_offloads(uint64_t offloads) 15893 { 15894 uint64_t single_offload; 15895 int begin; 15896 int end; 15897 int bit; 15898 15899 if (offloads == 0) 15900 return; 15901 15902 begin = __builtin_ctzll(offloads); 15903 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 15904 15905 single_offload = 1ULL << begin; 15906 for (bit = begin; bit < end; bit++) { 15907 if (offloads & single_offload) 15908 printf(" %s", 15909 rte_eth_dev_rx_offload_name(single_offload)); 15910 single_offload <<= 1; 15911 } 15912 } 15913 15914 static void 15915 cmd_rx_offload_get_capa_parsed( 15916 void *parsed_result, 15917 __rte_unused struct cmdline *cl, 15918 __rte_unused void *data) 15919 { 15920 struct cmd_rx_offload_get_capa_result *res = parsed_result; 15921 struct rte_eth_dev_info dev_info; 15922 portid_t port_id = res->port_id; 15923 uint64_t queue_offloads; 15924 uint64_t port_offloads; 15925 int ret; 15926 15927 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15928 if (ret != 0) 15929 return; 15930 15931 queue_offloads = dev_info.rx_queue_offload_capa; 15932 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 15933 15934 printf("Rx Offloading Capabilities of port %d :\n", port_id); 15935 printf(" Per Queue :"); 15936 print_rx_offloads(queue_offloads); 15937 15938 printf("\n"); 15939 printf(" Per Port :"); 15940 print_rx_offloads(port_offloads); 15941 printf("\n\n"); 15942 } 15943 15944 cmdline_parse_inst_t cmd_rx_offload_get_capa = { 15945 .f = cmd_rx_offload_get_capa_parsed, 15946 .data = NULL, 15947 .help_str = "show port <port_id> rx_offload capabilities", 15948 .tokens = { 15949 (void *)&cmd_rx_offload_get_capa_show, 15950 (void *)&cmd_rx_offload_get_capa_port, 15951 (void *)&cmd_rx_offload_get_capa_port_id, 15952 (void *)&cmd_rx_offload_get_capa_rx_offload, 15953 (void *)&cmd_rx_offload_get_capa_capabilities, 15954 NULL, 15955 } 15956 }; 15957 15958 /* Get Rx offloads configuration */ 15959 struct cmd_rx_offload_get_configuration_result { 15960 cmdline_fixed_string_t show; 15961 cmdline_fixed_string_t port; 15962 portid_t port_id; 15963 cmdline_fixed_string_t rx_offload; 15964 cmdline_fixed_string_t configuration; 15965 }; 15966 15967 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 15968 TOKEN_STRING_INITIALIZER 15969 (struct cmd_rx_offload_get_configuration_result, 15970 show, "show"); 15971 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 15972 TOKEN_STRING_INITIALIZER 15973 (struct cmd_rx_offload_get_configuration_result, 15974 port, "port"); 15975 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 15976 TOKEN_NUM_INITIALIZER 15977 (struct cmd_rx_offload_get_configuration_result, 15978 port_id, RTE_UINT16); 15979 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 15980 TOKEN_STRING_INITIALIZER 15981 (struct cmd_rx_offload_get_configuration_result, 15982 rx_offload, "rx_offload"); 15983 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 15984 TOKEN_STRING_INITIALIZER 15985 (struct cmd_rx_offload_get_configuration_result, 15986 configuration, "configuration"); 15987 15988 static void 15989 cmd_rx_offload_get_configuration_parsed( 15990 void *parsed_result, 15991 __rte_unused struct cmdline *cl, 15992 __rte_unused void *data) 15993 { 15994 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 15995 struct rte_eth_dev_info dev_info; 15996 portid_t port_id = res->port_id; 15997 struct rte_port *port = &ports[port_id]; 15998 uint64_t port_offloads; 15999 uint64_t queue_offloads; 16000 uint16_t nb_rx_queues; 16001 int q; 16002 int ret; 16003 16004 printf("Rx Offloading Configuration of port %d :\n", port_id); 16005 16006 port_offloads = port->dev_conf.rxmode.offloads; 16007 printf(" Port :"); 16008 print_rx_offloads(port_offloads); 16009 printf("\n"); 16010 16011 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16012 if (ret != 0) 16013 return; 16014 16015 nb_rx_queues = dev_info.nb_rx_queues; 16016 for (q = 0; q < nb_rx_queues; q++) { 16017 queue_offloads = port->rx_conf[q].offloads; 16018 printf(" Queue[%2d] :", q); 16019 print_rx_offloads(queue_offloads); 16020 printf("\n"); 16021 } 16022 printf("\n"); 16023 } 16024 16025 cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 16026 .f = cmd_rx_offload_get_configuration_parsed, 16027 .data = NULL, 16028 .help_str = "show port <port_id> rx_offload configuration", 16029 .tokens = { 16030 (void *)&cmd_rx_offload_get_configuration_show, 16031 (void *)&cmd_rx_offload_get_configuration_port, 16032 (void *)&cmd_rx_offload_get_configuration_port_id, 16033 (void *)&cmd_rx_offload_get_configuration_rx_offload, 16034 (void *)&cmd_rx_offload_get_configuration_configuration, 16035 NULL, 16036 } 16037 }; 16038 16039 /* Enable/Disable a per port offloading */ 16040 struct cmd_config_per_port_rx_offload_result { 16041 cmdline_fixed_string_t port; 16042 cmdline_fixed_string_t config; 16043 portid_t port_id; 16044 cmdline_fixed_string_t rx_offload; 16045 cmdline_fixed_string_t offload; 16046 cmdline_fixed_string_t on_off; 16047 }; 16048 16049 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 16050 TOKEN_STRING_INITIALIZER 16051 (struct cmd_config_per_port_rx_offload_result, 16052 port, "port"); 16053 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 16054 TOKEN_STRING_INITIALIZER 16055 (struct cmd_config_per_port_rx_offload_result, 16056 config, "config"); 16057 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 16058 TOKEN_NUM_INITIALIZER 16059 (struct cmd_config_per_port_rx_offload_result, 16060 port_id, RTE_UINT16); 16061 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 16062 TOKEN_STRING_INITIALIZER 16063 (struct cmd_config_per_port_rx_offload_result, 16064 rx_offload, "rx_offload"); 16065 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 16066 TOKEN_STRING_INITIALIZER 16067 (struct cmd_config_per_port_rx_offload_result, 16068 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 16069 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 16070 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 16071 "scatter#buffer_split#timestamp#security#" 16072 "keep_crc#rss_hash"); 16073 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 16074 TOKEN_STRING_INITIALIZER 16075 (struct cmd_config_per_port_rx_offload_result, 16076 on_off, "on#off"); 16077 16078 static uint64_t 16079 search_rx_offload(const char *name) 16080 { 16081 uint64_t single_offload; 16082 const char *single_name; 16083 int found = 0; 16084 unsigned int bit; 16085 16086 single_offload = 1; 16087 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 16088 single_name = rte_eth_dev_rx_offload_name(single_offload); 16089 if (!strcasecmp(single_name, name)) { 16090 found = 1; 16091 break; 16092 } 16093 single_offload <<= 1; 16094 } 16095 16096 if (found) 16097 return single_offload; 16098 16099 return 0; 16100 } 16101 16102 static void 16103 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 16104 __rte_unused struct cmdline *cl, 16105 __rte_unused void *data) 16106 { 16107 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 16108 portid_t port_id = res->port_id; 16109 struct rte_eth_dev_info dev_info; 16110 struct rte_port *port = &ports[port_id]; 16111 uint64_t single_offload; 16112 uint16_t nb_rx_queues; 16113 int q; 16114 int ret; 16115 16116 if (port->port_status != RTE_PORT_STOPPED) { 16117 fprintf(stderr, 16118 "Error: Can't config offload when Port %d is not stopped\n", 16119 port_id); 16120 return; 16121 } 16122 16123 single_offload = search_rx_offload(res->offload); 16124 if (single_offload == 0) { 16125 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 16126 return; 16127 } 16128 16129 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16130 if (ret != 0) 16131 return; 16132 16133 nb_rx_queues = dev_info.nb_rx_queues; 16134 if (!strcmp(res->on_off, "on")) { 16135 port->dev_conf.rxmode.offloads |= single_offload; 16136 for (q = 0; q < nb_rx_queues; q++) 16137 port->rx_conf[q].offloads |= single_offload; 16138 } else { 16139 port->dev_conf.rxmode.offloads &= ~single_offload; 16140 for (q = 0; q < nb_rx_queues; q++) 16141 port->rx_conf[q].offloads &= ~single_offload; 16142 } 16143 16144 cmd_reconfig_device_queue(port_id, 1, 1); 16145 } 16146 16147 cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 16148 .f = cmd_config_per_port_rx_offload_parsed, 16149 .data = NULL, 16150 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 16151 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 16152 "macsec_strip|header_split|vlan_filter|vlan_extend|" 16153 "jumbo_frame|scatter|buffer_split|timestamp|security|" 16154 "keep_crc|rss_hash on|off", 16155 .tokens = { 16156 (void *)&cmd_config_per_port_rx_offload_result_port, 16157 (void *)&cmd_config_per_port_rx_offload_result_config, 16158 (void *)&cmd_config_per_port_rx_offload_result_port_id, 16159 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 16160 (void *)&cmd_config_per_port_rx_offload_result_offload, 16161 (void *)&cmd_config_per_port_rx_offload_result_on_off, 16162 NULL, 16163 } 16164 }; 16165 16166 /* Enable/Disable a per queue offloading */ 16167 struct cmd_config_per_queue_rx_offload_result { 16168 cmdline_fixed_string_t port; 16169 portid_t port_id; 16170 cmdline_fixed_string_t rxq; 16171 uint16_t queue_id; 16172 cmdline_fixed_string_t rx_offload; 16173 cmdline_fixed_string_t offload; 16174 cmdline_fixed_string_t on_off; 16175 }; 16176 16177 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 16178 TOKEN_STRING_INITIALIZER 16179 (struct cmd_config_per_queue_rx_offload_result, 16180 port, "port"); 16181 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 16182 TOKEN_NUM_INITIALIZER 16183 (struct cmd_config_per_queue_rx_offload_result, 16184 port_id, RTE_UINT16); 16185 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 16186 TOKEN_STRING_INITIALIZER 16187 (struct cmd_config_per_queue_rx_offload_result, 16188 rxq, "rxq"); 16189 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 16190 TOKEN_NUM_INITIALIZER 16191 (struct cmd_config_per_queue_rx_offload_result, 16192 queue_id, RTE_UINT16); 16193 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 16194 TOKEN_STRING_INITIALIZER 16195 (struct cmd_config_per_queue_rx_offload_result, 16196 rx_offload, "rx_offload"); 16197 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 16198 TOKEN_STRING_INITIALIZER 16199 (struct cmd_config_per_queue_rx_offload_result, 16200 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 16201 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 16202 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 16203 "scatter#buffer_split#timestamp#security#keep_crc"); 16204 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 16205 TOKEN_STRING_INITIALIZER 16206 (struct cmd_config_per_queue_rx_offload_result, 16207 on_off, "on#off"); 16208 16209 static void 16210 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 16211 __rte_unused struct cmdline *cl, 16212 __rte_unused void *data) 16213 { 16214 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 16215 struct rte_eth_dev_info dev_info; 16216 portid_t port_id = res->port_id; 16217 uint16_t queue_id = res->queue_id; 16218 struct rte_port *port = &ports[port_id]; 16219 uint64_t single_offload; 16220 int ret; 16221 16222 if (port->port_status != RTE_PORT_STOPPED) { 16223 fprintf(stderr, 16224 "Error: Can't config offload when Port %d is not stopped\n", 16225 port_id); 16226 return; 16227 } 16228 16229 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16230 if (ret != 0) 16231 return; 16232 16233 if (queue_id >= dev_info.nb_rx_queues) { 16234 fprintf(stderr, 16235 "Error: input queue_id should be 0 ... %d\n", 16236 dev_info.nb_rx_queues - 1); 16237 return; 16238 } 16239 16240 single_offload = search_rx_offload(res->offload); 16241 if (single_offload == 0) { 16242 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 16243 return; 16244 } 16245 16246 if (!strcmp(res->on_off, "on")) 16247 port->rx_conf[queue_id].offloads |= single_offload; 16248 else 16249 port->rx_conf[queue_id].offloads &= ~single_offload; 16250 16251 cmd_reconfig_device_queue(port_id, 1, 1); 16252 } 16253 16254 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 16255 .f = cmd_config_per_queue_rx_offload_parsed, 16256 .data = NULL, 16257 .help_str = "port <port_id> rxq <queue_id> rx_offload " 16258 "vlan_strip|ipv4_cksum|" 16259 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 16260 "macsec_strip|header_split|vlan_filter|vlan_extend|" 16261 "jumbo_frame|scatter|buffer_split|timestamp|security|" 16262 "keep_crc on|off", 16263 .tokens = { 16264 (void *)&cmd_config_per_queue_rx_offload_result_port, 16265 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 16266 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 16267 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 16268 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 16269 (void *)&cmd_config_per_queue_rx_offload_result_offload, 16270 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 16271 NULL, 16272 } 16273 }; 16274 16275 /* Get Tx offloads capabilities */ 16276 struct cmd_tx_offload_get_capa_result { 16277 cmdline_fixed_string_t show; 16278 cmdline_fixed_string_t port; 16279 portid_t port_id; 16280 cmdline_fixed_string_t tx_offload; 16281 cmdline_fixed_string_t capabilities; 16282 }; 16283 16284 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 16285 TOKEN_STRING_INITIALIZER 16286 (struct cmd_tx_offload_get_capa_result, 16287 show, "show"); 16288 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 16289 TOKEN_STRING_INITIALIZER 16290 (struct cmd_tx_offload_get_capa_result, 16291 port, "port"); 16292 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 16293 TOKEN_NUM_INITIALIZER 16294 (struct cmd_tx_offload_get_capa_result, 16295 port_id, RTE_UINT16); 16296 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 16297 TOKEN_STRING_INITIALIZER 16298 (struct cmd_tx_offload_get_capa_result, 16299 tx_offload, "tx_offload"); 16300 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 16301 TOKEN_STRING_INITIALIZER 16302 (struct cmd_tx_offload_get_capa_result, 16303 capabilities, "capabilities"); 16304 16305 static void 16306 print_tx_offloads(uint64_t offloads) 16307 { 16308 uint64_t single_offload; 16309 int begin; 16310 int end; 16311 int bit; 16312 16313 if (offloads == 0) 16314 return; 16315 16316 begin = __builtin_ctzll(offloads); 16317 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 16318 16319 single_offload = 1ULL << begin; 16320 for (bit = begin; bit < end; bit++) { 16321 if (offloads & single_offload) 16322 printf(" %s", 16323 rte_eth_dev_tx_offload_name(single_offload)); 16324 single_offload <<= 1; 16325 } 16326 } 16327 16328 static void 16329 cmd_tx_offload_get_capa_parsed( 16330 void *parsed_result, 16331 __rte_unused struct cmdline *cl, 16332 __rte_unused void *data) 16333 { 16334 struct cmd_tx_offload_get_capa_result *res = parsed_result; 16335 struct rte_eth_dev_info dev_info; 16336 portid_t port_id = res->port_id; 16337 uint64_t queue_offloads; 16338 uint64_t port_offloads; 16339 int ret; 16340 16341 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16342 if (ret != 0) 16343 return; 16344 16345 queue_offloads = dev_info.tx_queue_offload_capa; 16346 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 16347 16348 printf("Tx Offloading Capabilities of port %d :\n", port_id); 16349 printf(" Per Queue :"); 16350 print_tx_offloads(queue_offloads); 16351 16352 printf("\n"); 16353 printf(" Per Port :"); 16354 print_tx_offloads(port_offloads); 16355 printf("\n\n"); 16356 } 16357 16358 cmdline_parse_inst_t cmd_tx_offload_get_capa = { 16359 .f = cmd_tx_offload_get_capa_parsed, 16360 .data = NULL, 16361 .help_str = "show port <port_id> tx_offload capabilities", 16362 .tokens = { 16363 (void *)&cmd_tx_offload_get_capa_show, 16364 (void *)&cmd_tx_offload_get_capa_port, 16365 (void *)&cmd_tx_offload_get_capa_port_id, 16366 (void *)&cmd_tx_offload_get_capa_tx_offload, 16367 (void *)&cmd_tx_offload_get_capa_capabilities, 16368 NULL, 16369 } 16370 }; 16371 16372 /* Get Tx offloads configuration */ 16373 struct cmd_tx_offload_get_configuration_result { 16374 cmdline_fixed_string_t show; 16375 cmdline_fixed_string_t port; 16376 portid_t port_id; 16377 cmdline_fixed_string_t tx_offload; 16378 cmdline_fixed_string_t configuration; 16379 }; 16380 16381 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 16382 TOKEN_STRING_INITIALIZER 16383 (struct cmd_tx_offload_get_configuration_result, 16384 show, "show"); 16385 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 16386 TOKEN_STRING_INITIALIZER 16387 (struct cmd_tx_offload_get_configuration_result, 16388 port, "port"); 16389 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 16390 TOKEN_NUM_INITIALIZER 16391 (struct cmd_tx_offload_get_configuration_result, 16392 port_id, RTE_UINT16); 16393 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 16394 TOKEN_STRING_INITIALIZER 16395 (struct cmd_tx_offload_get_configuration_result, 16396 tx_offload, "tx_offload"); 16397 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 16398 TOKEN_STRING_INITIALIZER 16399 (struct cmd_tx_offload_get_configuration_result, 16400 configuration, "configuration"); 16401 16402 static void 16403 cmd_tx_offload_get_configuration_parsed( 16404 void *parsed_result, 16405 __rte_unused struct cmdline *cl, 16406 __rte_unused void *data) 16407 { 16408 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 16409 struct rte_eth_dev_info dev_info; 16410 portid_t port_id = res->port_id; 16411 struct rte_port *port = &ports[port_id]; 16412 uint64_t port_offloads; 16413 uint64_t queue_offloads; 16414 uint16_t nb_tx_queues; 16415 int q; 16416 int ret; 16417 16418 printf("Tx Offloading Configuration of port %d :\n", port_id); 16419 16420 port_offloads = port->dev_conf.txmode.offloads; 16421 printf(" Port :"); 16422 print_tx_offloads(port_offloads); 16423 printf("\n"); 16424 16425 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16426 if (ret != 0) 16427 return; 16428 16429 nb_tx_queues = dev_info.nb_tx_queues; 16430 for (q = 0; q < nb_tx_queues; q++) { 16431 queue_offloads = port->tx_conf[q].offloads; 16432 printf(" Queue[%2d] :", q); 16433 print_tx_offloads(queue_offloads); 16434 printf("\n"); 16435 } 16436 printf("\n"); 16437 } 16438 16439 cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 16440 .f = cmd_tx_offload_get_configuration_parsed, 16441 .data = NULL, 16442 .help_str = "show port <port_id> tx_offload configuration", 16443 .tokens = { 16444 (void *)&cmd_tx_offload_get_configuration_show, 16445 (void *)&cmd_tx_offload_get_configuration_port, 16446 (void *)&cmd_tx_offload_get_configuration_port_id, 16447 (void *)&cmd_tx_offload_get_configuration_tx_offload, 16448 (void *)&cmd_tx_offload_get_configuration_configuration, 16449 NULL, 16450 } 16451 }; 16452 16453 /* Enable/Disable a per port offloading */ 16454 struct cmd_config_per_port_tx_offload_result { 16455 cmdline_fixed_string_t port; 16456 cmdline_fixed_string_t config; 16457 portid_t port_id; 16458 cmdline_fixed_string_t tx_offload; 16459 cmdline_fixed_string_t offload; 16460 cmdline_fixed_string_t on_off; 16461 }; 16462 16463 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 16464 TOKEN_STRING_INITIALIZER 16465 (struct cmd_config_per_port_tx_offload_result, 16466 port, "port"); 16467 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 16468 TOKEN_STRING_INITIALIZER 16469 (struct cmd_config_per_port_tx_offload_result, 16470 config, "config"); 16471 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 16472 TOKEN_NUM_INITIALIZER 16473 (struct cmd_config_per_port_tx_offload_result, 16474 port_id, RTE_UINT16); 16475 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 16476 TOKEN_STRING_INITIALIZER 16477 (struct cmd_config_per_port_tx_offload_result, 16478 tx_offload, "tx_offload"); 16479 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 16480 TOKEN_STRING_INITIALIZER 16481 (struct cmd_config_per_port_tx_offload_result, 16482 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 16483 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 16484 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 16485 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 16486 "mt_lockfree#multi_segs#mbuf_fast_free#security#" 16487 "send_on_timestamp"); 16488 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = 16489 TOKEN_STRING_INITIALIZER 16490 (struct cmd_config_per_port_tx_offload_result, 16491 on_off, "on#off"); 16492 16493 static uint64_t 16494 search_tx_offload(const char *name) 16495 { 16496 uint64_t single_offload; 16497 const char *single_name; 16498 int found = 0; 16499 unsigned int bit; 16500 16501 single_offload = 1; 16502 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 16503 single_name = rte_eth_dev_tx_offload_name(single_offload); 16504 if (single_name == NULL) 16505 break; 16506 if (!strcasecmp(single_name, name)) { 16507 found = 1; 16508 break; 16509 } else if (!strcasecmp(single_name, "UNKNOWN")) 16510 break; 16511 single_offload <<= 1; 16512 } 16513 16514 if (found) 16515 return single_offload; 16516 16517 return 0; 16518 } 16519 16520 static void 16521 cmd_config_per_port_tx_offload_parsed(void *parsed_result, 16522 __rte_unused struct cmdline *cl, 16523 __rte_unused void *data) 16524 { 16525 struct cmd_config_per_port_tx_offload_result *res = parsed_result; 16526 portid_t port_id = res->port_id; 16527 struct rte_eth_dev_info dev_info; 16528 struct rte_port *port = &ports[port_id]; 16529 uint64_t single_offload; 16530 uint16_t nb_tx_queues; 16531 int q; 16532 int ret; 16533 16534 if (port->port_status != RTE_PORT_STOPPED) { 16535 fprintf(stderr, 16536 "Error: Can't config offload when Port %d is not stopped\n", 16537 port_id); 16538 return; 16539 } 16540 16541 single_offload = search_tx_offload(res->offload); 16542 if (single_offload == 0) { 16543 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 16544 return; 16545 } 16546 16547 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16548 if (ret != 0) 16549 return; 16550 16551 nb_tx_queues = dev_info.nb_tx_queues; 16552 if (!strcmp(res->on_off, "on")) { 16553 port->dev_conf.txmode.offloads |= single_offload; 16554 for (q = 0; q < nb_tx_queues; q++) 16555 port->tx_conf[q].offloads |= single_offload; 16556 } else { 16557 port->dev_conf.txmode.offloads &= ~single_offload; 16558 for (q = 0; q < nb_tx_queues; q++) 16559 port->tx_conf[q].offloads &= ~single_offload; 16560 } 16561 16562 cmd_reconfig_device_queue(port_id, 1, 1); 16563 } 16564 16565 cmdline_parse_inst_t cmd_config_per_port_tx_offload = { 16566 .f = cmd_config_per_port_tx_offload_parsed, 16567 .data = NULL, 16568 .help_str = "port config <port_id> tx_offload " 16569 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 16570 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 16571 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 16572 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 16573 "mt_lockfree|multi_segs|mbuf_fast_free|security|" 16574 "send_on_timestamp on|off", 16575 .tokens = { 16576 (void *)&cmd_config_per_port_tx_offload_result_port, 16577 (void *)&cmd_config_per_port_tx_offload_result_config, 16578 (void *)&cmd_config_per_port_tx_offload_result_port_id, 16579 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 16580 (void *)&cmd_config_per_port_tx_offload_result_offload, 16581 (void *)&cmd_config_per_port_tx_offload_result_on_off, 16582 NULL, 16583 } 16584 }; 16585 16586 /* Enable/Disable a per queue offloading */ 16587 struct cmd_config_per_queue_tx_offload_result { 16588 cmdline_fixed_string_t port; 16589 portid_t port_id; 16590 cmdline_fixed_string_t txq; 16591 uint16_t queue_id; 16592 cmdline_fixed_string_t tx_offload; 16593 cmdline_fixed_string_t offload; 16594 cmdline_fixed_string_t on_off; 16595 }; 16596 16597 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 16598 TOKEN_STRING_INITIALIZER 16599 (struct cmd_config_per_queue_tx_offload_result, 16600 port, "port"); 16601 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 16602 TOKEN_NUM_INITIALIZER 16603 (struct cmd_config_per_queue_tx_offload_result, 16604 port_id, RTE_UINT16); 16605 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 16606 TOKEN_STRING_INITIALIZER 16607 (struct cmd_config_per_queue_tx_offload_result, 16608 txq, "txq"); 16609 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 16610 TOKEN_NUM_INITIALIZER 16611 (struct cmd_config_per_queue_tx_offload_result, 16612 queue_id, RTE_UINT16); 16613 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 16614 TOKEN_STRING_INITIALIZER 16615 (struct cmd_config_per_queue_tx_offload_result, 16616 tx_offload, "tx_offload"); 16617 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 16618 TOKEN_STRING_INITIALIZER 16619 (struct cmd_config_per_queue_tx_offload_result, 16620 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 16621 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 16622 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 16623 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 16624 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 16625 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 16626 TOKEN_STRING_INITIALIZER 16627 (struct cmd_config_per_queue_tx_offload_result, 16628 on_off, "on#off"); 16629 16630 static void 16631 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 16632 __rte_unused struct cmdline *cl, 16633 __rte_unused void *data) 16634 { 16635 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 16636 struct rte_eth_dev_info dev_info; 16637 portid_t port_id = res->port_id; 16638 uint16_t queue_id = res->queue_id; 16639 struct rte_port *port = &ports[port_id]; 16640 uint64_t single_offload; 16641 int ret; 16642 16643 if (port->port_status != RTE_PORT_STOPPED) { 16644 fprintf(stderr, 16645 "Error: Can't config offload when Port %d is not stopped\n", 16646 port_id); 16647 return; 16648 } 16649 16650 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16651 if (ret != 0) 16652 return; 16653 16654 if (queue_id >= dev_info.nb_tx_queues) { 16655 fprintf(stderr, 16656 "Error: input queue_id should be 0 ... %d\n", 16657 dev_info.nb_tx_queues - 1); 16658 return; 16659 } 16660 16661 single_offload = search_tx_offload(res->offload); 16662 if (single_offload == 0) { 16663 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 16664 return; 16665 } 16666 16667 if (!strcmp(res->on_off, "on")) 16668 port->tx_conf[queue_id].offloads |= single_offload; 16669 else 16670 port->tx_conf[queue_id].offloads &= ~single_offload; 16671 16672 cmd_reconfig_device_queue(port_id, 1, 1); 16673 } 16674 16675 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 16676 .f = cmd_config_per_queue_tx_offload_parsed, 16677 .data = NULL, 16678 .help_str = "port <port_id> txq <queue_id> tx_offload " 16679 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 16680 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 16681 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 16682 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 16683 "mt_lockfree|multi_segs|mbuf_fast_free|security " 16684 "on|off", 16685 .tokens = { 16686 (void *)&cmd_config_per_queue_tx_offload_result_port, 16687 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 16688 (void *)&cmd_config_per_queue_tx_offload_result_txq, 16689 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 16690 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 16691 (void *)&cmd_config_per_queue_tx_offload_result_offload, 16692 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 16693 NULL, 16694 } 16695 }; 16696 16697 /* *** configure tx_metadata for specific port *** */ 16698 struct cmd_config_tx_metadata_specific_result { 16699 cmdline_fixed_string_t port; 16700 cmdline_fixed_string_t keyword; 16701 uint16_t port_id; 16702 cmdline_fixed_string_t item; 16703 uint32_t value; 16704 }; 16705 16706 static void 16707 cmd_config_tx_metadata_specific_parsed(void *parsed_result, 16708 __rte_unused struct cmdline *cl, 16709 __rte_unused void *data) 16710 { 16711 struct cmd_config_tx_metadata_specific_result *res = parsed_result; 16712 16713 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16714 return; 16715 ports[res->port_id].tx_metadata = res->value; 16716 /* Add/remove callback to insert valid metadata in every Tx packet. */ 16717 if (ports[res->port_id].tx_metadata) 16718 add_tx_md_callback(res->port_id); 16719 else 16720 remove_tx_md_callback(res->port_id); 16721 rte_flow_dynf_metadata_register(); 16722 } 16723 16724 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = 16725 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16726 port, "port"); 16727 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = 16728 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16729 keyword, "config"); 16730 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = 16731 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16732 port_id, RTE_UINT16); 16733 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = 16734 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16735 item, "tx_metadata"); 16736 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = 16737 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16738 value, RTE_UINT32); 16739 16740 cmdline_parse_inst_t cmd_config_tx_metadata_specific = { 16741 .f = cmd_config_tx_metadata_specific_parsed, 16742 .data = NULL, 16743 .help_str = "port config <port_id> tx_metadata <value>", 16744 .tokens = { 16745 (void *)&cmd_config_tx_metadata_specific_port, 16746 (void *)&cmd_config_tx_metadata_specific_keyword, 16747 (void *)&cmd_config_tx_metadata_specific_id, 16748 (void *)&cmd_config_tx_metadata_specific_item, 16749 (void *)&cmd_config_tx_metadata_specific_value, 16750 NULL, 16751 }, 16752 }; 16753 16754 /* *** set dynf *** */ 16755 struct cmd_config_tx_dynf_specific_result { 16756 cmdline_fixed_string_t port; 16757 cmdline_fixed_string_t keyword; 16758 uint16_t port_id; 16759 cmdline_fixed_string_t item; 16760 cmdline_fixed_string_t name; 16761 cmdline_fixed_string_t value; 16762 }; 16763 16764 static void 16765 cmd_config_dynf_specific_parsed(void *parsed_result, 16766 __rte_unused struct cmdline *cl, 16767 __rte_unused void *data) 16768 { 16769 struct cmd_config_tx_dynf_specific_result *res = parsed_result; 16770 struct rte_mbuf_dynflag desc_flag; 16771 int flag; 16772 uint64_t old_port_flags; 16773 16774 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16775 return; 16776 flag = rte_mbuf_dynflag_lookup(res->name, NULL); 16777 if (flag <= 0) { 16778 if (strlcpy(desc_flag.name, res->name, 16779 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) { 16780 fprintf(stderr, "Flag name too long\n"); 16781 return; 16782 } 16783 desc_flag.flags = 0; 16784 flag = rte_mbuf_dynflag_register(&desc_flag); 16785 if (flag < 0) { 16786 fprintf(stderr, "Can't register flag\n"); 16787 return; 16788 } 16789 strcpy(dynf_names[flag], desc_flag.name); 16790 } 16791 old_port_flags = ports[res->port_id].mbuf_dynf; 16792 if (!strcmp(res->value, "set")) { 16793 ports[res->port_id].mbuf_dynf |= 1UL << flag; 16794 if (old_port_flags == 0) 16795 add_tx_dynf_callback(res->port_id); 16796 } else { 16797 ports[res->port_id].mbuf_dynf &= ~(1UL << flag); 16798 if (ports[res->port_id].mbuf_dynf == 0) 16799 remove_tx_dynf_callback(res->port_id); 16800 } 16801 } 16802 16803 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port = 16804 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16805 keyword, "port"); 16806 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword = 16807 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16808 keyword, "config"); 16809 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id = 16810 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16811 port_id, RTE_UINT16); 16812 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item = 16813 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16814 item, "dynf"); 16815 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name = 16816 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16817 name, NULL); 16818 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value = 16819 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16820 value, "set#clear"); 16821 16822 cmdline_parse_inst_t cmd_config_tx_dynf_specific = { 16823 .f = cmd_config_dynf_specific_parsed, 16824 .data = NULL, 16825 .help_str = "port config <port id> dynf <name> set|clear", 16826 .tokens = { 16827 (void *)&cmd_config_tx_dynf_specific_port, 16828 (void *)&cmd_config_tx_dynf_specific_keyword, 16829 (void *)&cmd_config_tx_dynf_specific_port_id, 16830 (void *)&cmd_config_tx_dynf_specific_item, 16831 (void *)&cmd_config_tx_dynf_specific_name, 16832 (void *)&cmd_config_tx_dynf_specific_value, 16833 NULL, 16834 }, 16835 }; 16836 16837 /* *** display tx_metadata per port configuration *** */ 16838 struct cmd_show_tx_metadata_result { 16839 cmdline_fixed_string_t cmd_show; 16840 cmdline_fixed_string_t cmd_port; 16841 cmdline_fixed_string_t cmd_keyword; 16842 portid_t cmd_pid; 16843 }; 16844 16845 static void 16846 cmd_show_tx_metadata_parsed(void *parsed_result, 16847 __rte_unused struct cmdline *cl, 16848 __rte_unused void *data) 16849 { 16850 struct cmd_show_tx_metadata_result *res = parsed_result; 16851 16852 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16853 fprintf(stderr, "invalid port id %u\n", res->cmd_pid); 16854 return; 16855 } 16856 if (!strcmp(res->cmd_keyword, "tx_metadata")) { 16857 printf("Port %u tx_metadata: %u\n", res->cmd_pid, 16858 ports[res->cmd_pid].tx_metadata); 16859 } 16860 } 16861 16862 cmdline_parse_token_string_t cmd_show_tx_metadata_show = 16863 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 16864 cmd_show, "show"); 16865 cmdline_parse_token_string_t cmd_show_tx_metadata_port = 16866 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 16867 cmd_port, "port"); 16868 cmdline_parse_token_num_t cmd_show_tx_metadata_pid = 16869 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, 16870 cmd_pid, RTE_UINT16); 16871 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = 16872 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 16873 cmd_keyword, "tx_metadata"); 16874 16875 cmdline_parse_inst_t cmd_show_tx_metadata = { 16876 .f = cmd_show_tx_metadata_parsed, 16877 .data = NULL, 16878 .help_str = "show port <port_id> tx_metadata", 16879 .tokens = { 16880 (void *)&cmd_show_tx_metadata_show, 16881 (void *)&cmd_show_tx_metadata_port, 16882 (void *)&cmd_show_tx_metadata_pid, 16883 (void *)&cmd_show_tx_metadata_keyword, 16884 NULL, 16885 }, 16886 }; 16887 16888 /* *** show fec capability per port configuration *** */ 16889 struct cmd_show_fec_capability_result { 16890 cmdline_fixed_string_t cmd_show; 16891 cmdline_fixed_string_t cmd_port; 16892 cmdline_fixed_string_t cmd_fec; 16893 cmdline_fixed_string_t cmd_keyword; 16894 portid_t cmd_pid; 16895 }; 16896 16897 static void 16898 cmd_show_fec_capability_parsed(void *parsed_result, 16899 __rte_unused struct cmdline *cl, 16900 __rte_unused void *data) 16901 { 16902 struct cmd_show_fec_capability_result *res = parsed_result; 16903 struct rte_eth_fec_capa *speed_fec_capa; 16904 unsigned int num; 16905 int ret; 16906 16907 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16908 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid); 16909 return; 16910 } 16911 16912 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0); 16913 if (ret == -ENOTSUP) { 16914 fprintf(stderr, "Function not implemented\n"); 16915 return; 16916 } else if (ret < 0) { 16917 fprintf(stderr, "Get FEC capability failed: %d\n", ret); 16918 return; 16919 } 16920 16921 num = (unsigned int)ret; 16922 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa)); 16923 if (speed_fec_capa == NULL) { 16924 fprintf(stderr, "Failed to alloc FEC capability buffer\n"); 16925 return; 16926 } 16927 16928 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num); 16929 if (ret < 0) { 16930 fprintf(stderr, "Error getting FEC capability: %d\n", ret); 16931 goto out; 16932 } 16933 16934 show_fec_capability(num, speed_fec_capa); 16935 out: 16936 free(speed_fec_capa); 16937 } 16938 16939 cmdline_parse_token_string_t cmd_show_fec_capability_show = 16940 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16941 cmd_show, "show"); 16942 cmdline_parse_token_string_t cmd_show_fec_capability_port = 16943 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16944 cmd_port, "port"); 16945 cmdline_parse_token_num_t cmd_show_fec_capability_pid = 16946 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result, 16947 cmd_pid, RTE_UINT16); 16948 cmdline_parse_token_string_t cmd_show_fec_capability_fec = 16949 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16950 cmd_fec, "fec"); 16951 cmdline_parse_token_string_t cmd_show_fec_capability_keyword = 16952 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16953 cmd_keyword, "capabilities"); 16954 16955 cmdline_parse_inst_t cmd_show_capability = { 16956 .f = cmd_show_fec_capability_parsed, 16957 .data = NULL, 16958 .help_str = "show port <port_id> fec capabilities", 16959 .tokens = { 16960 (void *)&cmd_show_fec_capability_show, 16961 (void *)&cmd_show_fec_capability_port, 16962 (void *)&cmd_show_fec_capability_pid, 16963 (void *)&cmd_show_fec_capability_fec, 16964 (void *)&cmd_show_fec_capability_keyword, 16965 NULL, 16966 }, 16967 }; 16968 16969 /* *** show fec mode per port configuration *** */ 16970 struct cmd_show_fec_metadata_result { 16971 cmdline_fixed_string_t cmd_show; 16972 cmdline_fixed_string_t cmd_port; 16973 cmdline_fixed_string_t cmd_keyword; 16974 portid_t cmd_pid; 16975 }; 16976 16977 static void 16978 cmd_show_fec_mode_parsed(void *parsed_result, 16979 __rte_unused struct cmdline *cl, 16980 __rte_unused void *data) 16981 { 16982 #define FEC_NAME_SIZE 16 16983 struct cmd_show_fec_metadata_result *res = parsed_result; 16984 uint32_t mode; 16985 char buf[FEC_NAME_SIZE]; 16986 int ret; 16987 16988 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16989 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid); 16990 return; 16991 } 16992 ret = rte_eth_fec_get(res->cmd_pid, &mode); 16993 if (ret == -ENOTSUP) { 16994 fprintf(stderr, "Function not implemented\n"); 16995 return; 16996 } else if (ret < 0) { 16997 fprintf(stderr, "Get FEC mode failed\n"); 16998 return; 16999 } 17000 17001 switch (mode) { 17002 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC): 17003 strlcpy(buf, "off", sizeof(buf)); 17004 break; 17005 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO): 17006 strlcpy(buf, "auto", sizeof(buf)); 17007 break; 17008 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER): 17009 strlcpy(buf, "baser", sizeof(buf)); 17010 break; 17011 case RTE_ETH_FEC_MODE_CAPA_MASK(RS): 17012 strlcpy(buf, "rs", sizeof(buf)); 17013 break; 17014 default: 17015 return; 17016 } 17017 17018 printf("%s\n", buf); 17019 } 17020 17021 cmdline_parse_token_string_t cmd_show_fec_mode_show = 17022 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 17023 cmd_show, "show"); 17024 cmdline_parse_token_string_t cmd_show_fec_mode_port = 17025 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 17026 cmd_port, "port"); 17027 cmdline_parse_token_num_t cmd_show_fec_mode_pid = 17028 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result, 17029 cmd_pid, RTE_UINT16); 17030 cmdline_parse_token_string_t cmd_show_fec_mode_keyword = 17031 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 17032 cmd_keyword, "fec_mode"); 17033 17034 cmdline_parse_inst_t cmd_show_fec_mode = { 17035 .f = cmd_show_fec_mode_parsed, 17036 .data = NULL, 17037 .help_str = "show port <port_id> fec_mode", 17038 .tokens = { 17039 (void *)&cmd_show_fec_mode_show, 17040 (void *)&cmd_show_fec_mode_port, 17041 (void *)&cmd_show_fec_mode_pid, 17042 (void *)&cmd_show_fec_mode_keyword, 17043 NULL, 17044 }, 17045 }; 17046 17047 /* *** set fec mode per port configuration *** */ 17048 struct cmd_set_port_fec_mode { 17049 cmdline_fixed_string_t set; 17050 cmdline_fixed_string_t port; 17051 portid_t port_id; 17052 cmdline_fixed_string_t fec_mode; 17053 cmdline_fixed_string_t fec_value; 17054 }; 17055 17056 /* Common CLI fields for set fec mode */ 17057 cmdline_parse_token_string_t cmd_set_port_fec_mode_set = 17058 TOKEN_STRING_INITIALIZER 17059 (struct cmd_set_port_fec_mode, 17060 set, "set"); 17061 cmdline_parse_token_string_t cmd_set_port_fec_mode_port = 17062 TOKEN_STRING_INITIALIZER 17063 (struct cmd_set_port_fec_mode, 17064 port, "port"); 17065 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id = 17066 TOKEN_NUM_INITIALIZER 17067 (struct cmd_set_port_fec_mode, 17068 port_id, RTE_UINT16); 17069 cmdline_parse_token_string_t cmd_set_port_fec_mode_str = 17070 TOKEN_STRING_INITIALIZER 17071 (struct cmd_set_port_fec_mode, 17072 fec_mode, "fec_mode"); 17073 cmdline_parse_token_string_t cmd_set_port_fec_mode_value = 17074 TOKEN_STRING_INITIALIZER 17075 (struct cmd_set_port_fec_mode, 17076 fec_value, NULL); 17077 17078 static void 17079 cmd_set_port_fec_mode_parsed( 17080 void *parsed_result, 17081 __rte_unused struct cmdline *cl, 17082 __rte_unused void *data) 17083 { 17084 struct cmd_set_port_fec_mode *res = parsed_result; 17085 uint16_t port_id = res->port_id; 17086 uint32_t fec_capa; 17087 int ret; 17088 17089 ret = parse_fec_mode(res->fec_value, &fec_capa); 17090 if (ret < 0) { 17091 fprintf(stderr, "Unknown fec mode: %s for port %d\n", 17092 res->fec_value, port_id); 17093 return; 17094 } 17095 17096 ret = rte_eth_fec_set(port_id, fec_capa); 17097 if (ret == -ENOTSUP) { 17098 fprintf(stderr, "Function not implemented\n"); 17099 return; 17100 } else if (ret < 0) { 17101 fprintf(stderr, "Set FEC mode failed\n"); 17102 return; 17103 } 17104 } 17105 17106 cmdline_parse_inst_t cmd_set_fec_mode = { 17107 .f = cmd_set_port_fec_mode_parsed, 17108 .data = NULL, 17109 .help_str = "set port <port_id> fec_mode auto|off|rs|baser", 17110 .tokens = { 17111 (void *)&cmd_set_port_fec_mode_set, 17112 (void *)&cmd_set_port_fec_mode_port, 17113 (void *)&cmd_set_port_fec_mode_port_id, 17114 (void *)&cmd_set_port_fec_mode_str, 17115 (void *)&cmd_set_port_fec_mode_value, 17116 NULL, 17117 }, 17118 }; 17119 17120 /* show port supported ptypes */ 17121 17122 /* Common result structure for show port ptypes */ 17123 struct cmd_show_port_supported_ptypes_result { 17124 cmdline_fixed_string_t show; 17125 cmdline_fixed_string_t port; 17126 portid_t port_id; 17127 cmdline_fixed_string_t ptypes; 17128 }; 17129 17130 /* Common CLI fields for show port ptypes */ 17131 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show = 17132 TOKEN_STRING_INITIALIZER 17133 (struct cmd_show_port_supported_ptypes_result, 17134 show, "show"); 17135 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port = 17136 TOKEN_STRING_INITIALIZER 17137 (struct cmd_show_port_supported_ptypes_result, 17138 port, "port"); 17139 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id = 17140 TOKEN_NUM_INITIALIZER 17141 (struct cmd_show_port_supported_ptypes_result, 17142 port_id, RTE_UINT16); 17143 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes = 17144 TOKEN_STRING_INITIALIZER 17145 (struct cmd_show_port_supported_ptypes_result, 17146 ptypes, "ptypes"); 17147 17148 static void 17149 cmd_show_port_supported_ptypes_parsed( 17150 void *parsed_result, 17151 __rte_unused struct cmdline *cl, 17152 __rte_unused void *data) 17153 { 17154 #define RSVD_PTYPE_MASK 0xf0000000 17155 #define MAX_PTYPES_PER_LAYER 16 17156 #define LTYPE_NAMESIZE 32 17157 #define PTYPE_NAMESIZE 256 17158 struct cmd_show_port_supported_ptypes_result *res = parsed_result; 17159 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE]; 17160 uint32_t ptype_mask = RTE_PTYPE_L2_MASK; 17161 uint32_t ptypes[MAX_PTYPES_PER_LAYER]; 17162 uint16_t port_id = res->port_id; 17163 int ret, i; 17164 17165 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0); 17166 if (ret < 0) 17167 return; 17168 17169 while (ptype_mask != RSVD_PTYPE_MASK) { 17170 17171 switch (ptype_mask) { 17172 case RTE_PTYPE_L2_MASK: 17173 strlcpy(ltype, "L2", sizeof(ltype)); 17174 break; 17175 case RTE_PTYPE_L3_MASK: 17176 strlcpy(ltype, "L3", sizeof(ltype)); 17177 break; 17178 case RTE_PTYPE_L4_MASK: 17179 strlcpy(ltype, "L4", sizeof(ltype)); 17180 break; 17181 case RTE_PTYPE_TUNNEL_MASK: 17182 strlcpy(ltype, "Tunnel", sizeof(ltype)); 17183 break; 17184 case RTE_PTYPE_INNER_L2_MASK: 17185 strlcpy(ltype, "Inner L2", sizeof(ltype)); 17186 break; 17187 case RTE_PTYPE_INNER_L3_MASK: 17188 strlcpy(ltype, "Inner L3", sizeof(ltype)); 17189 break; 17190 case RTE_PTYPE_INNER_L4_MASK: 17191 strlcpy(ltype, "Inner L4", sizeof(ltype)); 17192 break; 17193 default: 17194 return; 17195 } 17196 17197 ret = rte_eth_dev_get_supported_ptypes(res->port_id, 17198 ptype_mask, ptypes, 17199 MAX_PTYPES_PER_LAYER); 17200 17201 if (ret > 0) 17202 printf("Supported %s ptypes:\n", ltype); 17203 else 17204 printf("%s ptypes unsupported\n", ltype); 17205 17206 for (i = 0; i < ret; ++i) { 17207 rte_get_ptype_name(ptypes[i], buf, sizeof(buf)); 17208 printf("%s\n", buf); 17209 } 17210 17211 ptype_mask <<= 4; 17212 } 17213 } 17214 17215 cmdline_parse_inst_t cmd_show_port_supported_ptypes = { 17216 .f = cmd_show_port_supported_ptypes_parsed, 17217 .data = NULL, 17218 .help_str = "show port <port_id> ptypes", 17219 .tokens = { 17220 (void *)&cmd_show_port_supported_ptypes_show, 17221 (void *)&cmd_show_port_supported_ptypes_port, 17222 (void *)&cmd_show_port_supported_ptypes_port_id, 17223 (void *)&cmd_show_port_supported_ptypes_ptypes, 17224 NULL, 17225 }, 17226 }; 17227 17228 /* *** display rx/tx descriptor status *** */ 17229 struct cmd_show_rx_tx_desc_status_result { 17230 cmdline_fixed_string_t cmd_show; 17231 cmdline_fixed_string_t cmd_port; 17232 cmdline_fixed_string_t cmd_keyword; 17233 cmdline_fixed_string_t cmd_desc; 17234 cmdline_fixed_string_t cmd_status; 17235 portid_t cmd_pid; 17236 portid_t cmd_qid; 17237 portid_t cmd_did; 17238 }; 17239 17240 static void 17241 cmd_show_rx_tx_desc_status_parsed(void *parsed_result, 17242 __rte_unused struct cmdline *cl, 17243 __rte_unused void *data) 17244 { 17245 struct cmd_show_rx_tx_desc_status_result *res = parsed_result; 17246 int rc; 17247 17248 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 17249 fprintf(stderr, "invalid port id %u\n", res->cmd_pid); 17250 return; 17251 } 17252 17253 if (!strcmp(res->cmd_keyword, "rxq")) { 17254 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid, 17255 res->cmd_did); 17256 if (rc < 0) { 17257 fprintf(stderr, 17258 "Invalid input: queue id = %d, desc id = %d\n", 17259 res->cmd_qid, res->cmd_did); 17260 return; 17261 } 17262 if (rc == RTE_ETH_RX_DESC_AVAIL) 17263 printf("Desc status = AVAILABLE\n"); 17264 else if (rc == RTE_ETH_RX_DESC_DONE) 17265 printf("Desc status = DONE\n"); 17266 else 17267 printf("Desc status = UNAVAILABLE\n"); 17268 } else if (!strcmp(res->cmd_keyword, "txq")) { 17269 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid, 17270 res->cmd_did); 17271 if (rc < 0) { 17272 fprintf(stderr, 17273 "Invalid input: queue id = %d, desc id = %d\n", 17274 res->cmd_qid, res->cmd_did); 17275 return; 17276 } 17277 if (rc == RTE_ETH_TX_DESC_FULL) 17278 printf("Desc status = FULL\n"); 17279 else if (rc == RTE_ETH_TX_DESC_DONE) 17280 printf("Desc status = DONE\n"); 17281 else 17282 printf("Desc status = UNAVAILABLE\n"); 17283 } 17284 } 17285 17286 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show = 17287 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17288 cmd_show, "show"); 17289 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port = 17290 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17291 cmd_port, "port"); 17292 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid = 17293 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17294 cmd_pid, RTE_UINT16); 17295 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword = 17296 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17297 cmd_keyword, "rxq#txq"); 17298 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid = 17299 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17300 cmd_qid, RTE_UINT16); 17301 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc = 17302 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17303 cmd_desc, "desc"); 17304 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did = 17305 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17306 cmd_did, RTE_UINT16); 17307 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status = 17308 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 17309 cmd_status, "status"); 17310 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = { 17311 .f = cmd_show_rx_tx_desc_status_parsed, 17312 .data = NULL, 17313 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> " 17314 "status", 17315 .tokens = { 17316 (void *)&cmd_show_rx_tx_desc_status_show, 17317 (void *)&cmd_show_rx_tx_desc_status_port, 17318 (void *)&cmd_show_rx_tx_desc_status_pid, 17319 (void *)&cmd_show_rx_tx_desc_status_keyword, 17320 (void *)&cmd_show_rx_tx_desc_status_qid, 17321 (void *)&cmd_show_rx_tx_desc_status_desc, 17322 (void *)&cmd_show_rx_tx_desc_status_did, 17323 (void *)&cmd_show_rx_tx_desc_status_status, 17324 NULL, 17325 }, 17326 }; 17327 17328 /* *** display rx queue desc used count *** */ 17329 struct cmd_show_rx_queue_desc_used_count_result { 17330 cmdline_fixed_string_t cmd_show; 17331 cmdline_fixed_string_t cmd_port; 17332 cmdline_fixed_string_t cmd_rxq; 17333 cmdline_fixed_string_t cmd_desc; 17334 cmdline_fixed_string_t cmd_used; 17335 cmdline_fixed_string_t cmd_count; 17336 portid_t cmd_pid; 17337 portid_t cmd_qid; 17338 }; 17339 17340 static void 17341 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result, 17342 __rte_unused struct cmdline *cl, 17343 __rte_unused void *data) 17344 { 17345 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result; 17346 int rc; 17347 17348 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 17349 fprintf(stderr, "invalid port id %u\n", res->cmd_pid); 17350 return; 17351 } 17352 17353 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid); 17354 if (rc < 0) { 17355 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid); 17356 return; 17357 } 17358 printf("Used desc count = %d\n", rc); 17359 } 17360 17361 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show = 17362 TOKEN_STRING_INITIALIZER 17363 (struct cmd_show_rx_queue_desc_used_count_result, 17364 cmd_show, "show"); 17365 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port = 17366 TOKEN_STRING_INITIALIZER 17367 (struct cmd_show_rx_queue_desc_used_count_result, 17368 cmd_port, "port"); 17369 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid = 17370 TOKEN_NUM_INITIALIZER 17371 (struct cmd_show_rx_queue_desc_used_count_result, 17372 cmd_pid, RTE_UINT16); 17373 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq = 17374 TOKEN_STRING_INITIALIZER 17375 (struct cmd_show_rx_queue_desc_used_count_result, 17376 cmd_rxq, "rxq"); 17377 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid = 17378 TOKEN_NUM_INITIALIZER 17379 (struct cmd_show_rx_queue_desc_used_count_result, 17380 cmd_qid, RTE_UINT16); 17381 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc = 17382 TOKEN_STRING_INITIALIZER 17383 (struct cmd_show_rx_queue_desc_used_count_result, 17384 cmd_count, "desc"); 17385 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used = 17386 TOKEN_STRING_INITIALIZER 17387 (struct cmd_show_rx_queue_desc_used_count_result, 17388 cmd_count, "used"); 17389 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count = 17390 TOKEN_STRING_INITIALIZER 17391 (struct cmd_show_rx_queue_desc_used_count_result, 17392 cmd_count, "count"); 17393 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = { 17394 .f = cmd_show_rx_queue_desc_used_count_parsed, 17395 .data = NULL, 17396 .help_str = "show port <port_id> rxq <queue_id> desc used count", 17397 .tokens = { 17398 (void *)&cmd_show_rx_queue_desc_used_count_show, 17399 (void *)&cmd_show_rx_queue_desc_used_count_port, 17400 (void *)&cmd_show_rx_queue_desc_used_count_pid, 17401 (void *)&cmd_show_rx_queue_desc_used_count_rxq, 17402 (void *)&cmd_show_rx_queue_desc_used_count_qid, 17403 (void *)&cmd_show_rx_queue_desc_used_count_desc, 17404 (void *)&cmd_show_rx_queue_desc_used_count_used, 17405 (void *)&cmd_show_rx_queue_desc_used_count_count, 17406 NULL, 17407 }, 17408 }; 17409 17410 /* Common result structure for set port ptypes */ 17411 struct cmd_set_port_ptypes_result { 17412 cmdline_fixed_string_t set; 17413 cmdline_fixed_string_t port; 17414 portid_t port_id; 17415 cmdline_fixed_string_t ptype_mask; 17416 uint32_t mask; 17417 }; 17418 17419 /* Common CLI fields for set port ptypes */ 17420 cmdline_parse_token_string_t cmd_set_port_ptypes_set = 17421 TOKEN_STRING_INITIALIZER 17422 (struct cmd_set_port_ptypes_result, 17423 set, "set"); 17424 cmdline_parse_token_string_t cmd_set_port_ptypes_port = 17425 TOKEN_STRING_INITIALIZER 17426 (struct cmd_set_port_ptypes_result, 17427 port, "port"); 17428 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id = 17429 TOKEN_NUM_INITIALIZER 17430 (struct cmd_set_port_ptypes_result, 17431 port_id, RTE_UINT16); 17432 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str = 17433 TOKEN_STRING_INITIALIZER 17434 (struct cmd_set_port_ptypes_result, 17435 ptype_mask, "ptype_mask"); 17436 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 = 17437 TOKEN_NUM_INITIALIZER 17438 (struct cmd_set_port_ptypes_result, 17439 mask, RTE_UINT32); 17440 17441 static void 17442 cmd_set_port_ptypes_parsed( 17443 void *parsed_result, 17444 __rte_unused struct cmdline *cl, 17445 __rte_unused void *data) 17446 { 17447 struct cmd_set_port_ptypes_result *res = parsed_result; 17448 #define PTYPE_NAMESIZE 256 17449 char ptype_name[PTYPE_NAMESIZE]; 17450 uint16_t port_id = res->port_id; 17451 uint32_t ptype_mask = res->mask; 17452 int ret, i; 17453 17454 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK, 17455 NULL, 0); 17456 if (ret <= 0) { 17457 fprintf(stderr, "Port %d doesn't support any ptypes.\n", 17458 port_id); 17459 return; 17460 } 17461 17462 uint32_t ptypes[ret]; 17463 17464 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); 17465 if (ret < 0) { 17466 fprintf(stderr, "Unable to set requested ptypes for Port %d\n", 17467 port_id); 17468 return; 17469 } 17470 17471 printf("Successfully set following ptypes for Port %d\n", port_id); 17472 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) { 17473 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name)); 17474 printf("%s\n", ptype_name); 17475 } 17476 17477 clear_ptypes = false; 17478 } 17479 17480 cmdline_parse_inst_t cmd_set_port_ptypes = { 17481 .f = cmd_set_port_ptypes_parsed, 17482 .data = NULL, 17483 .help_str = "set port <port_id> ptype_mask <mask>", 17484 .tokens = { 17485 (void *)&cmd_set_port_ptypes_set, 17486 (void *)&cmd_set_port_ptypes_port, 17487 (void *)&cmd_set_port_ptypes_port_id, 17488 (void *)&cmd_set_port_ptypes_mask_str, 17489 (void *)&cmd_set_port_ptypes_mask_u32, 17490 NULL, 17491 }, 17492 }; 17493 17494 /* *** display mac addresses added to a port *** */ 17495 struct cmd_showport_macs_result { 17496 cmdline_fixed_string_t cmd_show; 17497 cmdline_fixed_string_t cmd_port; 17498 cmdline_fixed_string_t cmd_keyword; 17499 portid_t cmd_pid; 17500 }; 17501 17502 static void 17503 cmd_showport_macs_parsed(void *parsed_result, 17504 __rte_unused struct cmdline *cl, 17505 __rte_unused void *data) 17506 { 17507 struct cmd_showport_macs_result *res = parsed_result; 17508 17509 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN)) 17510 return; 17511 17512 if (!strcmp(res->cmd_keyword, "macs")) 17513 show_macs(res->cmd_pid); 17514 else if (!strcmp(res->cmd_keyword, "mcast_macs")) 17515 show_mcast_macs(res->cmd_pid); 17516 } 17517 17518 cmdline_parse_token_string_t cmd_showport_macs_show = 17519 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 17520 cmd_show, "show"); 17521 cmdline_parse_token_string_t cmd_showport_macs_port = 17522 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 17523 cmd_port, "port"); 17524 cmdline_parse_token_num_t cmd_showport_macs_pid = 17525 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result, 17526 cmd_pid, RTE_UINT16); 17527 cmdline_parse_token_string_t cmd_showport_macs_keyword = 17528 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 17529 cmd_keyword, "macs#mcast_macs"); 17530 17531 cmdline_parse_inst_t cmd_showport_macs = { 17532 .f = cmd_showport_macs_parsed, 17533 .data = NULL, 17534 .help_str = "show port <port_id> macs|mcast_macs", 17535 .tokens = { 17536 (void *)&cmd_showport_macs_show, 17537 (void *)&cmd_showport_macs_port, 17538 (void *)&cmd_showport_macs_pid, 17539 (void *)&cmd_showport_macs_keyword, 17540 NULL, 17541 }, 17542 }; 17543 17544 /* ******************************************************************************** */ 17545 17546 /* list of instructions */ 17547 cmdline_parse_ctx_t main_ctx[] = { 17548 (cmdline_parse_inst_t *)&cmd_help_brief, 17549 (cmdline_parse_inst_t *)&cmd_help_long, 17550 (cmdline_parse_inst_t *)&cmd_quit, 17551 (cmdline_parse_inst_t *)&cmd_load_from_file, 17552 (cmdline_parse_inst_t *)&cmd_showport, 17553 (cmdline_parse_inst_t *)&cmd_showqueue, 17554 (cmdline_parse_inst_t *)&cmd_showeeprom, 17555 (cmdline_parse_inst_t *)&cmd_showportall, 17556 (cmdline_parse_inst_t *)&cmd_showdevice, 17557 (cmdline_parse_inst_t *)&cmd_showcfg, 17558 (cmdline_parse_inst_t *)&cmd_showfwdall, 17559 (cmdline_parse_inst_t *)&cmd_start, 17560 (cmdline_parse_inst_t *)&cmd_start_tx_first, 17561 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 17562 (cmdline_parse_inst_t *)&cmd_set_link_up, 17563 (cmdline_parse_inst_t *)&cmd_set_link_down, 17564 (cmdline_parse_inst_t *)&cmd_reset, 17565 (cmdline_parse_inst_t *)&cmd_set_numbers, 17566 (cmdline_parse_inst_t *)&cmd_set_log, 17567 (cmdline_parse_inst_t *)&cmd_set_rxoffs, 17568 (cmdline_parse_inst_t *)&cmd_set_rxpkts, 17569 (cmdline_parse_inst_t *)&cmd_set_txpkts, 17570 (cmdline_parse_inst_t *)&cmd_set_txsplit, 17571 (cmdline_parse_inst_t *)&cmd_set_txtimes, 17572 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 17573 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 17574 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 17575 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 17576 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 17577 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 17578 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 17579 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 17580 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 17581 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 17582 (cmdline_parse_inst_t *)&cmd_set_link_check, 17583 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 17584 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 17585 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 17586 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 17587 #ifdef RTE_NET_BOND 17588 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 17589 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 17590 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 17591 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 17592 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 17593 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 17594 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 17595 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 17596 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 17597 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 17598 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 17599 #endif 17600 (cmdline_parse_inst_t *)&cmd_vlan_offload, 17601 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 17602 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 17603 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 17604 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 17605 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 17606 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 17607 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 17608 (cmdline_parse_inst_t *)&cmd_csum_set, 17609 (cmdline_parse_inst_t *)&cmd_csum_show, 17610 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 17611 (cmdline_parse_inst_t *)&cmd_tso_set, 17612 (cmdline_parse_inst_t *)&cmd_tso_show, 17613 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 17614 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 17615 (cmdline_parse_inst_t *)&cmd_gro_enable, 17616 (cmdline_parse_inst_t *)&cmd_gro_flush, 17617 (cmdline_parse_inst_t *)&cmd_gro_show, 17618 (cmdline_parse_inst_t *)&cmd_gso_enable, 17619 (cmdline_parse_inst_t *)&cmd_gso_size, 17620 (cmdline_parse_inst_t *)&cmd_gso_show, 17621 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 17622 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 17623 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 17624 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 17625 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 17626 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 17627 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 17628 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 17629 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 17630 (cmdline_parse_inst_t *)&cmd_link_flow_control_show, 17631 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 17632 (cmdline_parse_inst_t *)&cmd_config_dcb, 17633 (cmdline_parse_inst_t *)&cmd_read_reg, 17634 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 17635 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 17636 (cmdline_parse_inst_t *)&cmd_write_reg, 17637 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 17638 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 17639 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 17640 (cmdline_parse_inst_t *)&cmd_stop, 17641 (cmdline_parse_inst_t *)&cmd_mac_addr, 17642 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 17643 (cmdline_parse_inst_t *)&cmd_set_qmap, 17644 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 17645 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles, 17646 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats, 17647 (cmdline_parse_inst_t *)&cmd_operate_port, 17648 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 17649 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 17650 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 17651 (cmdline_parse_inst_t *)&cmd_operate_detach_device, 17652 (cmdline_parse_inst_t *)&cmd_set_port_setup_on, 17653 (cmdline_parse_inst_t *)&cmd_config_speed_all, 17654 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 17655 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 17656 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 17657 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 17658 (cmdline_parse_inst_t *)&cmd_config_mtu, 17659 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 17660 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size, 17661 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 17662 (cmdline_parse_inst_t *)&cmd_config_rss, 17663 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 17664 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 17665 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 17666 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 17667 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 17668 (cmdline_parse_inst_t *)&cmd_showport_reta, 17669 (cmdline_parse_inst_t *)&cmd_showport_macs, 17670 (cmdline_parse_inst_t *)&cmd_config_burst, 17671 (cmdline_parse_inst_t *)&cmd_config_thresh, 17672 (cmdline_parse_inst_t *)&cmd_config_threshold, 17673 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 17674 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 17675 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 17676 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 17677 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 17678 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 17679 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 17680 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 17681 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 17682 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 17683 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 17684 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs, 17685 (cmdline_parse_inst_t *)&cmd_dump, 17686 (cmdline_parse_inst_t *)&cmd_dump_one, 17687 #ifdef RTE_NET_I40E 17688 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 17689 #endif 17690 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 17691 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 17692 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 17693 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 17694 (cmdline_parse_inst_t *)&cmd_flow, 17695 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 17696 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 17697 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 17698 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 17699 (cmdline_parse_inst_t *)&cmd_create_port_meter, 17700 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 17701 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 17702 (cmdline_parse_inst_t *)&cmd_del_port_meter, 17703 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy, 17704 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 17705 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 17706 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 17707 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 17708 (cmdline_parse_inst_t *)&cmd_mcast_addr, 17709 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 17710 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 17711 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 17712 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 17713 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 17714 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 17715 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 17716 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 17717 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 17718 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 17719 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 17720 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 17721 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 17722 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 17723 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 17724 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 17725 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 17726 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 17727 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 17728 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 17729 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 17730 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 17731 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 17732 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 17733 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 17734 (cmdline_parse_inst_t *)&cmd_set_vxlan, 17735 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl, 17736 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 17737 (cmdline_parse_inst_t *)&cmd_set_nvgre, 17738 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 17739 (cmdline_parse_inst_t *)&cmd_set_l2_encap, 17740 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, 17741 (cmdline_parse_inst_t *)&cmd_set_l2_decap, 17742 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, 17743 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, 17744 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, 17745 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, 17746 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, 17747 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, 17748 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, 17749 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, 17750 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, 17751 (cmdline_parse_inst_t *)&cmd_set_conntrack_common, 17752 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir, 17753 (cmdline_parse_inst_t *)&cmd_ddp_add, 17754 (cmdline_parse_inst_t *)&cmd_ddp_del, 17755 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 17756 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 17757 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 17758 (cmdline_parse_inst_t *)&cmd_clear_input_set, 17759 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 17760 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 17761 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes, 17762 (cmdline_parse_inst_t *)&cmd_set_port_ptypes, 17763 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 17764 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 17765 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 17766 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 17767 17768 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 17769 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 17770 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 17771 (cmdline_parse_inst_t *)&cmd_queue_region, 17772 (cmdline_parse_inst_t *)&cmd_region_flowtype, 17773 (cmdline_parse_inst_t *)&cmd_user_priority_region, 17774 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 17775 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 17776 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 17777 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 17778 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 17779 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 17780 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 17781 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 17782 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 17783 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 17784 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 17785 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 17786 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 17787 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 17788 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 17789 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode, 17790 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 17791 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 17792 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 17793 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 17794 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 17795 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 17796 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, 17797 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, 17798 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, 17799 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 17800 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 17801 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 17802 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 17803 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 17804 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 17805 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 17806 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 17807 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 17808 #ifdef RTE_LIB_BPF 17809 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 17810 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 17811 #endif 17812 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, 17813 (cmdline_parse_inst_t *)&cmd_show_tx_metadata, 17814 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status, 17815 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count, 17816 (cmdline_parse_inst_t *)&cmd_set_raw, 17817 (cmdline_parse_inst_t *)&cmd_show_set_raw, 17818 (cmdline_parse_inst_t *)&cmd_show_set_raw_all, 17819 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific, 17820 (cmdline_parse_inst_t *)&cmd_show_fec_mode, 17821 (cmdline_parse_inst_t *)&cmd_set_fec_mode, 17822 (cmdline_parse_inst_t *)&cmd_show_capability, 17823 NULL, 17824 }; 17825 17826 /* read cmdline commands from file */ 17827 void 17828 cmdline_read_from_file(const char *filename) 17829 { 17830 struct cmdline *cl; 17831 17832 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 17833 if (cl == NULL) { 17834 fprintf(stderr, 17835 "Failed to create file based cmdline context: %s\n", 17836 filename); 17837 return; 17838 } 17839 17840 cmdline_interact(cl); 17841 cmdline_quit(cl); 17842 17843 cmdline_free(cl); 17844 17845 printf("Read CLI commands from %s\n", filename); 17846 } 17847 17848 /* prompt function, called from main on MAIN lcore */ 17849 void 17850 prompt(void) 17851 { 17852 int ret; 17853 /* initialize non-constant commands */ 17854 cmd_set_fwd_mode_init(); 17855 cmd_set_fwd_retry_mode_init(); 17856 17857 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 17858 if (testpmd_cl == NULL) 17859 return; 17860 17861 ret = atexit(prompt_exit); 17862 if (ret != 0) 17863 fprintf(stderr, "Cannot set exit function for cmdline\n"); 17864 17865 cmdline_interact(testpmd_cl); 17866 if (ret != 0) 17867 cmdline_stdin_exit(testpmd_cl); 17868 } 17869 17870 void 17871 prompt_exit(void) 17872 { 17873 if (testpmd_cl != NULL) { 17874 cmdline_quit(testpmd_cl); 17875 cmdline_stdin_exit(testpmd_cl); 17876 } 17877 } 17878 17879 static void 17880 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 17881 { 17882 if (id == (portid_t)RTE_PORT_ALL) { 17883 portid_t pid; 17884 17885 RTE_ETH_FOREACH_DEV(pid) { 17886 /* check if need_reconfig has been set to 1 */ 17887 if (ports[pid].need_reconfig == 0) 17888 ports[pid].need_reconfig = dev; 17889 /* check if need_reconfig_queues has been set to 1 */ 17890 if (ports[pid].need_reconfig_queues == 0) 17891 ports[pid].need_reconfig_queues = queue; 17892 } 17893 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 17894 /* check if need_reconfig has been set to 1 */ 17895 if (ports[id].need_reconfig == 0) 17896 ports[id].need_reconfig = dev; 17897 /* check if need_reconfig_queues has been set to 1 */ 17898 if (ports[id].need_reconfig_queues == 0) 17899 ports[id].need_reconfig_queues = queue; 17900 } 17901 } 17902