1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2016 Intel Corporation. 3 * Copyright(c) 2014 6WIND S.A. 4 */ 5 6 #include <stdarg.h> 7 #include <errno.h> 8 #include <stdio.h> 9 #include <stdint.h> 10 #include <string.h> 11 #include <termios.h> 12 #include <unistd.h> 13 #include <inttypes.h> 14 #include <sys/socket.h> 15 #include <netinet/in.h> 16 17 #include <sys/queue.h> 18 19 #include <rte_common.h> 20 #include <rte_byteorder.h> 21 #include <rte_log.h> 22 #include <rte_debug.h> 23 #include <rte_cycles.h> 24 #include <rte_memory.h> 25 #include <rte_memzone.h> 26 #include <rte_malloc.h> 27 #include <rte_launch.h> 28 #include <rte_eal.h> 29 #include <rte_per_lcore.h> 30 #include <rte_lcore.h> 31 #include <rte_atomic.h> 32 #include <rte_branch_prediction.h> 33 #include <rte_ring.h> 34 #include <rte_mempool.h> 35 #include <rte_interrupts.h> 36 #include <rte_pci.h> 37 #include <rte_ether.h> 38 #include <rte_ethdev.h> 39 #include <rte_string_fns.h> 40 #include <rte_devargs.h> 41 #include <rte_flow.h> 42 #include <rte_gro.h> 43 #include <rte_mbuf_dyn.h> 44 45 #include <cmdline_rdline.h> 46 #include <cmdline_parse.h> 47 #include <cmdline_parse_num.h> 48 #include <cmdline_parse_string.h> 49 #include <cmdline_parse_ipaddr.h> 50 #include <cmdline_parse_etheraddr.h> 51 #include <cmdline_socket.h> 52 #include <cmdline.h> 53 #ifdef RTE_NET_BOND 54 #include <rte_eth_bond.h> 55 #include <rte_eth_bond_8023ad.h> 56 #endif 57 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA 58 #include <rte_pmd_dpaa.h> 59 #endif 60 #ifdef RTE_NET_IXGBE 61 #include <rte_pmd_ixgbe.h> 62 #endif 63 #ifdef RTE_NET_I40E 64 #include <rte_pmd_i40e.h> 65 #endif 66 #ifdef RTE_NET_BNXT 67 #include <rte_pmd_bnxt.h> 68 #endif 69 #include "testpmd.h" 70 #include "cmdline_mtr.h" 71 #include "cmdline_tm.h" 72 #include "bpf_cmd.h" 73 74 static struct cmdline *testpmd_cl; 75 76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); 77 78 /* *** Help command with introduction. *** */ 79 struct cmd_help_brief_result { 80 cmdline_fixed_string_t help; 81 }; 82 83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result, 84 struct cmdline *cl, 85 __rte_unused void *data) 86 { 87 cmdline_printf( 88 cl, 89 "\n" 90 "Help is available for the following sections:\n\n" 91 " help control : Start and stop forwarding.\n" 92 " help display : Displaying port, stats and config " 93 "information.\n" 94 " help config : Configuration information.\n" 95 " help ports : Configuring ports.\n" 96 " help registers : Reading and setting port registers.\n" 97 " help filters : Filters configuration help.\n" 98 " help traffic_management : Traffic Management commands.\n" 99 " help devices : Device related cmds.\n" 100 " help all : All of the above sections.\n\n" 101 ); 102 103 } 104 105 cmdline_parse_token_string_t cmd_help_brief_help = 106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help"); 107 108 cmdline_parse_inst_t cmd_help_brief = { 109 .f = cmd_help_brief_parsed, 110 .data = NULL, 111 .help_str = "help: Show help", 112 .tokens = { 113 (void *)&cmd_help_brief_help, 114 NULL, 115 }, 116 }; 117 118 /* *** Help command with help sections. *** */ 119 struct cmd_help_long_result { 120 cmdline_fixed_string_t help; 121 cmdline_fixed_string_t section; 122 }; 123 124 static void cmd_help_long_parsed(void *parsed_result, 125 struct cmdline *cl, 126 __rte_unused void *data) 127 { 128 int show_all = 0; 129 struct cmd_help_long_result *res = parsed_result; 130 131 if (!strcmp(res->section, "all")) 132 show_all = 1; 133 134 if (show_all || !strcmp(res->section, "control")) { 135 136 cmdline_printf( 137 cl, 138 "\n" 139 "Control forwarding:\n" 140 "-------------------\n\n" 141 142 "start\n" 143 " Start packet forwarding with current configuration.\n\n" 144 145 "start tx_first\n" 146 " Start packet forwarding with current config" 147 " after sending one burst of packets.\n\n" 148 149 "stop\n" 150 " Stop packet forwarding, and display accumulated" 151 " statistics.\n\n" 152 153 "quit\n" 154 " Quit to prompt.\n\n" 155 ); 156 } 157 158 if (show_all || !strcmp(res->section, "display")) { 159 160 cmdline_printf( 161 cl, 162 "\n" 163 "Display:\n" 164 "--------\n\n" 165 166 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n" 167 " Display information for port_id, or all.\n\n" 168 169 "show port port_id (module_eeprom|eeprom)\n" 170 " Display the module EEPROM or EEPROM information for port_id.\n\n" 171 172 "show port X rss reta (size) (mask0,mask1,...)\n" 173 " Display the rss redirection table entry indicated" 174 " by masks on port X. size is used to indicate the" 175 " hardware supported reta size\n\n" 176 177 "show port (port_id) rss-hash [key]\n" 178 " Display the RSS hash functions and RSS hash key of port\n\n" 179 180 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n" 181 " Clear information for port_id, or all.\n\n" 182 183 "show (rxq|txq) info (port_id) (queue_id)\n" 184 " Display information for configured RX/TX queue.\n\n" 185 186 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n" 187 " Display the given configuration.\n\n" 188 189 "read rxd (port_id) (queue_id) (rxd_id)\n" 190 " Display an RX descriptor of a port RX queue.\n\n" 191 192 "read txd (port_id) (queue_id) (txd_id)\n" 193 " Display a TX descriptor of a port TX queue.\n\n" 194 195 "ddp get list (port_id)\n" 196 " Get ddp profile info list\n\n" 197 198 "ddp get info (profile_path)\n" 199 " Get ddp profile information.\n\n" 200 201 "show vf stats (port_id) (vf_id)\n" 202 " Display a VF's statistics.\n\n" 203 204 "clear vf stats (port_id) (vf_id)\n" 205 " Reset a VF's statistics.\n\n" 206 207 "show port (port_id) pctype mapping\n" 208 " Get flow ptype to pctype mapping on a port\n\n" 209 210 "show port meter stats (port_id) (meter_id) (clear)\n" 211 " Get meter stats on a port\n\n" 212 213 "show fwd stats all\n" 214 " Display statistics for all fwd engines.\n\n" 215 216 "clear fwd stats all\n" 217 " Clear statistics for all fwd engines.\n\n" 218 219 "show port (port_id) rx_offload capabilities\n" 220 " List all per queue and per port Rx offloading" 221 " capabilities of a port\n\n" 222 223 "show port (port_id) rx_offload configuration\n" 224 " List port level and all queue level" 225 " Rx offloading configuration\n\n" 226 227 "show port (port_id) tx_offload capabilities\n" 228 " List all per queue and per port" 229 " Tx offloading capabilities of a port\n\n" 230 231 "show port (port_id) tx_offload configuration\n" 232 " List port level and all queue level" 233 " Tx offloading configuration\n\n" 234 235 "show port (port_id) tx_metadata\n" 236 " Show Tx metadata value set" 237 " for a specific port\n\n" 238 239 "show port (port_id) ptypes\n" 240 " Show port supported ptypes" 241 " for a specific port\n\n" 242 243 "show device info (<identifier>|all)" 244 " Show general information about devices probed.\n\n" 245 246 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status" 247 " Show status of rx|tx descriptor.\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 } 259 260 if (show_all || !strcmp(res->section, "config")) { 261 cmdline_printf( 262 cl, 263 "\n" 264 "Configuration:\n" 265 "--------------\n" 266 "Configuration changes only become active when" 267 " forwarding is started/restarted.\n\n" 268 269 "set default\n" 270 " Reset forwarding to the default configuration.\n\n" 271 272 "set verbose (level)\n" 273 " Set the debug verbosity level X.\n\n" 274 275 "set log global|(type) (level)\n" 276 " Set the log level.\n\n" 277 278 "set nbport (num)\n" 279 " Set number of ports.\n\n" 280 281 "set nbcore (num)\n" 282 " Set number of cores.\n\n" 283 284 "set coremask (mask)\n" 285 " Set the forwarding cores hexadecimal mask.\n\n" 286 287 "set portmask (mask)\n" 288 " Set the forwarding ports hexadecimal mask.\n\n" 289 290 "set burst (num)\n" 291 " Set number of packets per burst.\n\n" 292 293 "set burst tx delay (microseconds) retry (num)\n" 294 " Set the transmit delay time and number of retries," 295 " effective when retry is enabled.\n\n" 296 297 "set rxoffs (x[,y]*)\n" 298 " Set the offset of each packet segment on" 299 " receiving if split feature is engaged." 300 " Affects only the queues configured with split" 301 " offloads.\n\n" 302 303 "set rxpkts (x[,y]*)\n" 304 " Set the length of each segment to scatter" 305 " packets on receiving if split feature is engaged." 306 " Affects only the queues configured with split" 307 " offloads.\n\n" 308 309 "set txpkts (x[,y]*)\n" 310 " Set the length of each segment of TXONLY" 311 " and optionally CSUM packets.\n\n" 312 313 "set txsplit (off|on|rand)\n" 314 " Set the split policy for the TX packets." 315 " Right now only applicable for CSUM and TXONLY" 316 " modes\n\n" 317 318 "set txtimes (x, y)\n" 319 " Set the scheduling on timestamps" 320 " timings for the TXONLY mode\n\n" 321 322 "set corelist (x[,y]*)\n" 323 " Set the list of forwarding cores.\n\n" 324 325 "set portlist (x[,y]*)\n" 326 " Set the list of forwarding ports.\n\n" 327 328 "set port setup on (iterator|event)\n" 329 " Select how attached port is retrieved for setup.\n\n" 330 331 "set tx loopback (port_id) (on|off)\n" 332 " Enable or disable tx loopback.\n\n" 333 334 "set all queues drop (port_id) (on|off)\n" 335 " Set drop enable bit for all queues.\n\n" 336 337 "set vf split drop (port_id) (vf_id) (on|off)\n" 338 " Set split drop enable bit for a VF from the PF.\n\n" 339 340 "set vf mac antispoof (port_id) (vf_id) (on|off).\n" 341 " Set MAC antispoof for a VF from the PF.\n\n" 342 343 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" 344 " Enable MACsec offload.\n\n" 345 346 "set macsec offload (port_id) off\n" 347 " Disable MACsec offload.\n\n" 348 349 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" 350 " Configure MACsec secure connection (SC).\n\n" 351 352 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" 353 " Configure MACsec secure association (SA).\n\n" 354 355 "set vf broadcast (port_id) (vf_id) (on|off)\n" 356 " Set VF broadcast for a VF from the PF.\n\n" 357 358 "vlan set stripq (on|off) (port_id,queue_id)\n" 359 " Set the VLAN strip for a queue on a port.\n\n" 360 361 "set vf vlan stripq (port_id) (vf_id) (on|off)\n" 362 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" 363 364 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" 365 " Set VLAN insert for a VF from the PF.\n\n" 366 367 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" 368 " Set VLAN antispoof for a VF from the PF.\n\n" 369 370 "set vf vlan tag (port_id) (vf_id) (on|off)\n" 371 " Set VLAN tag for a VF from the PF.\n\n" 372 373 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n" 374 " Set a VF's max bandwidth(Mbps).\n\n" 375 376 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n" 377 " Set all TCs' min bandwidth(%%) on a VF.\n\n" 378 379 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n" 380 " Set a TC's max bandwidth(Mbps) on a VF.\n\n" 381 382 "set tx strict-link-priority (port_id) (tc_bitmap)\n" 383 " Set some TCs' strict link priority mode on a physical port.\n\n" 384 385 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" 386 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n" 387 388 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n" 389 " Set the VLAN strip or filter or qinq strip or extend\n\n" 390 391 "vlan set (inner|outer) tpid (value) (port_id)\n" 392 " Set the VLAN TPID for Packet Filtering on" 393 " a port\n\n" 394 395 "rx_vlan add (vlan_id|all) (port_id)\n" 396 " Add a vlan_id, or all identifiers, to the set" 397 " of VLAN identifiers filtered by port_id.\n\n" 398 399 "rx_vlan rm (vlan_id|all) (port_id)\n" 400 " Remove a vlan_id, or all identifiers, from the set" 401 " of VLAN identifiers filtered by port_id.\n\n" 402 403 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n" 404 " Add a vlan_id, to the set of VLAN identifiers" 405 "filtered for VF(s) from port_id.\n\n" 406 407 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n" 408 " Remove a vlan_id, to the set of VLAN identifiers" 409 "filtered for VF(s) from port_id.\n\n" 410 411 "rx_vxlan_port add (udp_port) (port_id)\n" 412 " Add an UDP port for VXLAN packet filter on a port\n\n" 413 414 "rx_vxlan_port rm (udp_port) (port_id)\n" 415 " Remove an UDP port for VXLAN packet filter on a port\n\n" 416 417 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" 418 " Set hardware insertion of VLAN IDs (single or double VLAN " 419 "depends on the number of VLAN IDs) in packets sent on a port.\n\n" 420 421 "tx_vlan set pvid port_id vlan_id (on|off)\n" 422 " Set port based TX VLAN insertion.\n\n" 423 424 "tx_vlan reset (port_id)\n" 425 " Disable hardware insertion of a VLAN header in" 426 " packets sent on a port.\n\n" 427 428 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n" 429 " Select hardware or software calculation of the" 430 " checksum when transmitting a packet using the" 431 " csum forward engine.\n" 432 " ip|udp|tcp|sctp always concern the inner layer.\n" 433 " outer-ip concerns the outer IP layer in" 434 " outer-udp concerns the outer UDP layer in" 435 " case the packet is recognized as a tunnel packet by" 436 " the forward engine (vxlan, gre and ipip are supported)\n" 437 " Please check the NIC datasheet for HW limits.\n\n" 438 439 "csum parse-tunnel (on|off) (tx_port_id)\n" 440 " If disabled, treat tunnel packets as non-tunneled" 441 " packets (treat inner headers as payload). The port\n" 442 " argument is the port used for TX in csum forward" 443 " engine.\n\n" 444 445 "csum show (port_id)\n" 446 " Display tx checksum offload configuration\n\n" 447 448 "tso set (segsize) (portid)\n" 449 " Enable TCP Segmentation Offload in csum forward" 450 " engine.\n" 451 " Please check the NIC datasheet for HW limits.\n\n" 452 453 "tso show (portid)" 454 " Display the status of TCP Segmentation Offload.\n\n" 455 456 "set port (port_id) gro on|off\n" 457 " Enable or disable Generic Receive Offload in" 458 " csum forwarding engine.\n\n" 459 460 "show port (port_id) gro\n" 461 " Display GRO configuration.\n\n" 462 463 "set gro flush (cycles)\n" 464 " Set the cycle to flush GROed packets from" 465 " reassembly tables.\n\n" 466 467 "set port (port_id) gso (on|off)" 468 " Enable or disable Generic Segmentation Offload in" 469 " csum forwarding engine.\n\n" 470 471 "set gso segsz (length)\n" 472 " Set max packet length for output GSO segments," 473 " including packet header and payload.\n\n" 474 475 "show port (port_id) gso\n" 476 " Show GSO configuration.\n\n" 477 478 "set fwd (%s)\n" 479 " Set packet forwarding mode.\n\n" 480 481 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" 482 " Add a MAC address on port_id.\n\n" 483 484 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n" 485 " Remove a MAC address from port_id.\n\n" 486 487 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n" 488 " Set the default MAC address for port_id.\n\n" 489 490 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n" 491 " Add a MAC address for a VF on the port.\n\n" 492 493 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n" 494 " Set the MAC address for a VF from the PF.\n\n" 495 496 "set eth-peer (port_id) (peer_addr)\n" 497 " set the peer address for certain port.\n\n" 498 499 "set port (port_id) uta (mac_address|all) (on|off)\n" 500 " Add/Remove a or all unicast hash filter(s)" 501 "from port X.\n\n" 502 503 "set promisc (port_id|all) (on|off)\n" 504 " Set the promiscuous mode on port_id, or all.\n\n" 505 506 "set allmulti (port_id|all) (on|off)\n" 507 " Set the allmulti mode on port_id, or all.\n\n" 508 509 "set vf promisc (port_id) (vf_id) (on|off)\n" 510 " Set unicast promiscuous mode for a VF from the PF.\n\n" 511 512 "set vf allmulti (port_id) (vf_id) (on|off)\n" 513 " Set multicast promiscuous mode for a VF from the PF.\n\n" 514 515 "set flow_ctrl rx (on|off) tx (on|off) (high_water)" 516 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" 517 " (on|off) autoneg (on|off) (port_id)\n" 518 "set flow_ctrl rx (on|off) (portid)\n" 519 "set flow_ctrl tx (on|off) (portid)\n" 520 "set flow_ctrl high_water (high_water) (portid)\n" 521 "set flow_ctrl low_water (low_water) (portid)\n" 522 "set flow_ctrl pause_time (pause_time) (portid)\n" 523 "set flow_ctrl send_xon (send_xon) (portid)\n" 524 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n" 525 "set flow_ctrl autoneg (on|off) (port_id)\n" 526 " Set the link flow control parameter on a port.\n\n" 527 528 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)" 529 " (low_water) (pause_time) (priority) (port_id)\n" 530 " Set the priority flow control parameter on a" 531 " port.\n\n" 532 533 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n" 534 " Set statistics mapping (qmapping 0..15) for RX/TX" 535 " queue on port.\n" 536 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2" 537 " on port 0 to mapping 5.\n\n" 538 539 "set xstats-hide-zero on|off\n" 540 " Set the option to hide the zero values" 541 " for xstats display.\n" 542 543 "set record-core-cycles on|off\n" 544 " Set the option to enable measurement of CPU cycles.\n" 545 546 "set record-burst-stats on|off\n" 547 " Set the option to enable display of RX and TX bursts.\n" 548 549 "set port (port_id) vf (vf_id) rx|tx on|off\n" 550 " Enable/Disable a VF receive/tranmit from a port\n\n" 551 552 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" 553 "|MPE) (on|off)\n" 554 " AUPE:accepts untagged VLAN;" 555 "ROPE:accept unicast hash\n\n" 556 " BAM:accepts broadcast packets;" 557 "MPE:accepts all multicast packets\n\n" 558 " Enable/Disable a VF receive mode of a port\n\n" 559 560 "set port (port_id) queue (queue_id) rate (rate_num)\n" 561 " Set rate limit for a queue of a port\n\n" 562 563 "set port (port_id) vf (vf_id) rate (rate_num) " 564 "queue_mask (queue_mask_value)\n" 565 " Set rate limit for queues in VF of a port\n\n" 566 567 "set port (port_id) mirror-rule (rule_id)" 568 " (pool-mirror-up|pool-mirror-down|vlan-mirror)" 569 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n" 570 " Set pool or vlan type mirror rule on a port.\n" 571 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1" 572 " dst-pool 0 on' enable mirror traffic with vlan 0,1" 573 " to pool 0.\n\n" 574 575 "set port (port_id) mirror-rule (rule_id)" 576 " (uplink-mirror|downlink-mirror) dst-pool" 577 " (pool_id) (on|off)\n" 578 " Set uplink or downlink type mirror rule on a port.\n" 579 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool" 580 " 0 on' enable mirror income traffic to pool 0.\n\n" 581 582 "reset port (port_id) mirror-rule (rule_id)\n" 583 " Reset a mirror rule.\n\n" 584 585 "set flush_rx (on|off)\n" 586 " Flush (default) or don't flush RX streams before" 587 " forwarding. Mainly used with PCAP drivers.\n\n" 588 589 "set bypass mode (normal|bypass|isolate) (port_id)\n" 590 " Set the bypass mode for the lowest port on bypass enabled" 591 " NIC.\n\n" 592 593 "set bypass event (timeout|os_on|os_off|power_on|power_off) " 594 "mode (normal|bypass|isolate) (port_id)\n" 595 " Set the event required to initiate specified bypass mode for" 596 " the lowest port on a bypass enabled NIC where:\n" 597 " timeout = enable bypass after watchdog timeout.\n" 598 " os_on = enable bypass when OS/board is powered on.\n" 599 " os_off = enable bypass when OS/board is powered off.\n" 600 " power_on = enable bypass when power supply is turned on.\n" 601 " power_off = enable bypass when power supply is turned off." 602 "\n\n" 603 604 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" 605 " Set the bypass watchdog timeout to 'n' seconds" 606 " where 0 = instant.\n\n" 607 608 "show bypass config (port_id)\n" 609 " Show the bypass configuration for a bypass enabled NIC" 610 " using the lowest port on the NIC.\n\n" 611 612 #ifdef RTE_NET_BOND 613 "create bonded device (mode) (socket)\n" 614 " Create a new bonded device with specific bonding mode and socket.\n\n" 615 616 "add bonding slave (slave_id) (port_id)\n" 617 " Add a slave device to a bonded device.\n\n" 618 619 "remove bonding slave (slave_id) (port_id)\n" 620 " Remove a slave device from a bonded device.\n\n" 621 622 "set bonding mode (value) (port_id)\n" 623 " Set the bonding mode on a bonded device.\n\n" 624 625 "set bonding primary (slave_id) (port_id)\n" 626 " Set the primary slave for a bonded device.\n\n" 627 628 "show bonding config (port_id)\n" 629 " Show the bonding config for port_id.\n\n" 630 631 "set bonding mac_addr (port_id) (address)\n" 632 " Set the MAC address of a bonded device.\n\n" 633 634 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)" 635 " Set Aggregation mode for IEEE802.3AD (mode 4)" 636 637 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n" 638 " Set the transmit balance policy for bonded device running in balance mode.\n\n" 639 640 "set bonding mon_period (port_id) (value)\n" 641 " Set the bonding link status monitoring polling period in ms.\n\n" 642 643 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n" 644 " Enable/disable dedicated queues for LACP control traffic.\n\n" 645 646 #endif 647 "set link-up port (port_id)\n" 648 " Set link up for a port.\n\n" 649 650 "set link-down port (port_id)\n" 651 " Set link down for a port.\n\n" 652 653 "E-tag set insertion on port-tag-id (value)" 654 " port (port_id) vf (vf_id)\n" 655 " Enable E-tag insertion for a VF on a port\n\n" 656 657 "E-tag set insertion off port (port_id) vf (vf_id)\n" 658 " Disable E-tag insertion for a VF on a port\n\n" 659 660 "E-tag set stripping (on|off) port (port_id)\n" 661 " Enable/disable E-tag stripping on a port\n\n" 662 663 "E-tag set forwarding (on|off) port (port_id)\n" 664 " Enable/disable E-tag based forwarding" 665 " on a port\n\n" 666 667 "E-tag set filter add e-tag-id (value) dst-pool" 668 " (pool_id) port (port_id)\n" 669 " Add an E-tag forwarding filter on a port\n\n" 670 671 "E-tag set filter del e-tag-id (value) port (port_id)\n" 672 " Delete an E-tag forwarding filter on a port\n\n" 673 674 "ddp add (port_id) (profile_path[,backup_profile_path])\n" 675 " Load a profile package on a port\n\n" 676 677 "ddp del (port_id) (backup_profile_path)\n" 678 " Delete a profile package from a port\n\n" 679 680 "ptype mapping get (port_id) (valid_only)\n" 681 " Get ptype mapping on a port\n\n" 682 683 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n" 684 " Replace target with the pkt_type in ptype mapping\n\n" 685 686 "ptype mapping reset (port_id)\n" 687 " Reset ptype mapping on a port\n\n" 688 689 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" 690 " Update a ptype mapping item on a port\n\n" 691 692 "set port (port_id) ptype_mask (ptype_mask)\n" 693 " set packet types classification for a specific port\n\n" 694 695 "set port (port_id) queue-region region_id (value) " 696 "queue_start_index (value) queue_num (value)\n" 697 " Set a queue region on a port\n\n" 698 699 "set port (port_id) queue-region region_id (value) " 700 "flowtype (value)\n" 701 " Set a flowtype region index on a port\n\n" 702 703 "set port (port_id) queue-region UP (value) region_id (value)\n" 704 " Set the mapping of User Priority to " 705 "queue region on a port\n\n" 706 707 "set port (port_id) queue-region flush (on|off)\n" 708 " flush all queue region related configuration\n\n" 709 710 "show port meter cap (port_id)\n" 711 " Show port meter capability information\n\n" 712 713 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n" 714 " meter profile add - srtcm rfc 2697\n\n" 715 716 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n" 717 " meter profile add - trtcm rfc 2698\n\n" 718 719 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n" 720 " meter profile add - trtcm rfc 4115\n\n" 721 722 "del port meter profile (port_id) (profile_id)\n" 723 " meter profile delete\n\n" 724 725 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" 726 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n" 727 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 728 "(dscp_tbl_entry63)]\n" 729 " meter create\n\n" 730 731 "enable port meter (port_id) (mtr_id)\n" 732 " meter enable\n\n" 733 734 "disable port meter (port_id) (mtr_id)\n" 735 " meter disable\n\n" 736 737 "del port meter (port_id) (mtr_id)\n" 738 " meter delete\n\n" 739 740 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 741 " meter update meter profile\n\n" 742 743 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 744 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 745 " update meter dscp table entries\n\n" 746 747 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 748 "(action0) [(action1) (action2)]\n" 749 " meter update policer action\n\n" 750 751 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 752 " meter update stats\n\n" 753 754 "show port (port_id) queue-region\n" 755 " show all queue region related configuration info\n\n" 756 757 "set port (port_id) fec_mode auto|off|rs|baser\n" 758 " set fec mode for a specific port\n\n" 759 760 , list_pkt_forwarding_modes() 761 ); 762 } 763 764 if (show_all || !strcmp(res->section, "ports")) { 765 766 cmdline_printf( 767 cl, 768 "\n" 769 "Port Operations:\n" 770 "----------------\n\n" 771 772 "port start (port_id|all)\n" 773 " Start all ports or port_id.\n\n" 774 775 "port stop (port_id|all)\n" 776 " Stop all ports or port_id.\n\n" 777 778 "port close (port_id|all)\n" 779 " Close all ports or port_id.\n\n" 780 781 "port reset (port_id|all)\n" 782 " Reset all ports or port_id.\n\n" 783 784 "port attach (ident)\n" 785 " Attach physical or virtual dev by pci address or virtual device name\n\n" 786 787 "port detach (port_id)\n" 788 " Detach physical or virtual dev by port_id\n\n" 789 790 "port config (port_id|all)" 791 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)" 792 " duplex (half|full|auto)\n" 793 " Set speed and duplex for all ports or port_id\n\n" 794 795 "port config (port_id|all) loopback (mode)\n" 796 " Set loopback mode for all ports or port_id\n\n" 797 798 "port config all (rxq|txq|rxd|txd) (value)\n" 799 " Set number for rxq/txq/rxd/txd.\n\n" 800 801 "port config all max-pkt-len (value)\n" 802 " Set the max packet length.\n\n" 803 804 "port config all max-lro-pkt-size (value)\n" 805 " Set the max LRO aggregated packet size.\n\n" 806 807 "port config all drop-en (on|off)\n" 808 " Enable or disable packet drop on all RX queues of all ports when no " 809 "receive buffers available.\n\n" 810 811 "port config all rss (all|default|ip|tcp|udp|sctp|" 812 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|level-default|" 813 "level-outer|level-inner|<flowtype_id>)\n" 814 " Set the RSS mode.\n\n" 815 816 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 817 " Set the RSS redirection table.\n\n" 818 819 "port config (port_id) dcb vt (on|off) (traffic_class)" 820 " pfc (on|off)\n" 821 " Set the DCB mode.\n\n" 822 823 "port config all burst (value)\n" 824 " Set the number of packets per burst.\n\n" 825 826 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 827 " (value)\n" 828 " Set the ring prefetch/host/writeback threshold" 829 " for tx/rx queue.\n\n" 830 831 "port config all (txfreet|txrst|rxfreet) (value)\n" 832 " Set free threshold for rx/tx, or set" 833 " tx rs bit threshold.\n\n" 834 "port config mtu X value\n" 835 " Set the MTU of port X to a given value\n\n" 836 837 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n" 838 " Set a rx/tx queue's ring size configuration, the new" 839 " value will take effect after command that (re-)start the port" 840 " or command that setup the specific queue\n\n" 841 842 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 843 " Start/stop a rx/tx queue of port X. Only take effect" 844 " when port X is started\n\n" 845 846 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n" 847 " Switch on/off a deferred start of port X rx/tx queue. Only" 848 " take effect when port X is stopped.\n\n" 849 850 "port (port_id) (rxq|txq) (queue_id) setup\n" 851 " Setup a rx/tx queue of port X.\n\n" 852 853 "port config (port_id|all) l2-tunnel E-tag ether-type" 854 " (value)\n" 855 " Set the value of E-tag ether-type.\n\n" 856 857 "port config (port_id|all) l2-tunnel E-tag" 858 " (enable|disable)\n" 859 " Enable/disable the E-tag support.\n\n" 860 861 "port config (port_id) pctype mapping reset\n" 862 " Reset flow type to pctype mapping on a port\n\n" 863 864 "port config (port_id) pctype mapping update" 865 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 866 " Update a flow type to pctype mapping item on a port\n\n" 867 868 "port config (port_id) pctype (pctype_id) hash_inset|" 869 "fdir_inset|fdir_flx_inset get|set|clear field\n" 870 " (field_idx)\n" 871 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n" 872 873 "port config (port_id) pctype (pctype_id) hash_inset|" 874 "fdir_inset|fdir_flx_inset clear all" 875 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n" 876 877 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n" 878 " Add/remove UDP tunnel port for tunneling offload\n\n" 879 880 "port config <port_id> rx_offload vlan_strip|" 881 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 882 "outer_ipv4_cksum|macsec_strip|header_split|" 883 "vlan_filter|vlan_extend|jumbo_frame|scatter|" 884 "buffer_split|timestamp|security|keep_crc on|off\n" 885 " Enable or disable a per port Rx offloading" 886 " on all Rx queues of a port\n\n" 887 888 "port (port_id) rxq (queue_id) rx_offload vlan_strip|" 889 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 890 "outer_ipv4_cksum|macsec_strip|header_split|" 891 "vlan_filter|vlan_extend|jumbo_frame|scatter|" 892 "buffer_split|timestamp|security|keep_crc on|off\n" 893 " Enable or disable a per queue Rx offloading" 894 " only on a specific Rx queue\n\n" 895 896 "port config (port_id) tx_offload vlan_insert|" 897 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 898 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 899 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|" 900 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|" 901 "security on|off\n" 902 " Enable or disable a per port Tx offloading" 903 " on all Tx queues of a port\n\n" 904 905 "port (port_id) txq (queue_id) tx_offload vlan_insert|" 906 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 907 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 908 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert" 909 "|mt_lockfree|multi_segs|mbuf_fast_free|security" 910 " on|off\n" 911 " Enable or disable a per queue Tx offloading" 912 " only on a specific Tx queue\n\n" 913 914 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n" 915 " Load an eBPF program as a callback" 916 " for particular RX/TX queue\n\n" 917 918 "bpf-unload rx|tx (port) (queue)\n" 919 " Unload previously loaded eBPF program" 920 " for particular RX/TX queue\n\n" 921 922 "port config (port_id) tx_metadata (value)\n" 923 " Set Tx metadata value per port. Testpmd will add this value" 924 " to any Tx packet sent from this port\n\n" 925 926 "port config (port_id) dynf (name) set|clear\n" 927 " Register a dynf and Set/clear this flag on Tx. " 928 "Testpmd will set this value to any Tx packet " 929 "sent from this port\n\n" 930 ); 931 } 932 933 if (show_all || !strcmp(res->section, "registers")) { 934 935 cmdline_printf( 936 cl, 937 "\n" 938 "Registers:\n" 939 "----------\n\n" 940 941 "read reg (port_id) (address)\n" 942 " Display value of a port register.\n\n" 943 944 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 945 " Display a port register bit field.\n\n" 946 947 "read regbit (port_id) (address) (bit_x)\n" 948 " Display a single port register bit.\n\n" 949 950 "write reg (port_id) (address) (value)\n" 951 " Set value of a port register.\n\n" 952 953 "write regfield (port_id) (address) (bit_x) (bit_y)" 954 " (value)\n" 955 " Set bit field of a port register.\n\n" 956 957 "write regbit (port_id) (address) (bit_x) (value)\n" 958 " Set single bit value of a port register.\n\n" 959 ); 960 } 961 if (show_all || !strcmp(res->section, "filters")) { 962 963 cmdline_printf( 964 cl, 965 "\n" 966 "filters:\n" 967 "--------\n\n" 968 969 "flow_director_filter (port_id) mode IP (add|del|update)" 970 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)" 971 " src (src_ip_address) dst (dst_ip_address)" 972 " tos (tos_value) proto (proto_value) ttl (ttl_value)" 973 " vlan (vlan_value) flexbytes (flexbytes_value)" 974 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 975 " fd_id (fd_id_value)\n" 976 " Add/Del an IP type flow director filter.\n\n" 977 978 "flow_director_filter (port_id) mode IP (add|del|update)" 979 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)" 980 " src (src_ip_address) (src_port)" 981 " dst (dst_ip_address) (dst_port)" 982 " tos (tos_value) ttl (ttl_value)" 983 " vlan (vlan_value) flexbytes (flexbytes_value)" 984 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 985 " fd_id (fd_id_value)\n" 986 " Add/Del an UDP/TCP type flow director filter.\n\n" 987 988 "flow_director_filter (port_id) mode IP (add|del|update)" 989 " flow (ipv4-sctp|ipv6-sctp)" 990 " src (src_ip_address) (src_port)" 991 " dst (dst_ip_address) (dst_port)" 992 " tag (verification_tag) " 993 " tos (tos_value) ttl (ttl_value)" 994 " vlan (vlan_value)" 995 " flexbytes (flexbytes_value) (drop|fwd)" 996 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 997 " Add/Del a SCTP type flow director filter.\n\n" 998 999 "flow_director_filter (port_id) mode IP (add|del|update)" 1000 " flow l2_payload ether (ethertype)" 1001 " flexbytes (flexbytes_value) (drop|fwd)" 1002 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 1003 " Add/Del a l2 payload type flow director filter.\n\n" 1004 1005 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)" 1006 " mac (mac_address) vlan (vlan_value)" 1007 " flexbytes (flexbytes_value) (drop|fwd)" 1008 " queue (queue_id) fd_id (fd_id_value)\n" 1009 " Add/Del a MAC-VLAN flow director filter.\n\n" 1010 1011 "flow_director_filter (port_id) mode Tunnel (add|del|update)" 1012 " mac (mac_address) vlan (vlan_value)" 1013 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)" 1014 " flexbytes (flexbytes_value) (drop|fwd)" 1015 " queue (queue_id) fd_id (fd_id_value)\n" 1016 " Add/Del a Tunnel flow director filter.\n\n" 1017 1018 "flow_director_filter (port_id) mode raw (add|del|update)" 1019 " flow (flow_id) (drop|fwd) queue (queue_id)" 1020 " fd_id (fd_id_value) packet (packet file name)\n" 1021 " Add/Del a raw type flow director filter.\n\n" 1022 1023 "flush_flow_director (port_id)\n" 1024 " Flush all flow director entries of a device.\n\n" 1025 1026 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 1027 " src_mask (ipv4_src) (ipv6_src) (src_port)" 1028 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 1029 " Set flow director IP mask.\n\n" 1030 1031 "flow_director_mask (port_id) mode MAC-VLAN" 1032 " vlan (vlan_value)\n" 1033 " Set flow director MAC-VLAN mask.\n\n" 1034 1035 "flow_director_mask (port_id) mode Tunnel" 1036 " vlan (vlan_value) mac (mac_value)" 1037 " tunnel-type (tunnel_type_value)" 1038 " tunnel-id (tunnel_id_value)\n" 1039 " Set flow director Tunnel mask.\n\n" 1040 1041 "flow_director_flex_mask (port_id)" 1042 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 1043 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)" 1044 " (mask)\n" 1045 " Configure mask of flex payload.\n\n" 1046 1047 "flow_director_flex_payload (port_id)" 1048 " (raw|l2|l3|l4) (config)\n" 1049 " Configure flex payload selection.\n\n" 1050 1051 "get_sym_hash_ena_per_port (port_id)\n" 1052 " get symmetric hash enable configuration per port.\n\n" 1053 1054 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n" 1055 " set symmetric hash enable configuration per port" 1056 " to enable or disable.\n\n" 1057 1058 "get_hash_global_config (port_id)\n" 1059 " Get the global configurations of hash filters.\n\n" 1060 1061 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)" 1062 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1063 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)" 1064 " (enable|disable)\n" 1065 " Set the global configurations of hash filters.\n\n" 1066 1067 "set_hash_input_set (port_id) (ipv4|ipv4-frag|" 1068 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1069 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1070 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|" 1071 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|" 1072 "ipv6-next-header|udp-src-port|udp-dst-port|" 1073 "tcp-src-port|tcp-dst-port|sctp-src-port|" 1074 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|" 1075 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|" 1076 "fld-8th|none) (select|add)\n" 1077 " Set the input set for hash.\n\n" 1078 1079 "set_fdir_input_set (port_id) " 1080 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 1081 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1082 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|" 1083 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|" 1084 "ipv6-next-header|ipv6-hop-limits|udp-src-port|" 1085 "udp-dst-port|tcp-src-port|tcp-dst-port|" 1086 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)" 1087 " (select|add)\n" 1088 " Set the input set for FDir.\n\n" 1089 1090 "flow validate {port_id}" 1091 " [group {group_id}] [priority {level}]" 1092 " [ingress] [egress]" 1093 " pattern {item} [/ {item} [...]] / end" 1094 " actions {action} [/ {action} [...]] / end\n" 1095 " Check whether a flow rule can be created.\n\n" 1096 1097 "flow create {port_id}" 1098 " [group {group_id}] [priority {level}]" 1099 " [ingress] [egress]" 1100 " pattern {item} [/ {item} [...]] / end" 1101 " actions {action} [/ {action} [...]] / end\n" 1102 " Create a flow rule.\n\n" 1103 1104 "flow destroy {port_id} rule {rule_id} [...]\n" 1105 " Destroy specific flow rules.\n\n" 1106 1107 "flow flush {port_id}\n" 1108 " Destroy all flow rules.\n\n" 1109 1110 "flow query {port_id} {rule_id} {action}\n" 1111 " Query an existing flow rule.\n\n" 1112 1113 "flow list {port_id} [group {group_id}] [...]\n" 1114 " List existing flow rules sorted by priority," 1115 " filtered by group identifiers.\n\n" 1116 1117 "flow isolate {port_id} {boolean}\n" 1118 " Restrict ingress traffic to the defined" 1119 " flow rules\n\n" 1120 1121 "flow aged {port_id} [destroy]\n" 1122 " List and destroy aged flows" 1123 " flow rules\n\n" 1124 1125 "flow shared_action {port_id} create" 1126 " [action_id {shared_action_id}]" 1127 " [ingress] [egress]" 1128 " action {action} / end\n" 1129 " Create shared action.\n\n" 1130 1131 "flow shared_action {port_id} update" 1132 " {shared_action_id} action {action} / end\n" 1133 " Update shared action.\n\n" 1134 1135 "flow shared_action {port_id} destroy" 1136 " action_id {shared_action_id} [...]\n" 1137 " Destroy specific shared actions.\n\n" 1138 1139 "flow shared_action {port_id} query" 1140 " {shared_action_id}\n" 1141 " Query an existing shared action.\n\n" 1142 1143 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" 1144 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" 1145 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n" 1146 " Configure the VXLAN encapsulation for flows.\n\n" 1147 1148 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)" 1149 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)" 1150 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)" 1151 " eth-dst (eth-dst)\n" 1152 " Configure the VXLAN encapsulation for flows.\n\n" 1153 1154 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src" 1155 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)" 1156 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)" 1157 " eth-dst (eth-dst)\n" 1158 " Configure the VXLAN encapsulation for flows.\n\n" 1159 1160 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src" 1161 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst" 1162 " (eth-dst)\n" 1163 " Configure the NVGRE encapsulation for flows.\n\n" 1164 1165 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)" 1166 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)" 1167 " eth-src (eth-src) eth-dst (eth-dst)\n" 1168 " Configure the NVGRE encapsulation for flows.\n\n" 1169 1170 "set raw_encap {flow items}\n" 1171 " Configure the encapsulation with raw data.\n\n" 1172 1173 "set raw_decap {flow items}\n" 1174 " Configure the decapsulation with raw data.\n\n" 1175 1176 ); 1177 } 1178 1179 if (show_all || !strcmp(res->section, "traffic_management")) { 1180 cmdline_printf( 1181 cl, 1182 "\n" 1183 "Traffic Management:\n" 1184 "--------------\n" 1185 "show port tm cap (port_id)\n" 1186 " Display the port TM capability.\n\n" 1187 1188 "show port tm level cap (port_id) (level_id)\n" 1189 " Display the port TM hierarchical level capability.\n\n" 1190 1191 "show port tm node cap (port_id) (node_id)\n" 1192 " Display the port TM node capability.\n\n" 1193 1194 "show port tm node type (port_id) (node_id)\n" 1195 " Display the port TM node type.\n\n" 1196 1197 "show port tm node stats (port_id) (node_id) (clear)\n" 1198 " Display the port TM node stats.\n\n" 1199 1200 "add port tm node shaper profile (port_id) (shaper_profile_id)" 1201 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)" 1202 " (packet_length_adjust) (packet_mode)\n" 1203 " Add port tm node private shaper profile.\n\n" 1204 1205 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 1206 " Delete port tm node private shaper profile.\n\n" 1207 1208 "add port tm node shared shaper (port_id) (shared_shaper_id)" 1209 " (shaper_profile_id)\n" 1210 " Add/update port tm node shared shaper.\n\n" 1211 1212 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 1213 " Delete port tm node shared shaper.\n\n" 1214 1215 "set port tm node shaper profile (port_id) (node_id)" 1216 " (shaper_profile_id)\n" 1217 " Set port tm node shaper profile.\n\n" 1218 1219 "add port tm node wred profile (port_id) (wred_profile_id)" 1220 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 1221 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 1222 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 1223 " Add port tm node wred profile.\n\n" 1224 1225 "del port tm node wred profile (port_id) (wred_profile_id)\n" 1226 " Delete port tm node wred profile.\n\n" 1227 1228 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 1229 " (priority) (weight) (level_id) (shaper_profile_id)" 1230 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1231 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1232 " Add port tm nonleaf node.\n\n" 1233 1234 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)" 1235 " (priority) (weight) (level_id) (shaper_profile_id)" 1236 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1237 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1238 " Add port tm nonleaf node with pkt mode enabled.\n\n" 1239 1240 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 1241 " (priority) (weight) (level_id) (shaper_profile_id)" 1242 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 1243 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1244 " Add port tm leaf node.\n\n" 1245 1246 "del port tm node (port_id) (node_id)\n" 1247 " Delete port tm node.\n\n" 1248 1249 "set port tm node parent (port_id) (node_id) (parent_node_id)" 1250 " (priority) (weight)\n" 1251 " Set port tm node parent.\n\n" 1252 1253 "suspend port tm node (port_id) (node_id)" 1254 " Suspend tm node.\n\n" 1255 1256 "resume port tm node (port_id) (node_id)" 1257 " Resume tm node.\n\n" 1258 1259 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 1260 " Commit tm hierarchy.\n\n" 1261 1262 "set port tm mark ip_ecn (port) (green) (yellow)" 1263 " (red)\n" 1264 " Enables/Disables the traffic management marking" 1265 " for IP ECN (Explicit Congestion Notification)" 1266 " packets on a given port\n\n" 1267 1268 "set port tm mark ip_dscp (port) (green) (yellow)" 1269 " (red)\n" 1270 " Enables/Disables the traffic management marking" 1271 " on the port for IP dscp packets\n\n" 1272 1273 "set port tm mark vlan_dei (port) (green) (yellow)" 1274 " (red)\n" 1275 " Enables/Disables the traffic management marking" 1276 " on the port for VLAN packets with DEI enabled\n\n" 1277 ); 1278 } 1279 1280 if (show_all || !strcmp(res->section, "devices")) { 1281 cmdline_printf( 1282 cl, 1283 "\n" 1284 "Device Operations:\n" 1285 "--------------\n" 1286 "device detach (identifier)\n" 1287 " Detach device by identifier.\n\n" 1288 ); 1289 } 1290 1291 } 1292 1293 cmdline_parse_token_string_t cmd_help_long_help = 1294 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1295 1296 cmdline_parse_token_string_t cmd_help_long_section = 1297 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1298 "all#control#display#config#" 1299 "ports#registers#filters#traffic_management#devices"); 1300 1301 cmdline_parse_inst_t cmd_help_long = { 1302 .f = cmd_help_long_parsed, 1303 .data = NULL, 1304 .help_str = "help all|control|display|config|ports|register|" 1305 "filters|traffic_management|devices: " 1306 "Show help", 1307 .tokens = { 1308 (void *)&cmd_help_long_help, 1309 (void *)&cmd_help_long_section, 1310 NULL, 1311 }, 1312 }; 1313 1314 1315 /* *** start/stop/close all ports *** */ 1316 struct cmd_operate_port_result { 1317 cmdline_fixed_string_t keyword; 1318 cmdline_fixed_string_t name; 1319 cmdline_fixed_string_t value; 1320 }; 1321 1322 static void cmd_operate_port_parsed(void *parsed_result, 1323 __rte_unused struct cmdline *cl, 1324 __rte_unused void *data) 1325 { 1326 struct cmd_operate_port_result *res = parsed_result; 1327 1328 if (!strcmp(res->name, "start")) 1329 start_port(RTE_PORT_ALL); 1330 else if (!strcmp(res->name, "stop")) 1331 stop_port(RTE_PORT_ALL); 1332 else if (!strcmp(res->name, "close")) 1333 close_port(RTE_PORT_ALL); 1334 else if (!strcmp(res->name, "reset")) 1335 reset_port(RTE_PORT_ALL); 1336 else 1337 printf("Unknown parameter\n"); 1338 } 1339 1340 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1341 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1342 "port"); 1343 cmdline_parse_token_string_t cmd_operate_port_all_port = 1344 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1345 "start#stop#close#reset"); 1346 cmdline_parse_token_string_t cmd_operate_port_all_all = 1347 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1348 1349 cmdline_parse_inst_t cmd_operate_port = { 1350 .f = cmd_operate_port_parsed, 1351 .data = NULL, 1352 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports", 1353 .tokens = { 1354 (void *)&cmd_operate_port_all_cmd, 1355 (void *)&cmd_operate_port_all_port, 1356 (void *)&cmd_operate_port_all_all, 1357 NULL, 1358 }, 1359 }; 1360 1361 /* *** start/stop/close specific port *** */ 1362 struct cmd_operate_specific_port_result { 1363 cmdline_fixed_string_t keyword; 1364 cmdline_fixed_string_t name; 1365 uint8_t value; 1366 }; 1367 1368 static void cmd_operate_specific_port_parsed(void *parsed_result, 1369 __rte_unused struct cmdline *cl, 1370 __rte_unused void *data) 1371 { 1372 struct cmd_operate_specific_port_result *res = parsed_result; 1373 1374 if (!strcmp(res->name, "start")) 1375 start_port(res->value); 1376 else if (!strcmp(res->name, "stop")) 1377 stop_port(res->value); 1378 else if (!strcmp(res->name, "close")) 1379 close_port(res->value); 1380 else if (!strcmp(res->name, "reset")) 1381 reset_port(res->value); 1382 else 1383 printf("Unknown parameter\n"); 1384 } 1385 1386 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1387 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1388 keyword, "port"); 1389 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1390 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1391 name, "start#stop#close#reset"); 1392 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1393 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1394 value, UINT8); 1395 1396 cmdline_parse_inst_t cmd_operate_specific_port = { 1397 .f = cmd_operate_specific_port_parsed, 1398 .data = NULL, 1399 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id", 1400 .tokens = { 1401 (void *)&cmd_operate_specific_port_cmd, 1402 (void *)&cmd_operate_specific_port_port, 1403 (void *)&cmd_operate_specific_port_id, 1404 NULL, 1405 }, 1406 }; 1407 1408 /* *** enable port setup (after attach) via iterator or event *** */ 1409 struct cmd_set_port_setup_on_result { 1410 cmdline_fixed_string_t set; 1411 cmdline_fixed_string_t port; 1412 cmdline_fixed_string_t setup; 1413 cmdline_fixed_string_t on; 1414 cmdline_fixed_string_t mode; 1415 }; 1416 1417 static void cmd_set_port_setup_on_parsed(void *parsed_result, 1418 __rte_unused struct cmdline *cl, 1419 __rte_unused void *data) 1420 { 1421 struct cmd_set_port_setup_on_result *res = parsed_result; 1422 1423 if (strcmp(res->mode, "event") == 0) 1424 setup_on_probe_event = true; 1425 else if (strcmp(res->mode, "iterator") == 0) 1426 setup_on_probe_event = false; 1427 else 1428 printf("Unknown mode\n"); 1429 } 1430 1431 cmdline_parse_token_string_t cmd_set_port_setup_on_set = 1432 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1433 set, "set"); 1434 cmdline_parse_token_string_t cmd_set_port_setup_on_port = 1435 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1436 port, "port"); 1437 cmdline_parse_token_string_t cmd_set_port_setup_on_setup = 1438 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1439 setup, "setup"); 1440 cmdline_parse_token_string_t cmd_set_port_setup_on_on = 1441 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1442 on, "on"); 1443 cmdline_parse_token_string_t cmd_set_port_setup_on_mode = 1444 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1445 mode, "iterator#event"); 1446 1447 cmdline_parse_inst_t cmd_set_port_setup_on = { 1448 .f = cmd_set_port_setup_on_parsed, 1449 .data = NULL, 1450 .help_str = "set port setup on iterator|event", 1451 .tokens = { 1452 (void *)&cmd_set_port_setup_on_set, 1453 (void *)&cmd_set_port_setup_on_port, 1454 (void *)&cmd_set_port_setup_on_setup, 1455 (void *)&cmd_set_port_setup_on_on, 1456 (void *)&cmd_set_port_setup_on_mode, 1457 NULL, 1458 }, 1459 }; 1460 1461 /* *** attach a specified port *** */ 1462 struct cmd_operate_attach_port_result { 1463 cmdline_fixed_string_t port; 1464 cmdline_fixed_string_t keyword; 1465 cmdline_multi_string_t identifier; 1466 }; 1467 1468 static void cmd_operate_attach_port_parsed(void *parsed_result, 1469 __rte_unused struct cmdline *cl, 1470 __rte_unused void *data) 1471 { 1472 struct cmd_operate_attach_port_result *res = parsed_result; 1473 1474 if (!strcmp(res->keyword, "attach")) 1475 attach_port(res->identifier); 1476 else 1477 printf("Unknown parameter\n"); 1478 } 1479 1480 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1481 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1482 port, "port"); 1483 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1484 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1485 keyword, "attach"); 1486 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1487 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1488 identifier, TOKEN_STRING_MULTI); 1489 1490 cmdline_parse_inst_t cmd_operate_attach_port = { 1491 .f = cmd_operate_attach_port_parsed, 1492 .data = NULL, 1493 .help_str = "port attach <identifier>: " 1494 "(identifier: pci address or virtual dev name)", 1495 .tokens = { 1496 (void *)&cmd_operate_attach_port_port, 1497 (void *)&cmd_operate_attach_port_keyword, 1498 (void *)&cmd_operate_attach_port_identifier, 1499 NULL, 1500 }, 1501 }; 1502 1503 /* *** detach a specified port *** */ 1504 struct cmd_operate_detach_port_result { 1505 cmdline_fixed_string_t port; 1506 cmdline_fixed_string_t keyword; 1507 portid_t port_id; 1508 }; 1509 1510 static void cmd_operate_detach_port_parsed(void *parsed_result, 1511 __rte_unused struct cmdline *cl, 1512 __rte_unused void *data) 1513 { 1514 struct cmd_operate_detach_port_result *res = parsed_result; 1515 1516 if (!strcmp(res->keyword, "detach")) { 1517 RTE_ETH_VALID_PORTID_OR_RET(res->port_id); 1518 detach_port_device(res->port_id); 1519 } else { 1520 printf("Unknown parameter\n"); 1521 } 1522 } 1523 1524 cmdline_parse_token_string_t cmd_operate_detach_port_port = 1525 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1526 port, "port"); 1527 cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1528 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1529 keyword, "detach"); 1530 cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1531 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1532 port_id, UINT16); 1533 1534 cmdline_parse_inst_t cmd_operate_detach_port = { 1535 .f = cmd_operate_detach_port_parsed, 1536 .data = NULL, 1537 .help_str = "port detach <port_id>", 1538 .tokens = { 1539 (void *)&cmd_operate_detach_port_port, 1540 (void *)&cmd_operate_detach_port_keyword, 1541 (void *)&cmd_operate_detach_port_port_id, 1542 NULL, 1543 }, 1544 }; 1545 1546 /* *** detach device by identifier *** */ 1547 struct cmd_operate_detach_device_result { 1548 cmdline_fixed_string_t device; 1549 cmdline_fixed_string_t keyword; 1550 cmdline_fixed_string_t identifier; 1551 }; 1552 1553 static void cmd_operate_detach_device_parsed(void *parsed_result, 1554 __rte_unused struct cmdline *cl, 1555 __rte_unused void *data) 1556 { 1557 struct cmd_operate_detach_device_result *res = parsed_result; 1558 1559 if (!strcmp(res->keyword, "detach")) 1560 detach_devargs(res->identifier); 1561 else 1562 printf("Unknown parameter\n"); 1563 } 1564 1565 cmdline_parse_token_string_t cmd_operate_detach_device_device = 1566 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1567 device, "device"); 1568 cmdline_parse_token_string_t cmd_operate_detach_device_keyword = 1569 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1570 keyword, "detach"); 1571 cmdline_parse_token_string_t cmd_operate_detach_device_identifier = 1572 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1573 identifier, NULL); 1574 1575 cmdline_parse_inst_t cmd_operate_detach_device = { 1576 .f = cmd_operate_detach_device_parsed, 1577 .data = NULL, 1578 .help_str = "device detach <identifier>:" 1579 "(identifier: pci address or virtual dev name)", 1580 .tokens = { 1581 (void *)&cmd_operate_detach_device_device, 1582 (void *)&cmd_operate_detach_device_keyword, 1583 (void *)&cmd_operate_detach_device_identifier, 1584 NULL, 1585 }, 1586 }; 1587 /* *** configure speed for all ports *** */ 1588 struct cmd_config_speed_all { 1589 cmdline_fixed_string_t port; 1590 cmdline_fixed_string_t keyword; 1591 cmdline_fixed_string_t all; 1592 cmdline_fixed_string_t item1; 1593 cmdline_fixed_string_t item2; 1594 cmdline_fixed_string_t value1; 1595 cmdline_fixed_string_t value2; 1596 }; 1597 1598 static int 1599 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1600 { 1601 1602 int duplex; 1603 1604 if (!strcmp(duplexstr, "half")) { 1605 duplex = ETH_LINK_HALF_DUPLEX; 1606 } else if (!strcmp(duplexstr, "full")) { 1607 duplex = ETH_LINK_FULL_DUPLEX; 1608 } else if (!strcmp(duplexstr, "auto")) { 1609 duplex = ETH_LINK_FULL_DUPLEX; 1610 } else { 1611 printf("Unknown duplex parameter\n"); 1612 return -1; 1613 } 1614 1615 if (!strcmp(speedstr, "10")) { 1616 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1617 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M; 1618 } else if (!strcmp(speedstr, "100")) { 1619 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1620 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M; 1621 } else { 1622 if (duplex != ETH_LINK_FULL_DUPLEX) { 1623 printf("Invalid speed/duplex parameters\n"); 1624 return -1; 1625 } 1626 if (!strcmp(speedstr, "1000")) { 1627 *speed = ETH_LINK_SPEED_1G; 1628 } else if (!strcmp(speedstr, "10000")) { 1629 *speed = ETH_LINK_SPEED_10G; 1630 } else if (!strcmp(speedstr, "25000")) { 1631 *speed = ETH_LINK_SPEED_25G; 1632 } else if (!strcmp(speedstr, "40000")) { 1633 *speed = ETH_LINK_SPEED_40G; 1634 } else if (!strcmp(speedstr, "50000")) { 1635 *speed = ETH_LINK_SPEED_50G; 1636 } else if (!strcmp(speedstr, "100000")) { 1637 *speed = ETH_LINK_SPEED_100G; 1638 } else if (!strcmp(speedstr, "200000")) { 1639 *speed = ETH_LINK_SPEED_200G; 1640 } else if (!strcmp(speedstr, "auto")) { 1641 *speed = ETH_LINK_SPEED_AUTONEG; 1642 } else { 1643 printf("Unknown speed parameter\n"); 1644 return -1; 1645 } 1646 } 1647 1648 return 0; 1649 } 1650 1651 static void 1652 cmd_config_speed_all_parsed(void *parsed_result, 1653 __rte_unused struct cmdline *cl, 1654 __rte_unused void *data) 1655 { 1656 struct cmd_config_speed_all *res = parsed_result; 1657 uint32_t link_speed; 1658 portid_t pid; 1659 1660 if (!all_ports_stopped()) { 1661 printf("Please stop all ports first\n"); 1662 return; 1663 } 1664 1665 if (parse_and_check_speed_duplex(res->value1, res->value2, 1666 &link_speed) < 0) 1667 return; 1668 1669 RTE_ETH_FOREACH_DEV(pid) { 1670 ports[pid].dev_conf.link_speeds = link_speed; 1671 } 1672 1673 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1674 } 1675 1676 cmdline_parse_token_string_t cmd_config_speed_all_port = 1677 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1678 cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1679 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1680 "config"); 1681 cmdline_parse_token_string_t cmd_config_speed_all_all = 1682 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1683 cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1684 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1685 cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1686 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1687 "10#100#1000#10000#25000#40000#50000#100000#200000#auto"); 1688 cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1689 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1690 cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1691 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1692 "half#full#auto"); 1693 1694 cmdline_parse_inst_t cmd_config_speed_all = { 1695 .f = cmd_config_speed_all_parsed, 1696 .data = NULL, 1697 .help_str = "port config all speed " 1698 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex " 1699 "half|full|auto", 1700 .tokens = { 1701 (void *)&cmd_config_speed_all_port, 1702 (void *)&cmd_config_speed_all_keyword, 1703 (void *)&cmd_config_speed_all_all, 1704 (void *)&cmd_config_speed_all_item1, 1705 (void *)&cmd_config_speed_all_value1, 1706 (void *)&cmd_config_speed_all_item2, 1707 (void *)&cmd_config_speed_all_value2, 1708 NULL, 1709 }, 1710 }; 1711 1712 /* *** configure speed for specific port *** */ 1713 struct cmd_config_speed_specific { 1714 cmdline_fixed_string_t port; 1715 cmdline_fixed_string_t keyword; 1716 portid_t id; 1717 cmdline_fixed_string_t item1; 1718 cmdline_fixed_string_t item2; 1719 cmdline_fixed_string_t value1; 1720 cmdline_fixed_string_t value2; 1721 }; 1722 1723 static void 1724 cmd_config_speed_specific_parsed(void *parsed_result, 1725 __rte_unused struct cmdline *cl, 1726 __rte_unused void *data) 1727 { 1728 struct cmd_config_speed_specific *res = parsed_result; 1729 uint32_t link_speed; 1730 1731 if (!all_ports_stopped()) { 1732 printf("Please stop all ports first\n"); 1733 return; 1734 } 1735 1736 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1737 return; 1738 1739 if (parse_and_check_speed_duplex(res->value1, res->value2, 1740 &link_speed) < 0) 1741 return; 1742 1743 ports[res->id].dev_conf.link_speeds = link_speed; 1744 1745 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1746 } 1747 1748 1749 cmdline_parse_token_string_t cmd_config_speed_specific_port = 1750 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1751 "port"); 1752 cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1753 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1754 "config"); 1755 cmdline_parse_token_num_t cmd_config_speed_specific_id = 1756 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16); 1757 cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1758 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1759 "speed"); 1760 cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1761 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1762 "10#100#1000#10000#25000#40000#50000#100000#200000#auto"); 1763 cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1764 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1765 "duplex"); 1766 cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1767 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1768 "half#full#auto"); 1769 1770 cmdline_parse_inst_t cmd_config_speed_specific = { 1771 .f = cmd_config_speed_specific_parsed, 1772 .data = NULL, 1773 .help_str = "port config <port_id> speed " 1774 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex " 1775 "half|full|auto", 1776 .tokens = { 1777 (void *)&cmd_config_speed_specific_port, 1778 (void *)&cmd_config_speed_specific_keyword, 1779 (void *)&cmd_config_speed_specific_id, 1780 (void *)&cmd_config_speed_specific_item1, 1781 (void *)&cmd_config_speed_specific_value1, 1782 (void *)&cmd_config_speed_specific_item2, 1783 (void *)&cmd_config_speed_specific_value2, 1784 NULL, 1785 }, 1786 }; 1787 1788 /* *** configure loopback for all ports *** */ 1789 struct cmd_config_loopback_all { 1790 cmdline_fixed_string_t port; 1791 cmdline_fixed_string_t keyword; 1792 cmdline_fixed_string_t all; 1793 cmdline_fixed_string_t item; 1794 uint32_t mode; 1795 }; 1796 1797 static void 1798 cmd_config_loopback_all_parsed(void *parsed_result, 1799 __rte_unused struct cmdline *cl, 1800 __rte_unused void *data) 1801 { 1802 struct cmd_config_loopback_all *res = parsed_result; 1803 portid_t pid; 1804 1805 if (!all_ports_stopped()) { 1806 printf("Please stop all ports first\n"); 1807 return; 1808 } 1809 1810 RTE_ETH_FOREACH_DEV(pid) { 1811 ports[pid].dev_conf.lpbk_mode = res->mode; 1812 } 1813 1814 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1815 } 1816 1817 cmdline_parse_token_string_t cmd_config_loopback_all_port = 1818 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port"); 1819 cmdline_parse_token_string_t cmd_config_loopback_all_keyword = 1820 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword, 1821 "config"); 1822 cmdline_parse_token_string_t cmd_config_loopback_all_all = 1823 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all"); 1824 cmdline_parse_token_string_t cmd_config_loopback_all_item = 1825 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item, 1826 "loopback"); 1827 cmdline_parse_token_num_t cmd_config_loopback_all_mode = 1828 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32); 1829 1830 cmdline_parse_inst_t cmd_config_loopback_all = { 1831 .f = cmd_config_loopback_all_parsed, 1832 .data = NULL, 1833 .help_str = "port config all loopback <mode>", 1834 .tokens = { 1835 (void *)&cmd_config_loopback_all_port, 1836 (void *)&cmd_config_loopback_all_keyword, 1837 (void *)&cmd_config_loopback_all_all, 1838 (void *)&cmd_config_loopback_all_item, 1839 (void *)&cmd_config_loopback_all_mode, 1840 NULL, 1841 }, 1842 }; 1843 1844 /* *** configure loopback for specific port *** */ 1845 struct cmd_config_loopback_specific { 1846 cmdline_fixed_string_t port; 1847 cmdline_fixed_string_t keyword; 1848 uint16_t port_id; 1849 cmdline_fixed_string_t item; 1850 uint32_t mode; 1851 }; 1852 1853 static void 1854 cmd_config_loopback_specific_parsed(void *parsed_result, 1855 __rte_unused struct cmdline *cl, 1856 __rte_unused void *data) 1857 { 1858 struct cmd_config_loopback_specific *res = parsed_result; 1859 1860 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 1861 return; 1862 1863 if (!port_is_stopped(res->port_id)) { 1864 printf("Please stop port %u first\n", res->port_id); 1865 return; 1866 } 1867 1868 ports[res->port_id].dev_conf.lpbk_mode = res->mode; 1869 1870 cmd_reconfig_device_queue(res->port_id, 1, 1); 1871 } 1872 1873 1874 cmdline_parse_token_string_t cmd_config_loopback_specific_port = 1875 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port, 1876 "port"); 1877 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword = 1878 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword, 1879 "config"); 1880 cmdline_parse_token_num_t cmd_config_loopback_specific_id = 1881 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id, 1882 UINT16); 1883 cmdline_parse_token_string_t cmd_config_loopback_specific_item = 1884 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item, 1885 "loopback"); 1886 cmdline_parse_token_num_t cmd_config_loopback_specific_mode = 1887 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode, 1888 UINT32); 1889 1890 cmdline_parse_inst_t cmd_config_loopback_specific = { 1891 .f = cmd_config_loopback_specific_parsed, 1892 .data = NULL, 1893 .help_str = "port config <port_id> loopback <mode>", 1894 .tokens = { 1895 (void *)&cmd_config_loopback_specific_port, 1896 (void *)&cmd_config_loopback_specific_keyword, 1897 (void *)&cmd_config_loopback_specific_id, 1898 (void *)&cmd_config_loopback_specific_item, 1899 (void *)&cmd_config_loopback_specific_mode, 1900 NULL, 1901 }, 1902 }; 1903 1904 /* *** configure txq/rxq, txd/rxd *** */ 1905 struct cmd_config_rx_tx { 1906 cmdline_fixed_string_t port; 1907 cmdline_fixed_string_t keyword; 1908 cmdline_fixed_string_t all; 1909 cmdline_fixed_string_t name; 1910 uint16_t value; 1911 }; 1912 1913 static void 1914 cmd_config_rx_tx_parsed(void *parsed_result, 1915 __rte_unused struct cmdline *cl, 1916 __rte_unused void *data) 1917 { 1918 struct cmd_config_rx_tx *res = parsed_result; 1919 1920 if (!all_ports_stopped()) { 1921 printf("Please stop all ports first\n"); 1922 return; 1923 } 1924 if (!strcmp(res->name, "rxq")) { 1925 if (!res->value && !nb_txq) { 1926 printf("Warning: Either rx or tx queues should be non zero\n"); 1927 return; 1928 } 1929 if (check_nb_rxq(res->value) != 0) 1930 return; 1931 nb_rxq = res->value; 1932 } 1933 else if (!strcmp(res->name, "txq")) { 1934 if (!res->value && !nb_rxq) { 1935 printf("Warning: Either rx or tx queues should be non zero\n"); 1936 return; 1937 } 1938 if (check_nb_txq(res->value) != 0) 1939 return; 1940 nb_txq = res->value; 1941 } 1942 else if (!strcmp(res->name, "rxd")) { 1943 if (check_nb_rxd(res->value) != 0) 1944 return; 1945 nb_rxd = res->value; 1946 } else if (!strcmp(res->name, "txd")) { 1947 if (check_nb_txd(res->value) != 0) 1948 return; 1949 1950 nb_txd = res->value; 1951 } else { 1952 printf("Unknown parameter\n"); 1953 return; 1954 } 1955 1956 fwd_config_setup(); 1957 1958 init_port_config(); 1959 1960 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1961 } 1962 1963 cmdline_parse_token_string_t cmd_config_rx_tx_port = 1964 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1965 cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1966 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1967 cmdline_parse_token_string_t cmd_config_rx_tx_all = 1968 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1969 cmdline_parse_token_string_t cmd_config_rx_tx_name = 1970 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1971 "rxq#txq#rxd#txd"); 1972 cmdline_parse_token_num_t cmd_config_rx_tx_value = 1973 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16); 1974 1975 cmdline_parse_inst_t cmd_config_rx_tx = { 1976 .f = cmd_config_rx_tx_parsed, 1977 .data = NULL, 1978 .help_str = "port config all rxq|txq|rxd|txd <value>", 1979 .tokens = { 1980 (void *)&cmd_config_rx_tx_port, 1981 (void *)&cmd_config_rx_tx_keyword, 1982 (void *)&cmd_config_rx_tx_all, 1983 (void *)&cmd_config_rx_tx_name, 1984 (void *)&cmd_config_rx_tx_value, 1985 NULL, 1986 }, 1987 }; 1988 1989 /* *** config max packet length *** */ 1990 struct cmd_config_max_pkt_len_result { 1991 cmdline_fixed_string_t port; 1992 cmdline_fixed_string_t keyword; 1993 cmdline_fixed_string_t all; 1994 cmdline_fixed_string_t name; 1995 uint32_t value; 1996 }; 1997 1998 static void 1999 cmd_config_max_pkt_len_parsed(void *parsed_result, 2000 __rte_unused struct cmdline *cl, 2001 __rte_unused void *data) 2002 { 2003 struct cmd_config_max_pkt_len_result *res = parsed_result; 2004 portid_t pid; 2005 2006 if (!all_ports_stopped()) { 2007 printf("Please stop all ports first\n"); 2008 return; 2009 } 2010 2011 RTE_ETH_FOREACH_DEV(pid) { 2012 struct rte_port *port = &ports[pid]; 2013 uint64_t rx_offloads = port->dev_conf.rxmode.offloads; 2014 2015 if (!strcmp(res->name, "max-pkt-len")) { 2016 if (res->value < RTE_ETHER_MIN_LEN) { 2017 printf("max-pkt-len can not be less than %d\n", 2018 RTE_ETHER_MIN_LEN); 2019 return; 2020 } 2021 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len) 2022 return; 2023 2024 port->dev_conf.rxmode.max_rx_pkt_len = res->value; 2025 if (res->value > RTE_ETHER_MAX_LEN) 2026 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; 2027 else 2028 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; 2029 port->dev_conf.rxmode.offloads = rx_offloads; 2030 } else { 2031 printf("Unknown parameter\n"); 2032 return; 2033 } 2034 } 2035 2036 init_port_config(); 2037 2038 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2039 } 2040 2041 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 2042 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 2043 "port"); 2044 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 2045 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 2046 "config"); 2047 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 2048 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 2049 "all"); 2050 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 2051 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 2052 "max-pkt-len"); 2053 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 2054 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 2055 UINT32); 2056 2057 cmdline_parse_inst_t cmd_config_max_pkt_len = { 2058 .f = cmd_config_max_pkt_len_parsed, 2059 .data = NULL, 2060 .help_str = "port config all max-pkt-len <value>", 2061 .tokens = { 2062 (void *)&cmd_config_max_pkt_len_port, 2063 (void *)&cmd_config_max_pkt_len_keyword, 2064 (void *)&cmd_config_max_pkt_len_all, 2065 (void *)&cmd_config_max_pkt_len_name, 2066 (void *)&cmd_config_max_pkt_len_value, 2067 NULL, 2068 }, 2069 }; 2070 2071 /* *** config max LRO aggregated packet size *** */ 2072 struct cmd_config_max_lro_pkt_size_result { 2073 cmdline_fixed_string_t port; 2074 cmdline_fixed_string_t keyword; 2075 cmdline_fixed_string_t all; 2076 cmdline_fixed_string_t name; 2077 uint32_t value; 2078 }; 2079 2080 static void 2081 cmd_config_max_lro_pkt_size_parsed(void *parsed_result, 2082 __rte_unused struct cmdline *cl, 2083 __rte_unused void *data) 2084 { 2085 struct cmd_config_max_lro_pkt_size_result *res = parsed_result; 2086 portid_t pid; 2087 2088 if (!all_ports_stopped()) { 2089 printf("Please stop all ports first\n"); 2090 return; 2091 } 2092 2093 RTE_ETH_FOREACH_DEV(pid) { 2094 struct rte_port *port = &ports[pid]; 2095 2096 if (!strcmp(res->name, "max-lro-pkt-size")) { 2097 if (res->value == 2098 port->dev_conf.rxmode.max_lro_pkt_size) 2099 return; 2100 2101 port->dev_conf.rxmode.max_lro_pkt_size = res->value; 2102 } else { 2103 printf("Unknown parameter\n"); 2104 return; 2105 } 2106 } 2107 2108 init_port_config(); 2109 2110 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2111 } 2112 2113 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port = 2114 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2115 port, "port"); 2116 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword = 2117 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2118 keyword, "config"); 2119 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all = 2120 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2121 all, "all"); 2122 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name = 2123 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2124 name, "max-lro-pkt-size"); 2125 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value = 2126 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2127 value, UINT32); 2128 2129 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = { 2130 .f = cmd_config_max_lro_pkt_size_parsed, 2131 .data = NULL, 2132 .help_str = "port config all max-lro-pkt-size <value>", 2133 .tokens = { 2134 (void *)&cmd_config_max_lro_pkt_size_port, 2135 (void *)&cmd_config_max_lro_pkt_size_keyword, 2136 (void *)&cmd_config_max_lro_pkt_size_all, 2137 (void *)&cmd_config_max_lro_pkt_size_name, 2138 (void *)&cmd_config_max_lro_pkt_size_value, 2139 NULL, 2140 }, 2141 }; 2142 2143 /* *** configure port MTU *** */ 2144 struct cmd_config_mtu_result { 2145 cmdline_fixed_string_t port; 2146 cmdline_fixed_string_t keyword; 2147 cmdline_fixed_string_t mtu; 2148 portid_t port_id; 2149 uint16_t value; 2150 }; 2151 2152 static void 2153 cmd_config_mtu_parsed(void *parsed_result, 2154 __rte_unused struct cmdline *cl, 2155 __rte_unused void *data) 2156 { 2157 struct cmd_config_mtu_result *res = parsed_result; 2158 2159 if (res->value < RTE_ETHER_MIN_LEN) { 2160 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN); 2161 return; 2162 } 2163 port_mtu_set(res->port_id, res->value); 2164 } 2165 2166 cmdline_parse_token_string_t cmd_config_mtu_port = 2167 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 2168 "port"); 2169 cmdline_parse_token_string_t cmd_config_mtu_keyword = 2170 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2171 "config"); 2172 cmdline_parse_token_string_t cmd_config_mtu_mtu = 2173 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2174 "mtu"); 2175 cmdline_parse_token_num_t cmd_config_mtu_port_id = 2176 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16); 2177 cmdline_parse_token_num_t cmd_config_mtu_value = 2178 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16); 2179 2180 cmdline_parse_inst_t cmd_config_mtu = { 2181 .f = cmd_config_mtu_parsed, 2182 .data = NULL, 2183 .help_str = "port config mtu <port_id> <value>", 2184 .tokens = { 2185 (void *)&cmd_config_mtu_port, 2186 (void *)&cmd_config_mtu_keyword, 2187 (void *)&cmd_config_mtu_mtu, 2188 (void *)&cmd_config_mtu_port_id, 2189 (void *)&cmd_config_mtu_value, 2190 NULL, 2191 }, 2192 }; 2193 2194 /* *** configure rx mode *** */ 2195 struct cmd_config_rx_mode_flag { 2196 cmdline_fixed_string_t port; 2197 cmdline_fixed_string_t keyword; 2198 cmdline_fixed_string_t all; 2199 cmdline_fixed_string_t name; 2200 cmdline_fixed_string_t value; 2201 }; 2202 2203 static void 2204 cmd_config_rx_mode_flag_parsed(void *parsed_result, 2205 __rte_unused struct cmdline *cl, 2206 __rte_unused void *data) 2207 { 2208 struct cmd_config_rx_mode_flag *res = parsed_result; 2209 2210 if (!all_ports_stopped()) { 2211 printf("Please stop all ports first\n"); 2212 return; 2213 } 2214 2215 if (!strcmp(res->name, "drop-en")) { 2216 if (!strcmp(res->value, "on")) 2217 rx_drop_en = 1; 2218 else if (!strcmp(res->value, "off")) 2219 rx_drop_en = 0; 2220 else { 2221 printf("Unknown parameter\n"); 2222 return; 2223 } 2224 } else { 2225 printf("Unknown parameter\n"); 2226 return; 2227 } 2228 2229 init_port_config(); 2230 2231 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2232 } 2233 2234 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 2235 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 2236 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 2237 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 2238 "config"); 2239 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 2240 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 2241 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 2242 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 2243 "drop-en"); 2244 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 2245 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 2246 "on#off"); 2247 2248 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 2249 .f = cmd_config_rx_mode_flag_parsed, 2250 .data = NULL, 2251 .help_str = "port config all drop-en on|off", 2252 .tokens = { 2253 (void *)&cmd_config_rx_mode_flag_port, 2254 (void *)&cmd_config_rx_mode_flag_keyword, 2255 (void *)&cmd_config_rx_mode_flag_all, 2256 (void *)&cmd_config_rx_mode_flag_name, 2257 (void *)&cmd_config_rx_mode_flag_value, 2258 NULL, 2259 }, 2260 }; 2261 2262 /* *** configure rss *** */ 2263 struct cmd_config_rss { 2264 cmdline_fixed_string_t port; 2265 cmdline_fixed_string_t keyword; 2266 cmdline_fixed_string_t all; 2267 cmdline_fixed_string_t name; 2268 cmdline_fixed_string_t value; 2269 }; 2270 2271 static void 2272 cmd_config_rss_parsed(void *parsed_result, 2273 __rte_unused struct cmdline *cl, 2274 __rte_unused void *data) 2275 { 2276 struct cmd_config_rss *res = parsed_result; 2277 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2278 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2279 int use_default = 0; 2280 int all_updated = 1; 2281 int diag; 2282 uint16_t i; 2283 int ret; 2284 2285 if (!strcmp(res->value, "all")) 2286 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP | 2287 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP | 2288 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP | 2289 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU; 2290 else if (!strcmp(res->value, "eth")) 2291 rss_conf.rss_hf = ETH_RSS_ETH; 2292 else if (!strcmp(res->value, "vlan")) 2293 rss_conf.rss_hf = ETH_RSS_VLAN; 2294 else if (!strcmp(res->value, "ip")) 2295 rss_conf.rss_hf = ETH_RSS_IP; 2296 else if (!strcmp(res->value, "udp")) 2297 rss_conf.rss_hf = ETH_RSS_UDP; 2298 else if (!strcmp(res->value, "tcp")) 2299 rss_conf.rss_hf = ETH_RSS_TCP; 2300 else if (!strcmp(res->value, "sctp")) 2301 rss_conf.rss_hf = ETH_RSS_SCTP; 2302 else if (!strcmp(res->value, "ether")) 2303 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 2304 else if (!strcmp(res->value, "port")) 2305 rss_conf.rss_hf = ETH_RSS_PORT; 2306 else if (!strcmp(res->value, "vxlan")) 2307 rss_conf.rss_hf = ETH_RSS_VXLAN; 2308 else if (!strcmp(res->value, "geneve")) 2309 rss_conf.rss_hf = ETH_RSS_GENEVE; 2310 else if (!strcmp(res->value, "nvgre")) 2311 rss_conf.rss_hf = ETH_RSS_NVGRE; 2312 else if (!strcmp(res->value, "l3-pre32")) 2313 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32; 2314 else if (!strcmp(res->value, "l3-pre40")) 2315 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40; 2316 else if (!strcmp(res->value, "l3-pre48")) 2317 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48; 2318 else if (!strcmp(res->value, "l3-pre56")) 2319 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56; 2320 else if (!strcmp(res->value, "l3-pre64")) 2321 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64; 2322 else if (!strcmp(res->value, "l3-pre96")) 2323 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96; 2324 else if (!strcmp(res->value, "l3-src-only")) 2325 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY; 2326 else if (!strcmp(res->value, "l3-dst-only")) 2327 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY; 2328 else if (!strcmp(res->value, "l4-src-only")) 2329 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY; 2330 else if (!strcmp(res->value, "l4-dst-only")) 2331 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY; 2332 else if (!strcmp(res->value, "l2-src-only")) 2333 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY; 2334 else if (!strcmp(res->value, "l2-dst-only")) 2335 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY; 2336 else if (!strcmp(res->value, "l2tpv3")) 2337 rss_conf.rss_hf = ETH_RSS_L2TPV3; 2338 else if (!strcmp(res->value, "esp")) 2339 rss_conf.rss_hf = ETH_RSS_ESP; 2340 else if (!strcmp(res->value, "ah")) 2341 rss_conf.rss_hf = ETH_RSS_AH; 2342 else if (!strcmp(res->value, "pfcp")) 2343 rss_conf.rss_hf = ETH_RSS_PFCP; 2344 else if (!strcmp(res->value, "pppoe")) 2345 rss_conf.rss_hf = ETH_RSS_PPPOE; 2346 else if (!strcmp(res->value, "gtpu")) 2347 rss_conf.rss_hf = ETH_RSS_GTPU; 2348 else if (!strcmp(res->value, "none")) 2349 rss_conf.rss_hf = 0; 2350 else if (!strcmp(res->value, "level-default")) { 2351 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2352 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT); 2353 } else if (!strcmp(res->value, "level-outer")) { 2354 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2355 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST); 2356 } else if (!strcmp(res->value, "level-inner")) { 2357 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2358 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST); 2359 } else if (!strcmp(res->value, "default")) 2360 use_default = 1; 2361 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 2362 atoi(res->value) < 64) 2363 rss_conf.rss_hf = 1ULL << atoi(res->value); 2364 else { 2365 printf("Unknown parameter\n"); 2366 return; 2367 } 2368 rss_conf.rss_key = NULL; 2369 /* Update global configuration for RSS types. */ 2370 RTE_ETH_FOREACH_DEV(i) { 2371 struct rte_eth_rss_conf local_rss_conf; 2372 2373 ret = eth_dev_info_get_print_err(i, &dev_info); 2374 if (ret != 0) 2375 return; 2376 2377 if (use_default) 2378 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2379 2380 local_rss_conf = rss_conf; 2381 local_rss_conf.rss_hf = rss_conf.rss_hf & 2382 dev_info.flow_type_rss_offloads; 2383 if (local_rss_conf.rss_hf != rss_conf.rss_hf) { 2384 printf("Port %u modified RSS hash function based on hardware support," 2385 "requested:%#"PRIx64" configured:%#"PRIx64"\n", 2386 i, rss_conf.rss_hf, local_rss_conf.rss_hf); 2387 } 2388 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf); 2389 if (diag < 0) { 2390 all_updated = 0; 2391 printf("Configuration of RSS hash at ethernet port %d " 2392 "failed with error (%d): %s.\n", 2393 i, -diag, strerror(-diag)); 2394 } 2395 } 2396 if (all_updated && !use_default) { 2397 rss_hf = rss_conf.rss_hf; 2398 printf("rss_hf %#"PRIx64"\n", rss_hf); 2399 } 2400 } 2401 2402 cmdline_parse_token_string_t cmd_config_rss_port = 2403 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2404 cmdline_parse_token_string_t cmd_config_rss_keyword = 2405 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2406 cmdline_parse_token_string_t cmd_config_rss_all = 2407 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2408 cmdline_parse_token_string_t cmd_config_rss_name = 2409 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2410 cmdline_parse_token_string_t cmd_config_rss_value = 2411 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2412 2413 cmdline_parse_inst_t cmd_config_rss = { 2414 .f = cmd_config_rss_parsed, 2415 .data = NULL, 2416 .help_str = "port config all rss " 2417 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|" 2418 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|" 2419 "level-outer|level-inner|<flowtype_id>", 2420 .tokens = { 2421 (void *)&cmd_config_rss_port, 2422 (void *)&cmd_config_rss_keyword, 2423 (void *)&cmd_config_rss_all, 2424 (void *)&cmd_config_rss_name, 2425 (void *)&cmd_config_rss_value, 2426 NULL, 2427 }, 2428 }; 2429 2430 /* *** configure rss hash key *** */ 2431 struct cmd_config_rss_hash_key { 2432 cmdline_fixed_string_t port; 2433 cmdline_fixed_string_t config; 2434 portid_t port_id; 2435 cmdline_fixed_string_t rss_hash_key; 2436 cmdline_fixed_string_t rss_type; 2437 cmdline_fixed_string_t key; 2438 }; 2439 2440 static uint8_t 2441 hexa_digit_to_value(char hexa_digit) 2442 { 2443 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2444 return (uint8_t) (hexa_digit - '0'); 2445 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2446 return (uint8_t) ((hexa_digit - 'a') + 10); 2447 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2448 return (uint8_t) ((hexa_digit - 'A') + 10); 2449 /* Invalid hexa digit */ 2450 return 0xFF; 2451 } 2452 2453 static uint8_t 2454 parse_and_check_key_hexa_digit(char *key, int idx) 2455 { 2456 uint8_t hexa_v; 2457 2458 hexa_v = hexa_digit_to_value(key[idx]); 2459 if (hexa_v == 0xFF) 2460 printf("invalid key: character %c at position %d is not a " 2461 "valid hexa digit\n", key[idx], idx); 2462 return hexa_v; 2463 } 2464 2465 static void 2466 cmd_config_rss_hash_key_parsed(void *parsed_result, 2467 __rte_unused struct cmdline *cl, 2468 __rte_unused void *data) 2469 { 2470 struct cmd_config_rss_hash_key *res = parsed_result; 2471 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2472 uint8_t xdgt0; 2473 uint8_t xdgt1; 2474 int i; 2475 struct rte_eth_dev_info dev_info; 2476 uint8_t hash_key_size; 2477 uint32_t key_len; 2478 int ret; 2479 2480 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2481 if (ret != 0) 2482 return; 2483 2484 if (dev_info.hash_key_size > 0 && 2485 dev_info.hash_key_size <= sizeof(hash_key)) 2486 hash_key_size = dev_info.hash_key_size; 2487 else { 2488 printf("dev_info did not provide a valid hash key size\n"); 2489 return; 2490 } 2491 /* Check the length of the RSS hash key */ 2492 key_len = strlen(res->key); 2493 if (key_len != (hash_key_size * 2)) { 2494 printf("key length: %d invalid - key must be a string of %d" 2495 " hexa-decimal numbers\n", 2496 (int) key_len, hash_key_size * 2); 2497 return; 2498 } 2499 /* Translate RSS hash key into binary representation */ 2500 for (i = 0; i < hash_key_size; i++) { 2501 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2502 if (xdgt0 == 0xFF) 2503 return; 2504 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2505 if (xdgt1 == 0xFF) 2506 return; 2507 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2508 } 2509 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2510 hash_key_size); 2511 } 2512 2513 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2514 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2515 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2516 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2517 "config"); 2518 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2519 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16); 2520 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2521 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2522 rss_hash_key, "rss-hash-key"); 2523 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2524 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2525 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2526 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2527 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2528 "ipv6-tcp-ex#ipv6-udp-ex#" 2529 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#" 2530 "l2-src-only#l2-dst-only#s-vlan#c-vlan#" 2531 "l2tpv3#esp#ah#pfcp#pppoe#gtpu"); 2532 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2533 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2534 2535 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2536 .f = cmd_config_rss_hash_key_parsed, 2537 .data = NULL, 2538 .help_str = "port config <port_id> rss-hash-key " 2539 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2540 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2541 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|" 2542 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|" 2543 "l2-src-only|l2-dst-only|s-vlan|c-vlan|" 2544 "l2tpv3|esp|ah|pfcp|pppoe|gtpu " 2545 "<string of hex digits (variable length, NIC dependent)>", 2546 .tokens = { 2547 (void *)&cmd_config_rss_hash_key_port, 2548 (void *)&cmd_config_rss_hash_key_config, 2549 (void *)&cmd_config_rss_hash_key_port_id, 2550 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2551 (void *)&cmd_config_rss_hash_key_rss_type, 2552 (void *)&cmd_config_rss_hash_key_value, 2553 NULL, 2554 }, 2555 }; 2556 2557 /* *** configure port rxq/txq ring size *** */ 2558 struct cmd_config_rxtx_ring_size { 2559 cmdline_fixed_string_t port; 2560 cmdline_fixed_string_t config; 2561 portid_t portid; 2562 cmdline_fixed_string_t rxtxq; 2563 uint16_t qid; 2564 cmdline_fixed_string_t rsize; 2565 uint16_t size; 2566 }; 2567 2568 static void 2569 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2570 __rte_unused struct cmdline *cl, 2571 __rte_unused void *data) 2572 { 2573 struct cmd_config_rxtx_ring_size *res = parsed_result; 2574 struct rte_port *port; 2575 uint8_t isrx; 2576 2577 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2578 return; 2579 2580 if (res->portid == (portid_t)RTE_PORT_ALL) { 2581 printf("Invalid port id\n"); 2582 return; 2583 } 2584 2585 port = &ports[res->portid]; 2586 2587 if (!strcmp(res->rxtxq, "rxq")) 2588 isrx = 1; 2589 else if (!strcmp(res->rxtxq, "txq")) 2590 isrx = 0; 2591 else { 2592 printf("Unknown parameter\n"); 2593 return; 2594 } 2595 2596 if (isrx && rx_queue_id_is_invalid(res->qid)) 2597 return; 2598 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2599 return; 2600 2601 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2602 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n", 2603 rx_free_thresh); 2604 return; 2605 } 2606 2607 if (isrx) 2608 port->nb_rx_desc[res->qid] = res->size; 2609 else 2610 port->nb_tx_desc[res->qid] = res->size; 2611 2612 cmd_reconfig_device_queue(res->portid, 0, 1); 2613 } 2614 2615 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2616 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2617 port, "port"); 2618 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2619 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2620 config, "config"); 2621 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2622 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2623 portid, UINT16); 2624 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2625 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2626 rxtxq, "rxq#txq"); 2627 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2628 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2629 qid, UINT16); 2630 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2631 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2632 rsize, "ring_size"); 2633 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2634 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2635 size, UINT16); 2636 2637 cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2638 .f = cmd_config_rxtx_ring_size_parsed, 2639 .data = NULL, 2640 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2641 .tokens = { 2642 (void *)&cmd_config_rxtx_ring_size_port, 2643 (void *)&cmd_config_rxtx_ring_size_config, 2644 (void *)&cmd_config_rxtx_ring_size_portid, 2645 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2646 (void *)&cmd_config_rxtx_ring_size_qid, 2647 (void *)&cmd_config_rxtx_ring_size_rsize, 2648 (void *)&cmd_config_rxtx_ring_size_size, 2649 NULL, 2650 }, 2651 }; 2652 2653 /* *** configure port rxq/txq start/stop *** */ 2654 struct cmd_config_rxtx_queue { 2655 cmdline_fixed_string_t port; 2656 portid_t portid; 2657 cmdline_fixed_string_t rxtxq; 2658 uint16_t qid; 2659 cmdline_fixed_string_t opname; 2660 }; 2661 2662 static void 2663 cmd_config_rxtx_queue_parsed(void *parsed_result, 2664 __rte_unused struct cmdline *cl, 2665 __rte_unused void *data) 2666 { 2667 struct cmd_config_rxtx_queue *res = parsed_result; 2668 uint8_t isrx; 2669 uint8_t isstart; 2670 int ret = 0; 2671 2672 if (test_done == 0) { 2673 printf("Please stop forwarding first\n"); 2674 return; 2675 } 2676 2677 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2678 return; 2679 2680 if (port_is_started(res->portid) != 1) { 2681 printf("Please start port %u first\n", res->portid); 2682 return; 2683 } 2684 2685 if (!strcmp(res->rxtxq, "rxq")) 2686 isrx = 1; 2687 else if (!strcmp(res->rxtxq, "txq")) 2688 isrx = 0; 2689 else { 2690 printf("Unknown parameter\n"); 2691 return; 2692 } 2693 2694 if (isrx && rx_queue_id_is_invalid(res->qid)) 2695 return; 2696 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2697 return; 2698 2699 if (!strcmp(res->opname, "start")) 2700 isstart = 1; 2701 else if (!strcmp(res->opname, "stop")) 2702 isstart = 0; 2703 else { 2704 printf("Unknown parameter\n"); 2705 return; 2706 } 2707 2708 if (isstart && isrx) 2709 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2710 else if (!isstart && isrx) 2711 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2712 else if (isstart && !isrx) 2713 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2714 else 2715 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2716 2717 if (ret == -ENOTSUP) 2718 printf("Function not supported in PMD driver\n"); 2719 } 2720 2721 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2722 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2723 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2724 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16); 2725 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2726 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2727 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2728 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16); 2729 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2730 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2731 "start#stop"); 2732 2733 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2734 .f = cmd_config_rxtx_queue_parsed, 2735 .data = NULL, 2736 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2737 .tokens = { 2738 (void *)&cmd_config_rxtx_queue_port, 2739 (void *)&cmd_config_rxtx_queue_portid, 2740 (void *)&cmd_config_rxtx_queue_rxtxq, 2741 (void *)&cmd_config_rxtx_queue_qid, 2742 (void *)&cmd_config_rxtx_queue_opname, 2743 NULL, 2744 }, 2745 }; 2746 2747 /* *** configure port rxq/txq deferred start on/off *** */ 2748 struct cmd_config_deferred_start_rxtx_queue { 2749 cmdline_fixed_string_t port; 2750 portid_t port_id; 2751 cmdline_fixed_string_t rxtxq; 2752 uint16_t qid; 2753 cmdline_fixed_string_t opname; 2754 cmdline_fixed_string_t state; 2755 }; 2756 2757 static void 2758 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, 2759 __rte_unused struct cmdline *cl, 2760 __rte_unused void *data) 2761 { 2762 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; 2763 struct rte_port *port; 2764 uint8_t isrx; 2765 uint8_t ison; 2766 uint8_t needreconfig = 0; 2767 2768 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 2769 return; 2770 2771 if (port_is_started(res->port_id) != 0) { 2772 printf("Please stop port %u first\n", res->port_id); 2773 return; 2774 } 2775 2776 port = &ports[res->port_id]; 2777 2778 isrx = !strcmp(res->rxtxq, "rxq"); 2779 2780 if (isrx && rx_queue_id_is_invalid(res->qid)) 2781 return; 2782 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2783 return; 2784 2785 ison = !strcmp(res->state, "on"); 2786 2787 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) { 2788 port->rx_conf[res->qid].rx_deferred_start = ison; 2789 needreconfig = 1; 2790 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) { 2791 port->tx_conf[res->qid].tx_deferred_start = ison; 2792 needreconfig = 1; 2793 } 2794 2795 if (needreconfig) 2796 cmd_reconfig_device_queue(res->port_id, 0, 1); 2797 } 2798 2799 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = 2800 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2801 port, "port"); 2802 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = 2803 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2804 port_id, UINT16); 2805 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = 2806 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2807 rxtxq, "rxq#txq"); 2808 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = 2809 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2810 qid, UINT16); 2811 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = 2812 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2813 opname, "deferred_start"); 2814 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = 2815 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2816 state, "on#off"); 2817 2818 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { 2819 .f = cmd_config_deferred_start_rxtx_queue_parsed, 2820 .data = NULL, 2821 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", 2822 .tokens = { 2823 (void *)&cmd_config_deferred_start_rxtx_queue_port, 2824 (void *)&cmd_config_deferred_start_rxtx_queue_port_id, 2825 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, 2826 (void *)&cmd_config_deferred_start_rxtx_queue_qid, 2827 (void *)&cmd_config_deferred_start_rxtx_queue_opname, 2828 (void *)&cmd_config_deferred_start_rxtx_queue_state, 2829 NULL, 2830 }, 2831 }; 2832 2833 /* *** configure port rxq/txq setup *** */ 2834 struct cmd_setup_rxtx_queue { 2835 cmdline_fixed_string_t port; 2836 portid_t portid; 2837 cmdline_fixed_string_t rxtxq; 2838 uint16_t qid; 2839 cmdline_fixed_string_t setup; 2840 }; 2841 2842 /* Common CLI fields for queue setup */ 2843 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2844 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2845 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2846 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16); 2847 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2848 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2849 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2850 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16); 2851 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2852 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2853 2854 static void 2855 cmd_setup_rxtx_queue_parsed( 2856 void *parsed_result, 2857 __rte_unused struct cmdline *cl, 2858 __rte_unused void *data) 2859 { 2860 struct cmd_setup_rxtx_queue *res = parsed_result; 2861 struct rte_port *port; 2862 struct rte_mempool *mp; 2863 unsigned int socket_id; 2864 uint8_t isrx = 0; 2865 int ret; 2866 2867 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2868 return; 2869 2870 if (res->portid == (portid_t)RTE_PORT_ALL) { 2871 printf("Invalid port id\n"); 2872 return; 2873 } 2874 2875 if (!strcmp(res->rxtxq, "rxq")) 2876 isrx = 1; 2877 else if (!strcmp(res->rxtxq, "txq")) 2878 isrx = 0; 2879 else { 2880 printf("Unknown parameter\n"); 2881 return; 2882 } 2883 2884 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2885 printf("Invalid rx queue\n"); 2886 return; 2887 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2888 printf("Invalid tx queue\n"); 2889 return; 2890 } 2891 2892 port = &ports[res->portid]; 2893 if (isrx) { 2894 socket_id = rxring_numa[res->portid]; 2895 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2896 socket_id = port->socket_id; 2897 2898 mp = mbuf_pool_find(socket_id, 0); 2899 if (mp == NULL) { 2900 printf("Failed to setup RX queue: " 2901 "No mempool allocation" 2902 " on the socket %d\n", 2903 rxring_numa[res->portid]); 2904 return; 2905 } 2906 ret = rx_queue_setup(res->portid, 2907 res->qid, 2908 port->nb_rx_desc[res->qid], 2909 socket_id, 2910 &port->rx_conf[res->qid], 2911 mp); 2912 if (ret) 2913 printf("Failed to setup RX queue\n"); 2914 } else { 2915 socket_id = txring_numa[res->portid]; 2916 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2917 socket_id = port->socket_id; 2918 2919 ret = rte_eth_tx_queue_setup(res->portid, 2920 res->qid, 2921 port->nb_tx_desc[res->qid], 2922 socket_id, 2923 &port->tx_conf[res->qid]); 2924 if (ret) 2925 printf("Failed to setup TX queue\n"); 2926 } 2927 } 2928 2929 cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2930 .f = cmd_setup_rxtx_queue_parsed, 2931 .data = NULL, 2932 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2933 .tokens = { 2934 (void *)&cmd_setup_rxtx_queue_port, 2935 (void *)&cmd_setup_rxtx_queue_portid, 2936 (void *)&cmd_setup_rxtx_queue_rxtxq, 2937 (void *)&cmd_setup_rxtx_queue_qid, 2938 (void *)&cmd_setup_rxtx_queue_setup, 2939 NULL, 2940 }, 2941 }; 2942 2943 2944 /* *** Configure RSS RETA *** */ 2945 struct cmd_config_rss_reta { 2946 cmdline_fixed_string_t port; 2947 cmdline_fixed_string_t keyword; 2948 portid_t port_id; 2949 cmdline_fixed_string_t name; 2950 cmdline_fixed_string_t list_name; 2951 cmdline_fixed_string_t list_of_items; 2952 }; 2953 2954 static int 2955 parse_reta_config(const char *str, 2956 struct rte_eth_rss_reta_entry64 *reta_conf, 2957 uint16_t nb_entries) 2958 { 2959 int i; 2960 unsigned size; 2961 uint16_t hash_index, idx, shift; 2962 uint16_t nb_queue; 2963 char s[256]; 2964 const char *p, *p0 = str; 2965 char *end; 2966 enum fieldnames { 2967 FLD_HASH_INDEX = 0, 2968 FLD_QUEUE, 2969 _NUM_FLD 2970 }; 2971 unsigned long int_fld[_NUM_FLD]; 2972 char *str_fld[_NUM_FLD]; 2973 2974 while ((p = strchr(p0,'(')) != NULL) { 2975 ++p; 2976 if((p0 = strchr(p,')')) == NULL) 2977 return -1; 2978 2979 size = p0 - p; 2980 if(size >= sizeof(s)) 2981 return -1; 2982 2983 snprintf(s, sizeof(s), "%.*s", size, p); 2984 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2985 return -1; 2986 for (i = 0; i < _NUM_FLD; i++) { 2987 errno = 0; 2988 int_fld[i] = strtoul(str_fld[i], &end, 0); 2989 if (errno != 0 || end == str_fld[i] || 2990 int_fld[i] > 65535) 2991 return -1; 2992 } 2993 2994 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2995 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2996 2997 if (hash_index >= nb_entries) { 2998 printf("Invalid RETA hash index=%d\n", 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 printf("Redirection table size is 0 which is " 3027 "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 printf("Currently do not support more than %u entries of " 3034 "redirection table\n", ETH_RSS_RETA_SIZE_512); 3035 return; 3036 } 3037 3038 memset(reta_conf, 0, sizeof(reta_conf)); 3039 if (!strcmp(res->list_name, "reta")) { 3040 if (parse_reta_config(res->list_of_items, reta_conf, 3041 dev_info.reta_size)) { 3042 printf("Invalid RSS Redirection Table " 3043 "config entered\n"); 3044 return; 3045 } 3046 ret = rte_eth_dev_rss_reta_update(res->port_id, 3047 reta_conf, dev_info.reta_size); 3048 if (ret != 0) 3049 printf("Bad redirection table parameter, " 3050 "return code = %d \n", ret); 3051 } 3052 } 3053 3054 cmdline_parse_token_string_t cmd_config_rss_reta_port = 3055 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 3056 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 3057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 3058 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 3059 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16); 3060 cmdline_parse_token_string_t cmd_config_rss_reta_name = 3061 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 3062 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 3063 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 3064 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 3065 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 3066 NULL); 3067 cmdline_parse_inst_t cmd_config_rss_reta = { 3068 .f = cmd_set_rss_reta_parsed, 3069 .data = NULL, 3070 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 3071 .tokens = { 3072 (void *)&cmd_config_rss_reta_port, 3073 (void *)&cmd_config_rss_reta_keyword, 3074 (void *)&cmd_config_rss_reta_port_id, 3075 (void *)&cmd_config_rss_reta_name, 3076 (void *)&cmd_config_rss_reta_list_name, 3077 (void *)&cmd_config_rss_reta_list_of_items, 3078 NULL, 3079 }, 3080 }; 3081 3082 /* *** SHOW PORT RETA INFO *** */ 3083 struct cmd_showport_reta { 3084 cmdline_fixed_string_t show; 3085 cmdline_fixed_string_t port; 3086 portid_t port_id; 3087 cmdline_fixed_string_t rss; 3088 cmdline_fixed_string_t reta; 3089 uint16_t size; 3090 cmdline_fixed_string_t list_of_items; 3091 }; 3092 3093 static int 3094 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 3095 uint16_t nb_entries, 3096 char *str) 3097 { 3098 uint32_t size; 3099 const char *p, *p0 = str; 3100 char s[256]; 3101 char *end; 3102 char *str_fld[8]; 3103 uint16_t i; 3104 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 3105 RTE_RETA_GROUP_SIZE; 3106 int ret; 3107 3108 p = strchr(p0, '('); 3109 if (p == NULL) 3110 return -1; 3111 p++; 3112 p0 = strchr(p, ')'); 3113 if (p0 == NULL) 3114 return -1; 3115 size = p0 - p; 3116 if (size >= sizeof(s)) { 3117 printf("The string size exceeds the internal buffer size\n"); 3118 return -1; 3119 } 3120 snprintf(s, sizeof(s), "%.*s", size, p); 3121 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 3122 if (ret <= 0 || ret != num) { 3123 printf("The bits of masks do not match the number of " 3124 "reta entries: %u\n", num); 3125 return -1; 3126 } 3127 for (i = 0; i < ret; i++) 3128 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 3129 3130 return 0; 3131 } 3132 3133 static void 3134 cmd_showport_reta_parsed(void *parsed_result, 3135 __rte_unused struct cmdline *cl, 3136 __rte_unused void *data) 3137 { 3138 struct cmd_showport_reta *res = parsed_result; 3139 struct rte_eth_rss_reta_entry64 reta_conf[8]; 3140 struct rte_eth_dev_info dev_info; 3141 uint16_t max_reta_size; 3142 int ret; 3143 3144 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 3145 if (ret != 0) 3146 return; 3147 3148 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 3149 if (res->size == 0 || res->size > max_reta_size) { 3150 printf("Invalid redirection table size: %u (1-%u)\n", 3151 res->size, max_reta_size); 3152 return; 3153 } 3154 3155 memset(reta_conf, 0, sizeof(reta_conf)); 3156 if (showport_parse_reta_config(reta_conf, res->size, 3157 res->list_of_items) < 0) { 3158 printf("Invalid string: %s for reta masks\n", 3159 res->list_of_items); 3160 return; 3161 } 3162 port_rss_reta_info(res->port_id, reta_conf, res->size); 3163 } 3164 3165 cmdline_parse_token_string_t cmd_showport_reta_show = 3166 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 3167 cmdline_parse_token_string_t cmd_showport_reta_port = 3168 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 3169 cmdline_parse_token_num_t cmd_showport_reta_port_id = 3170 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16); 3171 cmdline_parse_token_string_t cmd_showport_reta_rss = 3172 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 3173 cmdline_parse_token_string_t cmd_showport_reta_reta = 3174 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 3175 cmdline_parse_token_num_t cmd_showport_reta_size = 3176 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16); 3177 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 3178 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 3179 list_of_items, NULL); 3180 3181 cmdline_parse_inst_t cmd_showport_reta = { 3182 .f = cmd_showport_reta_parsed, 3183 .data = NULL, 3184 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 3185 .tokens = { 3186 (void *)&cmd_showport_reta_show, 3187 (void *)&cmd_showport_reta_port, 3188 (void *)&cmd_showport_reta_port_id, 3189 (void *)&cmd_showport_reta_rss, 3190 (void *)&cmd_showport_reta_reta, 3191 (void *)&cmd_showport_reta_size, 3192 (void *)&cmd_showport_reta_list_of_items, 3193 NULL, 3194 }, 3195 }; 3196 3197 /* *** Show RSS hash configuration *** */ 3198 struct cmd_showport_rss_hash { 3199 cmdline_fixed_string_t show; 3200 cmdline_fixed_string_t port; 3201 portid_t port_id; 3202 cmdline_fixed_string_t rss_hash; 3203 cmdline_fixed_string_t rss_type; 3204 cmdline_fixed_string_t key; /* optional argument */ 3205 }; 3206 3207 static void cmd_showport_rss_hash_parsed(void *parsed_result, 3208 __rte_unused struct cmdline *cl, 3209 void *show_rss_key) 3210 { 3211 struct cmd_showport_rss_hash *res = parsed_result; 3212 3213 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); 3214 } 3215 3216 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 3217 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 3218 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 3219 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 3220 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 3221 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16); 3222 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 3223 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 3224 "rss-hash"); 3225 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 3226 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 3227 3228 cmdline_parse_inst_t cmd_showport_rss_hash = { 3229 .f = cmd_showport_rss_hash_parsed, 3230 .data = NULL, 3231 .help_str = "show port <port_id> rss-hash", 3232 .tokens = { 3233 (void *)&cmd_showport_rss_hash_show, 3234 (void *)&cmd_showport_rss_hash_port, 3235 (void *)&cmd_showport_rss_hash_port_id, 3236 (void *)&cmd_showport_rss_hash_rss_hash, 3237 NULL, 3238 }, 3239 }; 3240 3241 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 3242 .f = cmd_showport_rss_hash_parsed, 3243 .data = (void *)1, 3244 .help_str = "show port <port_id> rss-hash key", 3245 .tokens = { 3246 (void *)&cmd_showport_rss_hash_show, 3247 (void *)&cmd_showport_rss_hash_port, 3248 (void *)&cmd_showport_rss_hash_port_id, 3249 (void *)&cmd_showport_rss_hash_rss_hash, 3250 (void *)&cmd_showport_rss_hash_rss_key, 3251 NULL, 3252 }, 3253 }; 3254 3255 /* *** Configure DCB *** */ 3256 struct cmd_config_dcb { 3257 cmdline_fixed_string_t port; 3258 cmdline_fixed_string_t config; 3259 portid_t port_id; 3260 cmdline_fixed_string_t dcb; 3261 cmdline_fixed_string_t vt; 3262 cmdline_fixed_string_t vt_en; 3263 uint8_t num_tcs; 3264 cmdline_fixed_string_t pfc; 3265 cmdline_fixed_string_t pfc_en; 3266 }; 3267 3268 static void 3269 cmd_config_dcb_parsed(void *parsed_result, 3270 __rte_unused struct cmdline *cl, 3271 __rte_unused void *data) 3272 { 3273 struct cmd_config_dcb *res = parsed_result; 3274 portid_t port_id = res->port_id; 3275 struct rte_port *port; 3276 uint8_t pfc_en; 3277 int ret; 3278 3279 port = &ports[port_id]; 3280 /** Check if the port is not started **/ 3281 if (port->port_status != RTE_PORT_STOPPED) { 3282 printf("Please stop port %d first\n", port_id); 3283 return; 3284 } 3285 3286 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 3287 printf("The invalid number of traffic class," 3288 " only 4 or 8 allowed.\n"); 3289 return; 3290 } 3291 3292 if (nb_fwd_lcores < res->num_tcs) { 3293 printf("nb_cores shouldn't be less than number of TCs.\n"); 3294 return; 3295 } 3296 if (!strncmp(res->pfc_en, "on", 2)) 3297 pfc_en = 1; 3298 else 3299 pfc_en = 0; 3300 3301 /* DCB in VT mode */ 3302 if (!strncmp(res->vt_en, "on", 2)) 3303 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 3304 (enum rte_eth_nb_tcs)res->num_tcs, 3305 pfc_en); 3306 else 3307 ret = init_port_dcb_config(port_id, DCB_ENABLED, 3308 (enum rte_eth_nb_tcs)res->num_tcs, 3309 pfc_en); 3310 3311 3312 if (ret != 0) { 3313 printf("Cannot initialize network ports.\n"); 3314 return; 3315 } 3316 3317 cmd_reconfig_device_queue(port_id, 1, 1); 3318 } 3319 3320 cmdline_parse_token_string_t cmd_config_dcb_port = 3321 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 3322 cmdline_parse_token_string_t cmd_config_dcb_config = 3323 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 3324 cmdline_parse_token_num_t cmd_config_dcb_port_id = 3325 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16); 3326 cmdline_parse_token_string_t cmd_config_dcb_dcb = 3327 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 3328 cmdline_parse_token_string_t cmd_config_dcb_vt = 3329 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 3330 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 3331 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 3332 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 3333 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8); 3334 cmdline_parse_token_string_t cmd_config_dcb_pfc= 3335 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 3336 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 3337 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 3338 3339 cmdline_parse_inst_t cmd_config_dcb = { 3340 .f = cmd_config_dcb_parsed, 3341 .data = NULL, 3342 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 3343 .tokens = { 3344 (void *)&cmd_config_dcb_port, 3345 (void *)&cmd_config_dcb_config, 3346 (void *)&cmd_config_dcb_port_id, 3347 (void *)&cmd_config_dcb_dcb, 3348 (void *)&cmd_config_dcb_vt, 3349 (void *)&cmd_config_dcb_vt_en, 3350 (void *)&cmd_config_dcb_num_tcs, 3351 (void *)&cmd_config_dcb_pfc, 3352 (void *)&cmd_config_dcb_pfc_en, 3353 NULL, 3354 }, 3355 }; 3356 3357 /* *** configure number of packets per burst *** */ 3358 struct cmd_config_burst { 3359 cmdline_fixed_string_t port; 3360 cmdline_fixed_string_t keyword; 3361 cmdline_fixed_string_t all; 3362 cmdline_fixed_string_t name; 3363 uint16_t value; 3364 }; 3365 3366 static void 3367 cmd_config_burst_parsed(void *parsed_result, 3368 __rte_unused struct cmdline *cl, 3369 __rte_unused void *data) 3370 { 3371 struct cmd_config_burst *res = parsed_result; 3372 struct rte_eth_dev_info dev_info; 3373 uint16_t rec_nb_pkts; 3374 int ret; 3375 3376 if (!all_ports_stopped()) { 3377 printf("Please stop all ports first\n"); 3378 return; 3379 } 3380 3381 if (!strcmp(res->name, "burst")) { 3382 if (res->value == 0) { 3383 /* If user gives a value of zero, query the PMD for 3384 * its recommended Rx burst size. Testpmd uses a single 3385 * size for all ports, so assume all ports are the same 3386 * NIC model and use the values from Port 0. 3387 */ 3388 ret = eth_dev_info_get_print_err(0, &dev_info); 3389 if (ret != 0) 3390 return; 3391 3392 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 3393 3394 if (rec_nb_pkts == 0) { 3395 printf("PMD does not recommend a burst size.\n" 3396 "User provided value must be between" 3397 " 1 and %d\n", MAX_PKT_BURST); 3398 return; 3399 } else if (rec_nb_pkts > MAX_PKT_BURST) { 3400 printf("PMD recommended burst size of %d" 3401 " exceeds maximum value of %d\n", 3402 rec_nb_pkts, MAX_PKT_BURST); 3403 return; 3404 } 3405 printf("Using PMD-provided burst value of %d\n", 3406 rec_nb_pkts); 3407 nb_pkt_per_burst = rec_nb_pkts; 3408 } else if (res->value > MAX_PKT_BURST) { 3409 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST); 3410 return; 3411 } else 3412 nb_pkt_per_burst = res->value; 3413 } else { 3414 printf("Unknown parameter\n"); 3415 return; 3416 } 3417 3418 init_port_config(); 3419 3420 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3421 } 3422 3423 cmdline_parse_token_string_t cmd_config_burst_port = 3424 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3425 cmdline_parse_token_string_t cmd_config_burst_keyword = 3426 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3427 cmdline_parse_token_string_t cmd_config_burst_all = 3428 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3429 cmdline_parse_token_string_t cmd_config_burst_name = 3430 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3431 cmdline_parse_token_num_t cmd_config_burst_value = 3432 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16); 3433 3434 cmdline_parse_inst_t cmd_config_burst = { 3435 .f = cmd_config_burst_parsed, 3436 .data = NULL, 3437 .help_str = "port config all burst <value>", 3438 .tokens = { 3439 (void *)&cmd_config_burst_port, 3440 (void *)&cmd_config_burst_keyword, 3441 (void *)&cmd_config_burst_all, 3442 (void *)&cmd_config_burst_name, 3443 (void *)&cmd_config_burst_value, 3444 NULL, 3445 }, 3446 }; 3447 3448 /* *** configure rx/tx queues *** */ 3449 struct cmd_config_thresh { 3450 cmdline_fixed_string_t port; 3451 cmdline_fixed_string_t keyword; 3452 cmdline_fixed_string_t all; 3453 cmdline_fixed_string_t name; 3454 uint8_t value; 3455 }; 3456 3457 static void 3458 cmd_config_thresh_parsed(void *parsed_result, 3459 __rte_unused struct cmdline *cl, 3460 __rte_unused void *data) 3461 { 3462 struct cmd_config_thresh *res = parsed_result; 3463 3464 if (!all_ports_stopped()) { 3465 printf("Please stop all ports first\n"); 3466 return; 3467 } 3468 3469 if (!strcmp(res->name, "txpt")) 3470 tx_pthresh = res->value; 3471 else if(!strcmp(res->name, "txht")) 3472 tx_hthresh = res->value; 3473 else if(!strcmp(res->name, "txwt")) 3474 tx_wthresh = res->value; 3475 else if(!strcmp(res->name, "rxpt")) 3476 rx_pthresh = res->value; 3477 else if(!strcmp(res->name, "rxht")) 3478 rx_hthresh = res->value; 3479 else if(!strcmp(res->name, "rxwt")) 3480 rx_wthresh = res->value; 3481 else { 3482 printf("Unknown parameter\n"); 3483 return; 3484 } 3485 3486 init_port_config(); 3487 3488 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3489 } 3490 3491 cmdline_parse_token_string_t cmd_config_thresh_port = 3492 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3493 cmdline_parse_token_string_t cmd_config_thresh_keyword = 3494 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3495 cmdline_parse_token_string_t cmd_config_thresh_all = 3496 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3497 cmdline_parse_token_string_t cmd_config_thresh_name = 3498 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3499 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3500 cmdline_parse_token_num_t cmd_config_thresh_value = 3501 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8); 3502 3503 cmdline_parse_inst_t cmd_config_thresh = { 3504 .f = cmd_config_thresh_parsed, 3505 .data = NULL, 3506 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3507 .tokens = { 3508 (void *)&cmd_config_thresh_port, 3509 (void *)&cmd_config_thresh_keyword, 3510 (void *)&cmd_config_thresh_all, 3511 (void *)&cmd_config_thresh_name, 3512 (void *)&cmd_config_thresh_value, 3513 NULL, 3514 }, 3515 }; 3516 3517 /* *** configure free/rs threshold *** */ 3518 struct cmd_config_threshold { 3519 cmdline_fixed_string_t port; 3520 cmdline_fixed_string_t keyword; 3521 cmdline_fixed_string_t all; 3522 cmdline_fixed_string_t name; 3523 uint16_t value; 3524 }; 3525 3526 static void 3527 cmd_config_threshold_parsed(void *parsed_result, 3528 __rte_unused struct cmdline *cl, 3529 __rte_unused void *data) 3530 { 3531 struct cmd_config_threshold *res = parsed_result; 3532 3533 if (!all_ports_stopped()) { 3534 printf("Please stop all ports first\n"); 3535 return; 3536 } 3537 3538 if (!strcmp(res->name, "txfreet")) 3539 tx_free_thresh = res->value; 3540 else if (!strcmp(res->name, "txrst")) 3541 tx_rs_thresh = res->value; 3542 else if (!strcmp(res->name, "rxfreet")) 3543 rx_free_thresh = res->value; 3544 else { 3545 printf("Unknown parameter\n"); 3546 return; 3547 } 3548 3549 init_port_config(); 3550 3551 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3552 } 3553 3554 cmdline_parse_token_string_t cmd_config_threshold_port = 3555 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3556 cmdline_parse_token_string_t cmd_config_threshold_keyword = 3557 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3558 "config"); 3559 cmdline_parse_token_string_t cmd_config_threshold_all = 3560 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3561 cmdline_parse_token_string_t cmd_config_threshold_name = 3562 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3563 "txfreet#txrst#rxfreet"); 3564 cmdline_parse_token_num_t cmd_config_threshold_value = 3565 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16); 3566 3567 cmdline_parse_inst_t cmd_config_threshold = { 3568 .f = cmd_config_threshold_parsed, 3569 .data = NULL, 3570 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3571 .tokens = { 3572 (void *)&cmd_config_threshold_port, 3573 (void *)&cmd_config_threshold_keyword, 3574 (void *)&cmd_config_threshold_all, 3575 (void *)&cmd_config_threshold_name, 3576 (void *)&cmd_config_threshold_value, 3577 NULL, 3578 }, 3579 }; 3580 3581 /* *** stop *** */ 3582 struct cmd_stop_result { 3583 cmdline_fixed_string_t stop; 3584 }; 3585 3586 static void cmd_stop_parsed(__rte_unused void *parsed_result, 3587 __rte_unused struct cmdline *cl, 3588 __rte_unused void *data) 3589 { 3590 stop_packet_forwarding(); 3591 } 3592 3593 cmdline_parse_token_string_t cmd_stop_stop = 3594 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3595 3596 cmdline_parse_inst_t cmd_stop = { 3597 .f = cmd_stop_parsed, 3598 .data = NULL, 3599 .help_str = "stop: Stop packet forwarding", 3600 .tokens = { 3601 (void *)&cmd_stop_stop, 3602 NULL, 3603 }, 3604 }; 3605 3606 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3607 3608 unsigned int 3609 parse_item_list(char* str, const char* item_name, unsigned int max_items, 3610 unsigned int *parsed_items, int check_unique_values) 3611 { 3612 unsigned int nb_item; 3613 unsigned int value; 3614 unsigned int i; 3615 unsigned int j; 3616 int value_ok; 3617 char c; 3618 3619 /* 3620 * First parse all items in the list and store their value. 3621 */ 3622 value = 0; 3623 nb_item = 0; 3624 value_ok = 0; 3625 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3626 c = str[i]; 3627 if ((c >= '0') && (c <= '9')) { 3628 value = (unsigned int) (value * 10 + (c - '0')); 3629 value_ok = 1; 3630 continue; 3631 } 3632 if (c != ',') { 3633 printf("character %c is not a decimal digit\n", c); 3634 return 0; 3635 } 3636 if (! value_ok) { 3637 printf("No valid value before comma\n"); 3638 return 0; 3639 } 3640 if (nb_item < max_items) { 3641 parsed_items[nb_item] = value; 3642 value_ok = 0; 3643 value = 0; 3644 } 3645 nb_item++; 3646 } 3647 if (nb_item >= max_items) { 3648 printf("Number of %s = %u > %u (maximum items)\n", 3649 item_name, nb_item + 1, max_items); 3650 return 0; 3651 } 3652 parsed_items[nb_item++] = value; 3653 if (! check_unique_values) 3654 return nb_item; 3655 3656 /* 3657 * Then, check that all values in the list are differents. 3658 * No optimization here... 3659 */ 3660 for (i = 0; i < nb_item; i++) { 3661 for (j = i + 1; j < nb_item; j++) { 3662 if (parsed_items[j] == parsed_items[i]) { 3663 printf("duplicated %s %u at index %u and %u\n", 3664 item_name, parsed_items[i], i, j); 3665 return 0; 3666 } 3667 } 3668 } 3669 return nb_item; 3670 } 3671 3672 struct cmd_set_list_result { 3673 cmdline_fixed_string_t cmd_keyword; 3674 cmdline_fixed_string_t list_name; 3675 cmdline_fixed_string_t list_of_items; 3676 }; 3677 3678 static void cmd_set_list_parsed(void *parsed_result, 3679 __rte_unused struct cmdline *cl, 3680 __rte_unused void *data) 3681 { 3682 struct cmd_set_list_result *res; 3683 union { 3684 unsigned int lcorelist[RTE_MAX_LCORE]; 3685 unsigned int portlist[RTE_MAX_ETHPORTS]; 3686 } parsed_items; 3687 unsigned int nb_item; 3688 3689 if (test_done == 0) { 3690 printf("Please stop forwarding first\n"); 3691 return; 3692 } 3693 3694 res = parsed_result; 3695 if (!strcmp(res->list_name, "corelist")) { 3696 nb_item = parse_item_list(res->list_of_items, "core", 3697 RTE_MAX_LCORE, 3698 parsed_items.lcorelist, 1); 3699 if (nb_item > 0) { 3700 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3701 fwd_config_setup(); 3702 } 3703 return; 3704 } 3705 if (!strcmp(res->list_name, "portlist")) { 3706 nb_item = parse_item_list(res->list_of_items, "port", 3707 RTE_MAX_ETHPORTS, 3708 parsed_items.portlist, 1); 3709 if (nb_item > 0) { 3710 set_fwd_ports_list(parsed_items.portlist, nb_item); 3711 fwd_config_setup(); 3712 } 3713 } 3714 } 3715 3716 cmdline_parse_token_string_t cmd_set_list_keyword = 3717 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3718 "set"); 3719 cmdline_parse_token_string_t cmd_set_list_name = 3720 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3721 "corelist#portlist"); 3722 cmdline_parse_token_string_t cmd_set_list_of_items = 3723 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3724 NULL); 3725 3726 cmdline_parse_inst_t cmd_set_fwd_list = { 3727 .f = cmd_set_list_parsed, 3728 .data = NULL, 3729 .help_str = "set corelist|portlist <list0[,list1]*>", 3730 .tokens = { 3731 (void *)&cmd_set_list_keyword, 3732 (void *)&cmd_set_list_name, 3733 (void *)&cmd_set_list_of_items, 3734 NULL, 3735 }, 3736 }; 3737 3738 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3739 3740 struct cmd_setmask_result { 3741 cmdline_fixed_string_t set; 3742 cmdline_fixed_string_t mask; 3743 uint64_t hexavalue; 3744 }; 3745 3746 static void cmd_set_mask_parsed(void *parsed_result, 3747 __rte_unused struct cmdline *cl, 3748 __rte_unused void *data) 3749 { 3750 struct cmd_setmask_result *res = parsed_result; 3751 3752 if (test_done == 0) { 3753 printf("Please stop forwarding first\n"); 3754 return; 3755 } 3756 if (!strcmp(res->mask, "coremask")) { 3757 set_fwd_lcores_mask(res->hexavalue); 3758 fwd_config_setup(); 3759 } else if (!strcmp(res->mask, "portmask")) { 3760 set_fwd_ports_mask(res->hexavalue); 3761 fwd_config_setup(); 3762 } 3763 } 3764 3765 cmdline_parse_token_string_t cmd_setmask_set = 3766 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3767 cmdline_parse_token_string_t cmd_setmask_mask = 3768 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3769 "coremask#portmask"); 3770 cmdline_parse_token_num_t cmd_setmask_value = 3771 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64); 3772 3773 cmdline_parse_inst_t cmd_set_fwd_mask = { 3774 .f = cmd_set_mask_parsed, 3775 .data = NULL, 3776 .help_str = "set coremask|portmask <hexadecimal value>", 3777 .tokens = { 3778 (void *)&cmd_setmask_set, 3779 (void *)&cmd_setmask_mask, 3780 (void *)&cmd_setmask_value, 3781 NULL, 3782 }, 3783 }; 3784 3785 /* 3786 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3787 */ 3788 struct cmd_set_result { 3789 cmdline_fixed_string_t set; 3790 cmdline_fixed_string_t what; 3791 uint16_t value; 3792 }; 3793 3794 static void cmd_set_parsed(void *parsed_result, 3795 __rte_unused struct cmdline *cl, 3796 __rte_unused void *data) 3797 { 3798 struct cmd_set_result *res = parsed_result; 3799 if (!strcmp(res->what, "nbport")) { 3800 set_fwd_ports_number(res->value); 3801 fwd_config_setup(); 3802 } else if (!strcmp(res->what, "nbcore")) { 3803 set_fwd_lcores_number(res->value); 3804 fwd_config_setup(); 3805 } else if (!strcmp(res->what, "burst")) 3806 set_nb_pkt_per_burst(res->value); 3807 else if (!strcmp(res->what, "verbose")) 3808 set_verbose_level(res->value); 3809 } 3810 3811 cmdline_parse_token_string_t cmd_set_set = 3812 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3813 cmdline_parse_token_string_t cmd_set_what = 3814 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3815 "nbport#nbcore#burst#verbose"); 3816 cmdline_parse_token_num_t cmd_set_value = 3817 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16); 3818 3819 cmdline_parse_inst_t cmd_set_numbers = { 3820 .f = cmd_set_parsed, 3821 .data = NULL, 3822 .help_str = "set nbport|nbcore|burst|verbose <value>", 3823 .tokens = { 3824 (void *)&cmd_set_set, 3825 (void *)&cmd_set_what, 3826 (void *)&cmd_set_value, 3827 NULL, 3828 }, 3829 }; 3830 3831 /* *** SET LOG LEVEL CONFIGURATION *** */ 3832 3833 struct cmd_set_log_result { 3834 cmdline_fixed_string_t set; 3835 cmdline_fixed_string_t log; 3836 cmdline_fixed_string_t type; 3837 uint32_t level; 3838 }; 3839 3840 static void 3841 cmd_set_log_parsed(void *parsed_result, 3842 __rte_unused struct cmdline *cl, 3843 __rte_unused void *data) 3844 { 3845 struct cmd_set_log_result *res; 3846 int ret; 3847 3848 res = parsed_result; 3849 if (!strcmp(res->type, "global")) 3850 rte_log_set_global_level(res->level); 3851 else { 3852 ret = rte_log_set_level_regexp(res->type, res->level); 3853 if (ret < 0) 3854 printf("Unable to set log level\n"); 3855 } 3856 } 3857 3858 cmdline_parse_token_string_t cmd_set_log_set = 3859 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3860 cmdline_parse_token_string_t cmd_set_log_log = 3861 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3862 cmdline_parse_token_string_t cmd_set_log_type = 3863 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3864 cmdline_parse_token_num_t cmd_set_log_level = 3865 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32); 3866 3867 cmdline_parse_inst_t cmd_set_log = { 3868 .f = cmd_set_log_parsed, 3869 .data = NULL, 3870 .help_str = "set log global|<type> <level>", 3871 .tokens = { 3872 (void *)&cmd_set_log_set, 3873 (void *)&cmd_set_log_log, 3874 (void *)&cmd_set_log_type, 3875 (void *)&cmd_set_log_level, 3876 NULL, 3877 }, 3878 }; 3879 3880 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */ 3881 3882 struct cmd_set_rxoffs_result { 3883 cmdline_fixed_string_t cmd_keyword; 3884 cmdline_fixed_string_t rxoffs; 3885 cmdline_fixed_string_t seg_offsets; 3886 }; 3887 3888 static void 3889 cmd_set_rxoffs_parsed(void *parsed_result, 3890 __rte_unused struct cmdline *cl, 3891 __rte_unused void *data) 3892 { 3893 struct cmd_set_rxoffs_result *res; 3894 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT]; 3895 unsigned int nb_segs; 3896 3897 res = parsed_result; 3898 nb_segs = parse_item_list(res->seg_offsets, "segment offsets", 3899 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0); 3900 if (nb_segs > 0) 3901 set_rx_pkt_offsets(seg_offsets, nb_segs); 3902 } 3903 3904 cmdline_parse_token_string_t cmd_set_rxoffs_keyword = 3905 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3906 cmd_keyword, "set"); 3907 cmdline_parse_token_string_t cmd_set_rxoffs_name = 3908 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3909 rxoffs, "rxoffs"); 3910 cmdline_parse_token_string_t cmd_set_rxoffs_offsets = 3911 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3912 seg_offsets, NULL); 3913 3914 cmdline_parse_inst_t cmd_set_rxoffs = { 3915 .f = cmd_set_rxoffs_parsed, 3916 .data = NULL, 3917 .help_str = "set rxoffs <len0[,len1]*>", 3918 .tokens = { 3919 (void *)&cmd_set_rxoffs_keyword, 3920 (void *)&cmd_set_rxoffs_name, 3921 (void *)&cmd_set_rxoffs_offsets, 3922 NULL, 3923 }, 3924 }; 3925 3926 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */ 3927 3928 struct cmd_set_rxpkts_result { 3929 cmdline_fixed_string_t cmd_keyword; 3930 cmdline_fixed_string_t rxpkts; 3931 cmdline_fixed_string_t seg_lengths; 3932 }; 3933 3934 static void 3935 cmd_set_rxpkts_parsed(void *parsed_result, 3936 __rte_unused struct cmdline *cl, 3937 __rte_unused void *data) 3938 { 3939 struct cmd_set_rxpkts_result *res; 3940 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT]; 3941 unsigned int nb_segs; 3942 3943 res = parsed_result; 3944 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3945 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0); 3946 if (nb_segs > 0) 3947 set_rx_pkt_segments(seg_lengths, nb_segs); 3948 } 3949 3950 cmdline_parse_token_string_t cmd_set_rxpkts_keyword = 3951 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3952 cmd_keyword, "set"); 3953 cmdline_parse_token_string_t cmd_set_rxpkts_name = 3954 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3955 rxpkts, "rxpkts"); 3956 cmdline_parse_token_string_t cmd_set_rxpkts_lengths = 3957 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3958 seg_lengths, NULL); 3959 3960 cmdline_parse_inst_t cmd_set_rxpkts = { 3961 .f = cmd_set_rxpkts_parsed, 3962 .data = NULL, 3963 .help_str = "set rxpkts <len0[,len1]*>", 3964 .tokens = { 3965 (void *)&cmd_set_rxpkts_keyword, 3966 (void *)&cmd_set_rxpkts_name, 3967 (void *)&cmd_set_rxpkts_lengths, 3968 NULL, 3969 }, 3970 }; 3971 3972 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3973 3974 struct cmd_set_txpkts_result { 3975 cmdline_fixed_string_t cmd_keyword; 3976 cmdline_fixed_string_t txpkts; 3977 cmdline_fixed_string_t seg_lengths; 3978 }; 3979 3980 static void 3981 cmd_set_txpkts_parsed(void *parsed_result, 3982 __rte_unused struct cmdline *cl, 3983 __rte_unused void *data) 3984 { 3985 struct cmd_set_txpkts_result *res; 3986 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3987 unsigned int nb_segs; 3988 3989 res = parsed_result; 3990 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3991 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3992 if (nb_segs > 0) 3993 set_tx_pkt_segments(seg_lengths, nb_segs); 3994 } 3995 3996 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 3997 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3998 cmd_keyword, "set"); 3999 cmdline_parse_token_string_t cmd_set_txpkts_name = 4000 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 4001 txpkts, "txpkts"); 4002 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 4003 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 4004 seg_lengths, NULL); 4005 4006 cmdline_parse_inst_t cmd_set_txpkts = { 4007 .f = cmd_set_txpkts_parsed, 4008 .data = NULL, 4009 .help_str = "set txpkts <len0[,len1]*>", 4010 .tokens = { 4011 (void *)&cmd_set_txpkts_keyword, 4012 (void *)&cmd_set_txpkts_name, 4013 (void *)&cmd_set_txpkts_lengths, 4014 NULL, 4015 }, 4016 }; 4017 4018 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 4019 4020 struct cmd_set_txsplit_result { 4021 cmdline_fixed_string_t cmd_keyword; 4022 cmdline_fixed_string_t txsplit; 4023 cmdline_fixed_string_t mode; 4024 }; 4025 4026 static void 4027 cmd_set_txsplit_parsed(void *parsed_result, 4028 __rte_unused struct cmdline *cl, 4029 __rte_unused void *data) 4030 { 4031 struct cmd_set_txsplit_result *res; 4032 4033 res = parsed_result; 4034 set_tx_pkt_split(res->mode); 4035 } 4036 4037 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 4038 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 4039 cmd_keyword, "set"); 4040 cmdline_parse_token_string_t cmd_set_txsplit_name = 4041 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 4042 txsplit, "txsplit"); 4043 cmdline_parse_token_string_t cmd_set_txsplit_mode = 4044 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 4045 mode, NULL); 4046 4047 cmdline_parse_inst_t cmd_set_txsplit = { 4048 .f = cmd_set_txsplit_parsed, 4049 .data = NULL, 4050 .help_str = "set txsplit on|off|rand", 4051 .tokens = { 4052 (void *)&cmd_set_txsplit_keyword, 4053 (void *)&cmd_set_txsplit_name, 4054 (void *)&cmd_set_txsplit_mode, 4055 NULL, 4056 }, 4057 }; 4058 4059 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */ 4060 4061 struct cmd_set_txtimes_result { 4062 cmdline_fixed_string_t cmd_keyword; 4063 cmdline_fixed_string_t txtimes; 4064 cmdline_fixed_string_t tx_times; 4065 }; 4066 4067 static void 4068 cmd_set_txtimes_parsed(void *parsed_result, 4069 __rte_unused struct cmdline *cl, 4070 __rte_unused void *data) 4071 { 4072 struct cmd_set_txtimes_result *res; 4073 unsigned int tx_times[2] = {0, 0}; 4074 unsigned int n_times; 4075 4076 res = parsed_result; 4077 n_times = parse_item_list(res->tx_times, "tx times", 4078 2, tx_times, 0); 4079 if (n_times == 2) 4080 set_tx_pkt_times(tx_times); 4081 } 4082 4083 cmdline_parse_token_string_t cmd_set_txtimes_keyword = 4084 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 4085 cmd_keyword, "set"); 4086 cmdline_parse_token_string_t cmd_set_txtimes_name = 4087 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 4088 txtimes, "txtimes"); 4089 cmdline_parse_token_string_t cmd_set_txtimes_value = 4090 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 4091 tx_times, NULL); 4092 4093 cmdline_parse_inst_t cmd_set_txtimes = { 4094 .f = cmd_set_txtimes_parsed, 4095 .data = NULL, 4096 .help_str = "set txtimes <inter_burst>,<intra_burst>", 4097 .tokens = { 4098 (void *)&cmd_set_txtimes_keyword, 4099 (void *)&cmd_set_txtimes_name, 4100 (void *)&cmd_set_txtimes_value, 4101 NULL, 4102 }, 4103 }; 4104 4105 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 4106 struct cmd_rx_vlan_filter_all_result { 4107 cmdline_fixed_string_t rx_vlan; 4108 cmdline_fixed_string_t what; 4109 cmdline_fixed_string_t all; 4110 portid_t port_id; 4111 }; 4112 4113 static void 4114 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 4115 __rte_unused struct cmdline *cl, 4116 __rte_unused void *data) 4117 { 4118 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 4119 4120 if (!strcmp(res->what, "add")) 4121 rx_vlan_all_filter_set(res->port_id, 1); 4122 else 4123 rx_vlan_all_filter_set(res->port_id, 0); 4124 } 4125 4126 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 4127 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4128 rx_vlan, "rx_vlan"); 4129 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 4130 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4131 what, "add#rm"); 4132 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 4133 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4134 all, "all"); 4135 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 4136 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4137 port_id, UINT16); 4138 4139 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 4140 .f = cmd_rx_vlan_filter_all_parsed, 4141 .data = NULL, 4142 .help_str = "rx_vlan add|rm all <port_id>: " 4143 "Add/Remove all identifiers to/from the set of VLAN " 4144 "identifiers filtered by a port", 4145 .tokens = { 4146 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 4147 (void *)&cmd_rx_vlan_filter_all_what, 4148 (void *)&cmd_rx_vlan_filter_all_all, 4149 (void *)&cmd_rx_vlan_filter_all_portid, 4150 NULL, 4151 }, 4152 }; 4153 4154 /* *** VLAN OFFLOAD SET ON A PORT *** */ 4155 struct cmd_vlan_offload_result { 4156 cmdline_fixed_string_t vlan; 4157 cmdline_fixed_string_t set; 4158 cmdline_fixed_string_t vlan_type; 4159 cmdline_fixed_string_t what; 4160 cmdline_fixed_string_t on; 4161 cmdline_fixed_string_t port_id; 4162 }; 4163 4164 static void 4165 cmd_vlan_offload_parsed(void *parsed_result, 4166 __rte_unused struct cmdline *cl, 4167 __rte_unused void *data) 4168 { 4169 int on; 4170 struct cmd_vlan_offload_result *res = parsed_result; 4171 char *str; 4172 int i, len = 0; 4173 portid_t port_id = 0; 4174 unsigned int tmp; 4175 4176 str = res->port_id; 4177 len = strnlen(str, STR_TOKEN_SIZE); 4178 i = 0; 4179 /* Get port_id first */ 4180 while(i < len){ 4181 if(str[i] == ',') 4182 break; 4183 4184 i++; 4185 } 4186 str[i]='\0'; 4187 tmp = strtoul(str, NULL, 0); 4188 /* If port_id greater that what portid_t can represent, return */ 4189 if(tmp >= RTE_MAX_ETHPORTS) 4190 return; 4191 port_id = (portid_t)tmp; 4192 4193 if (!strcmp(res->on, "on")) 4194 on = 1; 4195 else 4196 on = 0; 4197 4198 if (!strcmp(res->what, "strip")) 4199 rx_vlan_strip_set(port_id, on); 4200 else if(!strcmp(res->what, "stripq")){ 4201 uint16_t queue_id = 0; 4202 4203 /* No queue_id, return */ 4204 if(i + 1 >= len) { 4205 printf("must specify (port,queue_id)\n"); 4206 return; 4207 } 4208 tmp = strtoul(str + i + 1, NULL, 0); 4209 /* If queue_id greater that what 16-bits can represent, return */ 4210 if(tmp > 0xffff) 4211 return; 4212 4213 queue_id = (uint16_t)tmp; 4214 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 4215 } 4216 else if (!strcmp(res->what, "filter")) 4217 rx_vlan_filter_set(port_id, on); 4218 else if (!strcmp(res->what, "qinq_strip")) 4219 rx_vlan_qinq_strip_set(port_id, on); 4220 else 4221 vlan_extend_set(port_id, on); 4222 4223 return; 4224 } 4225 4226 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 4227 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4228 vlan, "vlan"); 4229 cmdline_parse_token_string_t cmd_vlan_offload_set = 4230 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4231 set, "set"); 4232 cmdline_parse_token_string_t cmd_vlan_offload_what = 4233 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4234 what, "strip#filter#qinq_strip#extend#stripq"); 4235 cmdline_parse_token_string_t cmd_vlan_offload_on = 4236 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4237 on, "on#off"); 4238 cmdline_parse_token_string_t cmd_vlan_offload_portid = 4239 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4240 port_id, NULL); 4241 4242 cmdline_parse_inst_t cmd_vlan_offload = { 4243 .f = cmd_vlan_offload_parsed, 4244 .data = NULL, 4245 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off " 4246 "<port_id[,queue_id]>: " 4247 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides", 4248 .tokens = { 4249 (void *)&cmd_vlan_offload_vlan, 4250 (void *)&cmd_vlan_offload_set, 4251 (void *)&cmd_vlan_offload_what, 4252 (void *)&cmd_vlan_offload_on, 4253 (void *)&cmd_vlan_offload_portid, 4254 NULL, 4255 }, 4256 }; 4257 4258 /* *** VLAN TPID SET ON A PORT *** */ 4259 struct cmd_vlan_tpid_result { 4260 cmdline_fixed_string_t vlan; 4261 cmdline_fixed_string_t set; 4262 cmdline_fixed_string_t vlan_type; 4263 cmdline_fixed_string_t what; 4264 uint16_t tp_id; 4265 portid_t port_id; 4266 }; 4267 4268 static void 4269 cmd_vlan_tpid_parsed(void *parsed_result, 4270 __rte_unused struct cmdline *cl, 4271 __rte_unused void *data) 4272 { 4273 struct cmd_vlan_tpid_result *res = parsed_result; 4274 enum rte_vlan_type vlan_type; 4275 4276 if (!strcmp(res->vlan_type, "inner")) 4277 vlan_type = ETH_VLAN_TYPE_INNER; 4278 else if (!strcmp(res->vlan_type, "outer")) 4279 vlan_type = ETH_VLAN_TYPE_OUTER; 4280 else { 4281 printf("Unknown vlan type\n"); 4282 return; 4283 } 4284 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 4285 } 4286 4287 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 4288 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4289 vlan, "vlan"); 4290 cmdline_parse_token_string_t cmd_vlan_tpid_set = 4291 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4292 set, "set"); 4293 cmdline_parse_token_string_t cmd_vlan_type = 4294 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4295 vlan_type, "inner#outer"); 4296 cmdline_parse_token_string_t cmd_vlan_tpid_what = 4297 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4298 what, "tpid"); 4299 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 4300 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4301 tp_id, UINT16); 4302 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 4303 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4304 port_id, UINT16); 4305 4306 cmdline_parse_inst_t cmd_vlan_tpid = { 4307 .f = cmd_vlan_tpid_parsed, 4308 .data = NULL, 4309 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 4310 "Set the VLAN Ether type", 4311 .tokens = { 4312 (void *)&cmd_vlan_tpid_vlan, 4313 (void *)&cmd_vlan_tpid_set, 4314 (void *)&cmd_vlan_type, 4315 (void *)&cmd_vlan_tpid_what, 4316 (void *)&cmd_vlan_tpid_tpid, 4317 (void *)&cmd_vlan_tpid_portid, 4318 NULL, 4319 }, 4320 }; 4321 4322 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 4323 struct cmd_rx_vlan_filter_result { 4324 cmdline_fixed_string_t rx_vlan; 4325 cmdline_fixed_string_t what; 4326 uint16_t vlan_id; 4327 portid_t port_id; 4328 }; 4329 4330 static void 4331 cmd_rx_vlan_filter_parsed(void *parsed_result, 4332 __rte_unused struct cmdline *cl, 4333 __rte_unused void *data) 4334 { 4335 struct cmd_rx_vlan_filter_result *res = parsed_result; 4336 4337 if (!strcmp(res->what, "add")) 4338 rx_vft_set(res->port_id, res->vlan_id, 1); 4339 else 4340 rx_vft_set(res->port_id, res->vlan_id, 0); 4341 } 4342 4343 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 4344 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4345 rx_vlan, "rx_vlan"); 4346 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 4347 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4348 what, "add#rm"); 4349 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 4350 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4351 vlan_id, UINT16); 4352 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 4353 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4354 port_id, UINT16); 4355 4356 cmdline_parse_inst_t cmd_rx_vlan_filter = { 4357 .f = cmd_rx_vlan_filter_parsed, 4358 .data = NULL, 4359 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 4360 "Add/Remove a VLAN identifier to/from the set of VLAN " 4361 "identifiers filtered by a port", 4362 .tokens = { 4363 (void *)&cmd_rx_vlan_filter_rx_vlan, 4364 (void *)&cmd_rx_vlan_filter_what, 4365 (void *)&cmd_rx_vlan_filter_vlanid, 4366 (void *)&cmd_rx_vlan_filter_portid, 4367 NULL, 4368 }, 4369 }; 4370 4371 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4372 struct cmd_tx_vlan_set_result { 4373 cmdline_fixed_string_t tx_vlan; 4374 cmdline_fixed_string_t set; 4375 portid_t port_id; 4376 uint16_t vlan_id; 4377 }; 4378 4379 static void 4380 cmd_tx_vlan_set_parsed(void *parsed_result, 4381 __rte_unused struct cmdline *cl, 4382 __rte_unused void *data) 4383 { 4384 struct cmd_tx_vlan_set_result *res = parsed_result; 4385 4386 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4387 return; 4388 4389 if (!port_is_stopped(res->port_id)) { 4390 printf("Please stop port %d first\n", res->port_id); 4391 return; 4392 } 4393 4394 tx_vlan_set(res->port_id, res->vlan_id); 4395 4396 cmd_reconfig_device_queue(res->port_id, 1, 1); 4397 } 4398 4399 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 4400 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4401 tx_vlan, "tx_vlan"); 4402 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 4403 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4404 set, "set"); 4405 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 4406 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4407 port_id, UINT16); 4408 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 4409 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4410 vlan_id, UINT16); 4411 4412 cmdline_parse_inst_t cmd_tx_vlan_set = { 4413 .f = cmd_tx_vlan_set_parsed, 4414 .data = NULL, 4415 .help_str = "tx_vlan set <port_id> <vlan_id>: " 4416 "Enable hardware insertion of a single VLAN header " 4417 "with a given TAG Identifier in packets sent on a port", 4418 .tokens = { 4419 (void *)&cmd_tx_vlan_set_tx_vlan, 4420 (void *)&cmd_tx_vlan_set_set, 4421 (void *)&cmd_tx_vlan_set_portid, 4422 (void *)&cmd_tx_vlan_set_vlanid, 4423 NULL, 4424 }, 4425 }; 4426 4427 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 4428 struct cmd_tx_vlan_set_qinq_result { 4429 cmdline_fixed_string_t tx_vlan; 4430 cmdline_fixed_string_t set; 4431 portid_t port_id; 4432 uint16_t vlan_id; 4433 uint16_t vlan_id_outer; 4434 }; 4435 4436 static void 4437 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 4438 __rte_unused struct cmdline *cl, 4439 __rte_unused void *data) 4440 { 4441 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 4442 4443 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4444 return; 4445 4446 if (!port_is_stopped(res->port_id)) { 4447 printf("Please stop port %d first\n", res->port_id); 4448 return; 4449 } 4450 4451 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 4452 4453 cmd_reconfig_device_queue(res->port_id, 1, 1); 4454 } 4455 4456 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 4457 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4458 tx_vlan, "tx_vlan"); 4459 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 4460 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4461 set, "set"); 4462 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 4463 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4464 port_id, UINT16); 4465 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 4466 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4467 vlan_id, UINT16); 4468 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 4469 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4470 vlan_id_outer, UINT16); 4471 4472 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 4473 .f = cmd_tx_vlan_set_qinq_parsed, 4474 .data = NULL, 4475 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 4476 "Enable hardware insertion of double VLAN header " 4477 "with given TAG Identifiers in packets sent on a port", 4478 .tokens = { 4479 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 4480 (void *)&cmd_tx_vlan_set_qinq_set, 4481 (void *)&cmd_tx_vlan_set_qinq_portid, 4482 (void *)&cmd_tx_vlan_set_qinq_vlanid, 4483 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 4484 NULL, 4485 }, 4486 }; 4487 4488 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 4489 struct cmd_tx_vlan_set_pvid_result { 4490 cmdline_fixed_string_t tx_vlan; 4491 cmdline_fixed_string_t set; 4492 cmdline_fixed_string_t pvid; 4493 portid_t port_id; 4494 uint16_t vlan_id; 4495 cmdline_fixed_string_t mode; 4496 }; 4497 4498 static void 4499 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 4500 __rte_unused struct cmdline *cl, 4501 __rte_unused void *data) 4502 { 4503 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 4504 4505 if (strcmp(res->mode, "on") == 0) 4506 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 4507 else 4508 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 4509 } 4510 4511 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 4512 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4513 tx_vlan, "tx_vlan"); 4514 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 4515 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4516 set, "set"); 4517 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 4518 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4519 pvid, "pvid"); 4520 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 4521 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4522 port_id, UINT16); 4523 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 4524 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4525 vlan_id, UINT16); 4526 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 4527 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4528 mode, "on#off"); 4529 4530 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 4531 .f = cmd_tx_vlan_set_pvid_parsed, 4532 .data = NULL, 4533 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 4534 .tokens = { 4535 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 4536 (void *)&cmd_tx_vlan_set_pvid_set, 4537 (void *)&cmd_tx_vlan_set_pvid_pvid, 4538 (void *)&cmd_tx_vlan_set_pvid_port_id, 4539 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 4540 (void *)&cmd_tx_vlan_set_pvid_mode, 4541 NULL, 4542 }, 4543 }; 4544 4545 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4546 struct cmd_tx_vlan_reset_result { 4547 cmdline_fixed_string_t tx_vlan; 4548 cmdline_fixed_string_t reset; 4549 portid_t port_id; 4550 }; 4551 4552 static void 4553 cmd_tx_vlan_reset_parsed(void *parsed_result, 4554 __rte_unused struct cmdline *cl, 4555 __rte_unused void *data) 4556 { 4557 struct cmd_tx_vlan_reset_result *res = parsed_result; 4558 4559 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4560 return; 4561 4562 if (!port_is_stopped(res->port_id)) { 4563 printf("Please stop port %d first\n", res->port_id); 4564 return; 4565 } 4566 4567 tx_vlan_reset(res->port_id); 4568 4569 cmd_reconfig_device_queue(res->port_id, 1, 1); 4570 } 4571 4572 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4573 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4574 tx_vlan, "tx_vlan"); 4575 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4576 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4577 reset, "reset"); 4578 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4579 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4580 port_id, UINT16); 4581 4582 cmdline_parse_inst_t cmd_tx_vlan_reset = { 4583 .f = cmd_tx_vlan_reset_parsed, 4584 .data = NULL, 4585 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4586 "VLAN header in packets sent on a port", 4587 .tokens = { 4588 (void *)&cmd_tx_vlan_reset_tx_vlan, 4589 (void *)&cmd_tx_vlan_reset_reset, 4590 (void *)&cmd_tx_vlan_reset_portid, 4591 NULL, 4592 }, 4593 }; 4594 4595 4596 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4597 struct cmd_csum_result { 4598 cmdline_fixed_string_t csum; 4599 cmdline_fixed_string_t mode; 4600 cmdline_fixed_string_t proto; 4601 cmdline_fixed_string_t hwsw; 4602 portid_t port_id; 4603 }; 4604 4605 static void 4606 csum_show(int port_id) 4607 { 4608 struct rte_eth_dev_info dev_info; 4609 uint64_t tx_offloads; 4610 int ret; 4611 4612 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4613 printf("Parse tunnel is %s\n", 4614 (ports[port_id].parse_tunnel) ? "on" : "off"); 4615 printf("IP checksum offload is %s\n", 4616 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4617 printf("UDP checksum offload is %s\n", 4618 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4619 printf("TCP checksum offload is %s\n", 4620 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4621 printf("SCTP checksum offload is %s\n", 4622 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4623 printf("Outer-Ip checksum offload is %s\n", 4624 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4625 printf("Outer-Udp checksum offload is %s\n", 4626 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); 4627 4628 /* display warnings if configuration is not supported by the NIC */ 4629 ret = eth_dev_info_get_print_err(port_id, &dev_info); 4630 if (ret != 0) 4631 return; 4632 4633 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 4634 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4635 printf("Warning: hardware IP checksum enabled but not " 4636 "supported by port %d\n", port_id); 4637 } 4638 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 4639 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 4640 printf("Warning: hardware UDP checksum enabled but not " 4641 "supported by port %d\n", port_id); 4642 } 4643 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 4644 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 4645 printf("Warning: hardware TCP checksum enabled but not " 4646 "supported by port %d\n", port_id); 4647 } 4648 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 4649 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4650 printf("Warning: hardware SCTP checksum enabled but not " 4651 "supported by port %d\n", port_id); 4652 } 4653 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4654 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4655 printf("Warning: hardware outer IP checksum enabled but not " 4656 "supported by port %d\n", port_id); 4657 } 4658 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) && 4659 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) 4660 == 0) { 4661 printf("Warning: hardware outer UDP checksum enabled but not " 4662 "supported by port %d\n", port_id); 4663 } 4664 } 4665 4666 static void 4667 cmd_config_queue_tx_offloads(struct rte_port *port) 4668 { 4669 int k; 4670 4671 /* Apply queue tx offloads configuration */ 4672 for (k = 0; k < port->dev_info.max_rx_queues; k++) 4673 port->tx_conf[k].offloads = 4674 port->dev_conf.txmode.offloads; 4675 } 4676 4677 static void 4678 cmd_csum_parsed(void *parsed_result, 4679 __rte_unused struct cmdline *cl, 4680 __rte_unused void *data) 4681 { 4682 struct cmd_csum_result *res = parsed_result; 4683 int hw = 0; 4684 uint64_t csum_offloads = 0; 4685 struct rte_eth_dev_info dev_info; 4686 int ret; 4687 4688 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4689 printf("invalid port %d\n", res->port_id); 4690 return; 4691 } 4692 if (!port_is_stopped(res->port_id)) { 4693 printf("Please stop port %d first\n", res->port_id); 4694 return; 4695 } 4696 4697 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4698 if (ret != 0) 4699 return; 4700 4701 if (!strcmp(res->mode, "set")) { 4702 4703 if (!strcmp(res->hwsw, "hw")) 4704 hw = 1; 4705 4706 if (!strcmp(res->proto, "ip")) { 4707 if (hw == 0 || (dev_info.tx_offload_capa & 4708 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 4709 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 4710 } else { 4711 printf("IP checksum offload is not supported " 4712 "by port %u\n", res->port_id); 4713 } 4714 } else if (!strcmp(res->proto, "udp")) { 4715 if (hw == 0 || (dev_info.tx_offload_capa & 4716 DEV_TX_OFFLOAD_UDP_CKSUM)) { 4717 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 4718 } else { 4719 printf("UDP checksum offload is not supported " 4720 "by port %u\n", res->port_id); 4721 } 4722 } else if (!strcmp(res->proto, "tcp")) { 4723 if (hw == 0 || (dev_info.tx_offload_capa & 4724 DEV_TX_OFFLOAD_TCP_CKSUM)) { 4725 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 4726 } else { 4727 printf("TCP checksum offload is not supported " 4728 "by port %u\n", res->port_id); 4729 } 4730 } else if (!strcmp(res->proto, "sctp")) { 4731 if (hw == 0 || (dev_info.tx_offload_capa & 4732 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 4733 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 4734 } else { 4735 printf("SCTP checksum offload is not supported " 4736 "by port %u\n", res->port_id); 4737 } 4738 } else if (!strcmp(res->proto, "outer-ip")) { 4739 if (hw == 0 || (dev_info.tx_offload_capa & 4740 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4741 csum_offloads |= 4742 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4743 } else { 4744 printf("Outer IP checksum offload is not " 4745 "supported by port %u\n", res->port_id); 4746 } 4747 } else if (!strcmp(res->proto, "outer-udp")) { 4748 if (hw == 0 || (dev_info.tx_offload_capa & 4749 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) { 4750 csum_offloads |= 4751 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; 4752 } else { 4753 printf("Outer UDP checksum offload is not " 4754 "supported by port %u\n", res->port_id); 4755 } 4756 } 4757 4758 if (hw) { 4759 ports[res->port_id].dev_conf.txmode.offloads |= 4760 csum_offloads; 4761 } else { 4762 ports[res->port_id].dev_conf.txmode.offloads &= 4763 (~csum_offloads); 4764 } 4765 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4766 } 4767 csum_show(res->port_id); 4768 4769 cmd_reconfig_device_queue(res->port_id, 1, 1); 4770 } 4771 4772 cmdline_parse_token_string_t cmd_csum_csum = 4773 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4774 csum, "csum"); 4775 cmdline_parse_token_string_t cmd_csum_mode = 4776 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4777 mode, "set"); 4778 cmdline_parse_token_string_t cmd_csum_proto = 4779 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4780 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); 4781 cmdline_parse_token_string_t cmd_csum_hwsw = 4782 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4783 hwsw, "hw#sw"); 4784 cmdline_parse_token_num_t cmd_csum_portid = 4785 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4786 port_id, UINT16); 4787 4788 cmdline_parse_inst_t cmd_csum_set = { 4789 .f = cmd_csum_parsed, 4790 .data = NULL, 4791 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: " 4792 "Enable/Disable hardware calculation of L3/L4 checksum when " 4793 "using csum forward engine", 4794 .tokens = { 4795 (void *)&cmd_csum_csum, 4796 (void *)&cmd_csum_mode, 4797 (void *)&cmd_csum_proto, 4798 (void *)&cmd_csum_hwsw, 4799 (void *)&cmd_csum_portid, 4800 NULL, 4801 }, 4802 }; 4803 4804 cmdline_parse_token_string_t cmd_csum_mode_show = 4805 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4806 mode, "show"); 4807 4808 cmdline_parse_inst_t cmd_csum_show = { 4809 .f = cmd_csum_parsed, 4810 .data = NULL, 4811 .help_str = "csum show <port_id>: Show checksum offload configuration", 4812 .tokens = { 4813 (void *)&cmd_csum_csum, 4814 (void *)&cmd_csum_mode_show, 4815 (void *)&cmd_csum_portid, 4816 NULL, 4817 }, 4818 }; 4819 4820 /* Enable/disable tunnel parsing */ 4821 struct cmd_csum_tunnel_result { 4822 cmdline_fixed_string_t csum; 4823 cmdline_fixed_string_t parse; 4824 cmdline_fixed_string_t onoff; 4825 portid_t port_id; 4826 }; 4827 4828 static void 4829 cmd_csum_tunnel_parsed(void *parsed_result, 4830 __rte_unused struct cmdline *cl, 4831 __rte_unused void *data) 4832 { 4833 struct cmd_csum_tunnel_result *res = parsed_result; 4834 4835 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4836 return; 4837 4838 if (!strcmp(res->onoff, "on")) 4839 ports[res->port_id].parse_tunnel = 1; 4840 else 4841 ports[res->port_id].parse_tunnel = 0; 4842 4843 csum_show(res->port_id); 4844 } 4845 4846 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4847 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4848 csum, "csum"); 4849 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4850 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4851 parse, "parse-tunnel"); 4852 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4853 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4854 onoff, "on#off"); 4855 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4856 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4857 port_id, UINT16); 4858 4859 cmdline_parse_inst_t cmd_csum_tunnel = { 4860 .f = cmd_csum_tunnel_parsed, 4861 .data = NULL, 4862 .help_str = "csum parse-tunnel on|off <port_id>: " 4863 "Enable/Disable parsing of tunnels for csum engine", 4864 .tokens = { 4865 (void *)&cmd_csum_tunnel_csum, 4866 (void *)&cmd_csum_tunnel_parse, 4867 (void *)&cmd_csum_tunnel_onoff, 4868 (void *)&cmd_csum_tunnel_portid, 4869 NULL, 4870 }, 4871 }; 4872 4873 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4874 struct cmd_tso_set_result { 4875 cmdline_fixed_string_t tso; 4876 cmdline_fixed_string_t mode; 4877 uint16_t tso_segsz; 4878 portid_t port_id; 4879 }; 4880 4881 static void 4882 cmd_tso_set_parsed(void *parsed_result, 4883 __rte_unused struct cmdline *cl, 4884 __rte_unused void *data) 4885 { 4886 struct cmd_tso_set_result *res = parsed_result; 4887 struct rte_eth_dev_info dev_info; 4888 int ret; 4889 4890 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4891 return; 4892 if (!port_is_stopped(res->port_id)) { 4893 printf("Please stop port %d first\n", res->port_id); 4894 return; 4895 } 4896 4897 if (!strcmp(res->mode, "set")) 4898 ports[res->port_id].tso_segsz = res->tso_segsz; 4899 4900 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4901 if (ret != 0) 4902 return; 4903 4904 if ((ports[res->port_id].tso_segsz != 0) && 4905 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4906 printf("Error: TSO is not supported by port %d\n", 4907 res->port_id); 4908 return; 4909 } 4910 4911 if (ports[res->port_id].tso_segsz == 0) { 4912 ports[res->port_id].dev_conf.txmode.offloads &= 4913 ~DEV_TX_OFFLOAD_TCP_TSO; 4914 printf("TSO for non-tunneled packets is disabled\n"); 4915 } else { 4916 ports[res->port_id].dev_conf.txmode.offloads |= 4917 DEV_TX_OFFLOAD_TCP_TSO; 4918 printf("TSO segment size for non-tunneled packets is %d\n", 4919 ports[res->port_id].tso_segsz); 4920 } 4921 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4922 4923 /* display warnings if configuration is not supported by the NIC */ 4924 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4925 if (ret != 0) 4926 return; 4927 4928 if ((ports[res->port_id].tso_segsz != 0) && 4929 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4930 printf("Warning: TSO enabled but not " 4931 "supported by port %d\n", res->port_id); 4932 } 4933 4934 cmd_reconfig_device_queue(res->port_id, 1, 1); 4935 } 4936 4937 cmdline_parse_token_string_t cmd_tso_set_tso = 4938 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4939 tso, "tso"); 4940 cmdline_parse_token_string_t cmd_tso_set_mode = 4941 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4942 mode, "set"); 4943 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4944 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4945 tso_segsz, UINT16); 4946 cmdline_parse_token_num_t cmd_tso_set_portid = 4947 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4948 port_id, UINT16); 4949 4950 cmdline_parse_inst_t cmd_tso_set = { 4951 .f = cmd_tso_set_parsed, 4952 .data = NULL, 4953 .help_str = "tso set <tso_segsz> <port_id>: " 4954 "Set TSO segment size of non-tunneled packets for csum engine " 4955 "(0 to disable)", 4956 .tokens = { 4957 (void *)&cmd_tso_set_tso, 4958 (void *)&cmd_tso_set_mode, 4959 (void *)&cmd_tso_set_tso_segsz, 4960 (void *)&cmd_tso_set_portid, 4961 NULL, 4962 }, 4963 }; 4964 4965 cmdline_parse_token_string_t cmd_tso_show_mode = 4966 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4967 mode, "show"); 4968 4969 4970 cmdline_parse_inst_t cmd_tso_show = { 4971 .f = cmd_tso_set_parsed, 4972 .data = NULL, 4973 .help_str = "tso show <port_id>: " 4974 "Show TSO segment size of non-tunneled packets for csum engine", 4975 .tokens = { 4976 (void *)&cmd_tso_set_tso, 4977 (void *)&cmd_tso_show_mode, 4978 (void *)&cmd_tso_set_portid, 4979 NULL, 4980 }, 4981 }; 4982 4983 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 4984 struct cmd_tunnel_tso_set_result { 4985 cmdline_fixed_string_t tso; 4986 cmdline_fixed_string_t mode; 4987 uint16_t tso_segsz; 4988 portid_t port_id; 4989 }; 4990 4991 static struct rte_eth_dev_info 4992 check_tunnel_tso_nic_support(portid_t port_id) 4993 { 4994 struct rte_eth_dev_info dev_info; 4995 4996 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0) 4997 return dev_info; 4998 4999 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 5000 printf("Warning: VXLAN TUNNEL TSO not supported therefore " 5001 "not enabled for port %d\n", port_id); 5002 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 5003 printf("Warning: GRE TUNNEL TSO not supported therefore " 5004 "not enabled for port %d\n", port_id); 5005 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 5006 printf("Warning: IPIP TUNNEL TSO not supported therefore " 5007 "not enabled for port %d\n", port_id); 5008 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 5009 printf("Warning: GENEVE TUNNEL TSO not supported therefore " 5010 "not enabled for port %d\n", port_id); 5011 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO)) 5012 printf("Warning: IP TUNNEL TSO not supported therefore " 5013 "not enabled for port %d\n", port_id); 5014 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO)) 5015 printf("Warning: UDP TUNNEL TSO not supported therefore " 5016 "not enabled for port %d\n", port_id); 5017 return dev_info; 5018 } 5019 5020 static void 5021 cmd_tunnel_tso_set_parsed(void *parsed_result, 5022 __rte_unused struct cmdline *cl, 5023 __rte_unused void *data) 5024 { 5025 struct cmd_tunnel_tso_set_result *res = parsed_result; 5026 struct rte_eth_dev_info dev_info; 5027 5028 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 5029 return; 5030 if (!port_is_stopped(res->port_id)) { 5031 printf("Please stop port %d first\n", res->port_id); 5032 return; 5033 } 5034 5035 if (!strcmp(res->mode, "set")) 5036 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 5037 5038 dev_info = check_tunnel_tso_nic_support(res->port_id); 5039 if (ports[res->port_id].tunnel_tso_segsz == 0) { 5040 ports[res->port_id].dev_conf.txmode.offloads &= 5041 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 5042 DEV_TX_OFFLOAD_GRE_TNL_TSO | 5043 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 5044 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 5045 DEV_TX_OFFLOAD_IP_TNL_TSO | 5046 DEV_TX_OFFLOAD_UDP_TNL_TSO); 5047 printf("TSO for tunneled packets is disabled\n"); 5048 } else { 5049 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 5050 DEV_TX_OFFLOAD_GRE_TNL_TSO | 5051 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 5052 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 5053 DEV_TX_OFFLOAD_IP_TNL_TSO | 5054 DEV_TX_OFFLOAD_UDP_TNL_TSO); 5055 5056 ports[res->port_id].dev_conf.txmode.offloads |= 5057 (tso_offloads & dev_info.tx_offload_capa); 5058 printf("TSO segment size for tunneled packets is %d\n", 5059 ports[res->port_id].tunnel_tso_segsz); 5060 5061 /* Below conditions are needed to make it work: 5062 * (1) tunnel TSO is supported by the NIC; 5063 * (2) "csum parse_tunnel" must be set so that tunneled pkts 5064 * are recognized; 5065 * (3) for tunneled pkts with outer L3 of IPv4, 5066 * "csum set outer-ip" must be set to hw, because after tso, 5067 * total_len of outer IP header is changed, and the checksum 5068 * of outer IP header calculated by sw should be wrong; that 5069 * is not necessary for IPv6 tunneled pkts because there's no 5070 * checksum in IP header anymore. 5071 */ 5072 5073 if (!ports[res->port_id].parse_tunnel) 5074 printf("Warning: csum parse_tunnel must be set " 5075 "so that tunneled packets are recognized\n"); 5076 if (!(ports[res->port_id].dev_conf.txmode.offloads & 5077 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 5078 printf("Warning: csum set outer-ip must be set to hw " 5079 "if outer L3 is IPv4; not necessary for IPv6\n"); 5080 } 5081 5082 cmd_config_queue_tx_offloads(&ports[res->port_id]); 5083 cmd_reconfig_device_queue(res->port_id, 1, 1); 5084 } 5085 5086 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 5087 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5088 tso, "tunnel_tso"); 5089 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 5090 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5091 mode, "set"); 5092 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 5093 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 5094 tso_segsz, UINT16); 5095 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 5096 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 5097 port_id, UINT16); 5098 5099 cmdline_parse_inst_t cmd_tunnel_tso_set = { 5100 .f = cmd_tunnel_tso_set_parsed, 5101 .data = NULL, 5102 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 5103 "Set TSO segment size of tunneled packets for csum engine " 5104 "(0 to disable)", 5105 .tokens = { 5106 (void *)&cmd_tunnel_tso_set_tso, 5107 (void *)&cmd_tunnel_tso_set_mode, 5108 (void *)&cmd_tunnel_tso_set_tso_segsz, 5109 (void *)&cmd_tunnel_tso_set_portid, 5110 NULL, 5111 }, 5112 }; 5113 5114 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 5115 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5116 mode, "show"); 5117 5118 5119 cmdline_parse_inst_t cmd_tunnel_tso_show = { 5120 .f = cmd_tunnel_tso_set_parsed, 5121 .data = NULL, 5122 .help_str = "tunnel_tso show <port_id> " 5123 "Show TSO segment size of tunneled packets for csum engine", 5124 .tokens = { 5125 (void *)&cmd_tunnel_tso_set_tso, 5126 (void *)&cmd_tunnel_tso_show_mode, 5127 (void *)&cmd_tunnel_tso_set_portid, 5128 NULL, 5129 }, 5130 }; 5131 5132 /* *** SET GRO FOR A PORT *** */ 5133 struct cmd_gro_enable_result { 5134 cmdline_fixed_string_t cmd_set; 5135 cmdline_fixed_string_t cmd_port; 5136 cmdline_fixed_string_t cmd_keyword; 5137 cmdline_fixed_string_t cmd_onoff; 5138 portid_t cmd_pid; 5139 }; 5140 5141 static void 5142 cmd_gro_enable_parsed(void *parsed_result, 5143 __rte_unused struct cmdline *cl, 5144 __rte_unused void *data) 5145 { 5146 struct cmd_gro_enable_result *res; 5147 5148 res = parsed_result; 5149 if (!strcmp(res->cmd_keyword, "gro")) 5150 setup_gro(res->cmd_onoff, res->cmd_pid); 5151 } 5152 5153 cmdline_parse_token_string_t cmd_gro_enable_set = 5154 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5155 cmd_set, "set"); 5156 cmdline_parse_token_string_t cmd_gro_enable_port = 5157 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5158 cmd_keyword, "port"); 5159 cmdline_parse_token_num_t cmd_gro_enable_pid = 5160 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 5161 cmd_pid, UINT16); 5162 cmdline_parse_token_string_t cmd_gro_enable_keyword = 5163 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5164 cmd_keyword, "gro"); 5165 cmdline_parse_token_string_t cmd_gro_enable_onoff = 5166 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5167 cmd_onoff, "on#off"); 5168 5169 cmdline_parse_inst_t cmd_gro_enable = { 5170 .f = cmd_gro_enable_parsed, 5171 .data = NULL, 5172 .help_str = "set port <port_id> gro on|off", 5173 .tokens = { 5174 (void *)&cmd_gro_enable_set, 5175 (void *)&cmd_gro_enable_port, 5176 (void *)&cmd_gro_enable_pid, 5177 (void *)&cmd_gro_enable_keyword, 5178 (void *)&cmd_gro_enable_onoff, 5179 NULL, 5180 }, 5181 }; 5182 5183 /* *** DISPLAY GRO CONFIGURATION *** */ 5184 struct cmd_gro_show_result { 5185 cmdline_fixed_string_t cmd_show; 5186 cmdline_fixed_string_t cmd_port; 5187 cmdline_fixed_string_t cmd_keyword; 5188 portid_t cmd_pid; 5189 }; 5190 5191 static void 5192 cmd_gro_show_parsed(void *parsed_result, 5193 __rte_unused struct cmdline *cl, 5194 __rte_unused void *data) 5195 { 5196 struct cmd_gro_show_result *res; 5197 5198 res = parsed_result; 5199 if (!strcmp(res->cmd_keyword, "gro")) 5200 show_gro(res->cmd_pid); 5201 } 5202 5203 cmdline_parse_token_string_t cmd_gro_show_show = 5204 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5205 cmd_show, "show"); 5206 cmdline_parse_token_string_t cmd_gro_show_port = 5207 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5208 cmd_port, "port"); 5209 cmdline_parse_token_num_t cmd_gro_show_pid = 5210 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 5211 cmd_pid, UINT16); 5212 cmdline_parse_token_string_t cmd_gro_show_keyword = 5213 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5214 cmd_keyword, "gro"); 5215 5216 cmdline_parse_inst_t cmd_gro_show = { 5217 .f = cmd_gro_show_parsed, 5218 .data = NULL, 5219 .help_str = "show port <port_id> gro", 5220 .tokens = { 5221 (void *)&cmd_gro_show_show, 5222 (void *)&cmd_gro_show_port, 5223 (void *)&cmd_gro_show_pid, 5224 (void *)&cmd_gro_show_keyword, 5225 NULL, 5226 }, 5227 }; 5228 5229 /* *** SET FLUSH CYCLES FOR GRO *** */ 5230 struct cmd_gro_flush_result { 5231 cmdline_fixed_string_t cmd_set; 5232 cmdline_fixed_string_t cmd_keyword; 5233 cmdline_fixed_string_t cmd_flush; 5234 uint8_t cmd_cycles; 5235 }; 5236 5237 static void 5238 cmd_gro_flush_parsed(void *parsed_result, 5239 __rte_unused struct cmdline *cl, 5240 __rte_unused void *data) 5241 { 5242 struct cmd_gro_flush_result *res; 5243 5244 res = parsed_result; 5245 if ((!strcmp(res->cmd_keyword, "gro")) && 5246 (!strcmp(res->cmd_flush, "flush"))) 5247 setup_gro_flush_cycles(res->cmd_cycles); 5248 } 5249 5250 cmdline_parse_token_string_t cmd_gro_flush_set = 5251 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5252 cmd_set, "set"); 5253 cmdline_parse_token_string_t cmd_gro_flush_keyword = 5254 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5255 cmd_keyword, "gro"); 5256 cmdline_parse_token_string_t cmd_gro_flush_flush = 5257 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5258 cmd_flush, "flush"); 5259 cmdline_parse_token_num_t cmd_gro_flush_cycles = 5260 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 5261 cmd_cycles, UINT8); 5262 5263 cmdline_parse_inst_t cmd_gro_flush = { 5264 .f = cmd_gro_flush_parsed, 5265 .data = NULL, 5266 .help_str = "set gro flush <cycles>", 5267 .tokens = { 5268 (void *)&cmd_gro_flush_set, 5269 (void *)&cmd_gro_flush_keyword, 5270 (void *)&cmd_gro_flush_flush, 5271 (void *)&cmd_gro_flush_cycles, 5272 NULL, 5273 }, 5274 }; 5275 5276 /* *** ENABLE/DISABLE GSO *** */ 5277 struct cmd_gso_enable_result { 5278 cmdline_fixed_string_t cmd_set; 5279 cmdline_fixed_string_t cmd_port; 5280 cmdline_fixed_string_t cmd_keyword; 5281 cmdline_fixed_string_t cmd_mode; 5282 portid_t cmd_pid; 5283 }; 5284 5285 static void 5286 cmd_gso_enable_parsed(void *parsed_result, 5287 __rte_unused struct cmdline *cl, 5288 __rte_unused void *data) 5289 { 5290 struct cmd_gso_enable_result *res; 5291 5292 res = parsed_result; 5293 if (!strcmp(res->cmd_keyword, "gso")) 5294 setup_gso(res->cmd_mode, res->cmd_pid); 5295 } 5296 5297 cmdline_parse_token_string_t cmd_gso_enable_set = 5298 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5299 cmd_set, "set"); 5300 cmdline_parse_token_string_t cmd_gso_enable_port = 5301 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5302 cmd_port, "port"); 5303 cmdline_parse_token_string_t cmd_gso_enable_keyword = 5304 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5305 cmd_keyword, "gso"); 5306 cmdline_parse_token_string_t cmd_gso_enable_mode = 5307 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5308 cmd_mode, "on#off"); 5309 cmdline_parse_token_num_t cmd_gso_enable_pid = 5310 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 5311 cmd_pid, UINT16); 5312 5313 cmdline_parse_inst_t cmd_gso_enable = { 5314 .f = cmd_gso_enable_parsed, 5315 .data = NULL, 5316 .help_str = "set port <port_id> gso on|off", 5317 .tokens = { 5318 (void *)&cmd_gso_enable_set, 5319 (void *)&cmd_gso_enable_port, 5320 (void *)&cmd_gso_enable_pid, 5321 (void *)&cmd_gso_enable_keyword, 5322 (void *)&cmd_gso_enable_mode, 5323 NULL, 5324 }, 5325 }; 5326 5327 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 5328 struct cmd_gso_size_result { 5329 cmdline_fixed_string_t cmd_set; 5330 cmdline_fixed_string_t cmd_keyword; 5331 cmdline_fixed_string_t cmd_segsz; 5332 uint16_t cmd_size; 5333 }; 5334 5335 static void 5336 cmd_gso_size_parsed(void *parsed_result, 5337 __rte_unused struct cmdline *cl, 5338 __rte_unused void *data) 5339 { 5340 struct cmd_gso_size_result *res = parsed_result; 5341 5342 if (test_done == 0) { 5343 printf("Before setting GSO segsz, please first" 5344 " stop forwarding\n"); 5345 return; 5346 } 5347 5348 if (!strcmp(res->cmd_keyword, "gso") && 5349 !strcmp(res->cmd_segsz, "segsz")) { 5350 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 5351 printf("gso_size should be larger than %zu." 5352 " Please input a legal value\n", 5353 RTE_GSO_SEG_SIZE_MIN); 5354 else 5355 gso_max_segment_size = res->cmd_size; 5356 } 5357 } 5358 5359 cmdline_parse_token_string_t cmd_gso_size_set = 5360 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5361 cmd_set, "set"); 5362 cmdline_parse_token_string_t cmd_gso_size_keyword = 5363 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5364 cmd_keyword, "gso"); 5365 cmdline_parse_token_string_t cmd_gso_size_segsz = 5366 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5367 cmd_segsz, "segsz"); 5368 cmdline_parse_token_num_t cmd_gso_size_size = 5369 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 5370 cmd_size, UINT16); 5371 5372 cmdline_parse_inst_t cmd_gso_size = { 5373 .f = cmd_gso_size_parsed, 5374 .data = NULL, 5375 .help_str = "set gso segsz <length>", 5376 .tokens = { 5377 (void *)&cmd_gso_size_set, 5378 (void *)&cmd_gso_size_keyword, 5379 (void *)&cmd_gso_size_segsz, 5380 (void *)&cmd_gso_size_size, 5381 NULL, 5382 }, 5383 }; 5384 5385 /* *** SHOW GSO CONFIGURATION *** */ 5386 struct cmd_gso_show_result { 5387 cmdline_fixed_string_t cmd_show; 5388 cmdline_fixed_string_t cmd_port; 5389 cmdline_fixed_string_t cmd_keyword; 5390 portid_t cmd_pid; 5391 }; 5392 5393 static void 5394 cmd_gso_show_parsed(void *parsed_result, 5395 __rte_unused struct cmdline *cl, 5396 __rte_unused void *data) 5397 { 5398 struct cmd_gso_show_result *res = parsed_result; 5399 5400 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 5401 printf("invalid port id %u\n", res->cmd_pid); 5402 return; 5403 } 5404 if (!strcmp(res->cmd_keyword, "gso")) { 5405 if (gso_ports[res->cmd_pid].enable) { 5406 printf("Max GSO'd packet size: %uB\n" 5407 "Supported GSO types: TCP/IPv4, " 5408 "UDP/IPv4, VxLAN with inner " 5409 "TCP/IPv4 packet, GRE with inner " 5410 "TCP/IPv4 packet\n", 5411 gso_max_segment_size); 5412 } else 5413 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 5414 } 5415 } 5416 5417 cmdline_parse_token_string_t cmd_gso_show_show = 5418 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5419 cmd_show, "show"); 5420 cmdline_parse_token_string_t cmd_gso_show_port = 5421 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5422 cmd_port, "port"); 5423 cmdline_parse_token_string_t cmd_gso_show_keyword = 5424 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5425 cmd_keyword, "gso"); 5426 cmdline_parse_token_num_t cmd_gso_show_pid = 5427 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 5428 cmd_pid, UINT16); 5429 5430 cmdline_parse_inst_t cmd_gso_show = { 5431 .f = cmd_gso_show_parsed, 5432 .data = NULL, 5433 .help_str = "show port <port_id> gso", 5434 .tokens = { 5435 (void *)&cmd_gso_show_show, 5436 (void *)&cmd_gso_show_port, 5437 (void *)&cmd_gso_show_pid, 5438 (void *)&cmd_gso_show_keyword, 5439 NULL, 5440 }, 5441 }; 5442 5443 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 5444 struct cmd_set_flush_rx { 5445 cmdline_fixed_string_t set; 5446 cmdline_fixed_string_t flush_rx; 5447 cmdline_fixed_string_t mode; 5448 }; 5449 5450 static void 5451 cmd_set_flush_rx_parsed(void *parsed_result, 5452 __rte_unused struct cmdline *cl, 5453 __rte_unused void *data) 5454 { 5455 struct cmd_set_flush_rx *res = parsed_result; 5456 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5457 } 5458 5459 cmdline_parse_token_string_t cmd_setflushrx_set = 5460 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5461 set, "set"); 5462 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 5463 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5464 flush_rx, "flush_rx"); 5465 cmdline_parse_token_string_t cmd_setflushrx_mode = 5466 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5467 mode, "on#off"); 5468 5469 5470 cmdline_parse_inst_t cmd_set_flush_rx = { 5471 .f = cmd_set_flush_rx_parsed, 5472 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 5473 .data = NULL, 5474 .tokens = { 5475 (void *)&cmd_setflushrx_set, 5476 (void *)&cmd_setflushrx_flush_rx, 5477 (void *)&cmd_setflushrx_mode, 5478 NULL, 5479 }, 5480 }; 5481 5482 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 5483 struct cmd_set_link_check { 5484 cmdline_fixed_string_t set; 5485 cmdline_fixed_string_t link_check; 5486 cmdline_fixed_string_t mode; 5487 }; 5488 5489 static void 5490 cmd_set_link_check_parsed(void *parsed_result, 5491 __rte_unused struct cmdline *cl, 5492 __rte_unused void *data) 5493 { 5494 struct cmd_set_link_check *res = parsed_result; 5495 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5496 } 5497 5498 cmdline_parse_token_string_t cmd_setlinkcheck_set = 5499 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5500 set, "set"); 5501 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 5502 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5503 link_check, "link_check"); 5504 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 5505 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5506 mode, "on#off"); 5507 5508 5509 cmdline_parse_inst_t cmd_set_link_check = { 5510 .f = cmd_set_link_check_parsed, 5511 .help_str = "set link_check on|off: Enable/Disable link status check " 5512 "when starting/stopping a port", 5513 .data = NULL, 5514 .tokens = { 5515 (void *)&cmd_setlinkcheck_set, 5516 (void *)&cmd_setlinkcheck_link_check, 5517 (void *)&cmd_setlinkcheck_mode, 5518 NULL, 5519 }, 5520 }; 5521 5522 /* *** SET NIC BYPASS MODE *** */ 5523 struct cmd_set_bypass_mode_result { 5524 cmdline_fixed_string_t set; 5525 cmdline_fixed_string_t bypass; 5526 cmdline_fixed_string_t mode; 5527 cmdline_fixed_string_t value; 5528 portid_t port_id; 5529 }; 5530 5531 static void 5532 cmd_set_bypass_mode_parsed(void *parsed_result, 5533 __rte_unused struct cmdline *cl, 5534 __rte_unused void *data) 5535 { 5536 struct cmd_set_bypass_mode_result *res = parsed_result; 5537 portid_t port_id = res->port_id; 5538 int32_t rc = -EINVAL; 5539 5540 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5541 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5542 5543 if (!strcmp(res->value, "bypass")) 5544 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5545 else if (!strcmp(res->value, "isolate")) 5546 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5547 else 5548 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5549 5550 /* Set the bypass mode for the relevant port. */ 5551 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 5552 #endif 5553 if (rc != 0) 5554 printf("\t Failed to set bypass mode for port = %d.\n", port_id); 5555 } 5556 5557 cmdline_parse_token_string_t cmd_setbypass_mode_set = 5558 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5559 set, "set"); 5560 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 5561 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5562 bypass, "bypass"); 5563 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 5564 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5565 mode, "mode"); 5566 cmdline_parse_token_string_t cmd_setbypass_mode_value = 5567 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5568 value, "normal#bypass#isolate"); 5569 cmdline_parse_token_num_t cmd_setbypass_mode_port = 5570 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 5571 port_id, UINT16); 5572 5573 cmdline_parse_inst_t cmd_set_bypass_mode = { 5574 .f = cmd_set_bypass_mode_parsed, 5575 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 5576 "Set the NIC bypass mode for port_id", 5577 .data = NULL, 5578 .tokens = { 5579 (void *)&cmd_setbypass_mode_set, 5580 (void *)&cmd_setbypass_mode_bypass, 5581 (void *)&cmd_setbypass_mode_mode, 5582 (void *)&cmd_setbypass_mode_value, 5583 (void *)&cmd_setbypass_mode_port, 5584 NULL, 5585 }, 5586 }; 5587 5588 /* *** SET NIC BYPASS EVENT *** */ 5589 struct cmd_set_bypass_event_result { 5590 cmdline_fixed_string_t set; 5591 cmdline_fixed_string_t bypass; 5592 cmdline_fixed_string_t event; 5593 cmdline_fixed_string_t event_value; 5594 cmdline_fixed_string_t mode; 5595 cmdline_fixed_string_t mode_value; 5596 portid_t port_id; 5597 }; 5598 5599 static void 5600 cmd_set_bypass_event_parsed(void *parsed_result, 5601 __rte_unused struct cmdline *cl, 5602 __rte_unused void *data) 5603 { 5604 int32_t rc = -EINVAL; 5605 struct cmd_set_bypass_event_result *res = parsed_result; 5606 portid_t port_id = res->port_id; 5607 5608 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5609 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5610 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5611 5612 if (!strcmp(res->event_value, "timeout")) 5613 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 5614 else if (!strcmp(res->event_value, "os_on")) 5615 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 5616 else if (!strcmp(res->event_value, "os_off")) 5617 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 5618 else if (!strcmp(res->event_value, "power_on")) 5619 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 5620 else if (!strcmp(res->event_value, "power_off")) 5621 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 5622 else 5623 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5624 5625 if (!strcmp(res->mode_value, "bypass")) 5626 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5627 else if (!strcmp(res->mode_value, "isolate")) 5628 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5629 else 5630 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5631 5632 /* Set the watchdog timeout. */ 5633 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 5634 5635 rc = -EINVAL; 5636 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 5637 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 5638 bypass_timeout); 5639 } 5640 if (rc != 0) { 5641 printf("Failed to set timeout value %u " 5642 "for port %d, errto code: %d.\n", 5643 bypass_timeout, port_id, rc); 5644 } 5645 } 5646 5647 /* Set the bypass event to transition to bypass mode. */ 5648 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 5649 bypass_mode); 5650 #endif 5651 5652 if (rc != 0) 5653 printf("\t Failed to set bypass event for port = %d.\n", 5654 port_id); 5655 } 5656 5657 cmdline_parse_token_string_t cmd_setbypass_event_set = 5658 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5659 set, "set"); 5660 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 5661 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5662 bypass, "bypass"); 5663 cmdline_parse_token_string_t cmd_setbypass_event_event = 5664 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5665 event, "event"); 5666 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 5667 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5668 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 5669 cmdline_parse_token_string_t cmd_setbypass_event_mode = 5670 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5671 mode, "mode"); 5672 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 5673 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5674 mode_value, "normal#bypass#isolate"); 5675 cmdline_parse_token_num_t cmd_setbypass_event_port = 5676 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 5677 port_id, UINT16); 5678 5679 cmdline_parse_inst_t cmd_set_bypass_event = { 5680 .f = cmd_set_bypass_event_parsed, 5681 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 5682 "power_off mode normal|bypass|isolate <port_id>: " 5683 "Set the NIC bypass event mode for port_id", 5684 .data = NULL, 5685 .tokens = { 5686 (void *)&cmd_setbypass_event_set, 5687 (void *)&cmd_setbypass_event_bypass, 5688 (void *)&cmd_setbypass_event_event, 5689 (void *)&cmd_setbypass_event_event_value, 5690 (void *)&cmd_setbypass_event_mode, 5691 (void *)&cmd_setbypass_event_mode_value, 5692 (void *)&cmd_setbypass_event_port, 5693 NULL, 5694 }, 5695 }; 5696 5697 5698 /* *** SET NIC BYPASS TIMEOUT *** */ 5699 struct cmd_set_bypass_timeout_result { 5700 cmdline_fixed_string_t set; 5701 cmdline_fixed_string_t bypass; 5702 cmdline_fixed_string_t timeout; 5703 cmdline_fixed_string_t value; 5704 }; 5705 5706 static void 5707 cmd_set_bypass_timeout_parsed(void *parsed_result, 5708 __rte_unused struct cmdline *cl, 5709 __rte_unused void *data) 5710 { 5711 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 5712 5713 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5714 if (!strcmp(res->value, "1.5")) 5715 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 5716 else if (!strcmp(res->value, "2")) 5717 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 5718 else if (!strcmp(res->value, "3")) 5719 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 5720 else if (!strcmp(res->value, "4")) 5721 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 5722 else if (!strcmp(res->value, "8")) 5723 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 5724 else if (!strcmp(res->value, "16")) 5725 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 5726 else if (!strcmp(res->value, "32")) 5727 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 5728 else 5729 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5730 #endif 5731 } 5732 5733 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 5734 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5735 set, "set"); 5736 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 5737 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5738 bypass, "bypass"); 5739 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 5740 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5741 timeout, "timeout"); 5742 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 5743 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5744 value, "0#1.5#2#3#4#8#16#32"); 5745 5746 cmdline_parse_inst_t cmd_set_bypass_timeout = { 5747 .f = cmd_set_bypass_timeout_parsed, 5748 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 5749 "Set the NIC bypass watchdog timeout in seconds", 5750 .data = NULL, 5751 .tokens = { 5752 (void *)&cmd_setbypass_timeout_set, 5753 (void *)&cmd_setbypass_timeout_bypass, 5754 (void *)&cmd_setbypass_timeout_timeout, 5755 (void *)&cmd_setbypass_timeout_value, 5756 NULL, 5757 }, 5758 }; 5759 5760 /* *** SHOW NIC BYPASS MODE *** */ 5761 struct cmd_show_bypass_config_result { 5762 cmdline_fixed_string_t show; 5763 cmdline_fixed_string_t bypass; 5764 cmdline_fixed_string_t config; 5765 portid_t port_id; 5766 }; 5767 5768 static void 5769 cmd_show_bypass_config_parsed(void *parsed_result, 5770 __rte_unused struct cmdline *cl, 5771 __rte_unused void *data) 5772 { 5773 struct cmd_show_bypass_config_result *res = parsed_result; 5774 portid_t port_id = res->port_id; 5775 int rc = -EINVAL; 5776 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5777 uint32_t event_mode; 5778 uint32_t bypass_mode; 5779 uint32_t timeout = bypass_timeout; 5780 unsigned int i; 5781 5782 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 5783 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 5784 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 5785 {"UNKNOWN", "normal", "bypass", "isolate"}; 5786 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 5787 "NONE", 5788 "OS/board on", 5789 "power supply on", 5790 "OS/board off", 5791 "power supply off", 5792 "timeout"}; 5793 5794 /* Display the bypass mode.*/ 5795 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 5796 printf("\tFailed to get bypass mode for port = %d\n", port_id); 5797 return; 5798 } 5799 else { 5800 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 5801 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5802 5803 printf("\tbypass mode = %s\n", modes[bypass_mode]); 5804 } 5805 5806 /* Display the bypass timeout.*/ 5807 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 5808 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5809 5810 printf("\tbypass timeout = %s\n", timeouts[timeout]); 5811 5812 /* Display the bypass events and associated modes. */ 5813 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) { 5814 5815 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 5816 printf("\tFailed to get bypass mode for event = %s\n", 5817 events[i]); 5818 } else { 5819 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 5820 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5821 5822 printf("\tbypass event: %-16s = %s\n", events[i], 5823 modes[event_mode]); 5824 } 5825 } 5826 #endif 5827 if (rc != 0) 5828 printf("\tFailed to get bypass configuration for port = %d\n", 5829 port_id); 5830 } 5831 5832 cmdline_parse_token_string_t cmd_showbypass_config_show = 5833 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5834 show, "show"); 5835 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 5836 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5837 bypass, "bypass"); 5838 cmdline_parse_token_string_t cmd_showbypass_config_config = 5839 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5840 config, "config"); 5841 cmdline_parse_token_num_t cmd_showbypass_config_port = 5842 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 5843 port_id, UINT16); 5844 5845 cmdline_parse_inst_t cmd_show_bypass_config = { 5846 .f = cmd_show_bypass_config_parsed, 5847 .help_str = "show bypass config <port_id>: " 5848 "Show the NIC bypass config for port_id", 5849 .data = NULL, 5850 .tokens = { 5851 (void *)&cmd_showbypass_config_show, 5852 (void *)&cmd_showbypass_config_bypass, 5853 (void *)&cmd_showbypass_config_config, 5854 (void *)&cmd_showbypass_config_port, 5855 NULL, 5856 }, 5857 }; 5858 5859 #ifdef RTE_NET_BOND 5860 /* *** SET BONDING MODE *** */ 5861 struct cmd_set_bonding_mode_result { 5862 cmdline_fixed_string_t set; 5863 cmdline_fixed_string_t bonding; 5864 cmdline_fixed_string_t mode; 5865 uint8_t value; 5866 portid_t port_id; 5867 }; 5868 5869 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5870 __rte_unused struct cmdline *cl, 5871 __rte_unused void *data) 5872 { 5873 struct cmd_set_bonding_mode_result *res = parsed_result; 5874 portid_t port_id = res->port_id; 5875 5876 /* Set the bonding mode for the relevant port. */ 5877 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5878 printf("\t Failed to set bonding mode for port = %d.\n", port_id); 5879 } 5880 5881 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5882 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5883 set, "set"); 5884 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5885 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5886 bonding, "bonding"); 5887 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5888 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5889 mode, "mode"); 5890 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5891 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5892 value, UINT8); 5893 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5894 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5895 port_id, UINT16); 5896 5897 cmdline_parse_inst_t cmd_set_bonding_mode = { 5898 .f = cmd_set_bonding_mode_parsed, 5899 .help_str = "set bonding mode <mode_value> <port_id>: " 5900 "Set the bonding mode for port_id", 5901 .data = NULL, 5902 .tokens = { 5903 (void *) &cmd_setbonding_mode_set, 5904 (void *) &cmd_setbonding_mode_bonding, 5905 (void *) &cmd_setbonding_mode_mode, 5906 (void *) &cmd_setbonding_mode_value, 5907 (void *) &cmd_setbonding_mode_port, 5908 NULL 5909 } 5910 }; 5911 5912 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5913 struct cmd_set_bonding_lacp_dedicated_queues_result { 5914 cmdline_fixed_string_t set; 5915 cmdline_fixed_string_t bonding; 5916 cmdline_fixed_string_t lacp; 5917 cmdline_fixed_string_t dedicated_queues; 5918 portid_t port_id; 5919 cmdline_fixed_string_t mode; 5920 }; 5921 5922 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5923 __rte_unused struct cmdline *cl, 5924 __rte_unused void *data) 5925 { 5926 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5927 portid_t port_id = res->port_id; 5928 struct rte_port *port; 5929 5930 port = &ports[port_id]; 5931 5932 /** Check if the port is not started **/ 5933 if (port->port_status != RTE_PORT_STOPPED) { 5934 printf("Please stop port %d first\n", port_id); 5935 return; 5936 } 5937 5938 if (!strcmp(res->mode, "enable")) { 5939 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5940 printf("Dedicate queues for LACP control packets" 5941 " enabled\n"); 5942 else 5943 printf("Enabling dedicate queues for LACP control " 5944 "packets on port %d failed\n", port_id); 5945 } else if (!strcmp(res->mode, "disable")) { 5946 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5947 printf("Dedicated queues for LACP control packets " 5948 "disabled\n"); 5949 else 5950 printf("Disabling dedicated queues for LACP control " 5951 "traffic on port %d failed\n", port_id); 5952 } 5953 } 5954 5955 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 5956 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5957 set, "set"); 5958 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 5959 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5960 bonding, "bonding"); 5961 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 5962 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5963 lacp, "lacp"); 5964 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 5965 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5966 dedicated_queues, "dedicated_queues"); 5967 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 5968 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5969 port_id, UINT16); 5970 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 5971 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5972 mode, "enable#disable"); 5973 5974 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 5975 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 5976 .help_str = "set bonding lacp dedicated_queues <port_id> " 5977 "enable|disable: " 5978 "Enable/disable dedicated queues for LACP control traffic for port_id", 5979 .data = NULL, 5980 .tokens = { 5981 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 5982 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 5983 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 5984 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 5985 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 5986 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 5987 NULL 5988 } 5989 }; 5990 5991 /* *** SET BALANCE XMIT POLICY *** */ 5992 struct cmd_set_bonding_balance_xmit_policy_result { 5993 cmdline_fixed_string_t set; 5994 cmdline_fixed_string_t bonding; 5995 cmdline_fixed_string_t balance_xmit_policy; 5996 portid_t port_id; 5997 cmdline_fixed_string_t policy; 5998 }; 5999 6000 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 6001 __rte_unused struct cmdline *cl, 6002 __rte_unused void *data) 6003 { 6004 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 6005 portid_t port_id = res->port_id; 6006 uint8_t policy; 6007 6008 if (!strcmp(res->policy, "l2")) { 6009 policy = BALANCE_XMIT_POLICY_LAYER2; 6010 } else if (!strcmp(res->policy, "l23")) { 6011 policy = BALANCE_XMIT_POLICY_LAYER23; 6012 } else if (!strcmp(res->policy, "l34")) { 6013 policy = BALANCE_XMIT_POLICY_LAYER34; 6014 } else { 6015 printf("\t Invalid xmit policy selection"); 6016 return; 6017 } 6018 6019 /* Set the bonding mode for the relevant port. */ 6020 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 6021 printf("\t Failed to set bonding balance xmit policy for port = %d.\n", 6022 port_id); 6023 } 6024 } 6025 6026 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 6027 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6028 set, "set"); 6029 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 6030 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6031 bonding, "bonding"); 6032 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 6033 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6034 balance_xmit_policy, "balance_xmit_policy"); 6035 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 6036 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6037 port_id, UINT16); 6038 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 6039 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 6040 policy, "l2#l23#l34"); 6041 6042 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 6043 .f = cmd_set_bonding_balance_xmit_policy_parsed, 6044 .help_str = "set bonding balance_xmit_policy <port_id> " 6045 "l2|l23|l34: " 6046 "Set the bonding balance_xmit_policy for port_id", 6047 .data = NULL, 6048 .tokens = { 6049 (void *)&cmd_setbonding_balance_xmit_policy_set, 6050 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 6051 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 6052 (void *)&cmd_setbonding_balance_xmit_policy_port, 6053 (void *)&cmd_setbonding_balance_xmit_policy_policy, 6054 NULL 6055 } 6056 }; 6057 6058 /* *** SHOW NIC BONDING CONFIGURATION *** */ 6059 struct cmd_show_bonding_config_result { 6060 cmdline_fixed_string_t show; 6061 cmdline_fixed_string_t bonding; 6062 cmdline_fixed_string_t config; 6063 portid_t port_id; 6064 }; 6065 6066 static void cmd_show_bonding_config_parsed(void *parsed_result, 6067 __rte_unused struct cmdline *cl, 6068 __rte_unused void *data) 6069 { 6070 struct cmd_show_bonding_config_result *res = parsed_result; 6071 int bonding_mode, agg_mode; 6072 portid_t slaves[RTE_MAX_ETHPORTS]; 6073 int num_slaves, num_active_slaves; 6074 int primary_id; 6075 int i; 6076 portid_t port_id = res->port_id; 6077 6078 /* Display the bonding mode.*/ 6079 bonding_mode = rte_eth_bond_mode_get(port_id); 6080 if (bonding_mode < 0) { 6081 printf("\tFailed to get bonding mode for port = %d\n", port_id); 6082 return; 6083 } else 6084 printf("\tBonding mode: %d\n", bonding_mode); 6085 6086 if (bonding_mode == BONDING_MODE_BALANCE) { 6087 int balance_xmit_policy; 6088 6089 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 6090 if (balance_xmit_policy < 0) { 6091 printf("\tFailed to get balance xmit policy for port = %d\n", 6092 port_id); 6093 return; 6094 } else { 6095 printf("\tBalance Xmit Policy: "); 6096 6097 switch (balance_xmit_policy) { 6098 case BALANCE_XMIT_POLICY_LAYER2: 6099 printf("BALANCE_XMIT_POLICY_LAYER2"); 6100 break; 6101 case BALANCE_XMIT_POLICY_LAYER23: 6102 printf("BALANCE_XMIT_POLICY_LAYER23"); 6103 break; 6104 case BALANCE_XMIT_POLICY_LAYER34: 6105 printf("BALANCE_XMIT_POLICY_LAYER34"); 6106 break; 6107 } 6108 printf("\n"); 6109 } 6110 } 6111 6112 if (bonding_mode == BONDING_MODE_8023AD) { 6113 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 6114 printf("\tIEEE802.3AD Aggregator Mode: "); 6115 switch (agg_mode) { 6116 case AGG_BANDWIDTH: 6117 printf("bandwidth"); 6118 break; 6119 case AGG_STABLE: 6120 printf("stable"); 6121 break; 6122 case AGG_COUNT: 6123 printf("count"); 6124 break; 6125 } 6126 printf("\n"); 6127 } 6128 6129 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 6130 6131 if (num_slaves < 0) { 6132 printf("\tFailed to get slave list for port = %d\n", port_id); 6133 return; 6134 } 6135 if (num_slaves > 0) { 6136 printf("\tSlaves (%d): [", num_slaves); 6137 for (i = 0; i < num_slaves - 1; i++) 6138 printf("%d ", slaves[i]); 6139 6140 printf("%d]\n", slaves[num_slaves - 1]); 6141 } else { 6142 printf("\tSlaves: []\n"); 6143 6144 } 6145 6146 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 6147 RTE_MAX_ETHPORTS); 6148 6149 if (num_active_slaves < 0) { 6150 printf("\tFailed to get active slave list for port = %d\n", port_id); 6151 return; 6152 } 6153 if (num_active_slaves > 0) { 6154 printf("\tActive Slaves (%d): [", num_active_slaves); 6155 for (i = 0; i < num_active_slaves - 1; i++) 6156 printf("%d ", slaves[i]); 6157 6158 printf("%d]\n", slaves[num_active_slaves - 1]); 6159 6160 } else { 6161 printf("\tActive Slaves: []\n"); 6162 6163 } 6164 6165 primary_id = rte_eth_bond_primary_get(port_id); 6166 if (primary_id < 0) { 6167 printf("\tFailed to get primary slave for port = %d\n", port_id); 6168 return; 6169 } else 6170 printf("\tPrimary: [%d]\n", primary_id); 6171 6172 } 6173 6174 cmdline_parse_token_string_t cmd_showbonding_config_show = 6175 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6176 show, "show"); 6177 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 6178 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6179 bonding, "bonding"); 6180 cmdline_parse_token_string_t cmd_showbonding_config_config = 6181 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6182 config, "config"); 6183 cmdline_parse_token_num_t cmd_showbonding_config_port = 6184 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 6185 port_id, UINT16); 6186 6187 cmdline_parse_inst_t cmd_show_bonding_config = { 6188 .f = cmd_show_bonding_config_parsed, 6189 .help_str = "show bonding config <port_id>: " 6190 "Show the bonding config for port_id", 6191 .data = NULL, 6192 .tokens = { 6193 (void *)&cmd_showbonding_config_show, 6194 (void *)&cmd_showbonding_config_bonding, 6195 (void *)&cmd_showbonding_config_config, 6196 (void *)&cmd_showbonding_config_port, 6197 NULL 6198 } 6199 }; 6200 6201 /* *** SET BONDING PRIMARY *** */ 6202 struct cmd_set_bonding_primary_result { 6203 cmdline_fixed_string_t set; 6204 cmdline_fixed_string_t bonding; 6205 cmdline_fixed_string_t primary; 6206 portid_t slave_id; 6207 portid_t port_id; 6208 }; 6209 6210 static void cmd_set_bonding_primary_parsed(void *parsed_result, 6211 __rte_unused struct cmdline *cl, 6212 __rte_unused void *data) 6213 { 6214 struct cmd_set_bonding_primary_result *res = parsed_result; 6215 portid_t master_port_id = res->port_id; 6216 portid_t slave_port_id = res->slave_id; 6217 6218 /* Set the primary slave for a bonded device. */ 6219 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 6220 printf("\t Failed to set primary slave for port = %d.\n", 6221 master_port_id); 6222 return; 6223 } 6224 init_port_config(); 6225 } 6226 6227 cmdline_parse_token_string_t cmd_setbonding_primary_set = 6228 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6229 set, "set"); 6230 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 6231 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6232 bonding, "bonding"); 6233 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 6234 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6235 primary, "primary"); 6236 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 6237 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6238 slave_id, UINT16); 6239 cmdline_parse_token_num_t cmd_setbonding_primary_port = 6240 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6241 port_id, UINT16); 6242 6243 cmdline_parse_inst_t cmd_set_bonding_primary = { 6244 .f = cmd_set_bonding_primary_parsed, 6245 .help_str = "set bonding primary <slave_id> <port_id>: " 6246 "Set the primary slave for port_id", 6247 .data = NULL, 6248 .tokens = { 6249 (void *)&cmd_setbonding_primary_set, 6250 (void *)&cmd_setbonding_primary_bonding, 6251 (void *)&cmd_setbonding_primary_primary, 6252 (void *)&cmd_setbonding_primary_slave, 6253 (void *)&cmd_setbonding_primary_port, 6254 NULL 6255 } 6256 }; 6257 6258 /* *** ADD SLAVE *** */ 6259 struct cmd_add_bonding_slave_result { 6260 cmdline_fixed_string_t add; 6261 cmdline_fixed_string_t bonding; 6262 cmdline_fixed_string_t slave; 6263 portid_t slave_id; 6264 portid_t port_id; 6265 }; 6266 6267 static void cmd_add_bonding_slave_parsed(void *parsed_result, 6268 __rte_unused struct cmdline *cl, 6269 __rte_unused void *data) 6270 { 6271 struct cmd_add_bonding_slave_result *res = parsed_result; 6272 portid_t master_port_id = res->port_id; 6273 portid_t slave_port_id = res->slave_id; 6274 6275 /* add the slave for a bonded device. */ 6276 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 6277 printf("\t Failed to add slave %d to master port = %d.\n", 6278 slave_port_id, master_port_id); 6279 return; 6280 } 6281 init_port_config(); 6282 set_port_slave_flag(slave_port_id); 6283 } 6284 6285 cmdline_parse_token_string_t cmd_addbonding_slave_add = 6286 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6287 add, "add"); 6288 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 6289 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6290 bonding, "bonding"); 6291 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 6292 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6293 slave, "slave"); 6294 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 6295 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6296 slave_id, UINT16); 6297 cmdline_parse_token_num_t cmd_addbonding_slave_port = 6298 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6299 port_id, UINT16); 6300 6301 cmdline_parse_inst_t cmd_add_bonding_slave = { 6302 .f = cmd_add_bonding_slave_parsed, 6303 .help_str = "add bonding slave <slave_id> <port_id>: " 6304 "Add a slave device to a bonded device", 6305 .data = NULL, 6306 .tokens = { 6307 (void *)&cmd_addbonding_slave_add, 6308 (void *)&cmd_addbonding_slave_bonding, 6309 (void *)&cmd_addbonding_slave_slave, 6310 (void *)&cmd_addbonding_slave_slaveid, 6311 (void *)&cmd_addbonding_slave_port, 6312 NULL 6313 } 6314 }; 6315 6316 /* *** REMOVE SLAVE *** */ 6317 struct cmd_remove_bonding_slave_result { 6318 cmdline_fixed_string_t remove; 6319 cmdline_fixed_string_t bonding; 6320 cmdline_fixed_string_t slave; 6321 portid_t slave_id; 6322 portid_t port_id; 6323 }; 6324 6325 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 6326 __rte_unused struct cmdline *cl, 6327 __rte_unused void *data) 6328 { 6329 struct cmd_remove_bonding_slave_result *res = parsed_result; 6330 portid_t master_port_id = res->port_id; 6331 portid_t slave_port_id = res->slave_id; 6332 6333 /* remove the slave from a bonded device. */ 6334 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 6335 printf("\t Failed to remove slave %d from master port = %d.\n", 6336 slave_port_id, master_port_id); 6337 return; 6338 } 6339 init_port_config(); 6340 clear_port_slave_flag(slave_port_id); 6341 } 6342 6343 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 6344 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6345 remove, "remove"); 6346 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 6347 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6348 bonding, "bonding"); 6349 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 6350 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6351 slave, "slave"); 6352 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 6353 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6354 slave_id, UINT16); 6355 cmdline_parse_token_num_t cmd_removebonding_slave_port = 6356 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6357 port_id, UINT16); 6358 6359 cmdline_parse_inst_t cmd_remove_bonding_slave = { 6360 .f = cmd_remove_bonding_slave_parsed, 6361 .help_str = "remove bonding slave <slave_id> <port_id>: " 6362 "Remove a slave device from a bonded device", 6363 .data = NULL, 6364 .tokens = { 6365 (void *)&cmd_removebonding_slave_remove, 6366 (void *)&cmd_removebonding_slave_bonding, 6367 (void *)&cmd_removebonding_slave_slave, 6368 (void *)&cmd_removebonding_slave_slaveid, 6369 (void *)&cmd_removebonding_slave_port, 6370 NULL 6371 } 6372 }; 6373 6374 /* *** CREATE BONDED DEVICE *** */ 6375 struct cmd_create_bonded_device_result { 6376 cmdline_fixed_string_t create; 6377 cmdline_fixed_string_t bonded; 6378 cmdline_fixed_string_t device; 6379 uint8_t mode; 6380 uint8_t socket; 6381 }; 6382 6383 static int bond_dev_num = 0; 6384 6385 static void cmd_create_bonded_device_parsed(void *parsed_result, 6386 __rte_unused struct cmdline *cl, 6387 __rte_unused void *data) 6388 { 6389 struct cmd_create_bonded_device_result *res = parsed_result; 6390 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 6391 int port_id; 6392 int ret; 6393 6394 if (test_done == 0) { 6395 printf("Please stop forwarding first\n"); 6396 return; 6397 } 6398 6399 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 6400 bond_dev_num++); 6401 6402 /* Create a new bonded device. */ 6403 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 6404 if (port_id < 0) { 6405 printf("\t Failed to create bonded device.\n"); 6406 return; 6407 } else { 6408 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 6409 port_id); 6410 6411 /* Update number of ports */ 6412 nb_ports = rte_eth_dev_count_avail(); 6413 reconfig(port_id, res->socket); 6414 ret = rte_eth_promiscuous_enable(port_id); 6415 if (ret != 0) 6416 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n", 6417 port_id, rte_strerror(-ret)); 6418 6419 ports[port_id].need_setup = 0; 6420 ports[port_id].port_status = RTE_PORT_STOPPED; 6421 } 6422 6423 } 6424 6425 cmdline_parse_token_string_t cmd_createbonded_device_create = 6426 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6427 create, "create"); 6428 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 6429 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6430 bonded, "bonded"); 6431 cmdline_parse_token_string_t cmd_createbonded_device_device = 6432 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6433 device, "device"); 6434 cmdline_parse_token_num_t cmd_createbonded_device_mode = 6435 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6436 mode, UINT8); 6437 cmdline_parse_token_num_t cmd_createbonded_device_socket = 6438 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6439 socket, UINT8); 6440 6441 cmdline_parse_inst_t cmd_create_bonded_device = { 6442 .f = cmd_create_bonded_device_parsed, 6443 .help_str = "create bonded device <mode> <socket>: " 6444 "Create a new bonded device with specific bonding mode and socket", 6445 .data = NULL, 6446 .tokens = { 6447 (void *)&cmd_createbonded_device_create, 6448 (void *)&cmd_createbonded_device_bonded, 6449 (void *)&cmd_createbonded_device_device, 6450 (void *)&cmd_createbonded_device_mode, 6451 (void *)&cmd_createbonded_device_socket, 6452 NULL 6453 } 6454 }; 6455 6456 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 6457 struct cmd_set_bond_mac_addr_result { 6458 cmdline_fixed_string_t set; 6459 cmdline_fixed_string_t bonding; 6460 cmdline_fixed_string_t mac_addr; 6461 uint16_t port_num; 6462 struct rte_ether_addr address; 6463 }; 6464 6465 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 6466 __rte_unused struct cmdline *cl, 6467 __rte_unused void *data) 6468 { 6469 struct cmd_set_bond_mac_addr_result *res = parsed_result; 6470 int ret; 6471 6472 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 6473 return; 6474 6475 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 6476 6477 /* check the return value and print it if is < 0 */ 6478 if (ret < 0) 6479 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6480 } 6481 6482 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 6483 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 6484 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 6485 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 6486 "bonding"); 6487 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 6488 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 6489 "mac_addr"); 6490 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 6491 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 6492 port_num, UINT16); 6493 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 6494 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 6495 6496 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 6497 .f = cmd_set_bond_mac_addr_parsed, 6498 .data = (void *) 0, 6499 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 6500 .tokens = { 6501 (void *)&cmd_set_bond_mac_addr_set, 6502 (void *)&cmd_set_bond_mac_addr_bonding, 6503 (void *)&cmd_set_bond_mac_addr_mac, 6504 (void *)&cmd_set_bond_mac_addr_portnum, 6505 (void *)&cmd_set_bond_mac_addr_addr, 6506 NULL 6507 } 6508 }; 6509 6510 6511 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 6512 struct cmd_set_bond_mon_period_result { 6513 cmdline_fixed_string_t set; 6514 cmdline_fixed_string_t bonding; 6515 cmdline_fixed_string_t mon_period; 6516 uint16_t port_num; 6517 uint32_t period_ms; 6518 }; 6519 6520 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 6521 __rte_unused struct cmdline *cl, 6522 __rte_unused void *data) 6523 { 6524 struct cmd_set_bond_mon_period_result *res = parsed_result; 6525 int ret; 6526 6527 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 6528 6529 /* check the return value and print it if is < 0 */ 6530 if (ret < 0) 6531 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6532 } 6533 6534 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 6535 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6536 set, "set"); 6537 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 6538 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6539 bonding, "bonding"); 6540 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 6541 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6542 mon_period, "mon_period"); 6543 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 6544 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6545 port_num, UINT16); 6546 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 6547 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6548 period_ms, UINT32); 6549 6550 cmdline_parse_inst_t cmd_set_bond_mon_period = { 6551 .f = cmd_set_bond_mon_period_parsed, 6552 .data = (void *) 0, 6553 .help_str = "set bonding mon_period <port_id> <period_ms>", 6554 .tokens = { 6555 (void *)&cmd_set_bond_mon_period_set, 6556 (void *)&cmd_set_bond_mon_period_bonding, 6557 (void *)&cmd_set_bond_mon_period_mon_period, 6558 (void *)&cmd_set_bond_mon_period_portnum, 6559 (void *)&cmd_set_bond_mon_period_period_ms, 6560 NULL 6561 } 6562 }; 6563 6564 6565 6566 struct cmd_set_bonding_agg_mode_policy_result { 6567 cmdline_fixed_string_t set; 6568 cmdline_fixed_string_t bonding; 6569 cmdline_fixed_string_t agg_mode; 6570 uint16_t port_num; 6571 cmdline_fixed_string_t policy; 6572 }; 6573 6574 6575 static void 6576 cmd_set_bonding_agg_mode(void *parsed_result, 6577 __rte_unused struct cmdline *cl, 6578 __rte_unused void *data) 6579 { 6580 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 6581 uint8_t policy = AGG_BANDWIDTH; 6582 6583 if (!strcmp(res->policy, "bandwidth")) 6584 policy = AGG_BANDWIDTH; 6585 else if (!strcmp(res->policy, "stable")) 6586 policy = AGG_STABLE; 6587 else if (!strcmp(res->policy, "count")) 6588 policy = AGG_COUNT; 6589 6590 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 6591 } 6592 6593 6594 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 6595 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6596 set, "set"); 6597 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 6598 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6599 bonding, "bonding"); 6600 6601 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 6602 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6603 agg_mode, "agg_mode"); 6604 6605 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 6606 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6607 port_num, UINT16); 6608 6609 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 6610 TOKEN_STRING_INITIALIZER( 6611 struct cmd_set_bonding_balance_xmit_policy_result, 6612 policy, "stable#bandwidth#count"); 6613 6614 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 6615 .f = cmd_set_bonding_agg_mode, 6616 .data = (void *) 0, 6617 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 6618 .tokens = { 6619 (void *)&cmd_set_bonding_agg_mode_set, 6620 (void *)&cmd_set_bonding_agg_mode_bonding, 6621 (void *)&cmd_set_bonding_agg_mode_agg_mode, 6622 (void *)&cmd_set_bonding_agg_mode_portnum, 6623 (void *)&cmd_set_bonding_agg_mode_policy_string, 6624 NULL 6625 } 6626 }; 6627 6628 6629 #endif /* RTE_NET_BOND */ 6630 6631 /* *** SET FORWARDING MODE *** */ 6632 struct cmd_set_fwd_mode_result { 6633 cmdline_fixed_string_t set; 6634 cmdline_fixed_string_t fwd; 6635 cmdline_fixed_string_t mode; 6636 }; 6637 6638 static void cmd_set_fwd_mode_parsed(void *parsed_result, 6639 __rte_unused struct cmdline *cl, 6640 __rte_unused void *data) 6641 { 6642 struct cmd_set_fwd_mode_result *res = parsed_result; 6643 6644 retry_enabled = 0; 6645 set_pkt_forwarding_mode(res->mode); 6646 } 6647 6648 cmdline_parse_token_string_t cmd_setfwd_set = 6649 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 6650 cmdline_parse_token_string_t cmd_setfwd_fwd = 6651 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 6652 cmdline_parse_token_string_t cmd_setfwd_mode = 6653 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 6654 "" /* defined at init */); 6655 6656 cmdline_parse_inst_t cmd_set_fwd_mode = { 6657 .f = cmd_set_fwd_mode_parsed, 6658 .data = NULL, 6659 .help_str = NULL, /* defined at init */ 6660 .tokens = { 6661 (void *)&cmd_setfwd_set, 6662 (void *)&cmd_setfwd_fwd, 6663 (void *)&cmd_setfwd_mode, 6664 NULL, 6665 }, 6666 }; 6667 6668 static void cmd_set_fwd_mode_init(void) 6669 { 6670 char *modes, *c; 6671 static char token[128]; 6672 static char help[256]; 6673 cmdline_parse_token_string_t *token_struct; 6674 6675 modes = list_pkt_forwarding_modes(); 6676 snprintf(help, sizeof(help), "set fwd %s: " 6677 "Set packet forwarding mode", modes); 6678 cmd_set_fwd_mode.help_str = help; 6679 6680 /* string token separator is # */ 6681 for (c = token; *modes != '\0'; modes++) 6682 if (*modes == '|') 6683 *c++ = '#'; 6684 else 6685 *c++ = *modes; 6686 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 6687 token_struct->string_data.str = token; 6688 } 6689 6690 /* *** SET RETRY FORWARDING MODE *** */ 6691 struct cmd_set_fwd_retry_mode_result { 6692 cmdline_fixed_string_t set; 6693 cmdline_fixed_string_t fwd; 6694 cmdline_fixed_string_t mode; 6695 cmdline_fixed_string_t retry; 6696 }; 6697 6698 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 6699 __rte_unused struct cmdline *cl, 6700 __rte_unused void *data) 6701 { 6702 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 6703 6704 retry_enabled = 1; 6705 set_pkt_forwarding_mode(res->mode); 6706 } 6707 6708 cmdline_parse_token_string_t cmd_setfwd_retry_set = 6709 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6710 set, "set"); 6711 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 6712 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6713 fwd, "fwd"); 6714 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 6715 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6716 mode, 6717 "" /* defined at init */); 6718 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 6719 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6720 retry, "retry"); 6721 6722 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 6723 .f = cmd_set_fwd_retry_mode_parsed, 6724 .data = NULL, 6725 .help_str = NULL, /* defined at init */ 6726 .tokens = { 6727 (void *)&cmd_setfwd_retry_set, 6728 (void *)&cmd_setfwd_retry_fwd, 6729 (void *)&cmd_setfwd_retry_mode, 6730 (void *)&cmd_setfwd_retry_retry, 6731 NULL, 6732 }, 6733 }; 6734 6735 static void cmd_set_fwd_retry_mode_init(void) 6736 { 6737 char *modes, *c; 6738 static char token[128]; 6739 static char help[256]; 6740 cmdline_parse_token_string_t *token_struct; 6741 6742 modes = list_pkt_forwarding_retry_modes(); 6743 snprintf(help, sizeof(help), "set fwd %s retry: " 6744 "Set packet forwarding mode with retry", modes); 6745 cmd_set_fwd_retry_mode.help_str = help; 6746 6747 /* string token separator is # */ 6748 for (c = token; *modes != '\0'; modes++) 6749 if (*modes == '|') 6750 *c++ = '#'; 6751 else 6752 *c++ = *modes; 6753 token_struct = (cmdline_parse_token_string_t *) 6754 cmd_set_fwd_retry_mode.tokens[2]; 6755 token_struct->string_data.str = token; 6756 } 6757 6758 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 6759 struct cmd_set_burst_tx_retry_result { 6760 cmdline_fixed_string_t set; 6761 cmdline_fixed_string_t burst; 6762 cmdline_fixed_string_t tx; 6763 cmdline_fixed_string_t delay; 6764 uint32_t time; 6765 cmdline_fixed_string_t retry; 6766 uint32_t retry_num; 6767 }; 6768 6769 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 6770 __rte_unused struct cmdline *cl, 6771 __rte_unused void *data) 6772 { 6773 struct cmd_set_burst_tx_retry_result *res = parsed_result; 6774 6775 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 6776 && !strcmp(res->tx, "tx")) { 6777 if (!strcmp(res->delay, "delay")) 6778 burst_tx_delay_time = res->time; 6779 if (!strcmp(res->retry, "retry")) 6780 burst_tx_retry_num = res->retry_num; 6781 } 6782 6783 } 6784 6785 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 6786 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 6787 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 6788 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 6789 "burst"); 6790 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 6791 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 6792 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 6793 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 6794 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 6795 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32); 6796 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 6797 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 6798 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 6799 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32); 6800 6801 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 6802 .f = cmd_set_burst_tx_retry_parsed, 6803 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 6804 .tokens = { 6805 (void *)&cmd_set_burst_tx_retry_set, 6806 (void *)&cmd_set_burst_tx_retry_burst, 6807 (void *)&cmd_set_burst_tx_retry_tx, 6808 (void *)&cmd_set_burst_tx_retry_delay, 6809 (void *)&cmd_set_burst_tx_retry_time, 6810 (void *)&cmd_set_burst_tx_retry_retry, 6811 (void *)&cmd_set_burst_tx_retry_retry_num, 6812 NULL, 6813 }, 6814 }; 6815 6816 /* *** SET PROMISC MODE *** */ 6817 struct cmd_set_promisc_mode_result { 6818 cmdline_fixed_string_t set; 6819 cmdline_fixed_string_t promisc; 6820 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6821 uint16_t port_num; /* valid if "allports" argument == 0 */ 6822 cmdline_fixed_string_t mode; 6823 }; 6824 6825 static void cmd_set_promisc_mode_parsed(void *parsed_result, 6826 __rte_unused struct cmdline *cl, 6827 void *allports) 6828 { 6829 struct cmd_set_promisc_mode_result *res = parsed_result; 6830 int enable; 6831 portid_t i; 6832 6833 if (!strcmp(res->mode, "on")) 6834 enable = 1; 6835 else 6836 enable = 0; 6837 6838 /* all ports */ 6839 if (allports) { 6840 RTE_ETH_FOREACH_DEV(i) 6841 eth_set_promisc_mode(i, enable); 6842 } else { 6843 eth_set_promisc_mode(res->port_num, enable); 6844 } 6845 } 6846 6847 cmdline_parse_token_string_t cmd_setpromisc_set = 6848 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 6849 cmdline_parse_token_string_t cmd_setpromisc_promisc = 6850 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 6851 "promisc"); 6852 cmdline_parse_token_string_t cmd_setpromisc_portall = 6853 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 6854 "all"); 6855 cmdline_parse_token_num_t cmd_setpromisc_portnum = 6856 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 6857 UINT16); 6858 cmdline_parse_token_string_t cmd_setpromisc_mode = 6859 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 6860 "on#off"); 6861 6862 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 6863 .f = cmd_set_promisc_mode_parsed, 6864 .data = (void *)1, 6865 .help_str = "set promisc all on|off: Set promisc mode for all ports", 6866 .tokens = { 6867 (void *)&cmd_setpromisc_set, 6868 (void *)&cmd_setpromisc_promisc, 6869 (void *)&cmd_setpromisc_portall, 6870 (void *)&cmd_setpromisc_mode, 6871 NULL, 6872 }, 6873 }; 6874 6875 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 6876 .f = cmd_set_promisc_mode_parsed, 6877 .data = (void *)0, 6878 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 6879 .tokens = { 6880 (void *)&cmd_setpromisc_set, 6881 (void *)&cmd_setpromisc_promisc, 6882 (void *)&cmd_setpromisc_portnum, 6883 (void *)&cmd_setpromisc_mode, 6884 NULL, 6885 }, 6886 }; 6887 6888 /* *** SET ALLMULTI MODE *** */ 6889 struct cmd_set_allmulti_mode_result { 6890 cmdline_fixed_string_t set; 6891 cmdline_fixed_string_t allmulti; 6892 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6893 uint16_t port_num; /* valid if "allports" argument == 0 */ 6894 cmdline_fixed_string_t mode; 6895 }; 6896 6897 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 6898 __rte_unused struct cmdline *cl, 6899 void *allports) 6900 { 6901 struct cmd_set_allmulti_mode_result *res = parsed_result; 6902 int enable; 6903 portid_t i; 6904 6905 if (!strcmp(res->mode, "on")) 6906 enable = 1; 6907 else 6908 enable = 0; 6909 6910 /* all ports */ 6911 if (allports) { 6912 RTE_ETH_FOREACH_DEV(i) { 6913 eth_set_allmulticast_mode(i, enable); 6914 } 6915 } 6916 else { 6917 eth_set_allmulticast_mode(res->port_num, enable); 6918 } 6919 } 6920 6921 cmdline_parse_token_string_t cmd_setallmulti_set = 6922 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 6923 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 6924 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 6925 "allmulti"); 6926 cmdline_parse_token_string_t cmd_setallmulti_portall = 6927 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 6928 "all"); 6929 cmdline_parse_token_num_t cmd_setallmulti_portnum = 6930 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 6931 UINT16); 6932 cmdline_parse_token_string_t cmd_setallmulti_mode = 6933 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 6934 "on#off"); 6935 6936 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 6937 .f = cmd_set_allmulti_mode_parsed, 6938 .data = (void *)1, 6939 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 6940 .tokens = { 6941 (void *)&cmd_setallmulti_set, 6942 (void *)&cmd_setallmulti_allmulti, 6943 (void *)&cmd_setallmulti_portall, 6944 (void *)&cmd_setallmulti_mode, 6945 NULL, 6946 }, 6947 }; 6948 6949 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 6950 .f = cmd_set_allmulti_mode_parsed, 6951 .data = (void *)0, 6952 .help_str = "set allmulti <port_id> on|off: " 6953 "Set allmulti mode on port_id", 6954 .tokens = { 6955 (void *)&cmd_setallmulti_set, 6956 (void *)&cmd_setallmulti_allmulti, 6957 (void *)&cmd_setallmulti_portnum, 6958 (void *)&cmd_setallmulti_mode, 6959 NULL, 6960 }, 6961 }; 6962 6963 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 6964 struct cmd_link_flow_ctrl_set_result { 6965 cmdline_fixed_string_t set; 6966 cmdline_fixed_string_t flow_ctrl; 6967 cmdline_fixed_string_t rx; 6968 cmdline_fixed_string_t rx_lfc_mode; 6969 cmdline_fixed_string_t tx; 6970 cmdline_fixed_string_t tx_lfc_mode; 6971 cmdline_fixed_string_t mac_ctrl_frame_fwd; 6972 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 6973 cmdline_fixed_string_t autoneg_str; 6974 cmdline_fixed_string_t autoneg; 6975 cmdline_fixed_string_t hw_str; 6976 uint32_t high_water; 6977 cmdline_fixed_string_t lw_str; 6978 uint32_t low_water; 6979 cmdline_fixed_string_t pt_str; 6980 uint16_t pause_time; 6981 cmdline_fixed_string_t xon_str; 6982 uint16_t send_xon; 6983 portid_t port_id; 6984 }; 6985 6986 cmdline_parse_token_string_t cmd_lfc_set_set = 6987 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6988 set, "set"); 6989 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 6990 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6991 flow_ctrl, "flow_ctrl"); 6992 cmdline_parse_token_string_t cmd_lfc_set_rx = 6993 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6994 rx, "rx"); 6995 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 6996 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6997 rx_lfc_mode, "on#off"); 6998 cmdline_parse_token_string_t cmd_lfc_set_tx = 6999 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7000 tx, "tx"); 7001 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 7002 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7003 tx_lfc_mode, "on#off"); 7004 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 7005 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7006 hw_str, "high_water"); 7007 cmdline_parse_token_num_t cmd_lfc_set_high_water = 7008 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7009 high_water, UINT32); 7010 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 7011 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7012 lw_str, "low_water"); 7013 cmdline_parse_token_num_t cmd_lfc_set_low_water = 7014 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7015 low_water, UINT32); 7016 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 7017 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7018 pt_str, "pause_time"); 7019 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 7020 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7021 pause_time, UINT16); 7022 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 7023 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7024 xon_str, "send_xon"); 7025 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 7026 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7027 send_xon, UINT16); 7028 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 7029 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7030 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 7031 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 7032 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7033 mac_ctrl_frame_fwd_mode, "on#off"); 7034 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 7035 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7036 autoneg_str, "autoneg"); 7037 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 7038 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7039 autoneg, "on#off"); 7040 cmdline_parse_token_num_t cmd_lfc_set_portid = 7041 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 7042 port_id, UINT16); 7043 7044 /* forward declaration */ 7045 static void 7046 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 7047 void *data); 7048 7049 cmdline_parse_inst_t cmd_link_flow_control_set = { 7050 .f = cmd_link_flow_ctrl_set_parsed, 7051 .data = NULL, 7052 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 7053 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 7054 "autoneg on|off <port_id>: Configure the Ethernet flow control", 7055 .tokens = { 7056 (void *)&cmd_lfc_set_set, 7057 (void *)&cmd_lfc_set_flow_ctrl, 7058 (void *)&cmd_lfc_set_rx, 7059 (void *)&cmd_lfc_set_rx_mode, 7060 (void *)&cmd_lfc_set_tx, 7061 (void *)&cmd_lfc_set_tx_mode, 7062 (void *)&cmd_lfc_set_high_water, 7063 (void *)&cmd_lfc_set_low_water, 7064 (void *)&cmd_lfc_set_pause_time, 7065 (void *)&cmd_lfc_set_send_xon, 7066 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 7067 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 7068 (void *)&cmd_lfc_set_autoneg_str, 7069 (void *)&cmd_lfc_set_autoneg, 7070 (void *)&cmd_lfc_set_portid, 7071 NULL, 7072 }, 7073 }; 7074 7075 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 7076 .f = cmd_link_flow_ctrl_set_parsed, 7077 .data = (void *)&cmd_link_flow_control_set_rx, 7078 .help_str = "set flow_ctrl rx on|off <port_id>: " 7079 "Change rx flow control parameter", 7080 .tokens = { 7081 (void *)&cmd_lfc_set_set, 7082 (void *)&cmd_lfc_set_flow_ctrl, 7083 (void *)&cmd_lfc_set_rx, 7084 (void *)&cmd_lfc_set_rx_mode, 7085 (void *)&cmd_lfc_set_portid, 7086 NULL, 7087 }, 7088 }; 7089 7090 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 7091 .f = cmd_link_flow_ctrl_set_parsed, 7092 .data = (void *)&cmd_link_flow_control_set_tx, 7093 .help_str = "set flow_ctrl tx on|off <port_id>: " 7094 "Change tx flow control parameter", 7095 .tokens = { 7096 (void *)&cmd_lfc_set_set, 7097 (void *)&cmd_lfc_set_flow_ctrl, 7098 (void *)&cmd_lfc_set_tx, 7099 (void *)&cmd_lfc_set_tx_mode, 7100 (void *)&cmd_lfc_set_portid, 7101 NULL, 7102 }, 7103 }; 7104 7105 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 7106 .f = cmd_link_flow_ctrl_set_parsed, 7107 .data = (void *)&cmd_link_flow_control_set_hw, 7108 .help_str = "set flow_ctrl high_water <value> <port_id>: " 7109 "Change high water flow control parameter", 7110 .tokens = { 7111 (void *)&cmd_lfc_set_set, 7112 (void *)&cmd_lfc_set_flow_ctrl, 7113 (void *)&cmd_lfc_set_high_water_str, 7114 (void *)&cmd_lfc_set_high_water, 7115 (void *)&cmd_lfc_set_portid, 7116 NULL, 7117 }, 7118 }; 7119 7120 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 7121 .f = cmd_link_flow_ctrl_set_parsed, 7122 .data = (void *)&cmd_link_flow_control_set_lw, 7123 .help_str = "set flow_ctrl low_water <value> <port_id>: " 7124 "Change low water flow control parameter", 7125 .tokens = { 7126 (void *)&cmd_lfc_set_set, 7127 (void *)&cmd_lfc_set_flow_ctrl, 7128 (void *)&cmd_lfc_set_low_water_str, 7129 (void *)&cmd_lfc_set_low_water, 7130 (void *)&cmd_lfc_set_portid, 7131 NULL, 7132 }, 7133 }; 7134 7135 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 7136 .f = cmd_link_flow_ctrl_set_parsed, 7137 .data = (void *)&cmd_link_flow_control_set_pt, 7138 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 7139 "Change pause time flow control parameter", 7140 .tokens = { 7141 (void *)&cmd_lfc_set_set, 7142 (void *)&cmd_lfc_set_flow_ctrl, 7143 (void *)&cmd_lfc_set_pause_time_str, 7144 (void *)&cmd_lfc_set_pause_time, 7145 (void *)&cmd_lfc_set_portid, 7146 NULL, 7147 }, 7148 }; 7149 7150 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 7151 .f = cmd_link_flow_ctrl_set_parsed, 7152 .data = (void *)&cmd_link_flow_control_set_xon, 7153 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 7154 "Change send_xon flow control parameter", 7155 .tokens = { 7156 (void *)&cmd_lfc_set_set, 7157 (void *)&cmd_lfc_set_flow_ctrl, 7158 (void *)&cmd_lfc_set_send_xon_str, 7159 (void *)&cmd_lfc_set_send_xon, 7160 (void *)&cmd_lfc_set_portid, 7161 NULL, 7162 }, 7163 }; 7164 7165 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 7166 .f = cmd_link_flow_ctrl_set_parsed, 7167 .data = (void *)&cmd_link_flow_control_set_macfwd, 7168 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 7169 "Change mac ctrl fwd flow control parameter", 7170 .tokens = { 7171 (void *)&cmd_lfc_set_set, 7172 (void *)&cmd_lfc_set_flow_ctrl, 7173 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 7174 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 7175 (void *)&cmd_lfc_set_portid, 7176 NULL, 7177 }, 7178 }; 7179 7180 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 7181 .f = cmd_link_flow_ctrl_set_parsed, 7182 .data = (void *)&cmd_link_flow_control_set_autoneg, 7183 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 7184 "Change autoneg flow control parameter", 7185 .tokens = { 7186 (void *)&cmd_lfc_set_set, 7187 (void *)&cmd_lfc_set_flow_ctrl, 7188 (void *)&cmd_lfc_set_autoneg_str, 7189 (void *)&cmd_lfc_set_autoneg, 7190 (void *)&cmd_lfc_set_portid, 7191 NULL, 7192 }, 7193 }; 7194 7195 static void 7196 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 7197 __rte_unused struct cmdline *cl, 7198 void *data) 7199 { 7200 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 7201 cmdline_parse_inst_t *cmd = data; 7202 struct rte_eth_fc_conf fc_conf; 7203 int rx_fc_en = 0; 7204 int tx_fc_en = 0; 7205 int ret; 7206 7207 /* 7208 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 7209 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 7210 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 7211 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 7212 */ 7213 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 7214 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 7215 }; 7216 7217 /* Partial command line, retrieve current configuration */ 7218 if (cmd) { 7219 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 7220 if (ret != 0) { 7221 printf("cannot get current flow ctrl parameters, return" 7222 "code = %d\n", ret); 7223 return; 7224 } 7225 7226 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 7227 (fc_conf.mode == RTE_FC_FULL)) 7228 rx_fc_en = 1; 7229 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 7230 (fc_conf.mode == RTE_FC_FULL)) 7231 tx_fc_en = 1; 7232 } 7233 7234 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 7235 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 7236 7237 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 7238 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 7239 7240 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 7241 7242 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 7243 fc_conf.high_water = res->high_water; 7244 7245 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 7246 fc_conf.low_water = res->low_water; 7247 7248 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 7249 fc_conf.pause_time = res->pause_time; 7250 7251 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 7252 fc_conf.send_xon = res->send_xon; 7253 7254 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 7255 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 7256 fc_conf.mac_ctrl_frame_fwd = 1; 7257 else 7258 fc_conf.mac_ctrl_frame_fwd = 0; 7259 } 7260 7261 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 7262 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 7263 7264 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 7265 if (ret != 0) 7266 printf("bad flow contrl parameter, return code = %d \n", ret); 7267 } 7268 7269 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 7270 struct cmd_priority_flow_ctrl_set_result { 7271 cmdline_fixed_string_t set; 7272 cmdline_fixed_string_t pfc_ctrl; 7273 cmdline_fixed_string_t rx; 7274 cmdline_fixed_string_t rx_pfc_mode; 7275 cmdline_fixed_string_t tx; 7276 cmdline_fixed_string_t tx_pfc_mode; 7277 uint32_t high_water; 7278 uint32_t low_water; 7279 uint16_t pause_time; 7280 uint8_t priority; 7281 portid_t port_id; 7282 }; 7283 7284 static void 7285 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 7286 __rte_unused struct cmdline *cl, 7287 __rte_unused void *data) 7288 { 7289 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 7290 struct rte_eth_pfc_conf pfc_conf; 7291 int rx_fc_enable, tx_fc_enable; 7292 int ret; 7293 7294 /* 7295 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 7296 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 7297 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 7298 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 7299 */ 7300 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 7301 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 7302 }; 7303 7304 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf)); 7305 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 7306 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 7307 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 7308 pfc_conf.fc.high_water = res->high_water; 7309 pfc_conf.fc.low_water = res->low_water; 7310 pfc_conf.fc.pause_time = res->pause_time; 7311 pfc_conf.priority = res->priority; 7312 7313 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 7314 if (ret != 0) 7315 printf("bad priority flow contrl parameter, return code = %d \n", ret); 7316 } 7317 7318 cmdline_parse_token_string_t cmd_pfc_set_set = 7319 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7320 set, "set"); 7321 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 7322 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7323 pfc_ctrl, "pfc_ctrl"); 7324 cmdline_parse_token_string_t cmd_pfc_set_rx = 7325 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7326 rx, "rx"); 7327 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 7328 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7329 rx_pfc_mode, "on#off"); 7330 cmdline_parse_token_string_t cmd_pfc_set_tx = 7331 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7332 tx, "tx"); 7333 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 7334 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7335 tx_pfc_mode, "on#off"); 7336 cmdline_parse_token_num_t cmd_pfc_set_high_water = 7337 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7338 high_water, UINT32); 7339 cmdline_parse_token_num_t cmd_pfc_set_low_water = 7340 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7341 low_water, UINT32); 7342 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 7343 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7344 pause_time, UINT16); 7345 cmdline_parse_token_num_t cmd_pfc_set_priority = 7346 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7347 priority, UINT8); 7348 cmdline_parse_token_num_t cmd_pfc_set_portid = 7349 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7350 port_id, UINT16); 7351 7352 cmdline_parse_inst_t cmd_priority_flow_control_set = { 7353 .f = cmd_priority_flow_ctrl_set_parsed, 7354 .data = NULL, 7355 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 7356 "<pause_time> <priority> <port_id>: " 7357 "Configure the Ethernet priority flow control", 7358 .tokens = { 7359 (void *)&cmd_pfc_set_set, 7360 (void *)&cmd_pfc_set_flow_ctrl, 7361 (void *)&cmd_pfc_set_rx, 7362 (void *)&cmd_pfc_set_rx_mode, 7363 (void *)&cmd_pfc_set_tx, 7364 (void *)&cmd_pfc_set_tx_mode, 7365 (void *)&cmd_pfc_set_high_water, 7366 (void *)&cmd_pfc_set_low_water, 7367 (void *)&cmd_pfc_set_pause_time, 7368 (void *)&cmd_pfc_set_priority, 7369 (void *)&cmd_pfc_set_portid, 7370 NULL, 7371 }, 7372 }; 7373 7374 /* *** RESET CONFIGURATION *** */ 7375 struct cmd_reset_result { 7376 cmdline_fixed_string_t reset; 7377 cmdline_fixed_string_t def; 7378 }; 7379 7380 static void cmd_reset_parsed(__rte_unused void *parsed_result, 7381 struct cmdline *cl, 7382 __rte_unused void *data) 7383 { 7384 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 7385 set_def_fwd_config(); 7386 } 7387 7388 cmdline_parse_token_string_t cmd_reset_set = 7389 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 7390 cmdline_parse_token_string_t cmd_reset_def = 7391 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 7392 "default"); 7393 7394 cmdline_parse_inst_t cmd_reset = { 7395 .f = cmd_reset_parsed, 7396 .data = NULL, 7397 .help_str = "set default: Reset default forwarding configuration", 7398 .tokens = { 7399 (void *)&cmd_reset_set, 7400 (void *)&cmd_reset_def, 7401 NULL, 7402 }, 7403 }; 7404 7405 /* *** START FORWARDING *** */ 7406 struct cmd_start_result { 7407 cmdline_fixed_string_t start; 7408 }; 7409 7410 cmdline_parse_token_string_t cmd_start_start = 7411 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 7412 7413 static void cmd_start_parsed(__rte_unused void *parsed_result, 7414 __rte_unused struct cmdline *cl, 7415 __rte_unused void *data) 7416 { 7417 start_packet_forwarding(0); 7418 } 7419 7420 cmdline_parse_inst_t cmd_start = { 7421 .f = cmd_start_parsed, 7422 .data = NULL, 7423 .help_str = "start: Start packet forwarding", 7424 .tokens = { 7425 (void *)&cmd_start_start, 7426 NULL, 7427 }, 7428 }; 7429 7430 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 7431 struct cmd_start_tx_first_result { 7432 cmdline_fixed_string_t start; 7433 cmdline_fixed_string_t tx_first; 7434 }; 7435 7436 static void 7437 cmd_start_tx_first_parsed(__rte_unused void *parsed_result, 7438 __rte_unused struct cmdline *cl, 7439 __rte_unused void *data) 7440 { 7441 start_packet_forwarding(1); 7442 } 7443 7444 cmdline_parse_token_string_t cmd_start_tx_first_start = 7445 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 7446 "start"); 7447 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 7448 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 7449 tx_first, "tx_first"); 7450 7451 cmdline_parse_inst_t cmd_start_tx_first = { 7452 .f = cmd_start_tx_first_parsed, 7453 .data = NULL, 7454 .help_str = "start tx_first: Start packet forwarding, " 7455 "after sending 1 burst of packets", 7456 .tokens = { 7457 (void *)&cmd_start_tx_first_start, 7458 (void *)&cmd_start_tx_first_tx_first, 7459 NULL, 7460 }, 7461 }; 7462 7463 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 7464 struct cmd_start_tx_first_n_result { 7465 cmdline_fixed_string_t start; 7466 cmdline_fixed_string_t tx_first; 7467 uint32_t tx_num; 7468 }; 7469 7470 static void 7471 cmd_start_tx_first_n_parsed(void *parsed_result, 7472 __rte_unused struct cmdline *cl, 7473 __rte_unused void *data) 7474 { 7475 struct cmd_start_tx_first_n_result *res = parsed_result; 7476 7477 start_packet_forwarding(res->tx_num); 7478 } 7479 7480 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 7481 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7482 start, "start"); 7483 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 7484 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7485 tx_first, "tx_first"); 7486 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 7487 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 7488 tx_num, UINT32); 7489 7490 cmdline_parse_inst_t cmd_start_tx_first_n = { 7491 .f = cmd_start_tx_first_n_parsed, 7492 .data = NULL, 7493 .help_str = "start tx_first <num>: " 7494 "packet forwarding, after sending <num> bursts of packets", 7495 .tokens = { 7496 (void *)&cmd_start_tx_first_n_start, 7497 (void *)&cmd_start_tx_first_n_tx_first, 7498 (void *)&cmd_start_tx_first_n_tx_num, 7499 NULL, 7500 }, 7501 }; 7502 7503 /* *** SET LINK UP *** */ 7504 struct cmd_set_link_up_result { 7505 cmdline_fixed_string_t set; 7506 cmdline_fixed_string_t link_up; 7507 cmdline_fixed_string_t port; 7508 portid_t port_id; 7509 }; 7510 7511 cmdline_parse_token_string_t cmd_set_link_up_set = 7512 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 7513 cmdline_parse_token_string_t cmd_set_link_up_link_up = 7514 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 7515 "link-up"); 7516 cmdline_parse_token_string_t cmd_set_link_up_port = 7517 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 7518 cmdline_parse_token_num_t cmd_set_link_up_port_id = 7519 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16); 7520 7521 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result, 7522 __rte_unused struct cmdline *cl, 7523 __rte_unused void *data) 7524 { 7525 struct cmd_set_link_up_result *res = parsed_result; 7526 dev_set_link_up(res->port_id); 7527 } 7528 7529 cmdline_parse_inst_t cmd_set_link_up = { 7530 .f = cmd_set_link_up_parsed, 7531 .data = NULL, 7532 .help_str = "set link-up port <port id>", 7533 .tokens = { 7534 (void *)&cmd_set_link_up_set, 7535 (void *)&cmd_set_link_up_link_up, 7536 (void *)&cmd_set_link_up_port, 7537 (void *)&cmd_set_link_up_port_id, 7538 NULL, 7539 }, 7540 }; 7541 7542 /* *** SET LINK DOWN *** */ 7543 struct cmd_set_link_down_result { 7544 cmdline_fixed_string_t set; 7545 cmdline_fixed_string_t link_down; 7546 cmdline_fixed_string_t port; 7547 portid_t port_id; 7548 }; 7549 7550 cmdline_parse_token_string_t cmd_set_link_down_set = 7551 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 7552 cmdline_parse_token_string_t cmd_set_link_down_link_down = 7553 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 7554 "link-down"); 7555 cmdline_parse_token_string_t cmd_set_link_down_port = 7556 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 7557 cmdline_parse_token_num_t cmd_set_link_down_port_id = 7558 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16); 7559 7560 static void cmd_set_link_down_parsed( 7561 __rte_unused void *parsed_result, 7562 __rte_unused struct cmdline *cl, 7563 __rte_unused void *data) 7564 { 7565 struct cmd_set_link_down_result *res = parsed_result; 7566 dev_set_link_down(res->port_id); 7567 } 7568 7569 cmdline_parse_inst_t cmd_set_link_down = { 7570 .f = cmd_set_link_down_parsed, 7571 .data = NULL, 7572 .help_str = "set link-down port <port id>", 7573 .tokens = { 7574 (void *)&cmd_set_link_down_set, 7575 (void *)&cmd_set_link_down_link_down, 7576 (void *)&cmd_set_link_down_port, 7577 (void *)&cmd_set_link_down_port_id, 7578 NULL, 7579 }, 7580 }; 7581 7582 /* *** SHOW CFG *** */ 7583 struct cmd_showcfg_result { 7584 cmdline_fixed_string_t show; 7585 cmdline_fixed_string_t cfg; 7586 cmdline_fixed_string_t what; 7587 }; 7588 7589 static void cmd_showcfg_parsed(void *parsed_result, 7590 __rte_unused struct cmdline *cl, 7591 __rte_unused void *data) 7592 { 7593 struct cmd_showcfg_result *res = parsed_result; 7594 if (!strcmp(res->what, "rxtx")) 7595 rxtx_config_display(); 7596 else if (!strcmp(res->what, "cores")) 7597 fwd_lcores_config_display(); 7598 else if (!strcmp(res->what, "fwd")) 7599 pkt_fwd_config_display(&cur_fwd_config); 7600 else if (!strcmp(res->what, "rxoffs")) 7601 show_rx_pkt_offsets(); 7602 else if (!strcmp(res->what, "rxpkts")) 7603 show_rx_pkt_segments(); 7604 else if (!strcmp(res->what, "txpkts")) 7605 show_tx_pkt_segments(); 7606 else if (!strcmp(res->what, "txtimes")) 7607 show_tx_pkt_times(); 7608 } 7609 7610 cmdline_parse_token_string_t cmd_showcfg_show = 7611 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 7612 cmdline_parse_token_string_t cmd_showcfg_port = 7613 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7614 cmdline_parse_token_string_t cmd_showcfg_what = 7615 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7616 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes"); 7617 7618 cmdline_parse_inst_t cmd_showcfg = { 7619 .f = cmd_showcfg_parsed, 7620 .data = NULL, 7621 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes", 7622 .tokens = { 7623 (void *)&cmd_showcfg_show, 7624 (void *)&cmd_showcfg_port, 7625 (void *)&cmd_showcfg_what, 7626 NULL, 7627 }, 7628 }; 7629 7630 /* *** SHOW ALL PORT INFO *** */ 7631 struct cmd_showportall_result { 7632 cmdline_fixed_string_t show; 7633 cmdline_fixed_string_t port; 7634 cmdline_fixed_string_t what; 7635 cmdline_fixed_string_t all; 7636 }; 7637 7638 static void cmd_showportall_parsed(void *parsed_result, 7639 __rte_unused struct cmdline *cl, 7640 __rte_unused void *data) 7641 { 7642 portid_t i; 7643 7644 struct cmd_showportall_result *res = parsed_result; 7645 if (!strcmp(res->show, "clear")) { 7646 if (!strcmp(res->what, "stats")) 7647 RTE_ETH_FOREACH_DEV(i) 7648 nic_stats_clear(i); 7649 else if (!strcmp(res->what, "xstats")) 7650 RTE_ETH_FOREACH_DEV(i) 7651 nic_xstats_clear(i); 7652 } else if (!strcmp(res->what, "info")) 7653 RTE_ETH_FOREACH_DEV(i) 7654 port_infos_display(i); 7655 else if (!strcmp(res->what, "summary")) { 7656 port_summary_header_display(); 7657 RTE_ETH_FOREACH_DEV(i) 7658 port_summary_display(i); 7659 } 7660 else if (!strcmp(res->what, "stats")) 7661 RTE_ETH_FOREACH_DEV(i) 7662 nic_stats_display(i); 7663 else if (!strcmp(res->what, "xstats")) 7664 RTE_ETH_FOREACH_DEV(i) 7665 nic_xstats_display(i); 7666 else if (!strcmp(res->what, "fdir")) 7667 RTE_ETH_FOREACH_DEV(i) 7668 fdir_get_infos(i); 7669 else if (!strcmp(res->what, "stat_qmap")) 7670 RTE_ETH_FOREACH_DEV(i) 7671 nic_stats_mapping_display(i); 7672 else if (!strcmp(res->what, "dcb_tc")) 7673 RTE_ETH_FOREACH_DEV(i) 7674 port_dcb_info_display(i); 7675 else if (!strcmp(res->what, "cap")) 7676 RTE_ETH_FOREACH_DEV(i) 7677 port_offload_cap_display(i); 7678 } 7679 7680 cmdline_parse_token_string_t cmd_showportall_show = 7681 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7682 "show#clear"); 7683 cmdline_parse_token_string_t cmd_showportall_port = 7684 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7685 cmdline_parse_token_string_t cmd_showportall_what = 7686 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7687 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7688 cmdline_parse_token_string_t cmd_showportall_all = 7689 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 7690 cmdline_parse_inst_t cmd_showportall = { 7691 .f = cmd_showportall_parsed, 7692 .data = NULL, 7693 .help_str = "show|clear port " 7694 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", 7695 .tokens = { 7696 (void *)&cmd_showportall_show, 7697 (void *)&cmd_showportall_port, 7698 (void *)&cmd_showportall_what, 7699 (void *)&cmd_showportall_all, 7700 NULL, 7701 }, 7702 }; 7703 7704 /* *** SHOW PORT INFO *** */ 7705 struct cmd_showport_result { 7706 cmdline_fixed_string_t show; 7707 cmdline_fixed_string_t port; 7708 cmdline_fixed_string_t what; 7709 uint16_t portnum; 7710 }; 7711 7712 static void cmd_showport_parsed(void *parsed_result, 7713 __rte_unused struct cmdline *cl, 7714 __rte_unused void *data) 7715 { 7716 struct cmd_showport_result *res = parsed_result; 7717 if (!strcmp(res->show, "clear")) { 7718 if (!strcmp(res->what, "stats")) 7719 nic_stats_clear(res->portnum); 7720 else if (!strcmp(res->what, "xstats")) 7721 nic_xstats_clear(res->portnum); 7722 } else if (!strcmp(res->what, "info")) 7723 port_infos_display(res->portnum); 7724 else if (!strcmp(res->what, "summary")) { 7725 port_summary_header_display(); 7726 port_summary_display(res->portnum); 7727 } 7728 else if (!strcmp(res->what, "stats")) 7729 nic_stats_display(res->portnum); 7730 else if (!strcmp(res->what, "xstats")) 7731 nic_xstats_display(res->portnum); 7732 else if (!strcmp(res->what, "fdir")) 7733 fdir_get_infos(res->portnum); 7734 else if (!strcmp(res->what, "stat_qmap")) 7735 nic_stats_mapping_display(res->portnum); 7736 else if (!strcmp(res->what, "dcb_tc")) 7737 port_dcb_info_display(res->portnum); 7738 else if (!strcmp(res->what, "cap")) 7739 port_offload_cap_display(res->portnum); 7740 } 7741 7742 cmdline_parse_token_string_t cmd_showport_show = 7743 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 7744 "show#clear"); 7745 cmdline_parse_token_string_t cmd_showport_port = 7746 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 7747 cmdline_parse_token_string_t cmd_showport_what = 7748 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 7749 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7750 cmdline_parse_token_num_t cmd_showport_portnum = 7751 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16); 7752 7753 cmdline_parse_inst_t cmd_showport = { 7754 .f = cmd_showport_parsed, 7755 .data = NULL, 7756 .help_str = "show|clear port " 7757 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap " 7758 "<port_id>", 7759 .tokens = { 7760 (void *)&cmd_showport_show, 7761 (void *)&cmd_showport_port, 7762 (void *)&cmd_showport_what, 7763 (void *)&cmd_showport_portnum, 7764 NULL, 7765 }, 7766 }; 7767 7768 /* *** SHOW DEVICE INFO *** */ 7769 struct cmd_showdevice_result { 7770 cmdline_fixed_string_t show; 7771 cmdline_fixed_string_t device; 7772 cmdline_fixed_string_t what; 7773 cmdline_fixed_string_t identifier; 7774 }; 7775 7776 static void cmd_showdevice_parsed(void *parsed_result, 7777 __rte_unused struct cmdline *cl, 7778 __rte_unused void *data) 7779 { 7780 struct cmd_showdevice_result *res = parsed_result; 7781 if (!strcmp(res->what, "info")) { 7782 if (!strcmp(res->identifier, "all")) 7783 device_infos_display(NULL); 7784 else 7785 device_infos_display(res->identifier); 7786 } 7787 } 7788 7789 cmdline_parse_token_string_t cmd_showdevice_show = 7790 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show, 7791 "show"); 7792 cmdline_parse_token_string_t cmd_showdevice_device = 7793 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device"); 7794 cmdline_parse_token_string_t cmd_showdevice_what = 7795 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what, 7796 "info"); 7797 cmdline_parse_token_string_t cmd_showdevice_identifier = 7798 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, 7799 identifier, NULL); 7800 7801 cmdline_parse_inst_t cmd_showdevice = { 7802 .f = cmd_showdevice_parsed, 7803 .data = NULL, 7804 .help_str = "show device info <identifier>|all", 7805 .tokens = { 7806 (void *)&cmd_showdevice_show, 7807 (void *)&cmd_showdevice_device, 7808 (void *)&cmd_showdevice_what, 7809 (void *)&cmd_showdevice_identifier, 7810 NULL, 7811 }, 7812 }; 7813 7814 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */ 7815 struct cmd_showeeprom_result { 7816 cmdline_fixed_string_t show; 7817 cmdline_fixed_string_t port; 7818 uint16_t portnum; 7819 cmdline_fixed_string_t type; 7820 }; 7821 7822 static void cmd_showeeprom_parsed(void *parsed_result, 7823 __rte_unused struct cmdline *cl, 7824 __rte_unused void *data) 7825 { 7826 struct cmd_showeeprom_result *res = parsed_result; 7827 7828 if (!strcmp(res->type, "eeprom")) 7829 port_eeprom_display(res->portnum); 7830 else if (!strcmp(res->type, "module_eeprom")) 7831 port_module_eeprom_display(res->portnum); 7832 else 7833 printf("Unknown argument\n"); 7834 } 7835 7836 cmdline_parse_token_string_t cmd_showeeprom_show = 7837 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show"); 7838 cmdline_parse_token_string_t cmd_showeeprom_port = 7839 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port"); 7840 cmdline_parse_token_num_t cmd_showeeprom_portnum = 7841 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16); 7842 cmdline_parse_token_string_t cmd_showeeprom_type = 7843 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom"); 7844 7845 cmdline_parse_inst_t cmd_showeeprom = { 7846 .f = cmd_showeeprom_parsed, 7847 .data = NULL, 7848 .help_str = "show port <port_id> module_eeprom|eeprom", 7849 .tokens = { 7850 (void *)&cmd_showeeprom_show, 7851 (void *)&cmd_showeeprom_port, 7852 (void *)&cmd_showeeprom_portnum, 7853 (void *)&cmd_showeeprom_type, 7854 NULL, 7855 }, 7856 }; 7857 7858 /* *** SHOW QUEUE INFO *** */ 7859 struct cmd_showqueue_result { 7860 cmdline_fixed_string_t show; 7861 cmdline_fixed_string_t type; 7862 cmdline_fixed_string_t what; 7863 uint16_t portnum; 7864 uint16_t queuenum; 7865 }; 7866 7867 static void 7868 cmd_showqueue_parsed(void *parsed_result, 7869 __rte_unused struct cmdline *cl, 7870 __rte_unused void *data) 7871 { 7872 struct cmd_showqueue_result *res = parsed_result; 7873 7874 if (!strcmp(res->type, "rxq")) 7875 rx_queue_infos_display(res->portnum, res->queuenum); 7876 else if (!strcmp(res->type, "txq")) 7877 tx_queue_infos_display(res->portnum, res->queuenum); 7878 } 7879 7880 cmdline_parse_token_string_t cmd_showqueue_show = 7881 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 7882 cmdline_parse_token_string_t cmd_showqueue_type = 7883 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 7884 cmdline_parse_token_string_t cmd_showqueue_what = 7885 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 7886 cmdline_parse_token_num_t cmd_showqueue_portnum = 7887 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16); 7888 cmdline_parse_token_num_t cmd_showqueue_queuenum = 7889 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16); 7890 7891 cmdline_parse_inst_t cmd_showqueue = { 7892 .f = cmd_showqueue_parsed, 7893 .data = NULL, 7894 .help_str = "show rxq|txq info <port_id> <queue_id>", 7895 .tokens = { 7896 (void *)&cmd_showqueue_show, 7897 (void *)&cmd_showqueue_type, 7898 (void *)&cmd_showqueue_what, 7899 (void *)&cmd_showqueue_portnum, 7900 (void *)&cmd_showqueue_queuenum, 7901 NULL, 7902 }, 7903 }; 7904 7905 /* show/clear fwd engine statistics */ 7906 struct fwd_result { 7907 cmdline_fixed_string_t action; 7908 cmdline_fixed_string_t fwd; 7909 cmdline_fixed_string_t stats; 7910 cmdline_fixed_string_t all; 7911 }; 7912 7913 cmdline_parse_token_string_t cmd_fwd_action = 7914 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear"); 7915 cmdline_parse_token_string_t cmd_fwd_fwd = 7916 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd"); 7917 cmdline_parse_token_string_t cmd_fwd_stats = 7918 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats"); 7919 cmdline_parse_token_string_t cmd_fwd_all = 7920 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all"); 7921 7922 static void 7923 cmd_showfwdall_parsed(void *parsed_result, 7924 __rte_unused struct cmdline *cl, 7925 __rte_unused void *data) 7926 { 7927 struct fwd_result *res = parsed_result; 7928 7929 if (!strcmp(res->action, "show")) 7930 fwd_stats_display(); 7931 else 7932 fwd_stats_reset(); 7933 } 7934 7935 static cmdline_parse_inst_t cmd_showfwdall = { 7936 .f = cmd_showfwdall_parsed, 7937 .data = NULL, 7938 .help_str = "show|clear fwd stats all", 7939 .tokens = { 7940 (void *)&cmd_fwd_action, 7941 (void *)&cmd_fwd_fwd, 7942 (void *)&cmd_fwd_stats, 7943 (void *)&cmd_fwd_all, 7944 NULL, 7945 }, 7946 }; 7947 7948 /* *** READ PORT REGISTER *** */ 7949 struct cmd_read_reg_result { 7950 cmdline_fixed_string_t read; 7951 cmdline_fixed_string_t reg; 7952 portid_t port_id; 7953 uint32_t reg_off; 7954 }; 7955 7956 static void 7957 cmd_read_reg_parsed(void *parsed_result, 7958 __rte_unused struct cmdline *cl, 7959 __rte_unused void *data) 7960 { 7961 struct cmd_read_reg_result *res = parsed_result; 7962 port_reg_display(res->port_id, res->reg_off); 7963 } 7964 7965 cmdline_parse_token_string_t cmd_read_reg_read = 7966 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 7967 cmdline_parse_token_string_t cmd_read_reg_reg = 7968 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 7969 cmdline_parse_token_num_t cmd_read_reg_port_id = 7970 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16); 7971 cmdline_parse_token_num_t cmd_read_reg_reg_off = 7972 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32); 7973 7974 cmdline_parse_inst_t cmd_read_reg = { 7975 .f = cmd_read_reg_parsed, 7976 .data = NULL, 7977 .help_str = "read reg <port_id> <reg_off>", 7978 .tokens = { 7979 (void *)&cmd_read_reg_read, 7980 (void *)&cmd_read_reg_reg, 7981 (void *)&cmd_read_reg_port_id, 7982 (void *)&cmd_read_reg_reg_off, 7983 NULL, 7984 }, 7985 }; 7986 7987 /* *** READ PORT REGISTER BIT FIELD *** */ 7988 struct cmd_read_reg_bit_field_result { 7989 cmdline_fixed_string_t read; 7990 cmdline_fixed_string_t regfield; 7991 portid_t port_id; 7992 uint32_t reg_off; 7993 uint8_t bit1_pos; 7994 uint8_t bit2_pos; 7995 }; 7996 7997 static void 7998 cmd_read_reg_bit_field_parsed(void *parsed_result, 7999 __rte_unused struct cmdline *cl, 8000 __rte_unused void *data) 8001 { 8002 struct cmd_read_reg_bit_field_result *res = parsed_result; 8003 port_reg_bit_field_display(res->port_id, res->reg_off, 8004 res->bit1_pos, res->bit2_pos); 8005 } 8006 8007 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 8008 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 8009 "read"); 8010 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 8011 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 8012 regfield, "regfield"); 8013 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 8014 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 8015 UINT16); 8016 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 8017 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 8018 UINT32); 8019 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 8020 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 8021 UINT8); 8022 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 8023 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 8024 UINT8); 8025 8026 cmdline_parse_inst_t cmd_read_reg_bit_field = { 8027 .f = cmd_read_reg_bit_field_parsed, 8028 .data = NULL, 8029 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 8030 "Read register bit field between bit_x and bit_y included", 8031 .tokens = { 8032 (void *)&cmd_read_reg_bit_field_read, 8033 (void *)&cmd_read_reg_bit_field_regfield, 8034 (void *)&cmd_read_reg_bit_field_port_id, 8035 (void *)&cmd_read_reg_bit_field_reg_off, 8036 (void *)&cmd_read_reg_bit_field_bit1_pos, 8037 (void *)&cmd_read_reg_bit_field_bit2_pos, 8038 NULL, 8039 }, 8040 }; 8041 8042 /* *** READ PORT REGISTER BIT *** */ 8043 struct cmd_read_reg_bit_result { 8044 cmdline_fixed_string_t read; 8045 cmdline_fixed_string_t regbit; 8046 portid_t port_id; 8047 uint32_t reg_off; 8048 uint8_t bit_pos; 8049 }; 8050 8051 static void 8052 cmd_read_reg_bit_parsed(void *parsed_result, 8053 __rte_unused struct cmdline *cl, 8054 __rte_unused void *data) 8055 { 8056 struct cmd_read_reg_bit_result *res = parsed_result; 8057 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 8058 } 8059 8060 cmdline_parse_token_string_t cmd_read_reg_bit_read = 8061 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 8062 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 8063 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 8064 regbit, "regbit"); 8065 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 8066 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16); 8067 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 8068 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32); 8069 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 8070 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8); 8071 8072 cmdline_parse_inst_t cmd_read_reg_bit = { 8073 .f = cmd_read_reg_bit_parsed, 8074 .data = NULL, 8075 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 8076 .tokens = { 8077 (void *)&cmd_read_reg_bit_read, 8078 (void *)&cmd_read_reg_bit_regbit, 8079 (void *)&cmd_read_reg_bit_port_id, 8080 (void *)&cmd_read_reg_bit_reg_off, 8081 (void *)&cmd_read_reg_bit_bit_pos, 8082 NULL, 8083 }, 8084 }; 8085 8086 /* *** WRITE PORT REGISTER *** */ 8087 struct cmd_write_reg_result { 8088 cmdline_fixed_string_t write; 8089 cmdline_fixed_string_t reg; 8090 portid_t port_id; 8091 uint32_t reg_off; 8092 uint32_t value; 8093 }; 8094 8095 static void 8096 cmd_write_reg_parsed(void *parsed_result, 8097 __rte_unused struct cmdline *cl, 8098 __rte_unused void *data) 8099 { 8100 struct cmd_write_reg_result *res = parsed_result; 8101 port_reg_set(res->port_id, res->reg_off, res->value); 8102 } 8103 8104 cmdline_parse_token_string_t cmd_write_reg_write = 8105 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 8106 cmdline_parse_token_string_t cmd_write_reg_reg = 8107 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 8108 cmdline_parse_token_num_t cmd_write_reg_port_id = 8109 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16); 8110 cmdline_parse_token_num_t cmd_write_reg_reg_off = 8111 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32); 8112 cmdline_parse_token_num_t cmd_write_reg_value = 8113 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32); 8114 8115 cmdline_parse_inst_t cmd_write_reg = { 8116 .f = cmd_write_reg_parsed, 8117 .data = NULL, 8118 .help_str = "write reg <port_id> <reg_off> <reg_value>", 8119 .tokens = { 8120 (void *)&cmd_write_reg_write, 8121 (void *)&cmd_write_reg_reg, 8122 (void *)&cmd_write_reg_port_id, 8123 (void *)&cmd_write_reg_reg_off, 8124 (void *)&cmd_write_reg_value, 8125 NULL, 8126 }, 8127 }; 8128 8129 /* *** WRITE PORT REGISTER BIT FIELD *** */ 8130 struct cmd_write_reg_bit_field_result { 8131 cmdline_fixed_string_t write; 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 uint32_t value; 8138 }; 8139 8140 static void 8141 cmd_write_reg_bit_field_parsed(void *parsed_result, 8142 __rte_unused struct cmdline *cl, 8143 __rte_unused void *data) 8144 { 8145 struct cmd_write_reg_bit_field_result *res = parsed_result; 8146 port_reg_bit_field_set(res->port_id, res->reg_off, 8147 res->bit1_pos, res->bit2_pos, res->value); 8148 } 8149 8150 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 8151 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 8152 "write"); 8153 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 8154 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 8155 regfield, "regfield"); 8156 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 8157 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 8158 UINT16); 8159 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 8160 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 8161 UINT32); 8162 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 8163 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 8164 UINT8); 8165 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 8166 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 8167 UINT8); 8168 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 8169 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 8170 UINT32); 8171 8172 cmdline_parse_inst_t cmd_write_reg_bit_field = { 8173 .f = cmd_write_reg_bit_field_parsed, 8174 .data = NULL, 8175 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 8176 "<reg_value>: " 8177 "Set register bit field between bit_x and bit_y included", 8178 .tokens = { 8179 (void *)&cmd_write_reg_bit_field_write, 8180 (void *)&cmd_write_reg_bit_field_regfield, 8181 (void *)&cmd_write_reg_bit_field_port_id, 8182 (void *)&cmd_write_reg_bit_field_reg_off, 8183 (void *)&cmd_write_reg_bit_field_bit1_pos, 8184 (void *)&cmd_write_reg_bit_field_bit2_pos, 8185 (void *)&cmd_write_reg_bit_field_value, 8186 NULL, 8187 }, 8188 }; 8189 8190 /* *** WRITE PORT REGISTER BIT *** */ 8191 struct cmd_write_reg_bit_result { 8192 cmdline_fixed_string_t write; 8193 cmdline_fixed_string_t regbit; 8194 portid_t port_id; 8195 uint32_t reg_off; 8196 uint8_t bit_pos; 8197 uint8_t value; 8198 }; 8199 8200 static void 8201 cmd_write_reg_bit_parsed(void *parsed_result, 8202 __rte_unused struct cmdline *cl, 8203 __rte_unused void *data) 8204 { 8205 struct cmd_write_reg_bit_result *res = parsed_result; 8206 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 8207 } 8208 8209 cmdline_parse_token_string_t cmd_write_reg_bit_write = 8210 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 8211 "write"); 8212 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 8213 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 8214 regbit, "regbit"); 8215 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 8216 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16); 8217 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 8218 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32); 8219 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 8220 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8); 8221 cmdline_parse_token_num_t cmd_write_reg_bit_value = 8222 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8); 8223 8224 cmdline_parse_inst_t cmd_write_reg_bit = { 8225 .f = cmd_write_reg_bit_parsed, 8226 .data = NULL, 8227 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 8228 "0 <= bit_x <= 31", 8229 .tokens = { 8230 (void *)&cmd_write_reg_bit_write, 8231 (void *)&cmd_write_reg_bit_regbit, 8232 (void *)&cmd_write_reg_bit_port_id, 8233 (void *)&cmd_write_reg_bit_reg_off, 8234 (void *)&cmd_write_reg_bit_bit_pos, 8235 (void *)&cmd_write_reg_bit_value, 8236 NULL, 8237 }, 8238 }; 8239 8240 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 8241 struct cmd_read_rxd_txd_result { 8242 cmdline_fixed_string_t read; 8243 cmdline_fixed_string_t rxd_txd; 8244 portid_t port_id; 8245 uint16_t queue_id; 8246 uint16_t desc_id; 8247 }; 8248 8249 static void 8250 cmd_read_rxd_txd_parsed(void *parsed_result, 8251 __rte_unused struct cmdline *cl, 8252 __rte_unused void *data) 8253 { 8254 struct cmd_read_rxd_txd_result *res = parsed_result; 8255 8256 if (!strcmp(res->rxd_txd, "rxd")) 8257 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 8258 else if (!strcmp(res->rxd_txd, "txd")) 8259 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 8260 } 8261 8262 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 8263 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 8264 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 8265 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 8266 "rxd#txd"); 8267 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 8268 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16); 8269 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 8270 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16); 8271 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 8272 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16); 8273 8274 cmdline_parse_inst_t cmd_read_rxd_txd = { 8275 .f = cmd_read_rxd_txd_parsed, 8276 .data = NULL, 8277 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 8278 .tokens = { 8279 (void *)&cmd_read_rxd_txd_read, 8280 (void *)&cmd_read_rxd_txd_rxd_txd, 8281 (void *)&cmd_read_rxd_txd_port_id, 8282 (void *)&cmd_read_rxd_txd_queue_id, 8283 (void *)&cmd_read_rxd_txd_desc_id, 8284 NULL, 8285 }, 8286 }; 8287 8288 /* *** QUIT *** */ 8289 struct cmd_quit_result { 8290 cmdline_fixed_string_t quit; 8291 }; 8292 8293 static void cmd_quit_parsed(__rte_unused void *parsed_result, 8294 struct cmdline *cl, 8295 __rte_unused void *data) 8296 { 8297 cmdline_quit(cl); 8298 } 8299 8300 cmdline_parse_token_string_t cmd_quit_quit = 8301 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 8302 8303 cmdline_parse_inst_t cmd_quit = { 8304 .f = cmd_quit_parsed, 8305 .data = NULL, 8306 .help_str = "quit: Exit application", 8307 .tokens = { 8308 (void *)&cmd_quit_quit, 8309 NULL, 8310 }, 8311 }; 8312 8313 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 8314 struct cmd_mac_addr_result { 8315 cmdline_fixed_string_t mac_addr_cmd; 8316 cmdline_fixed_string_t what; 8317 uint16_t port_num; 8318 struct rte_ether_addr address; 8319 }; 8320 8321 static void cmd_mac_addr_parsed(void *parsed_result, 8322 __rte_unused struct cmdline *cl, 8323 __rte_unused void *data) 8324 { 8325 struct cmd_mac_addr_result *res = parsed_result; 8326 int ret; 8327 8328 if (strcmp(res->what, "add") == 0) 8329 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 8330 else if (strcmp(res->what, "set") == 0) 8331 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 8332 &res->address); 8333 else 8334 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 8335 8336 /* check the return value and print it if is < 0 */ 8337 if(ret < 0) 8338 printf("mac_addr_cmd error: (%s)\n", strerror(-ret)); 8339 8340 } 8341 8342 cmdline_parse_token_string_t cmd_mac_addr_cmd = 8343 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 8344 "mac_addr"); 8345 cmdline_parse_token_string_t cmd_mac_addr_what = 8346 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 8347 "add#remove#set"); 8348 cmdline_parse_token_num_t cmd_mac_addr_portnum = 8349 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 8350 UINT16); 8351 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 8352 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 8353 8354 cmdline_parse_inst_t cmd_mac_addr = { 8355 .f = cmd_mac_addr_parsed, 8356 .data = (void *)0, 8357 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 8358 "Add/Remove/Set MAC address on port_id", 8359 .tokens = { 8360 (void *)&cmd_mac_addr_cmd, 8361 (void *)&cmd_mac_addr_what, 8362 (void *)&cmd_mac_addr_portnum, 8363 (void *)&cmd_mac_addr_addr, 8364 NULL, 8365 }, 8366 }; 8367 8368 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 8369 struct cmd_eth_peer_result { 8370 cmdline_fixed_string_t set; 8371 cmdline_fixed_string_t eth_peer; 8372 portid_t port_id; 8373 cmdline_fixed_string_t peer_addr; 8374 }; 8375 8376 static void cmd_set_eth_peer_parsed(void *parsed_result, 8377 __rte_unused struct cmdline *cl, 8378 __rte_unused void *data) 8379 { 8380 struct cmd_eth_peer_result *res = parsed_result; 8381 8382 if (test_done == 0) { 8383 printf("Please stop forwarding first\n"); 8384 return; 8385 } 8386 if (!strcmp(res->eth_peer, "eth-peer")) { 8387 set_fwd_eth_peer(res->port_id, res->peer_addr); 8388 fwd_config_setup(); 8389 } 8390 } 8391 cmdline_parse_token_string_t cmd_eth_peer_set = 8392 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 8393 cmdline_parse_token_string_t cmd_eth_peer = 8394 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 8395 cmdline_parse_token_num_t cmd_eth_peer_port_id = 8396 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16); 8397 cmdline_parse_token_string_t cmd_eth_peer_addr = 8398 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 8399 8400 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 8401 .f = cmd_set_eth_peer_parsed, 8402 .data = NULL, 8403 .help_str = "set eth-peer <port_id> <peer_mac>", 8404 .tokens = { 8405 (void *)&cmd_eth_peer_set, 8406 (void *)&cmd_eth_peer, 8407 (void *)&cmd_eth_peer_port_id, 8408 (void *)&cmd_eth_peer_addr, 8409 NULL, 8410 }, 8411 }; 8412 8413 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 8414 struct cmd_set_qmap_result { 8415 cmdline_fixed_string_t set; 8416 cmdline_fixed_string_t qmap; 8417 cmdline_fixed_string_t what; 8418 portid_t port_id; 8419 uint16_t queue_id; 8420 uint8_t map_value; 8421 }; 8422 8423 static void 8424 cmd_set_qmap_parsed(void *parsed_result, 8425 __rte_unused struct cmdline *cl, 8426 __rte_unused void *data) 8427 { 8428 struct cmd_set_qmap_result *res = parsed_result; 8429 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 8430 8431 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 8432 } 8433 8434 cmdline_parse_token_string_t cmd_setqmap_set = 8435 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8436 set, "set"); 8437 cmdline_parse_token_string_t cmd_setqmap_qmap = 8438 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8439 qmap, "stat_qmap"); 8440 cmdline_parse_token_string_t cmd_setqmap_what = 8441 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8442 what, "tx#rx"); 8443 cmdline_parse_token_num_t cmd_setqmap_portid = 8444 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8445 port_id, UINT16); 8446 cmdline_parse_token_num_t cmd_setqmap_queueid = 8447 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8448 queue_id, UINT16); 8449 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 8450 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8451 map_value, UINT8); 8452 8453 cmdline_parse_inst_t cmd_set_qmap = { 8454 .f = cmd_set_qmap_parsed, 8455 .data = NULL, 8456 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 8457 "Set statistics mapping value on tx|rx queue_id of port_id", 8458 .tokens = { 8459 (void *)&cmd_setqmap_set, 8460 (void *)&cmd_setqmap_qmap, 8461 (void *)&cmd_setqmap_what, 8462 (void *)&cmd_setqmap_portid, 8463 (void *)&cmd_setqmap_queueid, 8464 (void *)&cmd_setqmap_mapvalue, 8465 NULL, 8466 }, 8467 }; 8468 8469 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 8470 struct cmd_set_xstats_hide_zero_result { 8471 cmdline_fixed_string_t keyword; 8472 cmdline_fixed_string_t name; 8473 cmdline_fixed_string_t on_off; 8474 }; 8475 8476 static void 8477 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 8478 __rte_unused struct cmdline *cl, 8479 __rte_unused void *data) 8480 { 8481 struct cmd_set_xstats_hide_zero_result *res; 8482 uint16_t on_off = 0; 8483 8484 res = parsed_result; 8485 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8486 set_xstats_hide_zero(on_off); 8487 } 8488 8489 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 8490 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8491 keyword, "set"); 8492 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 8493 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8494 name, "xstats-hide-zero"); 8495 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 8496 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8497 on_off, "on#off"); 8498 8499 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 8500 .f = cmd_set_xstats_hide_zero_parsed, 8501 .data = NULL, 8502 .help_str = "set xstats-hide-zero on|off", 8503 .tokens = { 8504 (void *)&cmd_set_xstats_hide_zero_keyword, 8505 (void *)&cmd_set_xstats_hide_zero_name, 8506 (void *)&cmd_set_xstats_hide_zero_on_off, 8507 NULL, 8508 }, 8509 }; 8510 8511 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */ 8512 struct cmd_set_record_core_cycles_result { 8513 cmdline_fixed_string_t keyword; 8514 cmdline_fixed_string_t name; 8515 cmdline_fixed_string_t on_off; 8516 }; 8517 8518 static void 8519 cmd_set_record_core_cycles_parsed(void *parsed_result, 8520 __rte_unused struct cmdline *cl, 8521 __rte_unused void *data) 8522 { 8523 struct cmd_set_record_core_cycles_result *res; 8524 uint16_t on_off = 0; 8525 8526 res = parsed_result; 8527 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8528 set_record_core_cycles(on_off); 8529 } 8530 8531 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword = 8532 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8533 keyword, "set"); 8534 cmdline_parse_token_string_t cmd_set_record_core_cycles_name = 8535 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8536 name, "record-core-cycles"); 8537 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off = 8538 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8539 on_off, "on#off"); 8540 8541 cmdline_parse_inst_t cmd_set_record_core_cycles = { 8542 .f = cmd_set_record_core_cycles_parsed, 8543 .data = NULL, 8544 .help_str = "set record-core-cycles on|off", 8545 .tokens = { 8546 (void *)&cmd_set_record_core_cycles_keyword, 8547 (void *)&cmd_set_record_core_cycles_name, 8548 (void *)&cmd_set_record_core_cycles_on_off, 8549 NULL, 8550 }, 8551 }; 8552 8553 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */ 8554 struct cmd_set_record_burst_stats_result { 8555 cmdline_fixed_string_t keyword; 8556 cmdline_fixed_string_t name; 8557 cmdline_fixed_string_t on_off; 8558 }; 8559 8560 static void 8561 cmd_set_record_burst_stats_parsed(void *parsed_result, 8562 __rte_unused struct cmdline *cl, 8563 __rte_unused void *data) 8564 { 8565 struct cmd_set_record_burst_stats_result *res; 8566 uint16_t on_off = 0; 8567 8568 res = parsed_result; 8569 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8570 set_record_burst_stats(on_off); 8571 } 8572 8573 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword = 8574 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8575 keyword, "set"); 8576 cmdline_parse_token_string_t cmd_set_record_burst_stats_name = 8577 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8578 name, "record-burst-stats"); 8579 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off = 8580 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8581 on_off, "on#off"); 8582 8583 cmdline_parse_inst_t cmd_set_record_burst_stats = { 8584 .f = cmd_set_record_burst_stats_parsed, 8585 .data = NULL, 8586 .help_str = "set record-burst-stats on|off", 8587 .tokens = { 8588 (void *)&cmd_set_record_burst_stats_keyword, 8589 (void *)&cmd_set_record_burst_stats_name, 8590 (void *)&cmd_set_record_burst_stats_on_off, 8591 NULL, 8592 }, 8593 }; 8594 8595 /* *** CONFIGURE UNICAST HASH TABLE *** */ 8596 struct cmd_set_uc_hash_table { 8597 cmdline_fixed_string_t set; 8598 cmdline_fixed_string_t port; 8599 portid_t port_id; 8600 cmdline_fixed_string_t what; 8601 struct rte_ether_addr address; 8602 cmdline_fixed_string_t mode; 8603 }; 8604 8605 static void 8606 cmd_set_uc_hash_parsed(void *parsed_result, 8607 __rte_unused struct cmdline *cl, 8608 __rte_unused void *data) 8609 { 8610 int ret=0; 8611 struct cmd_set_uc_hash_table *res = parsed_result; 8612 8613 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8614 8615 if (strcmp(res->what, "uta") == 0) 8616 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 8617 &res->address,(uint8_t)is_on); 8618 if (ret < 0) 8619 printf("bad unicast hash table parameter, return code = %d \n", ret); 8620 8621 } 8622 8623 cmdline_parse_token_string_t cmd_set_uc_hash_set = 8624 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8625 set, "set"); 8626 cmdline_parse_token_string_t cmd_set_uc_hash_port = 8627 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8628 port, "port"); 8629 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 8630 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 8631 port_id, UINT16); 8632 cmdline_parse_token_string_t cmd_set_uc_hash_what = 8633 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8634 what, "uta"); 8635 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 8636 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 8637 address); 8638 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 8639 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8640 mode, "on#off"); 8641 8642 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 8643 .f = cmd_set_uc_hash_parsed, 8644 .data = NULL, 8645 .help_str = "set port <port_id> uta <mac_addr> on|off)", 8646 .tokens = { 8647 (void *)&cmd_set_uc_hash_set, 8648 (void *)&cmd_set_uc_hash_port, 8649 (void *)&cmd_set_uc_hash_portid, 8650 (void *)&cmd_set_uc_hash_what, 8651 (void *)&cmd_set_uc_hash_mac, 8652 (void *)&cmd_set_uc_hash_mode, 8653 NULL, 8654 }, 8655 }; 8656 8657 struct cmd_set_uc_all_hash_table { 8658 cmdline_fixed_string_t set; 8659 cmdline_fixed_string_t port; 8660 portid_t port_id; 8661 cmdline_fixed_string_t what; 8662 cmdline_fixed_string_t value; 8663 cmdline_fixed_string_t mode; 8664 }; 8665 8666 static void 8667 cmd_set_uc_all_hash_parsed(void *parsed_result, 8668 __rte_unused struct cmdline *cl, 8669 __rte_unused void *data) 8670 { 8671 int ret=0; 8672 struct cmd_set_uc_all_hash_table *res = parsed_result; 8673 8674 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8675 8676 if ((strcmp(res->what, "uta") == 0) && 8677 (strcmp(res->value, "all") == 0)) 8678 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 8679 if (ret < 0) 8680 printf("bad unicast hash table parameter," 8681 "return code = %d \n", ret); 8682 } 8683 8684 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 8685 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8686 set, "set"); 8687 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 8688 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8689 port, "port"); 8690 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 8691 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 8692 port_id, UINT16); 8693 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 8694 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8695 what, "uta"); 8696 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 8697 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8698 value,"all"); 8699 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 8700 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8701 mode, "on#off"); 8702 8703 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 8704 .f = cmd_set_uc_all_hash_parsed, 8705 .data = NULL, 8706 .help_str = "set port <port_id> uta all on|off", 8707 .tokens = { 8708 (void *)&cmd_set_uc_all_hash_set, 8709 (void *)&cmd_set_uc_all_hash_port, 8710 (void *)&cmd_set_uc_all_hash_portid, 8711 (void *)&cmd_set_uc_all_hash_what, 8712 (void *)&cmd_set_uc_all_hash_value, 8713 (void *)&cmd_set_uc_all_hash_mode, 8714 NULL, 8715 }, 8716 }; 8717 8718 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 8719 struct cmd_set_vf_traffic { 8720 cmdline_fixed_string_t set; 8721 cmdline_fixed_string_t port; 8722 portid_t port_id; 8723 cmdline_fixed_string_t vf; 8724 uint8_t vf_id; 8725 cmdline_fixed_string_t what; 8726 cmdline_fixed_string_t mode; 8727 }; 8728 8729 static void 8730 cmd_set_vf_traffic_parsed(void *parsed_result, 8731 __rte_unused struct cmdline *cl, 8732 __rte_unused void *data) 8733 { 8734 struct cmd_set_vf_traffic *res = parsed_result; 8735 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 8736 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8737 8738 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 8739 } 8740 8741 cmdline_parse_token_string_t cmd_setvf_traffic_set = 8742 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8743 set, "set"); 8744 cmdline_parse_token_string_t cmd_setvf_traffic_port = 8745 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8746 port, "port"); 8747 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 8748 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8749 port_id, UINT16); 8750 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 8751 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8752 vf, "vf"); 8753 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 8754 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8755 vf_id, UINT8); 8756 cmdline_parse_token_string_t cmd_setvf_traffic_what = 8757 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8758 what, "tx#rx"); 8759 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 8760 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8761 mode, "on#off"); 8762 8763 cmdline_parse_inst_t cmd_set_vf_traffic = { 8764 .f = cmd_set_vf_traffic_parsed, 8765 .data = NULL, 8766 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 8767 .tokens = { 8768 (void *)&cmd_setvf_traffic_set, 8769 (void *)&cmd_setvf_traffic_port, 8770 (void *)&cmd_setvf_traffic_portid, 8771 (void *)&cmd_setvf_traffic_vf, 8772 (void *)&cmd_setvf_traffic_vfid, 8773 (void *)&cmd_setvf_traffic_what, 8774 (void *)&cmd_setvf_traffic_mode, 8775 NULL, 8776 }, 8777 }; 8778 8779 /* *** CONFIGURE VF RECEIVE MODE *** */ 8780 struct cmd_set_vf_rxmode { 8781 cmdline_fixed_string_t set; 8782 cmdline_fixed_string_t port; 8783 portid_t port_id; 8784 cmdline_fixed_string_t vf; 8785 uint8_t vf_id; 8786 cmdline_fixed_string_t what; 8787 cmdline_fixed_string_t mode; 8788 cmdline_fixed_string_t on; 8789 }; 8790 8791 static void 8792 cmd_set_vf_rxmode_parsed(void *parsed_result, 8793 __rte_unused struct cmdline *cl, 8794 __rte_unused void *data) 8795 { 8796 int ret = -ENOTSUP; 8797 uint16_t vf_rxmode = 0; 8798 struct cmd_set_vf_rxmode *res = parsed_result; 8799 8800 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 8801 if (!strcmp(res->what,"rxmode")) { 8802 if (!strcmp(res->mode, "AUPE")) 8803 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG; 8804 else if (!strcmp(res->mode, "ROPE")) 8805 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC; 8806 else if (!strcmp(res->mode, "BAM")) 8807 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST; 8808 else if (!strncmp(res->mode, "MPE",3)) 8809 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST; 8810 } 8811 8812 RTE_SET_USED(is_on); 8813 8814 #ifdef RTE_NET_IXGBE 8815 if (ret == -ENOTSUP) 8816 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 8817 vf_rxmode, (uint8_t)is_on); 8818 #endif 8819 #ifdef RTE_NET_BNXT 8820 if (ret == -ENOTSUP) 8821 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 8822 vf_rxmode, (uint8_t)is_on); 8823 #endif 8824 if (ret < 0) 8825 printf("bad VF receive mode parameter, return code = %d \n", 8826 ret); 8827 } 8828 8829 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 8830 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8831 set, "set"); 8832 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 8833 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8834 port, "port"); 8835 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 8836 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8837 port_id, UINT16); 8838 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 8839 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8840 vf, "vf"); 8841 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 8842 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8843 vf_id, UINT8); 8844 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 8845 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8846 what, "rxmode"); 8847 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 8848 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8849 mode, "AUPE#ROPE#BAM#MPE"); 8850 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 8851 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8852 on, "on#off"); 8853 8854 cmdline_parse_inst_t cmd_set_vf_rxmode = { 8855 .f = cmd_set_vf_rxmode_parsed, 8856 .data = NULL, 8857 .help_str = "set port <port_id> vf <vf_id> rxmode " 8858 "AUPE|ROPE|BAM|MPE on|off", 8859 .tokens = { 8860 (void *)&cmd_set_vf_rxmode_set, 8861 (void *)&cmd_set_vf_rxmode_port, 8862 (void *)&cmd_set_vf_rxmode_portid, 8863 (void *)&cmd_set_vf_rxmode_vf, 8864 (void *)&cmd_set_vf_rxmode_vfid, 8865 (void *)&cmd_set_vf_rxmode_what, 8866 (void *)&cmd_set_vf_rxmode_mode, 8867 (void *)&cmd_set_vf_rxmode_on, 8868 NULL, 8869 }, 8870 }; 8871 8872 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 8873 struct cmd_vf_mac_addr_result { 8874 cmdline_fixed_string_t mac_addr_cmd; 8875 cmdline_fixed_string_t what; 8876 cmdline_fixed_string_t port; 8877 uint16_t port_num; 8878 cmdline_fixed_string_t vf; 8879 uint8_t vf_num; 8880 struct rte_ether_addr address; 8881 }; 8882 8883 static void cmd_vf_mac_addr_parsed(void *parsed_result, 8884 __rte_unused struct cmdline *cl, 8885 __rte_unused void *data) 8886 { 8887 struct cmd_vf_mac_addr_result *res = parsed_result; 8888 int ret = -ENOTSUP; 8889 8890 if (strcmp(res->what, "add") != 0) 8891 return; 8892 8893 #ifdef RTE_NET_I40E 8894 if (ret == -ENOTSUP) 8895 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 8896 &res->address); 8897 #endif 8898 #ifdef RTE_NET_BNXT 8899 if (ret == -ENOTSUP) 8900 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 8901 res->vf_num); 8902 #endif 8903 8904 if(ret < 0) 8905 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 8906 8907 } 8908 8909 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 8910 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8911 mac_addr_cmd,"mac_addr"); 8912 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 8913 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8914 what,"add"); 8915 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 8916 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8917 port,"port"); 8918 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 8919 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8920 port_num, UINT16); 8921 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 8922 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8923 vf,"vf"); 8924 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 8925 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8926 vf_num, UINT8); 8927 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 8928 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 8929 address); 8930 8931 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 8932 .f = cmd_vf_mac_addr_parsed, 8933 .data = (void *)0, 8934 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 8935 "Add MAC address filtering for a VF on port_id", 8936 .tokens = { 8937 (void *)&cmd_vf_mac_addr_cmd, 8938 (void *)&cmd_vf_mac_addr_what, 8939 (void *)&cmd_vf_mac_addr_port, 8940 (void *)&cmd_vf_mac_addr_portnum, 8941 (void *)&cmd_vf_mac_addr_vf, 8942 (void *)&cmd_vf_mac_addr_vfnum, 8943 (void *)&cmd_vf_mac_addr_addr, 8944 NULL, 8945 }, 8946 }; 8947 8948 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 8949 struct cmd_vf_rx_vlan_filter { 8950 cmdline_fixed_string_t rx_vlan; 8951 cmdline_fixed_string_t what; 8952 uint16_t vlan_id; 8953 cmdline_fixed_string_t port; 8954 portid_t port_id; 8955 cmdline_fixed_string_t vf; 8956 uint64_t vf_mask; 8957 }; 8958 8959 static void 8960 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 8961 __rte_unused struct cmdline *cl, 8962 __rte_unused void *data) 8963 { 8964 struct cmd_vf_rx_vlan_filter *res = parsed_result; 8965 int ret = -ENOTSUP; 8966 8967 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 8968 8969 #ifdef RTE_NET_IXGBE 8970 if (ret == -ENOTSUP) 8971 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 8972 res->vlan_id, res->vf_mask, is_add); 8973 #endif 8974 #ifdef RTE_NET_I40E 8975 if (ret == -ENOTSUP) 8976 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 8977 res->vlan_id, res->vf_mask, is_add); 8978 #endif 8979 #ifdef RTE_NET_BNXT 8980 if (ret == -ENOTSUP) 8981 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 8982 res->vlan_id, res->vf_mask, is_add); 8983 #endif 8984 8985 switch (ret) { 8986 case 0: 8987 break; 8988 case -EINVAL: 8989 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n", 8990 res->vlan_id, res->vf_mask); 8991 break; 8992 case -ENODEV: 8993 printf("invalid port_id %d\n", res->port_id); 8994 break; 8995 case -ENOTSUP: 8996 printf("function not implemented or supported\n"); 8997 break; 8998 default: 8999 printf("programming error: (%s)\n", strerror(-ret)); 9000 } 9001 } 9002 9003 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 9004 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9005 rx_vlan, "rx_vlan"); 9006 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 9007 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9008 what, "add#rm"); 9009 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 9010 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9011 vlan_id, UINT16); 9012 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 9013 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9014 port, "port"); 9015 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 9016 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9017 port_id, UINT16); 9018 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 9019 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9020 vf, "vf"); 9021 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 9022 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 9023 vf_mask, UINT64); 9024 9025 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 9026 .f = cmd_vf_rx_vlan_filter_parsed, 9027 .data = NULL, 9028 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 9029 "(vf_mask = hexadecimal VF mask)", 9030 .tokens = { 9031 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 9032 (void *)&cmd_vf_rx_vlan_filter_what, 9033 (void *)&cmd_vf_rx_vlan_filter_vlanid, 9034 (void *)&cmd_vf_rx_vlan_filter_port, 9035 (void *)&cmd_vf_rx_vlan_filter_portid, 9036 (void *)&cmd_vf_rx_vlan_filter_vf, 9037 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 9038 NULL, 9039 }, 9040 }; 9041 9042 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 9043 struct cmd_queue_rate_limit_result { 9044 cmdline_fixed_string_t set; 9045 cmdline_fixed_string_t port; 9046 uint16_t port_num; 9047 cmdline_fixed_string_t queue; 9048 uint8_t queue_num; 9049 cmdline_fixed_string_t rate; 9050 uint16_t rate_num; 9051 }; 9052 9053 static void cmd_queue_rate_limit_parsed(void *parsed_result, 9054 __rte_unused struct cmdline *cl, 9055 __rte_unused void *data) 9056 { 9057 struct cmd_queue_rate_limit_result *res = parsed_result; 9058 int ret = 0; 9059 9060 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 9061 && (strcmp(res->queue, "queue") == 0) 9062 && (strcmp(res->rate, "rate") == 0)) 9063 ret = set_queue_rate_limit(res->port_num, res->queue_num, 9064 res->rate_num); 9065 if (ret < 0) 9066 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret)); 9067 9068 } 9069 9070 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 9071 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9072 set, "set"); 9073 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 9074 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9075 port, "port"); 9076 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 9077 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9078 port_num, UINT16); 9079 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 9080 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9081 queue, "queue"); 9082 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 9083 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9084 queue_num, UINT8); 9085 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 9086 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9087 rate, "rate"); 9088 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 9089 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9090 rate_num, UINT16); 9091 9092 cmdline_parse_inst_t cmd_queue_rate_limit = { 9093 .f = cmd_queue_rate_limit_parsed, 9094 .data = (void *)0, 9095 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 9096 "Set rate limit for a queue on port_id", 9097 .tokens = { 9098 (void *)&cmd_queue_rate_limit_set, 9099 (void *)&cmd_queue_rate_limit_port, 9100 (void *)&cmd_queue_rate_limit_portnum, 9101 (void *)&cmd_queue_rate_limit_queue, 9102 (void *)&cmd_queue_rate_limit_queuenum, 9103 (void *)&cmd_queue_rate_limit_rate, 9104 (void *)&cmd_queue_rate_limit_ratenum, 9105 NULL, 9106 }, 9107 }; 9108 9109 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 9110 struct cmd_vf_rate_limit_result { 9111 cmdline_fixed_string_t set; 9112 cmdline_fixed_string_t port; 9113 uint16_t port_num; 9114 cmdline_fixed_string_t vf; 9115 uint8_t vf_num; 9116 cmdline_fixed_string_t rate; 9117 uint16_t rate_num; 9118 cmdline_fixed_string_t q_msk; 9119 uint64_t q_msk_val; 9120 }; 9121 9122 static void cmd_vf_rate_limit_parsed(void *parsed_result, 9123 __rte_unused struct cmdline *cl, 9124 __rte_unused void *data) 9125 { 9126 struct cmd_vf_rate_limit_result *res = parsed_result; 9127 int ret = 0; 9128 9129 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 9130 && (strcmp(res->vf, "vf") == 0) 9131 && (strcmp(res->rate, "rate") == 0) 9132 && (strcmp(res->q_msk, "queue_mask") == 0)) 9133 ret = set_vf_rate_limit(res->port_num, res->vf_num, 9134 res->rate_num, res->q_msk_val); 9135 if (ret < 0) 9136 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret)); 9137 9138 } 9139 9140 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 9141 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9142 set, "set"); 9143 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 9144 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9145 port, "port"); 9146 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 9147 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9148 port_num, UINT16); 9149 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 9150 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9151 vf, "vf"); 9152 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 9153 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9154 vf_num, UINT8); 9155 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 9156 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9157 rate, "rate"); 9158 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 9159 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9160 rate_num, UINT16); 9161 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 9162 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9163 q_msk, "queue_mask"); 9164 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 9165 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9166 q_msk_val, UINT64); 9167 9168 cmdline_parse_inst_t cmd_vf_rate_limit = { 9169 .f = cmd_vf_rate_limit_parsed, 9170 .data = (void *)0, 9171 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 9172 "queue_mask <queue_mask_value>: " 9173 "Set rate limit for queues of VF on port_id", 9174 .tokens = { 9175 (void *)&cmd_vf_rate_limit_set, 9176 (void *)&cmd_vf_rate_limit_port, 9177 (void *)&cmd_vf_rate_limit_portnum, 9178 (void *)&cmd_vf_rate_limit_vf, 9179 (void *)&cmd_vf_rate_limit_vfnum, 9180 (void *)&cmd_vf_rate_limit_rate, 9181 (void *)&cmd_vf_rate_limit_ratenum, 9182 (void *)&cmd_vf_rate_limit_q_msk, 9183 (void *)&cmd_vf_rate_limit_q_msk_val, 9184 NULL, 9185 }, 9186 }; 9187 9188 /* *** CONFIGURE TUNNEL UDP PORT *** */ 9189 struct cmd_tunnel_udp_config { 9190 cmdline_fixed_string_t cmd; 9191 cmdline_fixed_string_t what; 9192 uint16_t udp_port; 9193 portid_t port_id; 9194 }; 9195 9196 static void 9197 cmd_tunnel_udp_config_parsed(void *parsed_result, 9198 __rte_unused struct cmdline *cl, 9199 __rte_unused void *data) 9200 { 9201 struct cmd_tunnel_udp_config *res = parsed_result; 9202 struct rte_eth_udp_tunnel tunnel_udp; 9203 int ret; 9204 9205 tunnel_udp.udp_port = res->udp_port; 9206 9207 if (!strcmp(res->cmd, "rx_vxlan_port")) 9208 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9209 9210 if (!strcmp(res->what, "add")) 9211 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9212 &tunnel_udp); 9213 else 9214 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9215 &tunnel_udp); 9216 9217 if (ret < 0) 9218 printf("udp tunneling add error: (%s)\n", strerror(-ret)); 9219 } 9220 9221 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd = 9222 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9223 cmd, "rx_vxlan_port"); 9224 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 9225 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9226 what, "add#rm"); 9227 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 9228 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9229 udp_port, UINT16); 9230 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 9231 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9232 port_id, UINT16); 9233 9234 cmdline_parse_inst_t cmd_tunnel_udp_config = { 9235 .f = cmd_tunnel_udp_config_parsed, 9236 .data = (void *)0, 9237 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 9238 "Add/Remove a tunneling UDP port filter", 9239 .tokens = { 9240 (void *)&cmd_tunnel_udp_config_cmd, 9241 (void *)&cmd_tunnel_udp_config_what, 9242 (void *)&cmd_tunnel_udp_config_udp_port, 9243 (void *)&cmd_tunnel_udp_config_port_id, 9244 NULL, 9245 }, 9246 }; 9247 9248 struct cmd_config_tunnel_udp_port { 9249 cmdline_fixed_string_t port; 9250 cmdline_fixed_string_t config; 9251 portid_t port_id; 9252 cmdline_fixed_string_t udp_tunnel_port; 9253 cmdline_fixed_string_t action; 9254 cmdline_fixed_string_t tunnel_type; 9255 uint16_t udp_port; 9256 }; 9257 9258 static void 9259 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 9260 __rte_unused struct cmdline *cl, 9261 __rte_unused void *data) 9262 { 9263 struct cmd_config_tunnel_udp_port *res = parsed_result; 9264 struct rte_eth_udp_tunnel tunnel_udp; 9265 int ret = 0; 9266 9267 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9268 return; 9269 9270 tunnel_udp.udp_port = res->udp_port; 9271 9272 if (!strcmp(res->tunnel_type, "vxlan")) { 9273 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9274 } else if (!strcmp(res->tunnel_type, "geneve")) { 9275 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 9276 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) { 9277 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 9278 } else { 9279 printf("Invalid tunnel type\n"); 9280 return; 9281 } 9282 9283 if (!strcmp(res->action, "add")) 9284 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9285 &tunnel_udp); 9286 else 9287 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9288 &tunnel_udp); 9289 9290 if (ret < 0) 9291 printf("udp tunneling port add error: (%s)\n", strerror(-ret)); 9292 } 9293 9294 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 9295 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 9296 "port"); 9297 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 9298 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 9299 "config"); 9300 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 9301 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 9302 UINT16); 9303 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 9304 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 9305 udp_tunnel_port, 9306 "udp_tunnel_port"); 9307 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 9308 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 9309 "add#rm"); 9310 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 9311 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 9312 "vxlan#geneve#vxlan-gpe"); 9313 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 9314 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 9315 UINT16); 9316 9317 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 9318 .f = cmd_cfg_tunnel_udp_port_parsed, 9319 .data = NULL, 9320 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>", 9321 .tokens = { 9322 (void *)&cmd_config_tunnel_udp_port_port, 9323 (void *)&cmd_config_tunnel_udp_port_config, 9324 (void *)&cmd_config_tunnel_udp_port_port_id, 9325 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 9326 (void *)&cmd_config_tunnel_udp_port_action, 9327 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 9328 (void *)&cmd_config_tunnel_udp_port_value, 9329 NULL, 9330 }, 9331 }; 9332 9333 /* *** GLOBAL CONFIG *** */ 9334 struct cmd_global_config_result { 9335 cmdline_fixed_string_t cmd; 9336 portid_t port_id; 9337 cmdline_fixed_string_t cfg_type; 9338 uint8_t len; 9339 }; 9340 9341 static void 9342 cmd_global_config_parsed(void *parsed_result, 9343 __rte_unused struct cmdline *cl, 9344 __rte_unused void *data) 9345 { 9346 struct cmd_global_config_result *res = parsed_result; 9347 struct rte_eth_global_cfg conf; 9348 int ret; 9349 9350 memset(&conf, 0, sizeof(conf)); 9351 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN; 9352 conf.cfg.gre_key_len = res->len; 9353 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE, 9354 RTE_ETH_FILTER_SET, &conf); 9355 #ifdef RTE_NET_I40E 9356 if (ret == -ENOTSUP) 9357 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len); 9358 #endif 9359 if (ret != 0) 9360 printf("Global config error\n"); 9361 } 9362 9363 cmdline_parse_token_string_t cmd_global_config_cmd = 9364 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd, 9365 "global_config"); 9366 cmdline_parse_token_num_t cmd_global_config_port_id = 9367 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, 9368 UINT16); 9369 cmdline_parse_token_string_t cmd_global_config_type = 9370 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, 9371 cfg_type, "gre-key-len"); 9372 cmdline_parse_token_num_t cmd_global_config_gre_key_len = 9373 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, 9374 len, UINT8); 9375 9376 cmdline_parse_inst_t cmd_global_config = { 9377 .f = cmd_global_config_parsed, 9378 .data = (void *)NULL, 9379 .help_str = "global_config <port_id> gre-key-len <key_len>", 9380 .tokens = { 9381 (void *)&cmd_global_config_cmd, 9382 (void *)&cmd_global_config_port_id, 9383 (void *)&cmd_global_config_type, 9384 (void *)&cmd_global_config_gre_key_len, 9385 NULL, 9386 }, 9387 }; 9388 9389 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 9390 struct cmd_set_mirror_mask_result { 9391 cmdline_fixed_string_t set; 9392 cmdline_fixed_string_t port; 9393 portid_t port_id; 9394 cmdline_fixed_string_t mirror; 9395 uint8_t rule_id; 9396 cmdline_fixed_string_t what; 9397 cmdline_fixed_string_t value; 9398 cmdline_fixed_string_t dstpool; 9399 uint8_t dstpool_id; 9400 cmdline_fixed_string_t on; 9401 }; 9402 9403 cmdline_parse_token_string_t cmd_mirror_mask_set = 9404 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9405 set, "set"); 9406 cmdline_parse_token_string_t cmd_mirror_mask_port = 9407 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9408 port, "port"); 9409 cmdline_parse_token_num_t cmd_mirror_mask_portid = 9410 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9411 port_id, UINT16); 9412 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 9413 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9414 mirror, "mirror-rule"); 9415 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 9416 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9417 rule_id, UINT8); 9418 cmdline_parse_token_string_t cmd_mirror_mask_what = 9419 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9420 what, "pool-mirror-up#pool-mirror-down" 9421 "#vlan-mirror"); 9422 cmdline_parse_token_string_t cmd_mirror_mask_value = 9423 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9424 value, NULL); 9425 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 9426 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9427 dstpool, "dst-pool"); 9428 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 9429 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9430 dstpool_id, UINT8); 9431 cmdline_parse_token_string_t cmd_mirror_mask_on = 9432 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9433 on, "on#off"); 9434 9435 static void 9436 cmd_set_mirror_mask_parsed(void *parsed_result, 9437 __rte_unused struct cmdline *cl, 9438 __rte_unused void *data) 9439 { 9440 int ret,nb_item,i; 9441 struct cmd_set_mirror_mask_result *res = parsed_result; 9442 struct rte_eth_mirror_conf mr_conf; 9443 9444 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9445 9446 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 9447 9448 mr_conf.dst_pool = res->dstpool_id; 9449 9450 if (!strcmp(res->what, "pool-mirror-up")) { 9451 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9452 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 9453 } else if (!strcmp(res->what, "pool-mirror-down")) { 9454 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9455 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 9456 } else if (!strcmp(res->what, "vlan-mirror")) { 9457 mr_conf.rule_type = ETH_MIRROR_VLAN; 9458 nb_item = parse_item_list(res->value, "vlan", 9459 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 9460 if (nb_item <= 0) 9461 return; 9462 9463 for (i = 0; i < nb_item; i++) { 9464 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) { 9465 printf("Invalid vlan_id: must be < 4096\n"); 9466 return; 9467 } 9468 9469 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 9470 mr_conf.vlan.vlan_mask |= 1ULL << i; 9471 } 9472 } 9473 9474 if (!strcmp(res->on, "on")) 9475 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9476 res->rule_id, 1); 9477 else 9478 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9479 res->rule_id, 0); 9480 if (ret < 0) 9481 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9482 } 9483 9484 cmdline_parse_inst_t cmd_set_mirror_mask = { 9485 .f = cmd_set_mirror_mask_parsed, 9486 .data = NULL, 9487 .help_str = "set port <port_id> mirror-rule <rule_id> " 9488 "pool-mirror-up|pool-mirror-down|vlan-mirror " 9489 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 9490 .tokens = { 9491 (void *)&cmd_mirror_mask_set, 9492 (void *)&cmd_mirror_mask_port, 9493 (void *)&cmd_mirror_mask_portid, 9494 (void *)&cmd_mirror_mask_mirror, 9495 (void *)&cmd_mirror_mask_ruleid, 9496 (void *)&cmd_mirror_mask_what, 9497 (void *)&cmd_mirror_mask_value, 9498 (void *)&cmd_mirror_mask_dstpool, 9499 (void *)&cmd_mirror_mask_poolid, 9500 (void *)&cmd_mirror_mask_on, 9501 NULL, 9502 }, 9503 }; 9504 9505 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 9506 struct cmd_set_mirror_link_result { 9507 cmdline_fixed_string_t set; 9508 cmdline_fixed_string_t port; 9509 portid_t port_id; 9510 cmdline_fixed_string_t mirror; 9511 uint8_t rule_id; 9512 cmdline_fixed_string_t what; 9513 cmdline_fixed_string_t dstpool; 9514 uint8_t dstpool_id; 9515 cmdline_fixed_string_t on; 9516 }; 9517 9518 cmdline_parse_token_string_t cmd_mirror_link_set = 9519 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9520 set, "set"); 9521 cmdline_parse_token_string_t cmd_mirror_link_port = 9522 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9523 port, "port"); 9524 cmdline_parse_token_num_t cmd_mirror_link_portid = 9525 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9526 port_id, UINT16); 9527 cmdline_parse_token_string_t cmd_mirror_link_mirror = 9528 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9529 mirror, "mirror-rule"); 9530 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 9531 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9532 rule_id, UINT8); 9533 cmdline_parse_token_string_t cmd_mirror_link_what = 9534 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9535 what, "uplink-mirror#downlink-mirror"); 9536 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 9537 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9538 dstpool, "dst-pool"); 9539 cmdline_parse_token_num_t cmd_mirror_link_poolid = 9540 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9541 dstpool_id, UINT8); 9542 cmdline_parse_token_string_t cmd_mirror_link_on = 9543 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9544 on, "on#off"); 9545 9546 static void 9547 cmd_set_mirror_link_parsed(void *parsed_result, 9548 __rte_unused struct cmdline *cl, 9549 __rte_unused void *data) 9550 { 9551 int ret; 9552 struct cmd_set_mirror_link_result *res = parsed_result; 9553 struct rte_eth_mirror_conf mr_conf; 9554 9555 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9556 if (!strcmp(res->what, "uplink-mirror")) 9557 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 9558 else 9559 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 9560 9561 mr_conf.dst_pool = res->dstpool_id; 9562 9563 if (!strcmp(res->on, "on")) 9564 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9565 res->rule_id, 1); 9566 else 9567 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9568 res->rule_id, 0); 9569 9570 /* check the return value and print it if is < 0 */ 9571 if (ret < 0) 9572 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9573 9574 } 9575 9576 cmdline_parse_inst_t cmd_set_mirror_link = { 9577 .f = cmd_set_mirror_link_parsed, 9578 .data = NULL, 9579 .help_str = "set port <port_id> mirror-rule <rule_id> " 9580 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 9581 .tokens = { 9582 (void *)&cmd_mirror_link_set, 9583 (void *)&cmd_mirror_link_port, 9584 (void *)&cmd_mirror_link_portid, 9585 (void *)&cmd_mirror_link_mirror, 9586 (void *)&cmd_mirror_link_ruleid, 9587 (void *)&cmd_mirror_link_what, 9588 (void *)&cmd_mirror_link_dstpool, 9589 (void *)&cmd_mirror_link_poolid, 9590 (void *)&cmd_mirror_link_on, 9591 NULL, 9592 }, 9593 }; 9594 9595 /* *** RESET VM MIRROR RULE *** */ 9596 struct cmd_rm_mirror_rule_result { 9597 cmdline_fixed_string_t reset; 9598 cmdline_fixed_string_t port; 9599 portid_t port_id; 9600 cmdline_fixed_string_t mirror; 9601 uint8_t rule_id; 9602 }; 9603 9604 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 9605 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9606 reset, "reset"); 9607 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 9608 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9609 port, "port"); 9610 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 9611 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9612 port_id, UINT16); 9613 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 9614 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9615 mirror, "mirror-rule"); 9616 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 9617 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9618 rule_id, UINT8); 9619 9620 static void 9621 cmd_reset_mirror_rule_parsed(void *parsed_result, 9622 __rte_unused struct cmdline *cl, 9623 __rte_unused void *data) 9624 { 9625 int ret; 9626 struct cmd_set_mirror_link_result *res = parsed_result; 9627 /* check rule_id */ 9628 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 9629 if(ret < 0) 9630 printf("mirror rule remove error: (%s)\n", strerror(-ret)); 9631 } 9632 9633 cmdline_parse_inst_t cmd_reset_mirror_rule = { 9634 .f = cmd_reset_mirror_rule_parsed, 9635 .data = NULL, 9636 .help_str = "reset port <port_id> mirror-rule <rule_id>", 9637 .tokens = { 9638 (void *)&cmd_rm_mirror_rule_reset, 9639 (void *)&cmd_rm_mirror_rule_port, 9640 (void *)&cmd_rm_mirror_rule_portid, 9641 (void *)&cmd_rm_mirror_rule_mirror, 9642 (void *)&cmd_rm_mirror_rule_ruleid, 9643 NULL, 9644 }, 9645 }; 9646 9647 /* ******************************************************************************** */ 9648 9649 struct cmd_dump_result { 9650 cmdline_fixed_string_t dump; 9651 }; 9652 9653 static void 9654 dump_struct_sizes(void) 9655 { 9656 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9657 DUMP_SIZE(struct rte_mbuf); 9658 DUMP_SIZE(struct rte_mempool); 9659 DUMP_SIZE(struct rte_ring); 9660 #undef DUMP_SIZE 9661 } 9662 9663 9664 /* Dump the socket memory statistics on console */ 9665 static void 9666 dump_socket_mem(FILE *f) 9667 { 9668 struct rte_malloc_socket_stats socket_stats; 9669 unsigned int i; 9670 size_t total = 0; 9671 size_t alloc = 0; 9672 size_t free = 0; 9673 unsigned int n_alloc = 0; 9674 unsigned int n_free = 0; 9675 static size_t last_allocs; 9676 static size_t last_total; 9677 9678 9679 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) { 9680 if (rte_malloc_get_socket_stats(i, &socket_stats) || 9681 !socket_stats.heap_totalsz_bytes) 9682 continue; 9683 total += socket_stats.heap_totalsz_bytes; 9684 alloc += socket_stats.heap_allocsz_bytes; 9685 free += socket_stats.heap_freesz_bytes; 9686 n_alloc += socket_stats.alloc_count; 9687 n_free += socket_stats.free_count; 9688 fprintf(f, 9689 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 9690 i, 9691 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024), 9692 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024), 9693 (double)socket_stats.heap_allocsz_bytes * 100 / 9694 (double)socket_stats.heap_totalsz_bytes, 9695 (double)socket_stats.heap_freesz_bytes / (1024 * 1024), 9696 socket_stats.alloc_count, 9697 socket_stats.free_count); 9698 } 9699 fprintf(f, 9700 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 9701 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024), 9702 (double)alloc * 100 / (double)total, 9703 (double)free / (1024 * 1024), 9704 n_alloc, n_free); 9705 if (last_allocs) 9706 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n", 9707 ((double)total - (double)last_total) / (1024 * 1024), 9708 (double)(alloc - (double)last_allocs) / 1024 / 1024); 9709 last_allocs = alloc; 9710 last_total = total; 9711 } 9712 9713 static void cmd_dump_parsed(void *parsed_result, 9714 __rte_unused struct cmdline *cl, 9715 __rte_unused void *data) 9716 { 9717 struct cmd_dump_result *res = parsed_result; 9718 9719 if (!strcmp(res->dump, "dump_physmem")) 9720 rte_dump_physmem_layout(stdout); 9721 else if (!strcmp(res->dump, "dump_socket_mem")) 9722 dump_socket_mem(stdout); 9723 else if (!strcmp(res->dump, "dump_memzone")) 9724 rte_memzone_dump(stdout); 9725 else if (!strcmp(res->dump, "dump_struct_sizes")) 9726 dump_struct_sizes(); 9727 else if (!strcmp(res->dump, "dump_ring")) 9728 rte_ring_list_dump(stdout); 9729 else if (!strcmp(res->dump, "dump_mempool")) 9730 rte_mempool_list_dump(stdout); 9731 else if (!strcmp(res->dump, "dump_devargs")) 9732 rte_devargs_dump(stdout); 9733 else if (!strcmp(res->dump, "dump_log_types")) 9734 rte_log_dump(stdout); 9735 } 9736 9737 cmdline_parse_token_string_t cmd_dump_dump = 9738 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9739 "dump_physmem#" 9740 "dump_memzone#" 9741 "dump_socket_mem#" 9742 "dump_struct_sizes#" 9743 "dump_ring#" 9744 "dump_mempool#" 9745 "dump_devargs#" 9746 "dump_log_types"); 9747 9748 cmdline_parse_inst_t cmd_dump = { 9749 .f = cmd_dump_parsed, /* function to call */ 9750 .data = NULL, /* 2nd arg of func */ 9751 .help_str = "Dump status", 9752 .tokens = { /* token list, NULL terminated */ 9753 (void *)&cmd_dump_dump, 9754 NULL, 9755 }, 9756 }; 9757 9758 /* ******************************************************************************** */ 9759 9760 struct cmd_dump_one_result { 9761 cmdline_fixed_string_t dump; 9762 cmdline_fixed_string_t name; 9763 }; 9764 9765 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9766 __rte_unused void *data) 9767 { 9768 struct cmd_dump_one_result *res = parsed_result; 9769 9770 if (!strcmp(res->dump, "dump_ring")) { 9771 struct rte_ring *r; 9772 r = rte_ring_lookup(res->name); 9773 if (r == NULL) { 9774 cmdline_printf(cl, "Cannot find ring\n"); 9775 return; 9776 } 9777 rte_ring_dump(stdout, r); 9778 } else if (!strcmp(res->dump, "dump_mempool")) { 9779 struct rte_mempool *mp; 9780 mp = rte_mempool_lookup(res->name); 9781 if (mp == NULL) { 9782 cmdline_printf(cl, "Cannot find mempool\n"); 9783 return; 9784 } 9785 rte_mempool_dump(stdout, mp); 9786 } 9787 } 9788 9789 cmdline_parse_token_string_t cmd_dump_one_dump = 9790 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9791 "dump_ring#dump_mempool"); 9792 9793 cmdline_parse_token_string_t cmd_dump_one_name = 9794 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9795 9796 cmdline_parse_inst_t cmd_dump_one = { 9797 .f = cmd_dump_one_parsed, /* function to call */ 9798 .data = NULL, /* 2nd arg of func */ 9799 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9800 .tokens = { /* token list, NULL terminated */ 9801 (void *)&cmd_dump_one_dump, 9802 (void *)&cmd_dump_one_name, 9803 NULL, 9804 }, 9805 }; 9806 9807 /* *** queue region set *** */ 9808 struct cmd_queue_region_result { 9809 cmdline_fixed_string_t set; 9810 cmdline_fixed_string_t port; 9811 portid_t port_id; 9812 cmdline_fixed_string_t cmd; 9813 cmdline_fixed_string_t region; 9814 uint8_t region_id; 9815 cmdline_fixed_string_t queue_start_index; 9816 uint8_t queue_id; 9817 cmdline_fixed_string_t queue_num; 9818 uint8_t queue_num_value; 9819 }; 9820 9821 static void 9822 cmd_queue_region_parsed(void *parsed_result, 9823 __rte_unused struct cmdline *cl, 9824 __rte_unused void *data) 9825 { 9826 struct cmd_queue_region_result *res = parsed_result; 9827 int ret = -ENOTSUP; 9828 #ifdef RTE_NET_I40E 9829 struct rte_pmd_i40e_queue_region_conf region_conf; 9830 enum rte_pmd_i40e_queue_region_op op_type; 9831 #endif 9832 9833 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9834 return; 9835 9836 #ifdef RTE_NET_I40E 9837 memset(®ion_conf, 0, sizeof(region_conf)); 9838 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 9839 region_conf.region_id = res->region_id; 9840 region_conf.queue_num = res->queue_num_value; 9841 region_conf.queue_start_index = res->queue_id; 9842 9843 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9844 op_type, ®ion_conf); 9845 #endif 9846 9847 switch (ret) { 9848 case 0: 9849 break; 9850 case -ENOTSUP: 9851 printf("function not implemented or supported\n"); 9852 break; 9853 default: 9854 printf("queue region config error: (%s)\n", strerror(-ret)); 9855 } 9856 } 9857 9858 cmdline_parse_token_string_t cmd_queue_region_set = 9859 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9860 set, "set"); 9861 cmdline_parse_token_string_t cmd_queue_region_port = 9862 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 9863 cmdline_parse_token_num_t cmd_queue_region_port_id = 9864 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9865 port_id, UINT16); 9866 cmdline_parse_token_string_t cmd_queue_region_cmd = 9867 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9868 cmd, "queue-region"); 9869 cmdline_parse_token_string_t cmd_queue_region_id = 9870 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9871 region, "region_id"); 9872 cmdline_parse_token_num_t cmd_queue_region_index = 9873 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9874 region_id, UINT8); 9875 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 9876 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9877 queue_start_index, "queue_start_index"); 9878 cmdline_parse_token_num_t cmd_queue_region_queue_id = 9879 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9880 queue_id, UINT8); 9881 cmdline_parse_token_string_t cmd_queue_region_queue_num = 9882 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9883 queue_num, "queue_num"); 9884 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 9885 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9886 queue_num_value, UINT8); 9887 9888 cmdline_parse_inst_t cmd_queue_region = { 9889 .f = cmd_queue_region_parsed, 9890 .data = NULL, 9891 .help_str = "set port <port_id> queue-region region_id <value> " 9892 "queue_start_index <value> queue_num <value>: Set a queue region", 9893 .tokens = { 9894 (void *)&cmd_queue_region_set, 9895 (void *)&cmd_queue_region_port, 9896 (void *)&cmd_queue_region_port_id, 9897 (void *)&cmd_queue_region_cmd, 9898 (void *)&cmd_queue_region_id, 9899 (void *)&cmd_queue_region_index, 9900 (void *)&cmd_queue_region_queue_start_index, 9901 (void *)&cmd_queue_region_queue_id, 9902 (void *)&cmd_queue_region_queue_num, 9903 (void *)&cmd_queue_region_queue_num_value, 9904 NULL, 9905 }, 9906 }; 9907 9908 /* *** queue region and flowtype set *** */ 9909 struct cmd_region_flowtype_result { 9910 cmdline_fixed_string_t set; 9911 cmdline_fixed_string_t port; 9912 portid_t port_id; 9913 cmdline_fixed_string_t cmd; 9914 cmdline_fixed_string_t region; 9915 uint8_t region_id; 9916 cmdline_fixed_string_t flowtype; 9917 uint8_t flowtype_id; 9918 }; 9919 9920 static void 9921 cmd_region_flowtype_parsed(void *parsed_result, 9922 __rte_unused struct cmdline *cl, 9923 __rte_unused void *data) 9924 { 9925 struct cmd_region_flowtype_result *res = parsed_result; 9926 int ret = -ENOTSUP; 9927 #ifdef RTE_NET_I40E 9928 struct rte_pmd_i40e_queue_region_conf region_conf; 9929 enum rte_pmd_i40e_queue_region_op op_type; 9930 #endif 9931 9932 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9933 return; 9934 9935 #ifdef RTE_NET_I40E 9936 memset(®ion_conf, 0, sizeof(region_conf)); 9937 9938 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 9939 region_conf.region_id = res->region_id; 9940 region_conf.hw_flowtype = res->flowtype_id; 9941 9942 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9943 op_type, ®ion_conf); 9944 #endif 9945 9946 switch (ret) { 9947 case 0: 9948 break; 9949 case -ENOTSUP: 9950 printf("function not implemented or supported\n"); 9951 break; 9952 default: 9953 printf("region flowtype config error: (%s)\n", strerror(-ret)); 9954 } 9955 } 9956 9957 cmdline_parse_token_string_t cmd_region_flowtype_set = 9958 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9959 set, "set"); 9960 cmdline_parse_token_string_t cmd_region_flowtype_port = 9961 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9962 port, "port"); 9963 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 9964 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9965 port_id, UINT16); 9966 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 9967 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9968 cmd, "queue-region"); 9969 cmdline_parse_token_string_t cmd_region_flowtype_index = 9970 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9971 region, "region_id"); 9972 cmdline_parse_token_num_t cmd_region_flowtype_id = 9973 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9974 region_id, UINT8); 9975 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 9976 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9977 flowtype, "flowtype"); 9978 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 9979 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9980 flowtype_id, UINT8); 9981 cmdline_parse_inst_t cmd_region_flowtype = { 9982 .f = cmd_region_flowtype_parsed, 9983 .data = NULL, 9984 .help_str = "set port <port_id> queue-region region_id <value> " 9985 "flowtype <value>: Set a flowtype region index", 9986 .tokens = { 9987 (void *)&cmd_region_flowtype_set, 9988 (void *)&cmd_region_flowtype_port, 9989 (void *)&cmd_region_flowtype_port_index, 9990 (void *)&cmd_region_flowtype_cmd, 9991 (void *)&cmd_region_flowtype_index, 9992 (void *)&cmd_region_flowtype_id, 9993 (void *)&cmd_region_flowtype_flow_index, 9994 (void *)&cmd_region_flowtype_flow_id, 9995 NULL, 9996 }, 9997 }; 9998 9999 /* *** User Priority (UP) to queue region (region_id) set *** */ 10000 struct cmd_user_priority_region_result { 10001 cmdline_fixed_string_t set; 10002 cmdline_fixed_string_t port; 10003 portid_t port_id; 10004 cmdline_fixed_string_t cmd; 10005 cmdline_fixed_string_t user_priority; 10006 uint8_t user_priority_id; 10007 cmdline_fixed_string_t region; 10008 uint8_t region_id; 10009 }; 10010 10011 static void 10012 cmd_user_priority_region_parsed(void *parsed_result, 10013 __rte_unused struct cmdline *cl, 10014 __rte_unused void *data) 10015 { 10016 struct cmd_user_priority_region_result *res = parsed_result; 10017 int ret = -ENOTSUP; 10018 #ifdef RTE_NET_I40E 10019 struct rte_pmd_i40e_queue_region_conf region_conf; 10020 enum rte_pmd_i40e_queue_region_op op_type; 10021 #endif 10022 10023 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10024 return; 10025 10026 #ifdef RTE_NET_I40E 10027 memset(®ion_conf, 0, sizeof(region_conf)); 10028 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 10029 region_conf.user_priority = res->user_priority_id; 10030 region_conf.region_id = res->region_id; 10031 10032 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10033 op_type, ®ion_conf); 10034 #endif 10035 10036 switch (ret) { 10037 case 0: 10038 break; 10039 case -ENOTSUP: 10040 printf("function not implemented or supported\n"); 10041 break; 10042 default: 10043 printf("user_priority region config error: (%s)\n", 10044 strerror(-ret)); 10045 } 10046 } 10047 10048 cmdline_parse_token_string_t cmd_user_priority_region_set = 10049 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10050 set, "set"); 10051 cmdline_parse_token_string_t cmd_user_priority_region_port = 10052 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10053 port, "port"); 10054 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 10055 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10056 port_id, UINT16); 10057 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 10058 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10059 cmd, "queue-region"); 10060 cmdline_parse_token_string_t cmd_user_priority_region_UP = 10061 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10062 user_priority, "UP"); 10063 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 10064 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10065 user_priority_id, UINT8); 10066 cmdline_parse_token_string_t cmd_user_priority_region_region = 10067 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10068 region, "region_id"); 10069 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 10070 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10071 region_id, UINT8); 10072 10073 cmdline_parse_inst_t cmd_user_priority_region = { 10074 .f = cmd_user_priority_region_parsed, 10075 .data = NULL, 10076 .help_str = "set port <port_id> queue-region UP <value> " 10077 "region_id <value>: Set the mapping of User Priority (UP) " 10078 "to queue region (region_id) ", 10079 .tokens = { 10080 (void *)&cmd_user_priority_region_set, 10081 (void *)&cmd_user_priority_region_port, 10082 (void *)&cmd_user_priority_region_port_index, 10083 (void *)&cmd_user_priority_region_cmd, 10084 (void *)&cmd_user_priority_region_UP, 10085 (void *)&cmd_user_priority_region_UP_id, 10086 (void *)&cmd_user_priority_region_region, 10087 (void *)&cmd_user_priority_region_region_id, 10088 NULL, 10089 }, 10090 }; 10091 10092 /* *** flush all queue region related configuration *** */ 10093 struct cmd_flush_queue_region_result { 10094 cmdline_fixed_string_t set; 10095 cmdline_fixed_string_t port; 10096 portid_t port_id; 10097 cmdline_fixed_string_t cmd; 10098 cmdline_fixed_string_t flush; 10099 cmdline_fixed_string_t what; 10100 }; 10101 10102 static void 10103 cmd_flush_queue_region_parsed(void *parsed_result, 10104 __rte_unused struct cmdline *cl, 10105 __rte_unused void *data) 10106 { 10107 struct cmd_flush_queue_region_result *res = parsed_result; 10108 int ret = -ENOTSUP; 10109 #ifdef RTE_NET_I40E 10110 struct rte_pmd_i40e_queue_region_conf region_conf; 10111 enum rte_pmd_i40e_queue_region_op op_type; 10112 #endif 10113 10114 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10115 return; 10116 10117 #ifdef RTE_NET_I40E 10118 memset(®ion_conf, 0, sizeof(region_conf)); 10119 10120 if (strcmp(res->what, "on") == 0) 10121 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 10122 else 10123 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 10124 10125 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10126 op_type, ®ion_conf); 10127 #endif 10128 10129 switch (ret) { 10130 case 0: 10131 break; 10132 case -ENOTSUP: 10133 printf("function not implemented or supported\n"); 10134 break; 10135 default: 10136 printf("queue region config flush error: (%s)\n", 10137 strerror(-ret)); 10138 } 10139 } 10140 10141 cmdline_parse_token_string_t cmd_flush_queue_region_set = 10142 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10143 set, "set"); 10144 cmdline_parse_token_string_t cmd_flush_queue_region_port = 10145 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10146 port, "port"); 10147 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 10148 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 10149 port_id, UINT16); 10150 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 10151 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10152 cmd, "queue-region"); 10153 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 10154 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10155 flush, "flush"); 10156 cmdline_parse_token_string_t cmd_flush_queue_region_what = 10157 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10158 what, "on#off"); 10159 10160 cmdline_parse_inst_t cmd_flush_queue_region = { 10161 .f = cmd_flush_queue_region_parsed, 10162 .data = NULL, 10163 .help_str = "set port <port_id> queue-region flush on|off" 10164 ": flush all queue region related configuration", 10165 .tokens = { 10166 (void *)&cmd_flush_queue_region_set, 10167 (void *)&cmd_flush_queue_region_port, 10168 (void *)&cmd_flush_queue_region_port_index, 10169 (void *)&cmd_flush_queue_region_cmd, 10170 (void *)&cmd_flush_queue_region_flush, 10171 (void *)&cmd_flush_queue_region_what, 10172 NULL, 10173 }, 10174 }; 10175 10176 /* *** get all queue region related configuration info *** */ 10177 struct cmd_show_queue_region_info { 10178 cmdline_fixed_string_t show; 10179 cmdline_fixed_string_t port; 10180 portid_t port_id; 10181 cmdline_fixed_string_t cmd; 10182 }; 10183 10184 static void 10185 cmd_show_queue_region_info_parsed(void *parsed_result, 10186 __rte_unused struct cmdline *cl, 10187 __rte_unused void *data) 10188 { 10189 struct cmd_show_queue_region_info *res = parsed_result; 10190 int ret = -ENOTSUP; 10191 #ifdef RTE_NET_I40E 10192 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 10193 enum rte_pmd_i40e_queue_region_op op_type; 10194 #endif 10195 10196 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10197 return; 10198 10199 #ifdef RTE_NET_I40E 10200 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 10201 10202 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 10203 10204 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10205 op_type, &rte_pmd_regions); 10206 10207 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 10208 #endif 10209 10210 switch (ret) { 10211 case 0: 10212 break; 10213 case -ENOTSUP: 10214 printf("function not implemented or supported\n"); 10215 break; 10216 default: 10217 printf("queue region config info show error: (%s)\n", 10218 strerror(-ret)); 10219 } 10220 } 10221 10222 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 10223 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10224 show, "show"); 10225 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 10226 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10227 port, "port"); 10228 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 10229 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 10230 port_id, UINT16); 10231 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 10232 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10233 cmd, "queue-region"); 10234 10235 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 10236 .f = cmd_show_queue_region_info_parsed, 10237 .data = NULL, 10238 .help_str = "show port <port_id> queue-region" 10239 ": show all queue region related configuration info", 10240 .tokens = { 10241 (void *)&cmd_show_queue_region_info_get, 10242 (void *)&cmd_show_queue_region_info_port, 10243 (void *)&cmd_show_queue_region_info_port_index, 10244 (void *)&cmd_show_queue_region_info_cmd, 10245 NULL, 10246 }, 10247 }; 10248 10249 /* *** Filters Control *** */ 10250 10251 /* *** deal with flow director filter *** */ 10252 struct cmd_flow_director_result { 10253 cmdline_fixed_string_t flow_director_filter; 10254 portid_t port_id; 10255 cmdline_fixed_string_t mode; 10256 cmdline_fixed_string_t mode_value; 10257 cmdline_fixed_string_t ops; 10258 cmdline_fixed_string_t flow; 10259 cmdline_fixed_string_t flow_type; 10260 cmdline_fixed_string_t ether; 10261 uint16_t ether_type; 10262 cmdline_fixed_string_t src; 10263 cmdline_ipaddr_t ip_src; 10264 uint16_t port_src; 10265 cmdline_fixed_string_t dst; 10266 cmdline_ipaddr_t ip_dst; 10267 uint16_t port_dst; 10268 cmdline_fixed_string_t verify_tag; 10269 uint32_t verify_tag_value; 10270 cmdline_fixed_string_t tos; 10271 uint8_t tos_value; 10272 cmdline_fixed_string_t proto; 10273 uint8_t proto_value; 10274 cmdline_fixed_string_t ttl; 10275 uint8_t ttl_value; 10276 cmdline_fixed_string_t vlan; 10277 uint16_t vlan_value; 10278 cmdline_fixed_string_t flexbytes; 10279 cmdline_fixed_string_t flexbytes_value; 10280 cmdline_fixed_string_t pf_vf; 10281 cmdline_fixed_string_t drop; 10282 cmdline_fixed_string_t queue; 10283 uint16_t queue_id; 10284 cmdline_fixed_string_t fd_id; 10285 uint32_t fd_id_value; 10286 cmdline_fixed_string_t mac; 10287 struct rte_ether_addr mac_addr; 10288 cmdline_fixed_string_t tunnel; 10289 cmdline_fixed_string_t tunnel_type; 10290 cmdline_fixed_string_t tunnel_id; 10291 uint32_t tunnel_id_value; 10292 cmdline_fixed_string_t packet; 10293 char filepath[]; 10294 }; 10295 10296 static inline int 10297 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num) 10298 { 10299 char s[256]; 10300 const char *p, *p0 = q_arg; 10301 char *end; 10302 unsigned long int_fld; 10303 char *str_fld[max_num]; 10304 int i; 10305 unsigned size; 10306 int ret = -1; 10307 10308 p = strchr(p0, '('); 10309 if (p == NULL) 10310 return -1; 10311 ++p; 10312 p0 = strchr(p, ')'); 10313 if (p0 == NULL) 10314 return -1; 10315 10316 size = p0 - p; 10317 if (size >= sizeof(s)) 10318 return -1; 10319 10320 snprintf(s, sizeof(s), "%.*s", size, p); 10321 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10322 if (ret < 0 || ret > max_num) 10323 return -1; 10324 for (i = 0; i < ret; i++) { 10325 errno = 0; 10326 int_fld = strtoul(str_fld[i], &end, 0); 10327 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX) 10328 return -1; 10329 flexbytes[i] = (uint8_t)int_fld; 10330 } 10331 return ret; 10332 } 10333 10334 static uint16_t 10335 str2flowtype(char *string) 10336 { 10337 uint8_t i = 0; 10338 static const struct { 10339 char str[32]; 10340 uint16_t type; 10341 } flowtype_str[] = { 10342 {"raw", RTE_ETH_FLOW_RAW}, 10343 {"ipv4", RTE_ETH_FLOW_IPV4}, 10344 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10345 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10346 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10347 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10348 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10349 {"ipv6", RTE_ETH_FLOW_IPV6}, 10350 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10351 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10352 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10353 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10354 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10355 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10356 }; 10357 10358 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10359 if (!strcmp(flowtype_str[i].str, string)) 10360 return flowtype_str[i].type; 10361 } 10362 10363 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10364 return (uint16_t)atoi(string); 10365 10366 return RTE_ETH_FLOW_UNKNOWN; 10367 } 10368 10369 static enum rte_eth_fdir_tunnel_type 10370 str2fdir_tunneltype(char *string) 10371 { 10372 uint8_t i = 0; 10373 10374 static const struct { 10375 char str[32]; 10376 enum rte_eth_fdir_tunnel_type type; 10377 } tunneltype_str[] = { 10378 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE}, 10379 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN}, 10380 }; 10381 10382 for (i = 0; i < RTE_DIM(tunneltype_str); i++) { 10383 if (!strcmp(tunneltype_str[i].str, string)) 10384 return tunneltype_str[i].type; 10385 } 10386 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN; 10387 } 10388 10389 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10390 do { \ 10391 if ((ip_addr).family == AF_INET) \ 10392 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10393 else { \ 10394 printf("invalid parameter.\n"); \ 10395 return; \ 10396 } \ 10397 } while (0) 10398 10399 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10400 do { \ 10401 if ((ip_addr).family == AF_INET6) \ 10402 rte_memcpy(&(ip), \ 10403 &((ip_addr).addr.ipv6), \ 10404 sizeof(struct in6_addr)); \ 10405 else { \ 10406 printf("invalid parameter.\n"); \ 10407 return; \ 10408 } \ 10409 } while (0) 10410 10411 static void 10412 cmd_flow_director_filter_parsed(void *parsed_result, 10413 __rte_unused struct cmdline *cl, 10414 __rte_unused void *data) 10415 { 10416 struct cmd_flow_director_result *res = parsed_result; 10417 struct rte_eth_fdir_filter entry; 10418 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; 10419 char *end; 10420 unsigned long vf_id; 10421 int ret = 0; 10422 10423 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 10424 if (ret < 0) { 10425 printf("flow director is not supported on port %u.\n", 10426 res->port_id); 10427 return; 10428 } 10429 memset(flexbytes, 0, sizeof(flexbytes)); 10430 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter)); 10431 10432 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10433 if (strcmp(res->mode_value, "MAC-VLAN")) { 10434 printf("Please set mode to MAC-VLAN.\n"); 10435 return; 10436 } 10437 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10438 if (strcmp(res->mode_value, "Tunnel")) { 10439 printf("Please set mode to Tunnel.\n"); 10440 return; 10441 } 10442 } else { 10443 if (!strcmp(res->mode_value, "raw")) { 10444 #ifdef RTE_NET_I40E 10445 struct rte_pmd_i40e_flow_type_mapping 10446 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 10447 struct rte_pmd_i40e_pkt_template_conf conf; 10448 uint16_t flow_type = str2flowtype(res->flow_type); 10449 uint16_t i, port = res->port_id; 10450 uint8_t add; 10451 10452 memset(&conf, 0, sizeof(conf)); 10453 10454 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 10455 printf("Invalid flow type specified.\n"); 10456 return; 10457 } 10458 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 10459 mapping); 10460 if (ret) 10461 return; 10462 if (mapping[flow_type].pctype == 0ULL) { 10463 printf("Invalid flow type specified.\n"); 10464 return; 10465 } 10466 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 10467 if (mapping[flow_type].pctype & (1ULL << i)) { 10468 conf.input.pctype = i; 10469 break; 10470 } 10471 } 10472 10473 conf.input.packet = open_file(res->filepath, 10474 &conf.input.length); 10475 if (!conf.input.packet) 10476 return; 10477 if (!strcmp(res->drop, "drop")) 10478 conf.action.behavior = 10479 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 10480 else 10481 conf.action.behavior = 10482 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 10483 conf.action.report_status = 10484 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 10485 conf.action.rx_queue = res->queue_id; 10486 conf.soft_id = res->fd_id_value; 10487 add = strcmp(res->ops, "del") ? 1 : 0; 10488 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 10489 &conf, 10490 add); 10491 if (ret < 0) 10492 printf("flow director config error: (%s)\n", 10493 strerror(-ret)); 10494 close_file(conf.input.packet); 10495 #endif 10496 return; 10497 } else if (strcmp(res->mode_value, "IP")) { 10498 printf("Please set mode to IP or raw.\n"); 10499 return; 10500 } 10501 entry.input.flow_type = str2flowtype(res->flow_type); 10502 } 10503 10504 ret = parse_flexbytes(res->flexbytes_value, 10505 flexbytes, 10506 RTE_ETH_FDIR_MAX_FLEXLEN); 10507 if (ret < 0) { 10508 printf("error: Cannot parse flexbytes input.\n"); 10509 return; 10510 } 10511 10512 switch (entry.input.flow_type) { 10513 case RTE_ETH_FLOW_FRAG_IPV4: 10514 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: 10515 entry.input.flow.ip4_flow.proto = res->proto_value; 10516 /* fall-through */ 10517 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: 10518 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: 10519 IPV4_ADDR_TO_UINT(res->ip_dst, 10520 entry.input.flow.ip4_flow.dst_ip); 10521 IPV4_ADDR_TO_UINT(res->ip_src, 10522 entry.input.flow.ip4_flow.src_ip); 10523 entry.input.flow.ip4_flow.tos = res->tos_value; 10524 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10525 /* need convert to big endian. */ 10526 entry.input.flow.udp4_flow.dst_port = 10527 rte_cpu_to_be_16(res->port_dst); 10528 entry.input.flow.udp4_flow.src_port = 10529 rte_cpu_to_be_16(res->port_src); 10530 break; 10531 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: 10532 IPV4_ADDR_TO_UINT(res->ip_dst, 10533 entry.input.flow.sctp4_flow.ip.dst_ip); 10534 IPV4_ADDR_TO_UINT(res->ip_src, 10535 entry.input.flow.sctp4_flow.ip.src_ip); 10536 entry.input.flow.ip4_flow.tos = res->tos_value; 10537 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10538 /* need convert to big endian. */ 10539 entry.input.flow.sctp4_flow.dst_port = 10540 rte_cpu_to_be_16(res->port_dst); 10541 entry.input.flow.sctp4_flow.src_port = 10542 rte_cpu_to_be_16(res->port_src); 10543 entry.input.flow.sctp4_flow.verify_tag = 10544 rte_cpu_to_be_32(res->verify_tag_value); 10545 break; 10546 case RTE_ETH_FLOW_FRAG_IPV6: 10547 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: 10548 entry.input.flow.ipv6_flow.proto = res->proto_value; 10549 /* fall-through */ 10550 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP: 10551 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP: 10552 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10553 entry.input.flow.ipv6_flow.dst_ip); 10554 IPV6_ADDR_TO_ARRAY(res->ip_src, 10555 entry.input.flow.ipv6_flow.src_ip); 10556 entry.input.flow.ipv6_flow.tc = res->tos_value; 10557 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10558 /* need convert to big endian. */ 10559 entry.input.flow.udp6_flow.dst_port = 10560 rte_cpu_to_be_16(res->port_dst); 10561 entry.input.flow.udp6_flow.src_port = 10562 rte_cpu_to_be_16(res->port_src); 10563 break; 10564 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: 10565 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10566 entry.input.flow.sctp6_flow.ip.dst_ip); 10567 IPV6_ADDR_TO_ARRAY(res->ip_src, 10568 entry.input.flow.sctp6_flow.ip.src_ip); 10569 entry.input.flow.ipv6_flow.tc = res->tos_value; 10570 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10571 /* need convert to big endian. */ 10572 entry.input.flow.sctp6_flow.dst_port = 10573 rte_cpu_to_be_16(res->port_dst); 10574 entry.input.flow.sctp6_flow.src_port = 10575 rte_cpu_to_be_16(res->port_src); 10576 entry.input.flow.sctp6_flow.verify_tag = 10577 rte_cpu_to_be_32(res->verify_tag_value); 10578 break; 10579 case RTE_ETH_FLOW_L2_PAYLOAD: 10580 entry.input.flow.l2_flow.ether_type = 10581 rte_cpu_to_be_16(res->ether_type); 10582 break; 10583 default: 10584 break; 10585 } 10586 10587 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) 10588 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr, 10589 &res->mac_addr, 10590 sizeof(struct rte_ether_addr)); 10591 10592 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10593 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr, 10594 &res->mac_addr, 10595 sizeof(struct rte_ether_addr)); 10596 entry.input.flow.tunnel_flow.tunnel_type = 10597 str2fdir_tunneltype(res->tunnel_type); 10598 entry.input.flow.tunnel_flow.tunnel_id = 10599 rte_cpu_to_be_32(res->tunnel_id_value); 10600 } 10601 10602 rte_memcpy(entry.input.flow_ext.flexbytes, 10603 flexbytes, 10604 RTE_ETH_FDIR_MAX_FLEXLEN); 10605 10606 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value); 10607 10608 entry.action.flex_off = 0; /*use 0 by default */ 10609 if (!strcmp(res->drop, "drop")) 10610 entry.action.behavior = RTE_ETH_FDIR_REJECT; 10611 else 10612 entry.action.behavior = RTE_ETH_FDIR_ACCEPT; 10613 10614 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN && 10615 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) { 10616 if (!strcmp(res->pf_vf, "pf")) 10617 entry.input.flow_ext.is_vf = 0; 10618 else if (!strncmp(res->pf_vf, "vf", 2)) { 10619 struct rte_eth_dev_info dev_info; 10620 10621 ret = eth_dev_info_get_print_err(res->port_id, 10622 &dev_info); 10623 if (ret != 0) 10624 return; 10625 10626 errno = 0; 10627 vf_id = strtoul(res->pf_vf + 2, &end, 10); 10628 if (errno != 0 || *end != '\0' || 10629 vf_id >= dev_info.max_vfs) { 10630 printf("invalid parameter %s.\n", res->pf_vf); 10631 return; 10632 } 10633 entry.input.flow_ext.is_vf = 1; 10634 entry.input.flow_ext.dst_id = (uint16_t)vf_id; 10635 } else { 10636 printf("invalid parameter %s.\n", res->pf_vf); 10637 return; 10638 } 10639 } 10640 10641 /* set to report FD ID by default */ 10642 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID; 10643 entry.action.rx_queue = res->queue_id; 10644 entry.soft_id = res->fd_id_value; 10645 if (!strcmp(res->ops, "add")) 10646 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10647 RTE_ETH_FILTER_ADD, &entry); 10648 else if (!strcmp(res->ops, "del")) 10649 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10650 RTE_ETH_FILTER_DELETE, &entry); 10651 else 10652 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10653 RTE_ETH_FILTER_UPDATE, &entry); 10654 if (ret < 0) 10655 printf("flow director programming error: (%s)\n", 10656 strerror(-ret)); 10657 } 10658 10659 cmdline_parse_token_string_t cmd_flow_director_filter = 10660 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10661 flow_director_filter, "flow_director_filter"); 10662 cmdline_parse_token_num_t cmd_flow_director_port_id = 10663 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10664 port_id, UINT16); 10665 cmdline_parse_token_string_t cmd_flow_director_ops = 10666 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10667 ops, "add#del#update"); 10668 cmdline_parse_token_string_t cmd_flow_director_flow = 10669 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10670 flow, "flow"); 10671 cmdline_parse_token_string_t cmd_flow_director_flow_type = 10672 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10673 flow_type, NULL); 10674 cmdline_parse_token_string_t cmd_flow_director_ether = 10675 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10676 ether, "ether"); 10677 cmdline_parse_token_num_t cmd_flow_director_ether_type = 10678 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10679 ether_type, UINT16); 10680 cmdline_parse_token_string_t cmd_flow_director_src = 10681 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10682 src, "src"); 10683 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src = 10684 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 10685 ip_src); 10686 cmdline_parse_token_num_t cmd_flow_director_port_src = 10687 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10688 port_src, UINT16); 10689 cmdline_parse_token_string_t cmd_flow_director_dst = 10690 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10691 dst, "dst"); 10692 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst = 10693 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 10694 ip_dst); 10695 cmdline_parse_token_num_t cmd_flow_director_port_dst = 10696 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10697 port_dst, UINT16); 10698 cmdline_parse_token_string_t cmd_flow_director_verify_tag = 10699 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10700 verify_tag, "verify_tag"); 10701 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value = 10702 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10703 verify_tag_value, UINT32); 10704 cmdline_parse_token_string_t cmd_flow_director_tos = 10705 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10706 tos, "tos"); 10707 cmdline_parse_token_num_t cmd_flow_director_tos_value = 10708 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10709 tos_value, UINT8); 10710 cmdline_parse_token_string_t cmd_flow_director_proto = 10711 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10712 proto, "proto"); 10713 cmdline_parse_token_num_t cmd_flow_director_proto_value = 10714 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10715 proto_value, UINT8); 10716 cmdline_parse_token_string_t cmd_flow_director_ttl = 10717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10718 ttl, "ttl"); 10719 cmdline_parse_token_num_t cmd_flow_director_ttl_value = 10720 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10721 ttl_value, UINT8); 10722 cmdline_parse_token_string_t cmd_flow_director_vlan = 10723 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10724 vlan, "vlan"); 10725 cmdline_parse_token_num_t cmd_flow_director_vlan_value = 10726 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10727 vlan_value, UINT16); 10728 cmdline_parse_token_string_t cmd_flow_director_flexbytes = 10729 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10730 flexbytes, "flexbytes"); 10731 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value = 10732 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10733 flexbytes_value, NULL); 10734 cmdline_parse_token_string_t cmd_flow_director_drop = 10735 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10736 drop, "drop#fwd"); 10737 cmdline_parse_token_string_t cmd_flow_director_pf_vf = 10738 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10739 pf_vf, NULL); 10740 cmdline_parse_token_string_t cmd_flow_director_queue = 10741 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10742 queue, "queue"); 10743 cmdline_parse_token_num_t cmd_flow_director_queue_id = 10744 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10745 queue_id, UINT16); 10746 cmdline_parse_token_string_t cmd_flow_director_fd_id = 10747 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10748 fd_id, "fd_id"); 10749 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 10750 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10751 fd_id_value, UINT32); 10752 10753 cmdline_parse_token_string_t cmd_flow_director_mode = 10754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10755 mode, "mode"); 10756 cmdline_parse_token_string_t cmd_flow_director_mode_ip = 10757 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10758 mode_value, "IP"); 10759 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan = 10760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10761 mode_value, "MAC-VLAN"); 10762 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel = 10763 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10764 mode_value, "Tunnel"); 10765 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 10766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10767 mode_value, "raw"); 10768 cmdline_parse_token_string_t cmd_flow_director_mac = 10769 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10770 mac, "mac"); 10771 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr = 10772 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result, 10773 mac_addr); 10774 cmdline_parse_token_string_t cmd_flow_director_tunnel = 10775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10776 tunnel, "tunnel"); 10777 cmdline_parse_token_string_t cmd_flow_director_tunnel_type = 10778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10779 tunnel_type, "NVGRE#VxLAN"); 10780 cmdline_parse_token_string_t cmd_flow_director_tunnel_id = 10781 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10782 tunnel_id, "tunnel-id"); 10783 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value = 10784 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10785 tunnel_id_value, UINT32); 10786 cmdline_parse_token_string_t cmd_flow_director_packet = 10787 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10788 packet, "packet"); 10789 cmdline_parse_token_string_t cmd_flow_director_filepath = 10790 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10791 filepath, NULL); 10792 10793 cmdline_parse_inst_t cmd_add_del_ip_flow_director = { 10794 .f = cmd_flow_director_filter_parsed, 10795 .data = NULL, 10796 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow" 10797 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 10798 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 10799 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> " 10800 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> " 10801 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> " 10802 "fd_id <fd_id_value>: " 10803 "Add or delete an ip flow director entry on NIC", 10804 .tokens = { 10805 (void *)&cmd_flow_director_filter, 10806 (void *)&cmd_flow_director_port_id, 10807 (void *)&cmd_flow_director_mode, 10808 (void *)&cmd_flow_director_mode_ip, 10809 (void *)&cmd_flow_director_ops, 10810 (void *)&cmd_flow_director_flow, 10811 (void *)&cmd_flow_director_flow_type, 10812 (void *)&cmd_flow_director_src, 10813 (void *)&cmd_flow_director_ip_src, 10814 (void *)&cmd_flow_director_dst, 10815 (void *)&cmd_flow_director_ip_dst, 10816 (void *)&cmd_flow_director_tos, 10817 (void *)&cmd_flow_director_tos_value, 10818 (void *)&cmd_flow_director_proto, 10819 (void *)&cmd_flow_director_proto_value, 10820 (void *)&cmd_flow_director_ttl, 10821 (void *)&cmd_flow_director_ttl_value, 10822 (void *)&cmd_flow_director_vlan, 10823 (void *)&cmd_flow_director_vlan_value, 10824 (void *)&cmd_flow_director_flexbytes, 10825 (void *)&cmd_flow_director_flexbytes_value, 10826 (void *)&cmd_flow_director_drop, 10827 (void *)&cmd_flow_director_pf_vf, 10828 (void *)&cmd_flow_director_queue, 10829 (void *)&cmd_flow_director_queue_id, 10830 (void *)&cmd_flow_director_fd_id, 10831 (void *)&cmd_flow_director_fd_id_value, 10832 NULL, 10833 }, 10834 }; 10835 10836 cmdline_parse_inst_t cmd_add_del_udp_flow_director = { 10837 .f = cmd_flow_director_filter_parsed, 10838 .data = NULL, 10839 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow " 10840 "director entry on NIC", 10841 .tokens = { 10842 (void *)&cmd_flow_director_filter, 10843 (void *)&cmd_flow_director_port_id, 10844 (void *)&cmd_flow_director_mode, 10845 (void *)&cmd_flow_director_mode_ip, 10846 (void *)&cmd_flow_director_ops, 10847 (void *)&cmd_flow_director_flow, 10848 (void *)&cmd_flow_director_flow_type, 10849 (void *)&cmd_flow_director_src, 10850 (void *)&cmd_flow_director_ip_src, 10851 (void *)&cmd_flow_director_port_src, 10852 (void *)&cmd_flow_director_dst, 10853 (void *)&cmd_flow_director_ip_dst, 10854 (void *)&cmd_flow_director_port_dst, 10855 (void *)&cmd_flow_director_tos, 10856 (void *)&cmd_flow_director_tos_value, 10857 (void *)&cmd_flow_director_ttl, 10858 (void *)&cmd_flow_director_ttl_value, 10859 (void *)&cmd_flow_director_vlan, 10860 (void *)&cmd_flow_director_vlan_value, 10861 (void *)&cmd_flow_director_flexbytes, 10862 (void *)&cmd_flow_director_flexbytes_value, 10863 (void *)&cmd_flow_director_drop, 10864 (void *)&cmd_flow_director_pf_vf, 10865 (void *)&cmd_flow_director_queue, 10866 (void *)&cmd_flow_director_queue_id, 10867 (void *)&cmd_flow_director_fd_id, 10868 (void *)&cmd_flow_director_fd_id_value, 10869 NULL, 10870 }, 10871 }; 10872 10873 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = { 10874 .f = cmd_flow_director_filter_parsed, 10875 .data = NULL, 10876 .help_str = "flow_director_filter ... : Add or delete a sctp flow " 10877 "director entry on NIC", 10878 .tokens = { 10879 (void *)&cmd_flow_director_filter, 10880 (void *)&cmd_flow_director_port_id, 10881 (void *)&cmd_flow_director_mode, 10882 (void *)&cmd_flow_director_mode_ip, 10883 (void *)&cmd_flow_director_ops, 10884 (void *)&cmd_flow_director_flow, 10885 (void *)&cmd_flow_director_flow_type, 10886 (void *)&cmd_flow_director_src, 10887 (void *)&cmd_flow_director_ip_src, 10888 (void *)&cmd_flow_director_port_src, 10889 (void *)&cmd_flow_director_dst, 10890 (void *)&cmd_flow_director_ip_dst, 10891 (void *)&cmd_flow_director_port_dst, 10892 (void *)&cmd_flow_director_verify_tag, 10893 (void *)&cmd_flow_director_verify_tag_value, 10894 (void *)&cmd_flow_director_tos, 10895 (void *)&cmd_flow_director_tos_value, 10896 (void *)&cmd_flow_director_ttl, 10897 (void *)&cmd_flow_director_ttl_value, 10898 (void *)&cmd_flow_director_vlan, 10899 (void *)&cmd_flow_director_vlan_value, 10900 (void *)&cmd_flow_director_flexbytes, 10901 (void *)&cmd_flow_director_flexbytes_value, 10902 (void *)&cmd_flow_director_drop, 10903 (void *)&cmd_flow_director_pf_vf, 10904 (void *)&cmd_flow_director_queue, 10905 (void *)&cmd_flow_director_queue_id, 10906 (void *)&cmd_flow_director_fd_id, 10907 (void *)&cmd_flow_director_fd_id_value, 10908 NULL, 10909 }, 10910 }; 10911 10912 cmdline_parse_inst_t cmd_add_del_l2_flow_director = { 10913 .f = cmd_flow_director_filter_parsed, 10914 .data = NULL, 10915 .help_str = "flow_director_filter ... : Add or delete a L2 flow " 10916 "director entry on NIC", 10917 .tokens = { 10918 (void *)&cmd_flow_director_filter, 10919 (void *)&cmd_flow_director_port_id, 10920 (void *)&cmd_flow_director_mode, 10921 (void *)&cmd_flow_director_mode_ip, 10922 (void *)&cmd_flow_director_ops, 10923 (void *)&cmd_flow_director_flow, 10924 (void *)&cmd_flow_director_flow_type, 10925 (void *)&cmd_flow_director_ether, 10926 (void *)&cmd_flow_director_ether_type, 10927 (void *)&cmd_flow_director_flexbytes, 10928 (void *)&cmd_flow_director_flexbytes_value, 10929 (void *)&cmd_flow_director_drop, 10930 (void *)&cmd_flow_director_pf_vf, 10931 (void *)&cmd_flow_director_queue, 10932 (void *)&cmd_flow_director_queue_id, 10933 (void *)&cmd_flow_director_fd_id, 10934 (void *)&cmd_flow_director_fd_id_value, 10935 NULL, 10936 }, 10937 }; 10938 10939 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = { 10940 .f = cmd_flow_director_filter_parsed, 10941 .data = NULL, 10942 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow " 10943 "director entry on NIC", 10944 .tokens = { 10945 (void *)&cmd_flow_director_filter, 10946 (void *)&cmd_flow_director_port_id, 10947 (void *)&cmd_flow_director_mode, 10948 (void *)&cmd_flow_director_mode_mac_vlan, 10949 (void *)&cmd_flow_director_ops, 10950 (void *)&cmd_flow_director_mac, 10951 (void *)&cmd_flow_director_mac_addr, 10952 (void *)&cmd_flow_director_vlan, 10953 (void *)&cmd_flow_director_vlan_value, 10954 (void *)&cmd_flow_director_flexbytes, 10955 (void *)&cmd_flow_director_flexbytes_value, 10956 (void *)&cmd_flow_director_drop, 10957 (void *)&cmd_flow_director_queue, 10958 (void *)&cmd_flow_director_queue_id, 10959 (void *)&cmd_flow_director_fd_id, 10960 (void *)&cmd_flow_director_fd_id_value, 10961 NULL, 10962 }, 10963 }; 10964 10965 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = { 10966 .f = cmd_flow_director_filter_parsed, 10967 .data = NULL, 10968 .help_str = "flow_director_filter ... : Add or delete a tunnel flow " 10969 "director entry on NIC", 10970 .tokens = { 10971 (void *)&cmd_flow_director_filter, 10972 (void *)&cmd_flow_director_port_id, 10973 (void *)&cmd_flow_director_mode, 10974 (void *)&cmd_flow_director_mode_tunnel, 10975 (void *)&cmd_flow_director_ops, 10976 (void *)&cmd_flow_director_mac, 10977 (void *)&cmd_flow_director_mac_addr, 10978 (void *)&cmd_flow_director_vlan, 10979 (void *)&cmd_flow_director_vlan_value, 10980 (void *)&cmd_flow_director_tunnel, 10981 (void *)&cmd_flow_director_tunnel_type, 10982 (void *)&cmd_flow_director_tunnel_id, 10983 (void *)&cmd_flow_director_tunnel_id_value, 10984 (void *)&cmd_flow_director_flexbytes, 10985 (void *)&cmd_flow_director_flexbytes_value, 10986 (void *)&cmd_flow_director_drop, 10987 (void *)&cmd_flow_director_queue, 10988 (void *)&cmd_flow_director_queue_id, 10989 (void *)&cmd_flow_director_fd_id, 10990 (void *)&cmd_flow_director_fd_id_value, 10991 NULL, 10992 }, 10993 }; 10994 10995 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 10996 .f = cmd_flow_director_filter_parsed, 10997 .data = NULL, 10998 .help_str = "flow_director_filter ... : Add or delete a raw flow " 10999 "director entry on NIC", 11000 .tokens = { 11001 (void *)&cmd_flow_director_filter, 11002 (void *)&cmd_flow_director_port_id, 11003 (void *)&cmd_flow_director_mode, 11004 (void *)&cmd_flow_director_mode_raw, 11005 (void *)&cmd_flow_director_ops, 11006 (void *)&cmd_flow_director_flow, 11007 (void *)&cmd_flow_director_flow_type, 11008 (void *)&cmd_flow_director_drop, 11009 (void *)&cmd_flow_director_queue, 11010 (void *)&cmd_flow_director_queue_id, 11011 (void *)&cmd_flow_director_fd_id, 11012 (void *)&cmd_flow_director_fd_id_value, 11013 (void *)&cmd_flow_director_packet, 11014 (void *)&cmd_flow_director_filepath, 11015 NULL, 11016 }, 11017 }; 11018 11019 struct cmd_flush_flow_director_result { 11020 cmdline_fixed_string_t flush_flow_director; 11021 portid_t port_id; 11022 }; 11023 11024 cmdline_parse_token_string_t cmd_flush_flow_director_flush = 11025 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result, 11026 flush_flow_director, "flush_flow_director"); 11027 cmdline_parse_token_num_t cmd_flush_flow_director_port_id = 11028 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result, 11029 port_id, UINT16); 11030 11031 static void 11032 cmd_flush_flow_director_parsed(void *parsed_result, 11033 __rte_unused struct cmdline *cl, 11034 __rte_unused void *data) 11035 { 11036 struct cmd_flow_director_result *res = parsed_result; 11037 int ret = 0; 11038 11039 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 11040 if (ret < 0) { 11041 printf("flow director is not supported on port %u.\n", 11042 res->port_id); 11043 return; 11044 } 11045 11046 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11047 RTE_ETH_FILTER_FLUSH, NULL); 11048 if (ret < 0) 11049 printf("flow director table flushing error: (%s)\n", 11050 strerror(-ret)); 11051 } 11052 11053 cmdline_parse_inst_t cmd_flush_flow_director = { 11054 .f = cmd_flush_flow_director_parsed, 11055 .data = NULL, 11056 .help_str = "flush_flow_director <port_id>: " 11057 "Flush all flow director entries of a device on NIC", 11058 .tokens = { 11059 (void *)&cmd_flush_flow_director_flush, 11060 (void *)&cmd_flush_flow_director_port_id, 11061 NULL, 11062 }, 11063 }; 11064 11065 /* *** deal with flow director mask *** */ 11066 struct cmd_flow_director_mask_result { 11067 cmdline_fixed_string_t flow_director_mask; 11068 portid_t port_id; 11069 cmdline_fixed_string_t mode; 11070 cmdline_fixed_string_t mode_value; 11071 cmdline_fixed_string_t vlan; 11072 uint16_t vlan_mask; 11073 cmdline_fixed_string_t src_mask; 11074 cmdline_ipaddr_t ipv4_src; 11075 cmdline_ipaddr_t ipv6_src; 11076 uint16_t port_src; 11077 cmdline_fixed_string_t dst_mask; 11078 cmdline_ipaddr_t ipv4_dst; 11079 cmdline_ipaddr_t ipv6_dst; 11080 uint16_t port_dst; 11081 cmdline_fixed_string_t mac; 11082 uint8_t mac_addr_byte_mask; 11083 cmdline_fixed_string_t tunnel_id; 11084 uint32_t tunnel_id_mask; 11085 cmdline_fixed_string_t tunnel_type; 11086 uint8_t tunnel_type_mask; 11087 }; 11088 11089 static void 11090 cmd_flow_director_mask_parsed(void *parsed_result, 11091 __rte_unused struct cmdline *cl, 11092 __rte_unused void *data) 11093 { 11094 struct cmd_flow_director_mask_result *res = parsed_result; 11095 struct rte_eth_fdir_masks *mask; 11096 struct rte_port *port; 11097 11098 port = &ports[res->port_id]; 11099 /** Check if the port is not started **/ 11100 if (port->port_status != RTE_PORT_STOPPED) { 11101 printf("Please stop port %d first\n", res->port_id); 11102 return; 11103 } 11104 11105 mask = &port->dev_conf.fdir_conf.mask; 11106 11107 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 11108 if (strcmp(res->mode_value, "MAC-VLAN")) { 11109 printf("Please set mode to MAC-VLAN.\n"); 11110 return; 11111 } 11112 11113 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11114 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11115 if (strcmp(res->mode_value, "Tunnel")) { 11116 printf("Please set mode to Tunnel.\n"); 11117 return; 11118 } 11119 11120 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11121 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 11122 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 11123 mask->tunnel_type_mask = res->tunnel_type_mask; 11124 } else { 11125 if (strcmp(res->mode_value, "IP")) { 11126 printf("Please set mode to IP.\n"); 11127 return; 11128 } 11129 11130 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11131 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 11132 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 11133 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 11134 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 11135 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 11136 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 11137 } 11138 11139 cmd_reconfig_device_queue(res->port_id, 1, 1); 11140 } 11141 11142 cmdline_parse_token_string_t cmd_flow_director_mask = 11143 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11144 flow_director_mask, "flow_director_mask"); 11145 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 11146 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11147 port_id, UINT16); 11148 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 11149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11150 vlan, "vlan"); 11151 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 11152 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11153 vlan_mask, UINT16); 11154 cmdline_parse_token_string_t cmd_flow_director_mask_src = 11155 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11156 src_mask, "src_mask"); 11157 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 11158 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11159 ipv4_src); 11160 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 11161 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11162 ipv6_src); 11163 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 11164 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11165 port_src, UINT16); 11166 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 11167 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11168 dst_mask, "dst_mask"); 11169 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 11170 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11171 ipv4_dst); 11172 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 11173 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11174 ipv6_dst); 11175 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 11176 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11177 port_dst, UINT16); 11178 11179 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 11180 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11181 mode, "mode"); 11182 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 11183 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11184 mode_value, "IP"); 11185 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 11186 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11187 mode_value, "MAC-VLAN"); 11188 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 11189 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11190 mode_value, "Tunnel"); 11191 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 11192 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11193 mac, "mac"); 11194 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 11195 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11196 mac_addr_byte_mask, UINT8); 11197 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 11198 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11199 tunnel_type, "tunnel-type"); 11200 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 11201 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11202 tunnel_type_mask, UINT8); 11203 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 11204 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11205 tunnel_id, "tunnel-id"); 11206 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 11207 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11208 tunnel_id_mask, UINT32); 11209 11210 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 11211 .f = cmd_flow_director_mask_parsed, 11212 .data = NULL, 11213 .help_str = "flow_director_mask ... : " 11214 "Set IP mode flow director's mask on NIC", 11215 .tokens = { 11216 (void *)&cmd_flow_director_mask, 11217 (void *)&cmd_flow_director_mask_port_id, 11218 (void *)&cmd_flow_director_mask_mode, 11219 (void *)&cmd_flow_director_mask_mode_ip, 11220 (void *)&cmd_flow_director_mask_vlan, 11221 (void *)&cmd_flow_director_mask_vlan_value, 11222 (void *)&cmd_flow_director_mask_src, 11223 (void *)&cmd_flow_director_mask_ipv4_src, 11224 (void *)&cmd_flow_director_mask_ipv6_src, 11225 (void *)&cmd_flow_director_mask_port_src, 11226 (void *)&cmd_flow_director_mask_dst, 11227 (void *)&cmd_flow_director_mask_ipv4_dst, 11228 (void *)&cmd_flow_director_mask_ipv6_dst, 11229 (void *)&cmd_flow_director_mask_port_dst, 11230 NULL, 11231 }, 11232 }; 11233 11234 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 11235 .f = cmd_flow_director_mask_parsed, 11236 .data = NULL, 11237 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 11238 "flow director's mask on NIC", 11239 .tokens = { 11240 (void *)&cmd_flow_director_mask, 11241 (void *)&cmd_flow_director_mask_port_id, 11242 (void *)&cmd_flow_director_mask_mode, 11243 (void *)&cmd_flow_director_mask_mode_mac_vlan, 11244 (void *)&cmd_flow_director_mask_vlan, 11245 (void *)&cmd_flow_director_mask_vlan_value, 11246 NULL, 11247 }, 11248 }; 11249 11250 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 11251 .f = cmd_flow_director_mask_parsed, 11252 .data = NULL, 11253 .help_str = "flow_director_mask ... : Set tunnel mode " 11254 "flow director's mask on NIC", 11255 .tokens = { 11256 (void *)&cmd_flow_director_mask, 11257 (void *)&cmd_flow_director_mask_port_id, 11258 (void *)&cmd_flow_director_mask_mode, 11259 (void *)&cmd_flow_director_mask_mode_tunnel, 11260 (void *)&cmd_flow_director_mask_vlan, 11261 (void *)&cmd_flow_director_mask_vlan_value, 11262 (void *)&cmd_flow_director_mask_mac, 11263 (void *)&cmd_flow_director_mask_mac_value, 11264 (void *)&cmd_flow_director_mask_tunnel_type, 11265 (void *)&cmd_flow_director_mask_tunnel_type_value, 11266 (void *)&cmd_flow_director_mask_tunnel_id, 11267 (void *)&cmd_flow_director_mask_tunnel_id_value, 11268 NULL, 11269 }, 11270 }; 11271 11272 /* *** deal with flow director mask on flexible payload *** */ 11273 struct cmd_flow_director_flex_mask_result { 11274 cmdline_fixed_string_t flow_director_flexmask; 11275 portid_t port_id; 11276 cmdline_fixed_string_t flow; 11277 cmdline_fixed_string_t flow_type; 11278 cmdline_fixed_string_t mask; 11279 }; 11280 11281 static void 11282 cmd_flow_director_flex_mask_parsed(void *parsed_result, 11283 __rte_unused struct cmdline *cl, 11284 __rte_unused void *data) 11285 { 11286 struct cmd_flow_director_flex_mask_result *res = parsed_result; 11287 struct rte_eth_fdir_info fdir_info; 11288 struct rte_eth_fdir_flex_mask flex_mask; 11289 struct rte_port *port; 11290 uint64_t flow_type_mask; 11291 uint16_t i; 11292 int ret; 11293 11294 port = &ports[res->port_id]; 11295 /** Check if the port is not started **/ 11296 if (port->port_status != RTE_PORT_STOPPED) { 11297 printf("Please stop port %d first\n", res->port_id); 11298 return; 11299 } 11300 11301 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask)); 11302 ret = parse_flexbytes(res->mask, 11303 flex_mask.mask, 11304 RTE_ETH_FDIR_MAX_FLEXLEN); 11305 if (ret < 0) { 11306 printf("error: Cannot parse mask input.\n"); 11307 return; 11308 } 11309 11310 memset(&fdir_info, 0, sizeof(fdir_info)); 11311 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11312 RTE_ETH_FILTER_INFO, &fdir_info); 11313 if (ret < 0) { 11314 printf("Cannot get FDir filter info\n"); 11315 return; 11316 } 11317 11318 if (!strcmp(res->flow_type, "none")) { 11319 /* means don't specify the flow type */ 11320 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN; 11321 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) 11322 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i], 11323 0, sizeof(struct rte_eth_fdir_flex_mask)); 11324 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1; 11325 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0], 11326 &flex_mask, 11327 sizeof(struct rte_eth_fdir_flex_mask)); 11328 cmd_reconfig_device_queue(res->port_id, 1, 1); 11329 return; 11330 } 11331 flow_type_mask = fdir_info.flow_types_mask[0]; 11332 if (!strcmp(res->flow_type, "all")) { 11333 if (!flow_type_mask) { 11334 printf("No flow type supported\n"); 11335 return; 11336 } 11337 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) { 11338 if (flow_type_mask & (1ULL << i)) { 11339 flex_mask.flow_type = i; 11340 fdir_set_flex_mask(res->port_id, &flex_mask); 11341 } 11342 } 11343 cmd_reconfig_device_queue(res->port_id, 1, 1); 11344 return; 11345 } 11346 flex_mask.flow_type = str2flowtype(res->flow_type); 11347 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) { 11348 printf("Flow type %s not supported on port %d\n", 11349 res->flow_type, res->port_id); 11350 return; 11351 } 11352 fdir_set_flex_mask(res->port_id, &flex_mask); 11353 cmd_reconfig_device_queue(res->port_id, 1, 1); 11354 } 11355 11356 cmdline_parse_token_string_t cmd_flow_director_flexmask = 11357 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11358 flow_director_flexmask, 11359 "flow_director_flex_mask"); 11360 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id = 11361 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11362 port_id, UINT16); 11363 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow = 11364 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11365 flow, "flow"); 11366 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type = 11367 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11368 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 11369 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all"); 11370 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask = 11371 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11372 mask, NULL); 11373 11374 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = { 11375 .f = cmd_flow_director_flex_mask_parsed, 11376 .data = NULL, 11377 .help_str = "flow_director_flex_mask ... : " 11378 "Set flow director's flex mask on NIC", 11379 .tokens = { 11380 (void *)&cmd_flow_director_flexmask, 11381 (void *)&cmd_flow_director_flexmask_port_id, 11382 (void *)&cmd_flow_director_flexmask_flow, 11383 (void *)&cmd_flow_director_flexmask_flow_type, 11384 (void *)&cmd_flow_director_flexmask_mask, 11385 NULL, 11386 }, 11387 }; 11388 11389 /* *** deal with flow director flexible payload configuration *** */ 11390 struct cmd_flow_director_flexpayload_result { 11391 cmdline_fixed_string_t flow_director_flexpayload; 11392 portid_t port_id; 11393 cmdline_fixed_string_t payload_layer; 11394 cmdline_fixed_string_t payload_cfg; 11395 }; 11396 11397 static inline int 11398 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 11399 { 11400 char s[256]; 11401 const char *p, *p0 = q_arg; 11402 char *end; 11403 unsigned long int_fld; 11404 char *str_fld[max_num]; 11405 int i; 11406 unsigned size; 11407 int ret = -1; 11408 11409 p = strchr(p0, '('); 11410 if (p == NULL) 11411 return -1; 11412 ++p; 11413 p0 = strchr(p, ')'); 11414 if (p0 == NULL) 11415 return -1; 11416 11417 size = p0 - p; 11418 if (size >= sizeof(s)) 11419 return -1; 11420 11421 snprintf(s, sizeof(s), "%.*s", size, p); 11422 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 11423 if (ret < 0 || ret > max_num) 11424 return -1; 11425 for (i = 0; i < ret; i++) { 11426 errno = 0; 11427 int_fld = strtoul(str_fld[i], &end, 0); 11428 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 11429 return -1; 11430 offsets[i] = (uint16_t)int_fld; 11431 } 11432 return ret; 11433 } 11434 11435 static void 11436 cmd_flow_director_flxpld_parsed(void *parsed_result, 11437 __rte_unused struct cmdline *cl, 11438 __rte_unused void *data) 11439 { 11440 struct cmd_flow_director_flexpayload_result *res = parsed_result; 11441 struct rte_eth_flex_payload_cfg flex_cfg; 11442 struct rte_port *port; 11443 int ret = 0; 11444 11445 port = &ports[res->port_id]; 11446 /** Check if the port is not started **/ 11447 if (port->port_status != RTE_PORT_STOPPED) { 11448 printf("Please stop port %d first\n", res->port_id); 11449 return; 11450 } 11451 11452 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 11453 11454 if (!strcmp(res->payload_layer, "raw")) 11455 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 11456 else if (!strcmp(res->payload_layer, "l2")) 11457 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 11458 else if (!strcmp(res->payload_layer, "l3")) 11459 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 11460 else if (!strcmp(res->payload_layer, "l4")) 11461 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 11462 11463 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 11464 RTE_ETH_FDIR_MAX_FLEXLEN); 11465 if (ret < 0) { 11466 printf("error: Cannot parse flex payload input.\n"); 11467 return; 11468 } 11469 11470 fdir_set_flex_payload(res->port_id, &flex_cfg); 11471 cmd_reconfig_device_queue(res->port_id, 1, 1); 11472 } 11473 11474 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 11475 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11476 flow_director_flexpayload, 11477 "flow_director_flex_payload"); 11478 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 11479 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11480 port_id, UINT16); 11481 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 11482 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11483 payload_layer, "raw#l2#l3#l4"); 11484 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 11485 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11486 payload_cfg, NULL); 11487 11488 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 11489 .f = cmd_flow_director_flxpld_parsed, 11490 .data = NULL, 11491 .help_str = "flow_director_flexpayload ... : " 11492 "Set flow director's flex payload on NIC", 11493 .tokens = { 11494 (void *)&cmd_flow_director_flexpayload, 11495 (void *)&cmd_flow_director_flexpayload_port_id, 11496 (void *)&cmd_flow_director_flexpayload_payload_layer, 11497 (void *)&cmd_flow_director_flexpayload_payload_cfg, 11498 NULL, 11499 }, 11500 }; 11501 11502 /* Generic flow interface command. */ 11503 extern cmdline_parse_inst_t cmd_flow; 11504 11505 /* *** Classification Filters Control *** */ 11506 /* *** Get symmetric hash enable per port *** */ 11507 struct cmd_get_sym_hash_ena_per_port_result { 11508 cmdline_fixed_string_t get_sym_hash_ena_per_port; 11509 portid_t port_id; 11510 }; 11511 11512 static void 11513 cmd_get_sym_hash_per_port_parsed(void *parsed_result, 11514 __rte_unused struct cmdline *cl, 11515 __rte_unused void *data) 11516 { 11517 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result; 11518 struct rte_eth_hash_filter_info info; 11519 int ret; 11520 11521 if (rte_eth_dev_filter_supported(res->port_id, 11522 RTE_ETH_FILTER_HASH) < 0) { 11523 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11524 res->port_id); 11525 return; 11526 } 11527 11528 memset(&info, 0, sizeof(info)); 11529 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11530 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11531 RTE_ETH_FILTER_GET, &info); 11532 11533 if (ret < 0) { 11534 printf("Cannot get symmetric hash enable per port " 11535 "on port %u\n", res->port_id); 11536 return; 11537 } 11538 11539 printf("Symmetric hash is %s on port %u\n", info.info.enable ? 11540 "enabled" : "disabled", res->port_id); 11541 } 11542 11543 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all = 11544 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11545 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port"); 11546 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id = 11547 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11548 port_id, UINT16); 11549 11550 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = { 11551 .f = cmd_get_sym_hash_per_port_parsed, 11552 .data = NULL, 11553 .help_str = "get_sym_hash_ena_per_port <port_id>", 11554 .tokens = { 11555 (void *)&cmd_get_sym_hash_ena_per_port_all, 11556 (void *)&cmd_get_sym_hash_ena_per_port_port_id, 11557 NULL, 11558 }, 11559 }; 11560 11561 /* *** Set symmetric hash enable per port *** */ 11562 struct cmd_set_sym_hash_ena_per_port_result { 11563 cmdline_fixed_string_t set_sym_hash_ena_per_port; 11564 cmdline_fixed_string_t enable; 11565 portid_t port_id; 11566 }; 11567 11568 static void 11569 cmd_set_sym_hash_per_port_parsed(void *parsed_result, 11570 __rte_unused struct cmdline *cl, 11571 __rte_unused void *data) 11572 { 11573 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result; 11574 struct rte_eth_hash_filter_info info; 11575 int ret; 11576 11577 if (rte_eth_dev_filter_supported(res->port_id, 11578 RTE_ETH_FILTER_HASH) < 0) { 11579 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11580 res->port_id); 11581 return; 11582 } 11583 11584 memset(&info, 0, sizeof(info)); 11585 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11586 if (!strcmp(res->enable, "enable")) 11587 info.info.enable = 1; 11588 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11589 RTE_ETH_FILTER_SET, &info); 11590 if (ret < 0) { 11591 printf("Cannot set symmetric hash enable per port on " 11592 "port %u\n", res->port_id); 11593 return; 11594 } 11595 printf("Symmetric hash has been set to %s on port %u\n", 11596 res->enable, res->port_id); 11597 } 11598 11599 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all = 11600 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11601 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port"); 11602 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id = 11603 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11604 port_id, UINT16); 11605 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable = 11606 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11607 enable, "enable#disable"); 11608 11609 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = { 11610 .f = cmd_set_sym_hash_per_port_parsed, 11611 .data = NULL, 11612 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable", 11613 .tokens = { 11614 (void *)&cmd_set_sym_hash_ena_per_port_all, 11615 (void *)&cmd_set_sym_hash_ena_per_port_port_id, 11616 (void *)&cmd_set_sym_hash_ena_per_port_enable, 11617 NULL, 11618 }, 11619 }; 11620 11621 /* Get global config of hash function */ 11622 struct cmd_get_hash_global_config_result { 11623 cmdline_fixed_string_t get_hash_global_config; 11624 portid_t port_id; 11625 }; 11626 11627 static char * 11628 flowtype_to_str(uint16_t ftype) 11629 { 11630 uint16_t i; 11631 static struct { 11632 char str[16]; 11633 uint16_t ftype; 11634 } ftype_table[] = { 11635 {"ipv4", RTE_ETH_FLOW_IPV4}, 11636 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 11637 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 11638 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 11639 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 11640 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 11641 {"ipv6", RTE_ETH_FLOW_IPV6}, 11642 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 11643 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 11644 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 11645 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 11646 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 11647 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 11648 {"port", RTE_ETH_FLOW_PORT}, 11649 {"vxlan", RTE_ETH_FLOW_VXLAN}, 11650 {"geneve", RTE_ETH_FLOW_GENEVE}, 11651 {"nvgre", RTE_ETH_FLOW_NVGRE}, 11652 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE}, 11653 }; 11654 11655 for (i = 0; i < RTE_DIM(ftype_table); i++) { 11656 if (ftype_table[i].ftype == ftype) 11657 return ftype_table[i].str; 11658 } 11659 11660 return NULL; 11661 } 11662 11663 static void 11664 cmd_get_hash_global_config_parsed(void *parsed_result, 11665 __rte_unused struct cmdline *cl, 11666 __rte_unused void *data) 11667 { 11668 struct cmd_get_hash_global_config_result *res = parsed_result; 11669 struct rte_eth_hash_filter_info info; 11670 uint32_t idx, offset; 11671 uint16_t i; 11672 char *str; 11673 int ret; 11674 11675 if (rte_eth_dev_filter_supported(res->port_id, 11676 RTE_ETH_FILTER_HASH) < 0) { 11677 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 11678 res->port_id); 11679 return; 11680 } 11681 11682 memset(&info, 0, sizeof(info)); 11683 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 11684 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11685 RTE_ETH_FILTER_GET, &info); 11686 if (ret < 0) { 11687 printf("Cannot get hash global configurations by port %d\n", 11688 res->port_id); 11689 return; 11690 } 11691 11692 switch (info.info.global_conf.hash_func) { 11693 case RTE_ETH_HASH_FUNCTION_TOEPLITZ: 11694 printf("Hash function is Toeplitz\n"); 11695 break; 11696 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: 11697 printf("Hash function is Simple XOR\n"); 11698 break; 11699 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ: 11700 printf("Hash function is Symmetric Toeplitz\n"); 11701 break; 11702 default: 11703 printf("Unknown hash function\n"); 11704 break; 11705 } 11706 11707 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) { 11708 idx = i / UINT64_BIT; 11709 offset = i % UINT64_BIT; 11710 if (!(info.info.global_conf.valid_bit_mask[idx] & 11711 (1ULL << offset))) 11712 continue; 11713 str = flowtype_to_str(i); 11714 if (!str) 11715 continue; 11716 printf("Symmetric hash is %s globally for flow type %s " 11717 "by port %d\n", 11718 ((info.info.global_conf.sym_hash_enable_mask[idx] & 11719 (1ULL << offset)) ? "enabled" : "disabled"), str, 11720 res->port_id); 11721 } 11722 } 11723 11724 cmdline_parse_token_string_t cmd_get_hash_global_config_all = 11725 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result, 11726 get_hash_global_config, "get_hash_global_config"); 11727 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id = 11728 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result, 11729 port_id, UINT16); 11730 11731 cmdline_parse_inst_t cmd_get_hash_global_config = { 11732 .f = cmd_get_hash_global_config_parsed, 11733 .data = NULL, 11734 .help_str = "get_hash_global_config <port_id>", 11735 .tokens = { 11736 (void *)&cmd_get_hash_global_config_all, 11737 (void *)&cmd_get_hash_global_config_port_id, 11738 NULL, 11739 }, 11740 }; 11741 11742 /* Set global config of hash function */ 11743 struct cmd_set_hash_global_config_result { 11744 cmdline_fixed_string_t set_hash_global_config; 11745 portid_t port_id; 11746 cmdline_fixed_string_t hash_func; 11747 cmdline_fixed_string_t flow_type; 11748 cmdline_fixed_string_t enable; 11749 }; 11750 11751 static void 11752 cmd_set_hash_global_config_parsed(void *parsed_result, 11753 __rte_unused struct cmdline *cl, 11754 __rte_unused void *data) 11755 { 11756 struct cmd_set_hash_global_config_result *res = parsed_result; 11757 struct rte_eth_hash_filter_info info; 11758 uint32_t ftype, idx, offset; 11759 int ret; 11760 11761 if (rte_eth_dev_filter_supported(res->port_id, 11762 RTE_ETH_FILTER_HASH) < 0) { 11763 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 11764 res->port_id); 11765 return; 11766 } 11767 memset(&info, 0, sizeof(info)); 11768 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 11769 if (!strcmp(res->hash_func, "toeplitz")) 11770 info.info.global_conf.hash_func = 11771 RTE_ETH_HASH_FUNCTION_TOEPLITZ; 11772 else if (!strcmp(res->hash_func, "simple_xor")) 11773 info.info.global_conf.hash_func = 11774 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; 11775 else if (!strcmp(res->hash_func, "symmetric_toeplitz")) 11776 info.info.global_conf.hash_func = 11777 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ; 11778 else if (!strcmp(res->hash_func, "default")) 11779 info.info.global_conf.hash_func = 11780 RTE_ETH_HASH_FUNCTION_DEFAULT; 11781 11782 ftype = str2flowtype(res->flow_type); 11783 idx = ftype / UINT64_BIT; 11784 offset = ftype % UINT64_BIT; 11785 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset); 11786 if (!strcmp(res->enable, "enable")) 11787 info.info.global_conf.sym_hash_enable_mask[idx] |= 11788 (1ULL << offset); 11789 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11790 RTE_ETH_FILTER_SET, &info); 11791 if (ret < 0) 11792 printf("Cannot set global hash configurations by port %d\n", 11793 res->port_id); 11794 else 11795 printf("Global hash configurations have been set " 11796 "successfully by port %d\n", res->port_id); 11797 } 11798 11799 cmdline_parse_token_string_t cmd_set_hash_global_config_all = 11800 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11801 set_hash_global_config, "set_hash_global_config"); 11802 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id = 11803 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result, 11804 port_id, UINT16); 11805 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func = 11806 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11807 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default"); 11808 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type = 11809 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11810 flow_type, 11811 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#" 11812 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 11813 cmdline_parse_token_string_t cmd_set_hash_global_config_enable = 11814 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11815 enable, "enable#disable"); 11816 11817 cmdline_parse_inst_t cmd_set_hash_global_config = { 11818 .f = cmd_set_hash_global_config_parsed, 11819 .data = NULL, 11820 .help_str = "set_hash_global_config <port_id> " 11821 "toeplitz|simple_xor|symmetric_toeplitz|default " 11822 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 11823 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 11824 "l2_payload enable|disable", 11825 .tokens = { 11826 (void *)&cmd_set_hash_global_config_all, 11827 (void *)&cmd_set_hash_global_config_port_id, 11828 (void *)&cmd_set_hash_global_config_hash_func, 11829 (void *)&cmd_set_hash_global_config_flow_type, 11830 (void *)&cmd_set_hash_global_config_enable, 11831 NULL, 11832 }, 11833 }; 11834 11835 /* Set hash input set */ 11836 struct cmd_set_hash_input_set_result { 11837 cmdline_fixed_string_t set_hash_input_set; 11838 portid_t port_id; 11839 cmdline_fixed_string_t flow_type; 11840 cmdline_fixed_string_t inset_field; 11841 cmdline_fixed_string_t select; 11842 }; 11843 11844 static enum rte_eth_input_set_field 11845 str2inset(char *string) 11846 { 11847 uint16_t i; 11848 11849 static const struct { 11850 char str[32]; 11851 enum rte_eth_input_set_field inset; 11852 } inset_table[] = { 11853 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE}, 11854 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN}, 11855 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN}, 11856 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4}, 11857 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4}, 11858 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS}, 11859 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO}, 11860 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL}, 11861 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6}, 11862 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6}, 11863 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC}, 11864 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER}, 11865 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS}, 11866 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT}, 11867 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT}, 11868 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT}, 11869 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT}, 11870 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT}, 11871 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT}, 11872 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG}, 11873 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY}, 11874 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY}, 11875 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD}, 11876 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD}, 11877 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD}, 11878 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD}, 11879 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD}, 11880 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD}, 11881 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD}, 11882 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD}, 11883 {"none", RTE_ETH_INPUT_SET_NONE}, 11884 }; 11885 11886 for (i = 0; i < RTE_DIM(inset_table); i++) { 11887 if (!strcmp(string, inset_table[i].str)) 11888 return inset_table[i].inset; 11889 } 11890 11891 return RTE_ETH_INPUT_SET_UNKNOWN; 11892 } 11893 11894 static void 11895 cmd_set_hash_input_set_parsed(void *parsed_result, 11896 __rte_unused struct cmdline *cl, 11897 __rte_unused void *data) 11898 { 11899 struct cmd_set_hash_input_set_result *res = parsed_result; 11900 struct rte_eth_hash_filter_info info; 11901 11902 memset(&info, 0, sizeof(info)); 11903 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT; 11904 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 11905 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 11906 info.info.input_set_conf.inset_size = 1; 11907 if (!strcmp(res->select, "select")) 11908 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 11909 else if (!strcmp(res->select, "add")) 11910 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 11911 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11912 RTE_ETH_FILTER_SET, &info); 11913 } 11914 11915 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd = 11916 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 11917 set_hash_input_set, "set_hash_input_set"); 11918 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id = 11919 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result, 11920 port_id, UINT16); 11921 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type = 11922 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 11923 flow_type, NULL); 11924 cmdline_parse_token_string_t cmd_set_hash_input_set_field = 11925 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 11926 inset_field, 11927 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 11928 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#" 11929 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#" 11930 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#" 11931 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#" 11932 "fld-8th#none"); 11933 cmdline_parse_token_string_t cmd_set_hash_input_set_select = 11934 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 11935 select, "select#add"); 11936 11937 cmdline_parse_inst_t cmd_set_hash_input_set = { 11938 .f = cmd_set_hash_input_set_parsed, 11939 .data = NULL, 11940 .help_str = "set_hash_input_set <port_id> " 11941 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 11942 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> " 11943 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|" 11944 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|" 11945 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|" 11946 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|" 11947 "fld-7th|fld-8th|none select|add", 11948 .tokens = { 11949 (void *)&cmd_set_hash_input_set_cmd, 11950 (void *)&cmd_set_hash_input_set_port_id, 11951 (void *)&cmd_set_hash_input_set_flow_type, 11952 (void *)&cmd_set_hash_input_set_field, 11953 (void *)&cmd_set_hash_input_set_select, 11954 NULL, 11955 }, 11956 }; 11957 11958 /* Set flow director input set */ 11959 struct cmd_set_fdir_input_set_result { 11960 cmdline_fixed_string_t set_fdir_input_set; 11961 portid_t port_id; 11962 cmdline_fixed_string_t flow_type; 11963 cmdline_fixed_string_t inset_field; 11964 cmdline_fixed_string_t select; 11965 }; 11966 11967 static void 11968 cmd_set_fdir_input_set_parsed(void *parsed_result, 11969 __rte_unused struct cmdline *cl, 11970 __rte_unused void *data) 11971 { 11972 struct cmd_set_fdir_input_set_result *res = parsed_result; 11973 struct rte_eth_fdir_filter_info info; 11974 11975 memset(&info, 0, sizeof(info)); 11976 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT; 11977 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 11978 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 11979 info.info.input_set_conf.inset_size = 1; 11980 if (!strcmp(res->select, "select")) 11981 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 11982 else if (!strcmp(res->select, "add")) 11983 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 11984 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11985 RTE_ETH_FILTER_SET, &info); 11986 } 11987 11988 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd = 11989 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 11990 set_fdir_input_set, "set_fdir_input_set"); 11991 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id = 11992 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result, 11993 port_id, UINT16); 11994 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type = 11995 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 11996 flow_type, 11997 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#" 11998 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 11999 cmdline_parse_token_string_t cmd_set_fdir_input_set_field = 12000 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12001 inset_field, 12002 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12003 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#" 12004 "ipv6-hop-limits#udp-src-port#udp-dst-port#" 12005 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#" 12006 "sctp-veri-tag#none"); 12007 cmdline_parse_token_string_t cmd_set_fdir_input_set_select = 12008 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12009 select, "select#add"); 12010 12011 cmdline_parse_inst_t cmd_set_fdir_input_set = { 12012 .f = cmd_set_fdir_input_set_parsed, 12013 .data = NULL, 12014 .help_str = "set_fdir_input_set <port_id> " 12015 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12016 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload " 12017 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|" 12018 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|" 12019 "ipv6-hop-limits|udp-src-port|udp-dst-port|" 12020 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|" 12021 "sctp-veri-tag|none select|add", 12022 .tokens = { 12023 (void *)&cmd_set_fdir_input_set_cmd, 12024 (void *)&cmd_set_fdir_input_set_port_id, 12025 (void *)&cmd_set_fdir_input_set_flow_type, 12026 (void *)&cmd_set_fdir_input_set_field, 12027 (void *)&cmd_set_fdir_input_set_select, 12028 NULL, 12029 }, 12030 }; 12031 12032 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 12033 struct cmd_mcast_addr_result { 12034 cmdline_fixed_string_t mcast_addr_cmd; 12035 cmdline_fixed_string_t what; 12036 uint16_t port_num; 12037 struct rte_ether_addr mc_addr; 12038 }; 12039 12040 static void cmd_mcast_addr_parsed(void *parsed_result, 12041 __rte_unused struct cmdline *cl, 12042 __rte_unused void *data) 12043 { 12044 struct cmd_mcast_addr_result *res = parsed_result; 12045 12046 if (!rte_is_multicast_ether_addr(&res->mc_addr)) { 12047 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", 12048 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], 12049 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], 12050 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); 12051 return; 12052 } 12053 if (strcmp(res->what, "add") == 0) 12054 mcast_addr_add(res->port_num, &res->mc_addr); 12055 else 12056 mcast_addr_remove(res->port_num, &res->mc_addr); 12057 } 12058 12059 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 12060 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 12061 mcast_addr_cmd, "mcast_addr"); 12062 cmdline_parse_token_string_t cmd_mcast_addr_what = 12063 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 12064 "add#remove"); 12065 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 12066 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16); 12067 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 12068 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 12069 12070 cmdline_parse_inst_t cmd_mcast_addr = { 12071 .f = cmd_mcast_addr_parsed, 12072 .data = (void *)0, 12073 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 12074 "Add/Remove multicast MAC address on port_id", 12075 .tokens = { 12076 (void *)&cmd_mcast_addr_cmd, 12077 (void *)&cmd_mcast_addr_what, 12078 (void *)&cmd_mcast_addr_portnum, 12079 (void *)&cmd_mcast_addr_addr, 12080 NULL, 12081 }, 12082 }; 12083 12084 /* l2 tunnel config 12085 * only support E-tag now. 12086 */ 12087 12088 /* Ether type config */ 12089 struct cmd_config_l2_tunnel_eth_type_result { 12090 cmdline_fixed_string_t port; 12091 cmdline_fixed_string_t config; 12092 cmdline_fixed_string_t all; 12093 portid_t id; 12094 cmdline_fixed_string_t l2_tunnel; 12095 cmdline_fixed_string_t l2_tunnel_type; 12096 cmdline_fixed_string_t eth_type; 12097 uint16_t eth_type_val; 12098 }; 12099 12100 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port = 12101 TOKEN_STRING_INITIALIZER 12102 (struct cmd_config_l2_tunnel_eth_type_result, 12103 port, "port"); 12104 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config = 12105 TOKEN_STRING_INITIALIZER 12106 (struct cmd_config_l2_tunnel_eth_type_result, 12107 config, "config"); 12108 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str = 12109 TOKEN_STRING_INITIALIZER 12110 (struct cmd_config_l2_tunnel_eth_type_result, 12111 all, "all"); 12112 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id = 12113 TOKEN_NUM_INITIALIZER 12114 (struct cmd_config_l2_tunnel_eth_type_result, 12115 id, UINT16); 12116 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel = 12117 TOKEN_STRING_INITIALIZER 12118 (struct cmd_config_l2_tunnel_eth_type_result, 12119 l2_tunnel, "l2-tunnel"); 12120 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type = 12121 TOKEN_STRING_INITIALIZER 12122 (struct cmd_config_l2_tunnel_eth_type_result, 12123 l2_tunnel_type, "E-tag"); 12124 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type = 12125 TOKEN_STRING_INITIALIZER 12126 (struct cmd_config_l2_tunnel_eth_type_result, 12127 eth_type, "ether-type"); 12128 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val = 12129 TOKEN_NUM_INITIALIZER 12130 (struct cmd_config_l2_tunnel_eth_type_result, 12131 eth_type_val, UINT16); 12132 12133 static enum rte_eth_tunnel_type 12134 str2fdir_l2_tunnel_type(char *string) 12135 { 12136 uint32_t i = 0; 12137 12138 static const struct { 12139 char str[32]; 12140 enum rte_eth_tunnel_type type; 12141 } l2_tunnel_type_str[] = { 12142 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG}, 12143 }; 12144 12145 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) { 12146 if (!strcmp(l2_tunnel_type_str[i].str, string)) 12147 return l2_tunnel_type_str[i].type; 12148 } 12149 return RTE_TUNNEL_TYPE_NONE; 12150 } 12151 12152 /* ether type config for all ports */ 12153 static void 12154 cmd_config_l2_tunnel_eth_type_all_parsed 12155 (void *parsed_result, 12156 __rte_unused struct cmdline *cl, 12157 __rte_unused void *data) 12158 { 12159 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result; 12160 struct rte_eth_l2_tunnel_conf entry; 12161 portid_t pid; 12162 12163 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12164 entry.ether_type = res->eth_type_val; 12165 12166 RTE_ETH_FOREACH_DEV(pid) { 12167 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry); 12168 } 12169 } 12170 12171 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = { 12172 .f = cmd_config_l2_tunnel_eth_type_all_parsed, 12173 .data = NULL, 12174 .help_str = "port config all l2-tunnel E-tag ether-type <value>", 12175 .tokens = { 12176 (void *)&cmd_config_l2_tunnel_eth_type_port, 12177 (void *)&cmd_config_l2_tunnel_eth_type_config, 12178 (void *)&cmd_config_l2_tunnel_eth_type_all_str, 12179 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12180 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12181 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12182 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12183 NULL, 12184 }, 12185 }; 12186 12187 /* ether type config for a specific port */ 12188 static void 12189 cmd_config_l2_tunnel_eth_type_specific_parsed( 12190 void *parsed_result, 12191 __rte_unused struct cmdline *cl, 12192 __rte_unused void *data) 12193 { 12194 struct cmd_config_l2_tunnel_eth_type_result *res = 12195 parsed_result; 12196 struct rte_eth_l2_tunnel_conf entry; 12197 12198 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12199 return; 12200 12201 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12202 entry.ether_type = res->eth_type_val; 12203 12204 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry); 12205 } 12206 12207 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = { 12208 .f = cmd_config_l2_tunnel_eth_type_specific_parsed, 12209 .data = NULL, 12210 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>", 12211 .tokens = { 12212 (void *)&cmd_config_l2_tunnel_eth_type_port, 12213 (void *)&cmd_config_l2_tunnel_eth_type_config, 12214 (void *)&cmd_config_l2_tunnel_eth_type_id, 12215 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12216 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12217 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12218 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12219 NULL, 12220 }, 12221 }; 12222 12223 /* Enable/disable l2 tunnel */ 12224 struct cmd_config_l2_tunnel_en_dis_result { 12225 cmdline_fixed_string_t port; 12226 cmdline_fixed_string_t config; 12227 cmdline_fixed_string_t all; 12228 portid_t id; 12229 cmdline_fixed_string_t l2_tunnel; 12230 cmdline_fixed_string_t l2_tunnel_type; 12231 cmdline_fixed_string_t en_dis; 12232 }; 12233 12234 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port = 12235 TOKEN_STRING_INITIALIZER 12236 (struct cmd_config_l2_tunnel_en_dis_result, 12237 port, "port"); 12238 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config = 12239 TOKEN_STRING_INITIALIZER 12240 (struct cmd_config_l2_tunnel_en_dis_result, 12241 config, "config"); 12242 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str = 12243 TOKEN_STRING_INITIALIZER 12244 (struct cmd_config_l2_tunnel_en_dis_result, 12245 all, "all"); 12246 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id = 12247 TOKEN_NUM_INITIALIZER 12248 (struct cmd_config_l2_tunnel_en_dis_result, 12249 id, UINT16); 12250 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel = 12251 TOKEN_STRING_INITIALIZER 12252 (struct cmd_config_l2_tunnel_en_dis_result, 12253 l2_tunnel, "l2-tunnel"); 12254 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type = 12255 TOKEN_STRING_INITIALIZER 12256 (struct cmd_config_l2_tunnel_en_dis_result, 12257 l2_tunnel_type, "E-tag"); 12258 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis = 12259 TOKEN_STRING_INITIALIZER 12260 (struct cmd_config_l2_tunnel_en_dis_result, 12261 en_dis, "enable#disable"); 12262 12263 /* enable/disable l2 tunnel for all ports */ 12264 static void 12265 cmd_config_l2_tunnel_en_dis_all_parsed( 12266 void *parsed_result, 12267 __rte_unused struct cmdline *cl, 12268 __rte_unused void *data) 12269 { 12270 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result; 12271 struct rte_eth_l2_tunnel_conf entry; 12272 portid_t pid; 12273 uint8_t en; 12274 12275 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12276 12277 if (!strcmp("enable", res->en_dis)) 12278 en = 1; 12279 else 12280 en = 0; 12281 12282 RTE_ETH_FOREACH_DEV(pid) { 12283 rte_eth_dev_l2_tunnel_offload_set(pid, 12284 &entry, 12285 ETH_L2_TUNNEL_ENABLE_MASK, 12286 en); 12287 } 12288 } 12289 12290 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = { 12291 .f = cmd_config_l2_tunnel_en_dis_all_parsed, 12292 .data = NULL, 12293 .help_str = "port config all l2-tunnel E-tag enable|disable", 12294 .tokens = { 12295 (void *)&cmd_config_l2_tunnel_en_dis_port, 12296 (void *)&cmd_config_l2_tunnel_en_dis_config, 12297 (void *)&cmd_config_l2_tunnel_en_dis_all_str, 12298 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12299 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12300 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12301 NULL, 12302 }, 12303 }; 12304 12305 /* enable/disable l2 tunnel for a port */ 12306 static void 12307 cmd_config_l2_tunnel_en_dis_specific_parsed( 12308 void *parsed_result, 12309 __rte_unused struct cmdline *cl, 12310 __rte_unused void *data) 12311 { 12312 struct cmd_config_l2_tunnel_en_dis_result *res = 12313 parsed_result; 12314 struct rte_eth_l2_tunnel_conf entry; 12315 12316 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12317 return; 12318 12319 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12320 12321 if (!strcmp("enable", res->en_dis)) 12322 rte_eth_dev_l2_tunnel_offload_set(res->id, 12323 &entry, 12324 ETH_L2_TUNNEL_ENABLE_MASK, 12325 1); 12326 else 12327 rte_eth_dev_l2_tunnel_offload_set(res->id, 12328 &entry, 12329 ETH_L2_TUNNEL_ENABLE_MASK, 12330 0); 12331 } 12332 12333 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = { 12334 .f = cmd_config_l2_tunnel_en_dis_specific_parsed, 12335 .data = NULL, 12336 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable", 12337 .tokens = { 12338 (void *)&cmd_config_l2_tunnel_en_dis_port, 12339 (void *)&cmd_config_l2_tunnel_en_dis_config, 12340 (void *)&cmd_config_l2_tunnel_en_dis_id, 12341 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12342 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12343 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12344 NULL, 12345 }, 12346 }; 12347 12348 /* E-tag configuration */ 12349 12350 /* Common result structure for all E-tag configuration */ 12351 struct cmd_config_e_tag_result { 12352 cmdline_fixed_string_t e_tag; 12353 cmdline_fixed_string_t set; 12354 cmdline_fixed_string_t insertion; 12355 cmdline_fixed_string_t stripping; 12356 cmdline_fixed_string_t forwarding; 12357 cmdline_fixed_string_t filter; 12358 cmdline_fixed_string_t add; 12359 cmdline_fixed_string_t del; 12360 cmdline_fixed_string_t on; 12361 cmdline_fixed_string_t off; 12362 cmdline_fixed_string_t on_off; 12363 cmdline_fixed_string_t port_tag_id; 12364 uint32_t port_tag_id_val; 12365 cmdline_fixed_string_t e_tag_id; 12366 uint16_t e_tag_id_val; 12367 cmdline_fixed_string_t dst_pool; 12368 uint8_t dst_pool_val; 12369 cmdline_fixed_string_t port; 12370 portid_t port_id; 12371 cmdline_fixed_string_t vf; 12372 uint8_t vf_id; 12373 }; 12374 12375 /* Common CLI fields for all E-tag configuration */ 12376 cmdline_parse_token_string_t cmd_config_e_tag_e_tag = 12377 TOKEN_STRING_INITIALIZER 12378 (struct cmd_config_e_tag_result, 12379 e_tag, "E-tag"); 12380 cmdline_parse_token_string_t cmd_config_e_tag_set = 12381 TOKEN_STRING_INITIALIZER 12382 (struct cmd_config_e_tag_result, 12383 set, "set"); 12384 cmdline_parse_token_string_t cmd_config_e_tag_insertion = 12385 TOKEN_STRING_INITIALIZER 12386 (struct cmd_config_e_tag_result, 12387 insertion, "insertion"); 12388 cmdline_parse_token_string_t cmd_config_e_tag_stripping = 12389 TOKEN_STRING_INITIALIZER 12390 (struct cmd_config_e_tag_result, 12391 stripping, "stripping"); 12392 cmdline_parse_token_string_t cmd_config_e_tag_forwarding = 12393 TOKEN_STRING_INITIALIZER 12394 (struct cmd_config_e_tag_result, 12395 forwarding, "forwarding"); 12396 cmdline_parse_token_string_t cmd_config_e_tag_filter = 12397 TOKEN_STRING_INITIALIZER 12398 (struct cmd_config_e_tag_result, 12399 filter, "filter"); 12400 cmdline_parse_token_string_t cmd_config_e_tag_add = 12401 TOKEN_STRING_INITIALIZER 12402 (struct cmd_config_e_tag_result, 12403 add, "add"); 12404 cmdline_parse_token_string_t cmd_config_e_tag_del = 12405 TOKEN_STRING_INITIALIZER 12406 (struct cmd_config_e_tag_result, 12407 del, "del"); 12408 cmdline_parse_token_string_t cmd_config_e_tag_on = 12409 TOKEN_STRING_INITIALIZER 12410 (struct cmd_config_e_tag_result, 12411 on, "on"); 12412 cmdline_parse_token_string_t cmd_config_e_tag_off = 12413 TOKEN_STRING_INITIALIZER 12414 (struct cmd_config_e_tag_result, 12415 off, "off"); 12416 cmdline_parse_token_string_t cmd_config_e_tag_on_off = 12417 TOKEN_STRING_INITIALIZER 12418 (struct cmd_config_e_tag_result, 12419 on_off, "on#off"); 12420 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id = 12421 TOKEN_STRING_INITIALIZER 12422 (struct cmd_config_e_tag_result, 12423 port_tag_id, "port-tag-id"); 12424 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val = 12425 TOKEN_NUM_INITIALIZER 12426 (struct cmd_config_e_tag_result, 12427 port_tag_id_val, UINT32); 12428 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id = 12429 TOKEN_STRING_INITIALIZER 12430 (struct cmd_config_e_tag_result, 12431 e_tag_id, "e-tag-id"); 12432 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val = 12433 TOKEN_NUM_INITIALIZER 12434 (struct cmd_config_e_tag_result, 12435 e_tag_id_val, UINT16); 12436 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool = 12437 TOKEN_STRING_INITIALIZER 12438 (struct cmd_config_e_tag_result, 12439 dst_pool, "dst-pool"); 12440 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val = 12441 TOKEN_NUM_INITIALIZER 12442 (struct cmd_config_e_tag_result, 12443 dst_pool_val, UINT8); 12444 cmdline_parse_token_string_t cmd_config_e_tag_port = 12445 TOKEN_STRING_INITIALIZER 12446 (struct cmd_config_e_tag_result, 12447 port, "port"); 12448 cmdline_parse_token_num_t cmd_config_e_tag_port_id = 12449 TOKEN_NUM_INITIALIZER 12450 (struct cmd_config_e_tag_result, 12451 port_id, UINT16); 12452 cmdline_parse_token_string_t cmd_config_e_tag_vf = 12453 TOKEN_STRING_INITIALIZER 12454 (struct cmd_config_e_tag_result, 12455 vf, "vf"); 12456 cmdline_parse_token_num_t cmd_config_e_tag_vf_id = 12457 TOKEN_NUM_INITIALIZER 12458 (struct cmd_config_e_tag_result, 12459 vf_id, UINT8); 12460 12461 /* E-tag insertion configuration */ 12462 static void 12463 cmd_config_e_tag_insertion_en_parsed( 12464 void *parsed_result, 12465 __rte_unused struct cmdline *cl, 12466 __rte_unused void *data) 12467 { 12468 struct cmd_config_e_tag_result *res = 12469 parsed_result; 12470 struct rte_eth_l2_tunnel_conf entry; 12471 12472 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12473 return; 12474 12475 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12476 entry.tunnel_id = res->port_tag_id_val; 12477 entry.vf_id = res->vf_id; 12478 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12479 &entry, 12480 ETH_L2_TUNNEL_INSERTION_MASK, 12481 1); 12482 } 12483 12484 static void 12485 cmd_config_e_tag_insertion_dis_parsed( 12486 void *parsed_result, 12487 __rte_unused struct cmdline *cl, 12488 __rte_unused void *data) 12489 { 12490 struct cmd_config_e_tag_result *res = 12491 parsed_result; 12492 struct rte_eth_l2_tunnel_conf entry; 12493 12494 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12495 return; 12496 12497 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12498 entry.vf_id = res->vf_id; 12499 12500 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12501 &entry, 12502 ETH_L2_TUNNEL_INSERTION_MASK, 12503 0); 12504 } 12505 12506 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = { 12507 .f = cmd_config_e_tag_insertion_en_parsed, 12508 .data = NULL, 12509 .help_str = "E-tag ... : E-tag insertion enable", 12510 .tokens = { 12511 (void *)&cmd_config_e_tag_e_tag, 12512 (void *)&cmd_config_e_tag_set, 12513 (void *)&cmd_config_e_tag_insertion, 12514 (void *)&cmd_config_e_tag_on, 12515 (void *)&cmd_config_e_tag_port_tag_id, 12516 (void *)&cmd_config_e_tag_port_tag_id_val, 12517 (void *)&cmd_config_e_tag_port, 12518 (void *)&cmd_config_e_tag_port_id, 12519 (void *)&cmd_config_e_tag_vf, 12520 (void *)&cmd_config_e_tag_vf_id, 12521 NULL, 12522 }, 12523 }; 12524 12525 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = { 12526 .f = cmd_config_e_tag_insertion_dis_parsed, 12527 .data = NULL, 12528 .help_str = "E-tag ... : E-tag insertion disable", 12529 .tokens = { 12530 (void *)&cmd_config_e_tag_e_tag, 12531 (void *)&cmd_config_e_tag_set, 12532 (void *)&cmd_config_e_tag_insertion, 12533 (void *)&cmd_config_e_tag_off, 12534 (void *)&cmd_config_e_tag_port, 12535 (void *)&cmd_config_e_tag_port_id, 12536 (void *)&cmd_config_e_tag_vf, 12537 (void *)&cmd_config_e_tag_vf_id, 12538 NULL, 12539 }, 12540 }; 12541 12542 /* E-tag stripping configuration */ 12543 static void 12544 cmd_config_e_tag_stripping_parsed( 12545 void *parsed_result, 12546 __rte_unused struct cmdline *cl, 12547 __rte_unused void *data) 12548 { 12549 struct cmd_config_e_tag_result *res = 12550 parsed_result; 12551 struct rte_eth_l2_tunnel_conf entry; 12552 12553 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12554 return; 12555 12556 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12557 12558 if (!strcmp(res->on_off, "on")) 12559 rte_eth_dev_l2_tunnel_offload_set 12560 (res->port_id, 12561 &entry, 12562 ETH_L2_TUNNEL_STRIPPING_MASK, 12563 1); 12564 else 12565 rte_eth_dev_l2_tunnel_offload_set 12566 (res->port_id, 12567 &entry, 12568 ETH_L2_TUNNEL_STRIPPING_MASK, 12569 0); 12570 } 12571 12572 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = { 12573 .f = cmd_config_e_tag_stripping_parsed, 12574 .data = NULL, 12575 .help_str = "E-tag ... : E-tag stripping enable/disable", 12576 .tokens = { 12577 (void *)&cmd_config_e_tag_e_tag, 12578 (void *)&cmd_config_e_tag_set, 12579 (void *)&cmd_config_e_tag_stripping, 12580 (void *)&cmd_config_e_tag_on_off, 12581 (void *)&cmd_config_e_tag_port, 12582 (void *)&cmd_config_e_tag_port_id, 12583 NULL, 12584 }, 12585 }; 12586 12587 /* E-tag forwarding configuration */ 12588 static void 12589 cmd_config_e_tag_forwarding_parsed( 12590 void *parsed_result, 12591 __rte_unused struct cmdline *cl, 12592 __rte_unused void *data) 12593 { 12594 struct cmd_config_e_tag_result *res = parsed_result; 12595 struct rte_eth_l2_tunnel_conf entry; 12596 12597 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12598 return; 12599 12600 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12601 12602 if (!strcmp(res->on_off, "on")) 12603 rte_eth_dev_l2_tunnel_offload_set 12604 (res->port_id, 12605 &entry, 12606 ETH_L2_TUNNEL_FORWARDING_MASK, 12607 1); 12608 else 12609 rte_eth_dev_l2_tunnel_offload_set 12610 (res->port_id, 12611 &entry, 12612 ETH_L2_TUNNEL_FORWARDING_MASK, 12613 0); 12614 } 12615 12616 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = { 12617 .f = cmd_config_e_tag_forwarding_parsed, 12618 .data = NULL, 12619 .help_str = "E-tag ... : E-tag forwarding enable/disable", 12620 .tokens = { 12621 (void *)&cmd_config_e_tag_e_tag, 12622 (void *)&cmd_config_e_tag_set, 12623 (void *)&cmd_config_e_tag_forwarding, 12624 (void *)&cmd_config_e_tag_on_off, 12625 (void *)&cmd_config_e_tag_port, 12626 (void *)&cmd_config_e_tag_port_id, 12627 NULL, 12628 }, 12629 }; 12630 12631 /* E-tag filter configuration */ 12632 static void 12633 cmd_config_e_tag_filter_add_parsed( 12634 void *parsed_result, 12635 __rte_unused struct cmdline *cl, 12636 __rte_unused void *data) 12637 { 12638 struct cmd_config_e_tag_result *res = parsed_result; 12639 struct rte_eth_l2_tunnel_conf entry; 12640 int ret = 0; 12641 12642 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12643 return; 12644 12645 if (res->e_tag_id_val > 0x3fff) { 12646 printf("e-tag-id must be equal or less than 0x3fff.\n"); 12647 return; 12648 } 12649 12650 ret = rte_eth_dev_filter_supported(res->port_id, 12651 RTE_ETH_FILTER_L2_TUNNEL); 12652 if (ret < 0) { 12653 printf("E-tag filter is not supported on port %u.\n", 12654 res->port_id); 12655 return; 12656 } 12657 12658 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12659 entry.tunnel_id = res->e_tag_id_val; 12660 entry.pool = res->dst_pool_val; 12661 12662 ret = rte_eth_dev_filter_ctrl(res->port_id, 12663 RTE_ETH_FILTER_L2_TUNNEL, 12664 RTE_ETH_FILTER_ADD, 12665 &entry); 12666 if (ret < 0) 12667 printf("E-tag filter programming error: (%s)\n", 12668 strerror(-ret)); 12669 } 12670 12671 cmdline_parse_inst_t cmd_config_e_tag_filter_add = { 12672 .f = cmd_config_e_tag_filter_add_parsed, 12673 .data = NULL, 12674 .help_str = "E-tag ... : E-tag filter add", 12675 .tokens = { 12676 (void *)&cmd_config_e_tag_e_tag, 12677 (void *)&cmd_config_e_tag_set, 12678 (void *)&cmd_config_e_tag_filter, 12679 (void *)&cmd_config_e_tag_add, 12680 (void *)&cmd_config_e_tag_e_tag_id, 12681 (void *)&cmd_config_e_tag_e_tag_id_val, 12682 (void *)&cmd_config_e_tag_dst_pool, 12683 (void *)&cmd_config_e_tag_dst_pool_val, 12684 (void *)&cmd_config_e_tag_port, 12685 (void *)&cmd_config_e_tag_port_id, 12686 NULL, 12687 }, 12688 }; 12689 12690 static void 12691 cmd_config_e_tag_filter_del_parsed( 12692 void *parsed_result, 12693 __rte_unused struct cmdline *cl, 12694 __rte_unused void *data) 12695 { 12696 struct cmd_config_e_tag_result *res = parsed_result; 12697 struct rte_eth_l2_tunnel_conf entry; 12698 int ret = 0; 12699 12700 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12701 return; 12702 12703 if (res->e_tag_id_val > 0x3fff) { 12704 printf("e-tag-id must be less than 0x3fff.\n"); 12705 return; 12706 } 12707 12708 ret = rte_eth_dev_filter_supported(res->port_id, 12709 RTE_ETH_FILTER_L2_TUNNEL); 12710 if (ret < 0) { 12711 printf("E-tag filter is not supported on port %u.\n", 12712 res->port_id); 12713 return; 12714 } 12715 12716 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12717 entry.tunnel_id = res->e_tag_id_val; 12718 12719 ret = rte_eth_dev_filter_ctrl(res->port_id, 12720 RTE_ETH_FILTER_L2_TUNNEL, 12721 RTE_ETH_FILTER_DELETE, 12722 &entry); 12723 if (ret < 0) 12724 printf("E-tag filter programming error: (%s)\n", 12725 strerror(-ret)); 12726 } 12727 12728 cmdline_parse_inst_t cmd_config_e_tag_filter_del = { 12729 .f = cmd_config_e_tag_filter_del_parsed, 12730 .data = NULL, 12731 .help_str = "E-tag ... : E-tag filter delete", 12732 .tokens = { 12733 (void *)&cmd_config_e_tag_e_tag, 12734 (void *)&cmd_config_e_tag_set, 12735 (void *)&cmd_config_e_tag_filter, 12736 (void *)&cmd_config_e_tag_del, 12737 (void *)&cmd_config_e_tag_e_tag_id, 12738 (void *)&cmd_config_e_tag_e_tag_id_val, 12739 (void *)&cmd_config_e_tag_port, 12740 (void *)&cmd_config_e_tag_port_id, 12741 NULL, 12742 }, 12743 }; 12744 12745 /* vf vlan anti spoof configuration */ 12746 12747 /* Common result structure for vf vlan anti spoof */ 12748 struct cmd_vf_vlan_anti_spoof_result { 12749 cmdline_fixed_string_t set; 12750 cmdline_fixed_string_t vf; 12751 cmdline_fixed_string_t vlan; 12752 cmdline_fixed_string_t antispoof; 12753 portid_t port_id; 12754 uint32_t vf_id; 12755 cmdline_fixed_string_t on_off; 12756 }; 12757 12758 /* Common CLI fields for vf vlan anti spoof enable disable */ 12759 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 12760 TOKEN_STRING_INITIALIZER 12761 (struct cmd_vf_vlan_anti_spoof_result, 12762 set, "set"); 12763 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 12764 TOKEN_STRING_INITIALIZER 12765 (struct cmd_vf_vlan_anti_spoof_result, 12766 vf, "vf"); 12767 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 12768 TOKEN_STRING_INITIALIZER 12769 (struct cmd_vf_vlan_anti_spoof_result, 12770 vlan, "vlan"); 12771 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 12772 TOKEN_STRING_INITIALIZER 12773 (struct cmd_vf_vlan_anti_spoof_result, 12774 antispoof, "antispoof"); 12775 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 12776 TOKEN_NUM_INITIALIZER 12777 (struct cmd_vf_vlan_anti_spoof_result, 12778 port_id, UINT16); 12779 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 12780 TOKEN_NUM_INITIALIZER 12781 (struct cmd_vf_vlan_anti_spoof_result, 12782 vf_id, UINT32); 12783 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 12784 TOKEN_STRING_INITIALIZER 12785 (struct cmd_vf_vlan_anti_spoof_result, 12786 on_off, "on#off"); 12787 12788 static void 12789 cmd_set_vf_vlan_anti_spoof_parsed( 12790 void *parsed_result, 12791 __rte_unused struct cmdline *cl, 12792 __rte_unused void *data) 12793 { 12794 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 12795 int ret = -ENOTSUP; 12796 12797 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12798 12799 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12800 return; 12801 12802 #ifdef RTE_NET_IXGBE 12803 if (ret == -ENOTSUP) 12804 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 12805 res->vf_id, is_on); 12806 #endif 12807 #ifdef RTE_NET_I40E 12808 if (ret == -ENOTSUP) 12809 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 12810 res->vf_id, is_on); 12811 #endif 12812 #ifdef RTE_NET_BNXT 12813 if (ret == -ENOTSUP) 12814 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 12815 res->vf_id, is_on); 12816 #endif 12817 12818 switch (ret) { 12819 case 0: 12820 break; 12821 case -EINVAL: 12822 printf("invalid vf_id %d\n", res->vf_id); 12823 break; 12824 case -ENODEV: 12825 printf("invalid port_id %d\n", res->port_id); 12826 break; 12827 case -ENOTSUP: 12828 printf("function not implemented\n"); 12829 break; 12830 default: 12831 printf("programming error: (%s)\n", strerror(-ret)); 12832 } 12833 } 12834 12835 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 12836 .f = cmd_set_vf_vlan_anti_spoof_parsed, 12837 .data = NULL, 12838 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 12839 .tokens = { 12840 (void *)&cmd_vf_vlan_anti_spoof_set, 12841 (void *)&cmd_vf_vlan_anti_spoof_vf, 12842 (void *)&cmd_vf_vlan_anti_spoof_vlan, 12843 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 12844 (void *)&cmd_vf_vlan_anti_spoof_port_id, 12845 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 12846 (void *)&cmd_vf_vlan_anti_spoof_on_off, 12847 NULL, 12848 }, 12849 }; 12850 12851 /* vf mac anti spoof configuration */ 12852 12853 /* Common result structure for vf mac anti spoof */ 12854 struct cmd_vf_mac_anti_spoof_result { 12855 cmdline_fixed_string_t set; 12856 cmdline_fixed_string_t vf; 12857 cmdline_fixed_string_t mac; 12858 cmdline_fixed_string_t antispoof; 12859 portid_t port_id; 12860 uint32_t vf_id; 12861 cmdline_fixed_string_t on_off; 12862 }; 12863 12864 /* Common CLI fields for vf mac anti spoof enable disable */ 12865 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 12866 TOKEN_STRING_INITIALIZER 12867 (struct cmd_vf_mac_anti_spoof_result, 12868 set, "set"); 12869 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 12870 TOKEN_STRING_INITIALIZER 12871 (struct cmd_vf_mac_anti_spoof_result, 12872 vf, "vf"); 12873 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 12874 TOKEN_STRING_INITIALIZER 12875 (struct cmd_vf_mac_anti_spoof_result, 12876 mac, "mac"); 12877 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 12878 TOKEN_STRING_INITIALIZER 12879 (struct cmd_vf_mac_anti_spoof_result, 12880 antispoof, "antispoof"); 12881 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 12882 TOKEN_NUM_INITIALIZER 12883 (struct cmd_vf_mac_anti_spoof_result, 12884 port_id, UINT16); 12885 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 12886 TOKEN_NUM_INITIALIZER 12887 (struct cmd_vf_mac_anti_spoof_result, 12888 vf_id, UINT32); 12889 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 12890 TOKEN_STRING_INITIALIZER 12891 (struct cmd_vf_mac_anti_spoof_result, 12892 on_off, "on#off"); 12893 12894 static void 12895 cmd_set_vf_mac_anti_spoof_parsed( 12896 void *parsed_result, 12897 __rte_unused struct cmdline *cl, 12898 __rte_unused void *data) 12899 { 12900 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 12901 int ret = -ENOTSUP; 12902 12903 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12904 12905 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12906 return; 12907 12908 #ifdef RTE_NET_IXGBE 12909 if (ret == -ENOTSUP) 12910 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 12911 res->vf_id, is_on); 12912 #endif 12913 #ifdef RTE_NET_I40E 12914 if (ret == -ENOTSUP) 12915 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 12916 res->vf_id, is_on); 12917 #endif 12918 #ifdef RTE_NET_BNXT 12919 if (ret == -ENOTSUP) 12920 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 12921 res->vf_id, is_on); 12922 #endif 12923 12924 switch (ret) { 12925 case 0: 12926 break; 12927 case -EINVAL: 12928 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 12929 break; 12930 case -ENODEV: 12931 printf("invalid port_id %d\n", res->port_id); 12932 break; 12933 case -ENOTSUP: 12934 printf("function not implemented\n"); 12935 break; 12936 default: 12937 printf("programming error: (%s)\n", strerror(-ret)); 12938 } 12939 } 12940 12941 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 12942 .f = cmd_set_vf_mac_anti_spoof_parsed, 12943 .data = NULL, 12944 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 12945 .tokens = { 12946 (void *)&cmd_vf_mac_anti_spoof_set, 12947 (void *)&cmd_vf_mac_anti_spoof_vf, 12948 (void *)&cmd_vf_mac_anti_spoof_mac, 12949 (void *)&cmd_vf_mac_anti_spoof_antispoof, 12950 (void *)&cmd_vf_mac_anti_spoof_port_id, 12951 (void *)&cmd_vf_mac_anti_spoof_vf_id, 12952 (void *)&cmd_vf_mac_anti_spoof_on_off, 12953 NULL, 12954 }, 12955 }; 12956 12957 /* vf vlan strip queue configuration */ 12958 12959 /* Common result structure for vf mac anti spoof */ 12960 struct cmd_vf_vlan_stripq_result { 12961 cmdline_fixed_string_t set; 12962 cmdline_fixed_string_t vf; 12963 cmdline_fixed_string_t vlan; 12964 cmdline_fixed_string_t stripq; 12965 portid_t port_id; 12966 uint16_t vf_id; 12967 cmdline_fixed_string_t on_off; 12968 }; 12969 12970 /* Common CLI fields for vf vlan strip enable disable */ 12971 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 12972 TOKEN_STRING_INITIALIZER 12973 (struct cmd_vf_vlan_stripq_result, 12974 set, "set"); 12975 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 12976 TOKEN_STRING_INITIALIZER 12977 (struct cmd_vf_vlan_stripq_result, 12978 vf, "vf"); 12979 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 12980 TOKEN_STRING_INITIALIZER 12981 (struct cmd_vf_vlan_stripq_result, 12982 vlan, "vlan"); 12983 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 12984 TOKEN_STRING_INITIALIZER 12985 (struct cmd_vf_vlan_stripq_result, 12986 stripq, "stripq"); 12987 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 12988 TOKEN_NUM_INITIALIZER 12989 (struct cmd_vf_vlan_stripq_result, 12990 port_id, UINT16); 12991 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 12992 TOKEN_NUM_INITIALIZER 12993 (struct cmd_vf_vlan_stripq_result, 12994 vf_id, UINT16); 12995 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 12996 TOKEN_STRING_INITIALIZER 12997 (struct cmd_vf_vlan_stripq_result, 12998 on_off, "on#off"); 12999 13000 static void 13001 cmd_set_vf_vlan_stripq_parsed( 13002 void *parsed_result, 13003 __rte_unused struct cmdline *cl, 13004 __rte_unused void *data) 13005 { 13006 struct cmd_vf_vlan_stripq_result *res = parsed_result; 13007 int ret = -ENOTSUP; 13008 13009 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13010 13011 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13012 return; 13013 13014 #ifdef RTE_NET_IXGBE 13015 if (ret == -ENOTSUP) 13016 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 13017 res->vf_id, is_on); 13018 #endif 13019 #ifdef RTE_NET_I40E 13020 if (ret == -ENOTSUP) 13021 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 13022 res->vf_id, is_on); 13023 #endif 13024 #ifdef RTE_NET_BNXT 13025 if (ret == -ENOTSUP) 13026 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 13027 res->vf_id, is_on); 13028 #endif 13029 13030 switch (ret) { 13031 case 0: 13032 break; 13033 case -EINVAL: 13034 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13035 break; 13036 case -ENODEV: 13037 printf("invalid port_id %d\n", res->port_id); 13038 break; 13039 case -ENOTSUP: 13040 printf("function not implemented\n"); 13041 break; 13042 default: 13043 printf("programming error: (%s)\n", strerror(-ret)); 13044 } 13045 } 13046 13047 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 13048 .f = cmd_set_vf_vlan_stripq_parsed, 13049 .data = NULL, 13050 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 13051 .tokens = { 13052 (void *)&cmd_vf_vlan_stripq_set, 13053 (void *)&cmd_vf_vlan_stripq_vf, 13054 (void *)&cmd_vf_vlan_stripq_vlan, 13055 (void *)&cmd_vf_vlan_stripq_stripq, 13056 (void *)&cmd_vf_vlan_stripq_port_id, 13057 (void *)&cmd_vf_vlan_stripq_vf_id, 13058 (void *)&cmd_vf_vlan_stripq_on_off, 13059 NULL, 13060 }, 13061 }; 13062 13063 /* vf vlan insert configuration */ 13064 13065 /* Common result structure for vf vlan insert */ 13066 struct cmd_vf_vlan_insert_result { 13067 cmdline_fixed_string_t set; 13068 cmdline_fixed_string_t vf; 13069 cmdline_fixed_string_t vlan; 13070 cmdline_fixed_string_t insert; 13071 portid_t port_id; 13072 uint16_t vf_id; 13073 uint16_t vlan_id; 13074 }; 13075 13076 /* Common CLI fields for vf vlan insert enable disable */ 13077 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 13078 TOKEN_STRING_INITIALIZER 13079 (struct cmd_vf_vlan_insert_result, 13080 set, "set"); 13081 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 13082 TOKEN_STRING_INITIALIZER 13083 (struct cmd_vf_vlan_insert_result, 13084 vf, "vf"); 13085 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 13086 TOKEN_STRING_INITIALIZER 13087 (struct cmd_vf_vlan_insert_result, 13088 vlan, "vlan"); 13089 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 13090 TOKEN_STRING_INITIALIZER 13091 (struct cmd_vf_vlan_insert_result, 13092 insert, "insert"); 13093 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 13094 TOKEN_NUM_INITIALIZER 13095 (struct cmd_vf_vlan_insert_result, 13096 port_id, UINT16); 13097 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 13098 TOKEN_NUM_INITIALIZER 13099 (struct cmd_vf_vlan_insert_result, 13100 vf_id, UINT16); 13101 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 13102 TOKEN_NUM_INITIALIZER 13103 (struct cmd_vf_vlan_insert_result, 13104 vlan_id, UINT16); 13105 13106 static void 13107 cmd_set_vf_vlan_insert_parsed( 13108 void *parsed_result, 13109 __rte_unused struct cmdline *cl, 13110 __rte_unused void *data) 13111 { 13112 struct cmd_vf_vlan_insert_result *res = parsed_result; 13113 int ret = -ENOTSUP; 13114 13115 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13116 return; 13117 13118 #ifdef RTE_NET_IXGBE 13119 if (ret == -ENOTSUP) 13120 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 13121 res->vlan_id); 13122 #endif 13123 #ifdef RTE_NET_I40E 13124 if (ret == -ENOTSUP) 13125 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 13126 res->vlan_id); 13127 #endif 13128 #ifdef RTE_NET_BNXT 13129 if (ret == -ENOTSUP) 13130 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 13131 res->vlan_id); 13132 #endif 13133 13134 switch (ret) { 13135 case 0: 13136 break; 13137 case -EINVAL: 13138 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); 13139 break; 13140 case -ENODEV: 13141 printf("invalid port_id %d\n", res->port_id); 13142 break; 13143 case -ENOTSUP: 13144 printf("function not implemented\n"); 13145 break; 13146 default: 13147 printf("programming error: (%s)\n", strerror(-ret)); 13148 } 13149 } 13150 13151 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 13152 .f = cmd_set_vf_vlan_insert_parsed, 13153 .data = NULL, 13154 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 13155 .tokens = { 13156 (void *)&cmd_vf_vlan_insert_set, 13157 (void *)&cmd_vf_vlan_insert_vf, 13158 (void *)&cmd_vf_vlan_insert_vlan, 13159 (void *)&cmd_vf_vlan_insert_insert, 13160 (void *)&cmd_vf_vlan_insert_port_id, 13161 (void *)&cmd_vf_vlan_insert_vf_id, 13162 (void *)&cmd_vf_vlan_insert_vlan_id, 13163 NULL, 13164 }, 13165 }; 13166 13167 /* tx loopback configuration */ 13168 13169 /* Common result structure for tx loopback */ 13170 struct cmd_tx_loopback_result { 13171 cmdline_fixed_string_t set; 13172 cmdline_fixed_string_t tx; 13173 cmdline_fixed_string_t loopback; 13174 portid_t port_id; 13175 cmdline_fixed_string_t on_off; 13176 }; 13177 13178 /* Common CLI fields for tx loopback enable disable */ 13179 cmdline_parse_token_string_t cmd_tx_loopback_set = 13180 TOKEN_STRING_INITIALIZER 13181 (struct cmd_tx_loopback_result, 13182 set, "set"); 13183 cmdline_parse_token_string_t cmd_tx_loopback_tx = 13184 TOKEN_STRING_INITIALIZER 13185 (struct cmd_tx_loopback_result, 13186 tx, "tx"); 13187 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 13188 TOKEN_STRING_INITIALIZER 13189 (struct cmd_tx_loopback_result, 13190 loopback, "loopback"); 13191 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 13192 TOKEN_NUM_INITIALIZER 13193 (struct cmd_tx_loopback_result, 13194 port_id, UINT16); 13195 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 13196 TOKEN_STRING_INITIALIZER 13197 (struct cmd_tx_loopback_result, 13198 on_off, "on#off"); 13199 13200 static void 13201 cmd_set_tx_loopback_parsed( 13202 void *parsed_result, 13203 __rte_unused struct cmdline *cl, 13204 __rte_unused void *data) 13205 { 13206 struct cmd_tx_loopback_result *res = parsed_result; 13207 int ret = -ENOTSUP; 13208 13209 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13210 13211 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13212 return; 13213 13214 #ifdef RTE_NET_IXGBE 13215 if (ret == -ENOTSUP) 13216 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 13217 #endif 13218 #ifdef RTE_NET_I40E 13219 if (ret == -ENOTSUP) 13220 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 13221 #endif 13222 #ifdef RTE_NET_BNXT 13223 if (ret == -ENOTSUP) 13224 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 13225 #endif 13226 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA 13227 if (ret == -ENOTSUP) 13228 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 13229 #endif 13230 13231 switch (ret) { 13232 case 0: 13233 break; 13234 case -EINVAL: 13235 printf("invalid is_on %d\n", is_on); 13236 break; 13237 case -ENODEV: 13238 printf("invalid port_id %d\n", res->port_id); 13239 break; 13240 case -ENOTSUP: 13241 printf("function not implemented\n"); 13242 break; 13243 default: 13244 printf("programming error: (%s)\n", strerror(-ret)); 13245 } 13246 } 13247 13248 cmdline_parse_inst_t cmd_set_tx_loopback = { 13249 .f = cmd_set_tx_loopback_parsed, 13250 .data = NULL, 13251 .help_str = "set tx loopback <port_id> on|off", 13252 .tokens = { 13253 (void *)&cmd_tx_loopback_set, 13254 (void *)&cmd_tx_loopback_tx, 13255 (void *)&cmd_tx_loopback_loopback, 13256 (void *)&cmd_tx_loopback_port_id, 13257 (void *)&cmd_tx_loopback_on_off, 13258 NULL, 13259 }, 13260 }; 13261 13262 /* all queues drop enable configuration */ 13263 13264 /* Common result structure for all queues drop enable */ 13265 struct cmd_all_queues_drop_en_result { 13266 cmdline_fixed_string_t set; 13267 cmdline_fixed_string_t all; 13268 cmdline_fixed_string_t queues; 13269 cmdline_fixed_string_t drop; 13270 portid_t port_id; 13271 cmdline_fixed_string_t on_off; 13272 }; 13273 13274 /* Common CLI fields for tx loopback enable disable */ 13275 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 13276 TOKEN_STRING_INITIALIZER 13277 (struct cmd_all_queues_drop_en_result, 13278 set, "set"); 13279 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 13280 TOKEN_STRING_INITIALIZER 13281 (struct cmd_all_queues_drop_en_result, 13282 all, "all"); 13283 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 13284 TOKEN_STRING_INITIALIZER 13285 (struct cmd_all_queues_drop_en_result, 13286 queues, "queues"); 13287 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 13288 TOKEN_STRING_INITIALIZER 13289 (struct cmd_all_queues_drop_en_result, 13290 drop, "drop"); 13291 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 13292 TOKEN_NUM_INITIALIZER 13293 (struct cmd_all_queues_drop_en_result, 13294 port_id, UINT16); 13295 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 13296 TOKEN_STRING_INITIALIZER 13297 (struct cmd_all_queues_drop_en_result, 13298 on_off, "on#off"); 13299 13300 static void 13301 cmd_set_all_queues_drop_en_parsed( 13302 void *parsed_result, 13303 __rte_unused struct cmdline *cl, 13304 __rte_unused void *data) 13305 { 13306 struct cmd_all_queues_drop_en_result *res = parsed_result; 13307 int ret = -ENOTSUP; 13308 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13309 13310 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13311 return; 13312 13313 #ifdef RTE_NET_IXGBE 13314 if (ret == -ENOTSUP) 13315 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 13316 #endif 13317 #ifdef RTE_NET_BNXT 13318 if (ret == -ENOTSUP) 13319 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 13320 #endif 13321 switch (ret) { 13322 case 0: 13323 break; 13324 case -EINVAL: 13325 printf("invalid is_on %d\n", is_on); 13326 break; 13327 case -ENODEV: 13328 printf("invalid port_id %d\n", res->port_id); 13329 break; 13330 case -ENOTSUP: 13331 printf("function not implemented\n"); 13332 break; 13333 default: 13334 printf("programming error: (%s)\n", strerror(-ret)); 13335 } 13336 } 13337 13338 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 13339 .f = cmd_set_all_queues_drop_en_parsed, 13340 .data = NULL, 13341 .help_str = "set all queues drop <port_id> on|off", 13342 .tokens = { 13343 (void *)&cmd_all_queues_drop_en_set, 13344 (void *)&cmd_all_queues_drop_en_all, 13345 (void *)&cmd_all_queues_drop_en_queues, 13346 (void *)&cmd_all_queues_drop_en_drop, 13347 (void *)&cmd_all_queues_drop_en_port_id, 13348 (void *)&cmd_all_queues_drop_en_on_off, 13349 NULL, 13350 }, 13351 }; 13352 13353 /* vf split drop enable configuration */ 13354 13355 /* Common result structure for vf split drop enable */ 13356 struct cmd_vf_split_drop_en_result { 13357 cmdline_fixed_string_t set; 13358 cmdline_fixed_string_t vf; 13359 cmdline_fixed_string_t split; 13360 cmdline_fixed_string_t drop; 13361 portid_t port_id; 13362 uint16_t vf_id; 13363 cmdline_fixed_string_t on_off; 13364 }; 13365 13366 /* Common CLI fields for vf split drop enable disable */ 13367 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 13368 TOKEN_STRING_INITIALIZER 13369 (struct cmd_vf_split_drop_en_result, 13370 set, "set"); 13371 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 13372 TOKEN_STRING_INITIALIZER 13373 (struct cmd_vf_split_drop_en_result, 13374 vf, "vf"); 13375 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 13376 TOKEN_STRING_INITIALIZER 13377 (struct cmd_vf_split_drop_en_result, 13378 split, "split"); 13379 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 13380 TOKEN_STRING_INITIALIZER 13381 (struct cmd_vf_split_drop_en_result, 13382 drop, "drop"); 13383 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 13384 TOKEN_NUM_INITIALIZER 13385 (struct cmd_vf_split_drop_en_result, 13386 port_id, UINT16); 13387 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 13388 TOKEN_NUM_INITIALIZER 13389 (struct cmd_vf_split_drop_en_result, 13390 vf_id, UINT16); 13391 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 13392 TOKEN_STRING_INITIALIZER 13393 (struct cmd_vf_split_drop_en_result, 13394 on_off, "on#off"); 13395 13396 static void 13397 cmd_set_vf_split_drop_en_parsed( 13398 void *parsed_result, 13399 __rte_unused struct cmdline *cl, 13400 __rte_unused void *data) 13401 { 13402 struct cmd_vf_split_drop_en_result *res = parsed_result; 13403 int ret = -ENOTSUP; 13404 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13405 13406 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13407 return; 13408 13409 #ifdef RTE_NET_IXGBE 13410 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 13411 is_on); 13412 #endif 13413 switch (ret) { 13414 case 0: 13415 break; 13416 case -EINVAL: 13417 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13418 break; 13419 case -ENODEV: 13420 printf("invalid port_id %d\n", res->port_id); 13421 break; 13422 case -ENOTSUP: 13423 printf("not supported on port %d\n", res->port_id); 13424 break; 13425 default: 13426 printf("programming error: (%s)\n", strerror(-ret)); 13427 } 13428 } 13429 13430 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 13431 .f = cmd_set_vf_split_drop_en_parsed, 13432 .data = NULL, 13433 .help_str = "set vf split drop <port_id> <vf_id> on|off", 13434 .tokens = { 13435 (void *)&cmd_vf_split_drop_en_set, 13436 (void *)&cmd_vf_split_drop_en_vf, 13437 (void *)&cmd_vf_split_drop_en_split, 13438 (void *)&cmd_vf_split_drop_en_drop, 13439 (void *)&cmd_vf_split_drop_en_port_id, 13440 (void *)&cmd_vf_split_drop_en_vf_id, 13441 (void *)&cmd_vf_split_drop_en_on_off, 13442 NULL, 13443 }, 13444 }; 13445 13446 /* vf mac address configuration */ 13447 13448 /* Common result structure for vf mac address */ 13449 struct cmd_set_vf_mac_addr_result { 13450 cmdline_fixed_string_t set; 13451 cmdline_fixed_string_t vf; 13452 cmdline_fixed_string_t mac; 13453 cmdline_fixed_string_t addr; 13454 portid_t port_id; 13455 uint16_t vf_id; 13456 struct rte_ether_addr mac_addr; 13457 13458 }; 13459 13460 /* Common CLI fields for vf split drop enable disable */ 13461 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 13462 TOKEN_STRING_INITIALIZER 13463 (struct cmd_set_vf_mac_addr_result, 13464 set, "set"); 13465 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 13466 TOKEN_STRING_INITIALIZER 13467 (struct cmd_set_vf_mac_addr_result, 13468 vf, "vf"); 13469 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 13470 TOKEN_STRING_INITIALIZER 13471 (struct cmd_set_vf_mac_addr_result, 13472 mac, "mac"); 13473 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 13474 TOKEN_STRING_INITIALIZER 13475 (struct cmd_set_vf_mac_addr_result, 13476 addr, "addr"); 13477 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 13478 TOKEN_NUM_INITIALIZER 13479 (struct cmd_set_vf_mac_addr_result, 13480 port_id, UINT16); 13481 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 13482 TOKEN_NUM_INITIALIZER 13483 (struct cmd_set_vf_mac_addr_result, 13484 vf_id, UINT16); 13485 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 13486 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 13487 mac_addr); 13488 13489 static void 13490 cmd_set_vf_mac_addr_parsed( 13491 void *parsed_result, 13492 __rte_unused struct cmdline *cl, 13493 __rte_unused void *data) 13494 { 13495 struct cmd_set_vf_mac_addr_result *res = parsed_result; 13496 int ret = -ENOTSUP; 13497 13498 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13499 return; 13500 13501 #ifdef RTE_NET_IXGBE 13502 if (ret == -ENOTSUP) 13503 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 13504 &res->mac_addr); 13505 #endif 13506 #ifdef RTE_NET_I40E 13507 if (ret == -ENOTSUP) 13508 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 13509 &res->mac_addr); 13510 #endif 13511 #ifdef RTE_NET_BNXT 13512 if (ret == -ENOTSUP) 13513 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 13514 &res->mac_addr); 13515 #endif 13516 13517 switch (ret) { 13518 case 0: 13519 break; 13520 case -EINVAL: 13521 printf("invalid vf_id %d or mac_addr\n", res->vf_id); 13522 break; 13523 case -ENODEV: 13524 printf("invalid port_id %d\n", res->port_id); 13525 break; 13526 case -ENOTSUP: 13527 printf("function not implemented\n"); 13528 break; 13529 default: 13530 printf("programming error: (%s)\n", strerror(-ret)); 13531 } 13532 } 13533 13534 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 13535 .f = cmd_set_vf_mac_addr_parsed, 13536 .data = NULL, 13537 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 13538 .tokens = { 13539 (void *)&cmd_set_vf_mac_addr_set, 13540 (void *)&cmd_set_vf_mac_addr_vf, 13541 (void *)&cmd_set_vf_mac_addr_mac, 13542 (void *)&cmd_set_vf_mac_addr_addr, 13543 (void *)&cmd_set_vf_mac_addr_port_id, 13544 (void *)&cmd_set_vf_mac_addr_vf_id, 13545 (void *)&cmd_set_vf_mac_addr_mac_addr, 13546 NULL, 13547 }, 13548 }; 13549 13550 /* MACsec configuration */ 13551 13552 /* Common result structure for MACsec offload enable */ 13553 struct cmd_macsec_offload_on_result { 13554 cmdline_fixed_string_t set; 13555 cmdline_fixed_string_t macsec; 13556 cmdline_fixed_string_t offload; 13557 portid_t port_id; 13558 cmdline_fixed_string_t on; 13559 cmdline_fixed_string_t encrypt; 13560 cmdline_fixed_string_t en_on_off; 13561 cmdline_fixed_string_t replay_protect; 13562 cmdline_fixed_string_t rp_on_off; 13563 }; 13564 13565 /* Common CLI fields for MACsec offload disable */ 13566 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 13567 TOKEN_STRING_INITIALIZER 13568 (struct cmd_macsec_offload_on_result, 13569 set, "set"); 13570 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 13571 TOKEN_STRING_INITIALIZER 13572 (struct cmd_macsec_offload_on_result, 13573 macsec, "macsec"); 13574 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 13575 TOKEN_STRING_INITIALIZER 13576 (struct cmd_macsec_offload_on_result, 13577 offload, "offload"); 13578 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 13579 TOKEN_NUM_INITIALIZER 13580 (struct cmd_macsec_offload_on_result, 13581 port_id, UINT16); 13582 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 13583 TOKEN_STRING_INITIALIZER 13584 (struct cmd_macsec_offload_on_result, 13585 on, "on"); 13586 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 13587 TOKEN_STRING_INITIALIZER 13588 (struct cmd_macsec_offload_on_result, 13589 encrypt, "encrypt"); 13590 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 13591 TOKEN_STRING_INITIALIZER 13592 (struct cmd_macsec_offload_on_result, 13593 en_on_off, "on#off"); 13594 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 13595 TOKEN_STRING_INITIALIZER 13596 (struct cmd_macsec_offload_on_result, 13597 replay_protect, "replay-protect"); 13598 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 13599 TOKEN_STRING_INITIALIZER 13600 (struct cmd_macsec_offload_on_result, 13601 rp_on_off, "on#off"); 13602 13603 static void 13604 cmd_set_macsec_offload_on_parsed( 13605 void *parsed_result, 13606 __rte_unused struct cmdline *cl, 13607 __rte_unused void *data) 13608 { 13609 struct cmd_macsec_offload_on_result *res = parsed_result; 13610 int ret = -ENOTSUP; 13611 portid_t port_id = res->port_id; 13612 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 13613 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 13614 struct rte_eth_dev_info dev_info; 13615 13616 if (port_id_is_invalid(port_id, ENABLED_WARN)) 13617 return; 13618 if (!port_is_stopped(port_id)) { 13619 printf("Please stop port %d first\n", port_id); 13620 return; 13621 } 13622 13623 ret = eth_dev_info_get_print_err(port_id, &dev_info); 13624 if (ret != 0) 13625 return; 13626 13627 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 13628 #ifdef RTE_NET_IXGBE 13629 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 13630 #endif 13631 } 13632 RTE_SET_USED(en); 13633 RTE_SET_USED(rp); 13634 13635 switch (ret) { 13636 case 0: 13637 ports[port_id].dev_conf.txmode.offloads |= 13638 DEV_TX_OFFLOAD_MACSEC_INSERT; 13639 cmd_reconfig_device_queue(port_id, 1, 1); 13640 break; 13641 case -ENODEV: 13642 printf("invalid port_id %d\n", port_id); 13643 break; 13644 case -ENOTSUP: 13645 printf("not supported on port %d\n", port_id); 13646 break; 13647 default: 13648 printf("programming error: (%s)\n", strerror(-ret)); 13649 } 13650 } 13651 13652 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 13653 .f = cmd_set_macsec_offload_on_parsed, 13654 .data = NULL, 13655 .help_str = "set macsec offload <port_id> on " 13656 "encrypt on|off replay-protect on|off", 13657 .tokens = { 13658 (void *)&cmd_macsec_offload_on_set, 13659 (void *)&cmd_macsec_offload_on_macsec, 13660 (void *)&cmd_macsec_offload_on_offload, 13661 (void *)&cmd_macsec_offload_on_port_id, 13662 (void *)&cmd_macsec_offload_on_on, 13663 (void *)&cmd_macsec_offload_on_encrypt, 13664 (void *)&cmd_macsec_offload_on_en_on_off, 13665 (void *)&cmd_macsec_offload_on_replay_protect, 13666 (void *)&cmd_macsec_offload_on_rp_on_off, 13667 NULL, 13668 }, 13669 }; 13670 13671 /* Common result structure for MACsec offload disable */ 13672 struct cmd_macsec_offload_off_result { 13673 cmdline_fixed_string_t set; 13674 cmdline_fixed_string_t macsec; 13675 cmdline_fixed_string_t offload; 13676 portid_t port_id; 13677 cmdline_fixed_string_t off; 13678 }; 13679 13680 /* Common CLI fields for MACsec offload disable */ 13681 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 13682 TOKEN_STRING_INITIALIZER 13683 (struct cmd_macsec_offload_off_result, 13684 set, "set"); 13685 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 13686 TOKEN_STRING_INITIALIZER 13687 (struct cmd_macsec_offload_off_result, 13688 macsec, "macsec"); 13689 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 13690 TOKEN_STRING_INITIALIZER 13691 (struct cmd_macsec_offload_off_result, 13692 offload, "offload"); 13693 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 13694 TOKEN_NUM_INITIALIZER 13695 (struct cmd_macsec_offload_off_result, 13696 port_id, UINT16); 13697 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 13698 TOKEN_STRING_INITIALIZER 13699 (struct cmd_macsec_offload_off_result, 13700 off, "off"); 13701 13702 static void 13703 cmd_set_macsec_offload_off_parsed( 13704 void *parsed_result, 13705 __rte_unused struct cmdline *cl, 13706 __rte_unused void *data) 13707 { 13708 struct cmd_macsec_offload_off_result *res = parsed_result; 13709 int ret = -ENOTSUP; 13710 struct rte_eth_dev_info dev_info; 13711 portid_t port_id = res->port_id; 13712 13713 if (port_id_is_invalid(port_id, ENABLED_WARN)) 13714 return; 13715 if (!port_is_stopped(port_id)) { 13716 printf("Please stop port %d first\n", port_id); 13717 return; 13718 } 13719 13720 ret = eth_dev_info_get_print_err(port_id, &dev_info); 13721 if (ret != 0) 13722 return; 13723 13724 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 13725 #ifdef RTE_NET_IXGBE 13726 ret = rte_pmd_ixgbe_macsec_disable(port_id); 13727 #endif 13728 } 13729 switch (ret) { 13730 case 0: 13731 ports[port_id].dev_conf.txmode.offloads &= 13732 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 13733 cmd_reconfig_device_queue(port_id, 1, 1); 13734 break; 13735 case -ENODEV: 13736 printf("invalid port_id %d\n", port_id); 13737 break; 13738 case -ENOTSUP: 13739 printf("not supported on port %d\n", port_id); 13740 break; 13741 default: 13742 printf("programming error: (%s)\n", strerror(-ret)); 13743 } 13744 } 13745 13746 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 13747 .f = cmd_set_macsec_offload_off_parsed, 13748 .data = NULL, 13749 .help_str = "set macsec offload <port_id> off", 13750 .tokens = { 13751 (void *)&cmd_macsec_offload_off_set, 13752 (void *)&cmd_macsec_offload_off_macsec, 13753 (void *)&cmd_macsec_offload_off_offload, 13754 (void *)&cmd_macsec_offload_off_port_id, 13755 (void *)&cmd_macsec_offload_off_off, 13756 NULL, 13757 }, 13758 }; 13759 13760 /* Common result structure for MACsec secure connection configure */ 13761 struct cmd_macsec_sc_result { 13762 cmdline_fixed_string_t set; 13763 cmdline_fixed_string_t macsec; 13764 cmdline_fixed_string_t sc; 13765 cmdline_fixed_string_t tx_rx; 13766 portid_t port_id; 13767 struct rte_ether_addr mac; 13768 uint16_t pi; 13769 }; 13770 13771 /* Common CLI fields for MACsec secure connection configure */ 13772 cmdline_parse_token_string_t cmd_macsec_sc_set = 13773 TOKEN_STRING_INITIALIZER 13774 (struct cmd_macsec_sc_result, 13775 set, "set"); 13776 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 13777 TOKEN_STRING_INITIALIZER 13778 (struct cmd_macsec_sc_result, 13779 macsec, "macsec"); 13780 cmdline_parse_token_string_t cmd_macsec_sc_sc = 13781 TOKEN_STRING_INITIALIZER 13782 (struct cmd_macsec_sc_result, 13783 sc, "sc"); 13784 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 13785 TOKEN_STRING_INITIALIZER 13786 (struct cmd_macsec_sc_result, 13787 tx_rx, "tx#rx"); 13788 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 13789 TOKEN_NUM_INITIALIZER 13790 (struct cmd_macsec_sc_result, 13791 port_id, UINT16); 13792 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 13793 TOKEN_ETHERADDR_INITIALIZER 13794 (struct cmd_macsec_sc_result, 13795 mac); 13796 cmdline_parse_token_num_t cmd_macsec_sc_pi = 13797 TOKEN_NUM_INITIALIZER 13798 (struct cmd_macsec_sc_result, 13799 pi, UINT16); 13800 13801 static void 13802 cmd_set_macsec_sc_parsed( 13803 void *parsed_result, 13804 __rte_unused struct cmdline *cl, 13805 __rte_unused void *data) 13806 { 13807 struct cmd_macsec_sc_result *res = parsed_result; 13808 int ret = -ENOTSUP; 13809 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 13810 13811 #ifdef RTE_NET_IXGBE 13812 ret = is_tx ? 13813 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 13814 res->mac.addr_bytes) : 13815 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 13816 res->mac.addr_bytes, res->pi); 13817 #endif 13818 RTE_SET_USED(is_tx); 13819 13820 switch (ret) { 13821 case 0: 13822 break; 13823 case -ENODEV: 13824 printf("invalid port_id %d\n", res->port_id); 13825 break; 13826 case -ENOTSUP: 13827 printf("not supported on port %d\n", res->port_id); 13828 break; 13829 default: 13830 printf("programming error: (%s)\n", strerror(-ret)); 13831 } 13832 } 13833 13834 cmdline_parse_inst_t cmd_set_macsec_sc = { 13835 .f = cmd_set_macsec_sc_parsed, 13836 .data = NULL, 13837 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 13838 .tokens = { 13839 (void *)&cmd_macsec_sc_set, 13840 (void *)&cmd_macsec_sc_macsec, 13841 (void *)&cmd_macsec_sc_sc, 13842 (void *)&cmd_macsec_sc_tx_rx, 13843 (void *)&cmd_macsec_sc_port_id, 13844 (void *)&cmd_macsec_sc_mac, 13845 (void *)&cmd_macsec_sc_pi, 13846 NULL, 13847 }, 13848 }; 13849 13850 /* Common result structure for MACsec secure connection configure */ 13851 struct cmd_macsec_sa_result { 13852 cmdline_fixed_string_t set; 13853 cmdline_fixed_string_t macsec; 13854 cmdline_fixed_string_t sa; 13855 cmdline_fixed_string_t tx_rx; 13856 portid_t port_id; 13857 uint8_t idx; 13858 uint8_t an; 13859 uint32_t pn; 13860 cmdline_fixed_string_t key; 13861 }; 13862 13863 /* Common CLI fields for MACsec secure connection configure */ 13864 cmdline_parse_token_string_t cmd_macsec_sa_set = 13865 TOKEN_STRING_INITIALIZER 13866 (struct cmd_macsec_sa_result, 13867 set, "set"); 13868 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 13869 TOKEN_STRING_INITIALIZER 13870 (struct cmd_macsec_sa_result, 13871 macsec, "macsec"); 13872 cmdline_parse_token_string_t cmd_macsec_sa_sa = 13873 TOKEN_STRING_INITIALIZER 13874 (struct cmd_macsec_sa_result, 13875 sa, "sa"); 13876 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 13877 TOKEN_STRING_INITIALIZER 13878 (struct cmd_macsec_sa_result, 13879 tx_rx, "tx#rx"); 13880 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 13881 TOKEN_NUM_INITIALIZER 13882 (struct cmd_macsec_sa_result, 13883 port_id, UINT16); 13884 cmdline_parse_token_num_t cmd_macsec_sa_idx = 13885 TOKEN_NUM_INITIALIZER 13886 (struct cmd_macsec_sa_result, 13887 idx, UINT8); 13888 cmdline_parse_token_num_t cmd_macsec_sa_an = 13889 TOKEN_NUM_INITIALIZER 13890 (struct cmd_macsec_sa_result, 13891 an, UINT8); 13892 cmdline_parse_token_num_t cmd_macsec_sa_pn = 13893 TOKEN_NUM_INITIALIZER 13894 (struct cmd_macsec_sa_result, 13895 pn, UINT32); 13896 cmdline_parse_token_string_t cmd_macsec_sa_key = 13897 TOKEN_STRING_INITIALIZER 13898 (struct cmd_macsec_sa_result, 13899 key, NULL); 13900 13901 static void 13902 cmd_set_macsec_sa_parsed( 13903 void *parsed_result, 13904 __rte_unused struct cmdline *cl, 13905 __rte_unused void *data) 13906 { 13907 struct cmd_macsec_sa_result *res = parsed_result; 13908 int ret = -ENOTSUP; 13909 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 13910 uint8_t key[16] = { 0 }; 13911 uint8_t xdgt0; 13912 uint8_t xdgt1; 13913 int key_len; 13914 int i; 13915 13916 key_len = strlen(res->key) / 2; 13917 if (key_len > 16) 13918 key_len = 16; 13919 13920 for (i = 0; i < key_len; i++) { 13921 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 13922 if (xdgt0 == 0xFF) 13923 return; 13924 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 13925 if (xdgt1 == 0xFF) 13926 return; 13927 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 13928 } 13929 13930 #ifdef RTE_NET_IXGBE 13931 ret = is_tx ? 13932 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 13933 res->idx, res->an, res->pn, key) : 13934 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 13935 res->idx, res->an, res->pn, key); 13936 #endif 13937 RTE_SET_USED(is_tx); 13938 RTE_SET_USED(key); 13939 13940 switch (ret) { 13941 case 0: 13942 break; 13943 case -EINVAL: 13944 printf("invalid idx %d or an %d\n", res->idx, res->an); 13945 break; 13946 case -ENODEV: 13947 printf("invalid port_id %d\n", res->port_id); 13948 break; 13949 case -ENOTSUP: 13950 printf("not supported on port %d\n", res->port_id); 13951 break; 13952 default: 13953 printf("programming error: (%s)\n", strerror(-ret)); 13954 } 13955 } 13956 13957 cmdline_parse_inst_t cmd_set_macsec_sa = { 13958 .f = cmd_set_macsec_sa_parsed, 13959 .data = NULL, 13960 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 13961 .tokens = { 13962 (void *)&cmd_macsec_sa_set, 13963 (void *)&cmd_macsec_sa_macsec, 13964 (void *)&cmd_macsec_sa_sa, 13965 (void *)&cmd_macsec_sa_tx_rx, 13966 (void *)&cmd_macsec_sa_port_id, 13967 (void *)&cmd_macsec_sa_idx, 13968 (void *)&cmd_macsec_sa_an, 13969 (void *)&cmd_macsec_sa_pn, 13970 (void *)&cmd_macsec_sa_key, 13971 NULL, 13972 }, 13973 }; 13974 13975 /* VF unicast promiscuous mode configuration */ 13976 13977 /* Common result structure for VF unicast promiscuous mode */ 13978 struct cmd_vf_promisc_result { 13979 cmdline_fixed_string_t set; 13980 cmdline_fixed_string_t vf; 13981 cmdline_fixed_string_t promisc; 13982 portid_t port_id; 13983 uint32_t vf_id; 13984 cmdline_fixed_string_t on_off; 13985 }; 13986 13987 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 13988 cmdline_parse_token_string_t cmd_vf_promisc_set = 13989 TOKEN_STRING_INITIALIZER 13990 (struct cmd_vf_promisc_result, 13991 set, "set"); 13992 cmdline_parse_token_string_t cmd_vf_promisc_vf = 13993 TOKEN_STRING_INITIALIZER 13994 (struct cmd_vf_promisc_result, 13995 vf, "vf"); 13996 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 13997 TOKEN_STRING_INITIALIZER 13998 (struct cmd_vf_promisc_result, 13999 promisc, "promisc"); 14000 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 14001 TOKEN_NUM_INITIALIZER 14002 (struct cmd_vf_promisc_result, 14003 port_id, UINT16); 14004 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 14005 TOKEN_NUM_INITIALIZER 14006 (struct cmd_vf_promisc_result, 14007 vf_id, UINT32); 14008 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 14009 TOKEN_STRING_INITIALIZER 14010 (struct cmd_vf_promisc_result, 14011 on_off, "on#off"); 14012 14013 static void 14014 cmd_set_vf_promisc_parsed( 14015 void *parsed_result, 14016 __rte_unused struct cmdline *cl, 14017 __rte_unused void *data) 14018 { 14019 struct cmd_vf_promisc_result *res = parsed_result; 14020 int ret = -ENOTSUP; 14021 14022 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14023 14024 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14025 return; 14026 14027 #ifdef RTE_NET_I40E 14028 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 14029 res->vf_id, is_on); 14030 #endif 14031 14032 switch (ret) { 14033 case 0: 14034 break; 14035 case -EINVAL: 14036 printf("invalid vf_id %d\n", res->vf_id); 14037 break; 14038 case -ENODEV: 14039 printf("invalid port_id %d\n", res->port_id); 14040 break; 14041 case -ENOTSUP: 14042 printf("function not implemented\n"); 14043 break; 14044 default: 14045 printf("programming error: (%s)\n", strerror(-ret)); 14046 } 14047 } 14048 14049 cmdline_parse_inst_t cmd_set_vf_promisc = { 14050 .f = cmd_set_vf_promisc_parsed, 14051 .data = NULL, 14052 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 14053 "Set unicast promiscuous mode for a VF from the PF", 14054 .tokens = { 14055 (void *)&cmd_vf_promisc_set, 14056 (void *)&cmd_vf_promisc_vf, 14057 (void *)&cmd_vf_promisc_promisc, 14058 (void *)&cmd_vf_promisc_port_id, 14059 (void *)&cmd_vf_promisc_vf_id, 14060 (void *)&cmd_vf_promisc_on_off, 14061 NULL, 14062 }, 14063 }; 14064 14065 /* VF multicast promiscuous mode configuration */ 14066 14067 /* Common result structure for VF multicast promiscuous mode */ 14068 struct cmd_vf_allmulti_result { 14069 cmdline_fixed_string_t set; 14070 cmdline_fixed_string_t vf; 14071 cmdline_fixed_string_t allmulti; 14072 portid_t port_id; 14073 uint32_t vf_id; 14074 cmdline_fixed_string_t on_off; 14075 }; 14076 14077 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 14078 cmdline_parse_token_string_t cmd_vf_allmulti_set = 14079 TOKEN_STRING_INITIALIZER 14080 (struct cmd_vf_allmulti_result, 14081 set, "set"); 14082 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 14083 TOKEN_STRING_INITIALIZER 14084 (struct cmd_vf_allmulti_result, 14085 vf, "vf"); 14086 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 14087 TOKEN_STRING_INITIALIZER 14088 (struct cmd_vf_allmulti_result, 14089 allmulti, "allmulti"); 14090 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 14091 TOKEN_NUM_INITIALIZER 14092 (struct cmd_vf_allmulti_result, 14093 port_id, UINT16); 14094 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 14095 TOKEN_NUM_INITIALIZER 14096 (struct cmd_vf_allmulti_result, 14097 vf_id, UINT32); 14098 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 14099 TOKEN_STRING_INITIALIZER 14100 (struct cmd_vf_allmulti_result, 14101 on_off, "on#off"); 14102 14103 static void 14104 cmd_set_vf_allmulti_parsed( 14105 void *parsed_result, 14106 __rte_unused struct cmdline *cl, 14107 __rte_unused void *data) 14108 { 14109 struct cmd_vf_allmulti_result *res = parsed_result; 14110 int ret = -ENOTSUP; 14111 14112 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14113 14114 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14115 return; 14116 14117 #ifdef RTE_NET_I40E 14118 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 14119 res->vf_id, is_on); 14120 #endif 14121 14122 switch (ret) { 14123 case 0: 14124 break; 14125 case -EINVAL: 14126 printf("invalid vf_id %d\n", res->vf_id); 14127 break; 14128 case -ENODEV: 14129 printf("invalid port_id %d\n", res->port_id); 14130 break; 14131 case -ENOTSUP: 14132 printf("function not implemented\n"); 14133 break; 14134 default: 14135 printf("programming error: (%s)\n", strerror(-ret)); 14136 } 14137 } 14138 14139 cmdline_parse_inst_t cmd_set_vf_allmulti = { 14140 .f = cmd_set_vf_allmulti_parsed, 14141 .data = NULL, 14142 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 14143 "Set multicast promiscuous mode for a VF from the PF", 14144 .tokens = { 14145 (void *)&cmd_vf_allmulti_set, 14146 (void *)&cmd_vf_allmulti_vf, 14147 (void *)&cmd_vf_allmulti_allmulti, 14148 (void *)&cmd_vf_allmulti_port_id, 14149 (void *)&cmd_vf_allmulti_vf_id, 14150 (void *)&cmd_vf_allmulti_on_off, 14151 NULL, 14152 }, 14153 }; 14154 14155 /* vf broadcast mode configuration */ 14156 14157 /* Common result structure for vf broadcast */ 14158 struct cmd_set_vf_broadcast_result { 14159 cmdline_fixed_string_t set; 14160 cmdline_fixed_string_t vf; 14161 cmdline_fixed_string_t broadcast; 14162 portid_t port_id; 14163 uint16_t vf_id; 14164 cmdline_fixed_string_t on_off; 14165 }; 14166 14167 /* Common CLI fields for vf broadcast enable disable */ 14168 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 14169 TOKEN_STRING_INITIALIZER 14170 (struct cmd_set_vf_broadcast_result, 14171 set, "set"); 14172 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 14173 TOKEN_STRING_INITIALIZER 14174 (struct cmd_set_vf_broadcast_result, 14175 vf, "vf"); 14176 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 14177 TOKEN_STRING_INITIALIZER 14178 (struct cmd_set_vf_broadcast_result, 14179 broadcast, "broadcast"); 14180 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 14181 TOKEN_NUM_INITIALIZER 14182 (struct cmd_set_vf_broadcast_result, 14183 port_id, UINT16); 14184 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 14185 TOKEN_NUM_INITIALIZER 14186 (struct cmd_set_vf_broadcast_result, 14187 vf_id, UINT16); 14188 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 14189 TOKEN_STRING_INITIALIZER 14190 (struct cmd_set_vf_broadcast_result, 14191 on_off, "on#off"); 14192 14193 static void 14194 cmd_set_vf_broadcast_parsed( 14195 void *parsed_result, 14196 __rte_unused struct cmdline *cl, 14197 __rte_unused void *data) 14198 { 14199 struct cmd_set_vf_broadcast_result *res = parsed_result; 14200 int ret = -ENOTSUP; 14201 14202 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14203 14204 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14205 return; 14206 14207 #ifdef RTE_NET_I40E 14208 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 14209 res->vf_id, is_on); 14210 #endif 14211 14212 switch (ret) { 14213 case 0: 14214 break; 14215 case -EINVAL: 14216 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14217 break; 14218 case -ENODEV: 14219 printf("invalid port_id %d\n", res->port_id); 14220 break; 14221 case -ENOTSUP: 14222 printf("function not implemented\n"); 14223 break; 14224 default: 14225 printf("programming error: (%s)\n", strerror(-ret)); 14226 } 14227 } 14228 14229 cmdline_parse_inst_t cmd_set_vf_broadcast = { 14230 .f = cmd_set_vf_broadcast_parsed, 14231 .data = NULL, 14232 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 14233 .tokens = { 14234 (void *)&cmd_set_vf_broadcast_set, 14235 (void *)&cmd_set_vf_broadcast_vf, 14236 (void *)&cmd_set_vf_broadcast_broadcast, 14237 (void *)&cmd_set_vf_broadcast_port_id, 14238 (void *)&cmd_set_vf_broadcast_vf_id, 14239 (void *)&cmd_set_vf_broadcast_on_off, 14240 NULL, 14241 }, 14242 }; 14243 14244 /* vf vlan tag configuration */ 14245 14246 /* Common result structure for vf vlan tag */ 14247 struct cmd_set_vf_vlan_tag_result { 14248 cmdline_fixed_string_t set; 14249 cmdline_fixed_string_t vf; 14250 cmdline_fixed_string_t vlan; 14251 cmdline_fixed_string_t tag; 14252 portid_t port_id; 14253 uint16_t vf_id; 14254 cmdline_fixed_string_t on_off; 14255 }; 14256 14257 /* Common CLI fields for vf vlan tag enable disable */ 14258 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 14259 TOKEN_STRING_INITIALIZER 14260 (struct cmd_set_vf_vlan_tag_result, 14261 set, "set"); 14262 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 14263 TOKEN_STRING_INITIALIZER 14264 (struct cmd_set_vf_vlan_tag_result, 14265 vf, "vf"); 14266 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 14267 TOKEN_STRING_INITIALIZER 14268 (struct cmd_set_vf_vlan_tag_result, 14269 vlan, "vlan"); 14270 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 14271 TOKEN_STRING_INITIALIZER 14272 (struct cmd_set_vf_vlan_tag_result, 14273 tag, "tag"); 14274 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 14275 TOKEN_NUM_INITIALIZER 14276 (struct cmd_set_vf_vlan_tag_result, 14277 port_id, UINT16); 14278 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 14279 TOKEN_NUM_INITIALIZER 14280 (struct cmd_set_vf_vlan_tag_result, 14281 vf_id, UINT16); 14282 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 14283 TOKEN_STRING_INITIALIZER 14284 (struct cmd_set_vf_vlan_tag_result, 14285 on_off, "on#off"); 14286 14287 static void 14288 cmd_set_vf_vlan_tag_parsed( 14289 void *parsed_result, 14290 __rte_unused struct cmdline *cl, 14291 __rte_unused void *data) 14292 { 14293 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 14294 int ret = -ENOTSUP; 14295 14296 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14297 14298 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14299 return; 14300 14301 #ifdef RTE_NET_I40E 14302 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 14303 res->vf_id, is_on); 14304 #endif 14305 14306 switch (ret) { 14307 case 0: 14308 break; 14309 case -EINVAL: 14310 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14311 break; 14312 case -ENODEV: 14313 printf("invalid port_id %d\n", res->port_id); 14314 break; 14315 case -ENOTSUP: 14316 printf("function not implemented\n"); 14317 break; 14318 default: 14319 printf("programming error: (%s)\n", strerror(-ret)); 14320 } 14321 } 14322 14323 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 14324 .f = cmd_set_vf_vlan_tag_parsed, 14325 .data = NULL, 14326 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 14327 .tokens = { 14328 (void *)&cmd_set_vf_vlan_tag_set, 14329 (void *)&cmd_set_vf_vlan_tag_vf, 14330 (void *)&cmd_set_vf_vlan_tag_vlan, 14331 (void *)&cmd_set_vf_vlan_tag_tag, 14332 (void *)&cmd_set_vf_vlan_tag_port_id, 14333 (void *)&cmd_set_vf_vlan_tag_vf_id, 14334 (void *)&cmd_set_vf_vlan_tag_on_off, 14335 NULL, 14336 }, 14337 }; 14338 14339 /* Common definition of VF and TC TX bandwidth configuration */ 14340 struct cmd_vf_tc_bw_result { 14341 cmdline_fixed_string_t set; 14342 cmdline_fixed_string_t vf; 14343 cmdline_fixed_string_t tc; 14344 cmdline_fixed_string_t tx; 14345 cmdline_fixed_string_t min_bw; 14346 cmdline_fixed_string_t max_bw; 14347 cmdline_fixed_string_t strict_link_prio; 14348 portid_t port_id; 14349 uint16_t vf_id; 14350 uint8_t tc_no; 14351 uint32_t bw; 14352 cmdline_fixed_string_t bw_list; 14353 uint8_t tc_map; 14354 }; 14355 14356 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 14357 TOKEN_STRING_INITIALIZER 14358 (struct cmd_vf_tc_bw_result, 14359 set, "set"); 14360 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 14361 TOKEN_STRING_INITIALIZER 14362 (struct cmd_vf_tc_bw_result, 14363 vf, "vf"); 14364 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 14365 TOKEN_STRING_INITIALIZER 14366 (struct cmd_vf_tc_bw_result, 14367 tc, "tc"); 14368 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 14369 TOKEN_STRING_INITIALIZER 14370 (struct cmd_vf_tc_bw_result, 14371 tx, "tx"); 14372 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 14373 TOKEN_STRING_INITIALIZER 14374 (struct cmd_vf_tc_bw_result, 14375 strict_link_prio, "strict-link-priority"); 14376 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 14377 TOKEN_STRING_INITIALIZER 14378 (struct cmd_vf_tc_bw_result, 14379 min_bw, "min-bandwidth"); 14380 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 14381 TOKEN_STRING_INITIALIZER 14382 (struct cmd_vf_tc_bw_result, 14383 max_bw, "max-bandwidth"); 14384 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 14385 TOKEN_NUM_INITIALIZER 14386 (struct cmd_vf_tc_bw_result, 14387 port_id, UINT16); 14388 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 14389 TOKEN_NUM_INITIALIZER 14390 (struct cmd_vf_tc_bw_result, 14391 vf_id, UINT16); 14392 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 14393 TOKEN_NUM_INITIALIZER 14394 (struct cmd_vf_tc_bw_result, 14395 tc_no, UINT8); 14396 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 14397 TOKEN_NUM_INITIALIZER 14398 (struct cmd_vf_tc_bw_result, 14399 bw, UINT32); 14400 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 14401 TOKEN_STRING_INITIALIZER 14402 (struct cmd_vf_tc_bw_result, 14403 bw_list, NULL); 14404 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 14405 TOKEN_NUM_INITIALIZER 14406 (struct cmd_vf_tc_bw_result, 14407 tc_map, UINT8); 14408 14409 /* VF max bandwidth setting */ 14410 static void 14411 cmd_vf_max_bw_parsed( 14412 void *parsed_result, 14413 __rte_unused struct cmdline *cl, 14414 __rte_unused void *data) 14415 { 14416 struct cmd_vf_tc_bw_result *res = parsed_result; 14417 int ret = -ENOTSUP; 14418 14419 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14420 return; 14421 14422 #ifdef RTE_NET_I40E 14423 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 14424 res->vf_id, res->bw); 14425 #endif 14426 14427 switch (ret) { 14428 case 0: 14429 break; 14430 case -EINVAL: 14431 printf("invalid vf_id %d or bandwidth %d\n", 14432 res->vf_id, res->bw); 14433 break; 14434 case -ENODEV: 14435 printf("invalid port_id %d\n", res->port_id); 14436 break; 14437 case -ENOTSUP: 14438 printf("function not implemented\n"); 14439 break; 14440 default: 14441 printf("programming error: (%s)\n", strerror(-ret)); 14442 } 14443 } 14444 14445 cmdline_parse_inst_t cmd_vf_max_bw = { 14446 .f = cmd_vf_max_bw_parsed, 14447 .data = NULL, 14448 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 14449 .tokens = { 14450 (void *)&cmd_vf_tc_bw_set, 14451 (void *)&cmd_vf_tc_bw_vf, 14452 (void *)&cmd_vf_tc_bw_tx, 14453 (void *)&cmd_vf_tc_bw_max_bw, 14454 (void *)&cmd_vf_tc_bw_port_id, 14455 (void *)&cmd_vf_tc_bw_vf_id, 14456 (void *)&cmd_vf_tc_bw_bw, 14457 NULL, 14458 }, 14459 }; 14460 14461 static int 14462 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 14463 uint8_t *tc_num, 14464 char *str) 14465 { 14466 uint32_t size; 14467 const char *p, *p0 = str; 14468 char s[256]; 14469 char *end; 14470 char *str_fld[16]; 14471 uint16_t i; 14472 int ret; 14473 14474 p = strchr(p0, '('); 14475 if (p == NULL) { 14476 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14477 return -1; 14478 } 14479 p++; 14480 p0 = strchr(p, ')'); 14481 if (p0 == NULL) { 14482 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14483 return -1; 14484 } 14485 size = p0 - p; 14486 if (size >= sizeof(s)) { 14487 printf("The string size exceeds the internal buffer size\n"); 14488 return -1; 14489 } 14490 snprintf(s, sizeof(s), "%.*s", size, p); 14491 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 14492 if (ret <= 0) { 14493 printf("Failed to get the bandwidth list. "); 14494 return -1; 14495 } 14496 *tc_num = ret; 14497 for (i = 0; i < ret; i++) 14498 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 14499 14500 return 0; 14501 } 14502 14503 /* TC min bandwidth setting */ 14504 static void 14505 cmd_vf_tc_min_bw_parsed( 14506 void *parsed_result, 14507 __rte_unused struct cmdline *cl, 14508 __rte_unused void *data) 14509 { 14510 struct cmd_vf_tc_bw_result *res = parsed_result; 14511 uint8_t tc_num; 14512 uint8_t bw[16]; 14513 int ret = -ENOTSUP; 14514 14515 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14516 return; 14517 14518 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14519 if (ret) 14520 return; 14521 14522 #ifdef RTE_NET_I40E 14523 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 14524 tc_num, bw); 14525 #endif 14526 14527 switch (ret) { 14528 case 0: 14529 break; 14530 case -EINVAL: 14531 printf("invalid vf_id %d or bandwidth\n", res->vf_id); 14532 break; 14533 case -ENODEV: 14534 printf("invalid port_id %d\n", res->port_id); 14535 break; 14536 case -ENOTSUP: 14537 printf("function not implemented\n"); 14538 break; 14539 default: 14540 printf("programming error: (%s)\n", strerror(-ret)); 14541 } 14542 } 14543 14544 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 14545 .f = cmd_vf_tc_min_bw_parsed, 14546 .data = NULL, 14547 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 14548 " <bw1, bw2, ...>", 14549 .tokens = { 14550 (void *)&cmd_vf_tc_bw_set, 14551 (void *)&cmd_vf_tc_bw_vf, 14552 (void *)&cmd_vf_tc_bw_tc, 14553 (void *)&cmd_vf_tc_bw_tx, 14554 (void *)&cmd_vf_tc_bw_min_bw, 14555 (void *)&cmd_vf_tc_bw_port_id, 14556 (void *)&cmd_vf_tc_bw_vf_id, 14557 (void *)&cmd_vf_tc_bw_bw_list, 14558 NULL, 14559 }, 14560 }; 14561 14562 static void 14563 cmd_tc_min_bw_parsed( 14564 void *parsed_result, 14565 __rte_unused struct cmdline *cl, 14566 __rte_unused void *data) 14567 { 14568 struct cmd_vf_tc_bw_result *res = parsed_result; 14569 struct rte_port *port; 14570 uint8_t tc_num; 14571 uint8_t bw[16]; 14572 int ret = -ENOTSUP; 14573 14574 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14575 return; 14576 14577 port = &ports[res->port_id]; 14578 /** Check if the port is not started **/ 14579 if (port->port_status != RTE_PORT_STOPPED) { 14580 printf("Please stop port %d first\n", res->port_id); 14581 return; 14582 } 14583 14584 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14585 if (ret) 14586 return; 14587 14588 #ifdef RTE_NET_IXGBE 14589 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 14590 #endif 14591 14592 switch (ret) { 14593 case 0: 14594 break; 14595 case -EINVAL: 14596 printf("invalid bandwidth\n"); 14597 break; 14598 case -ENODEV: 14599 printf("invalid port_id %d\n", res->port_id); 14600 break; 14601 case -ENOTSUP: 14602 printf("function not implemented\n"); 14603 break; 14604 default: 14605 printf("programming error: (%s)\n", strerror(-ret)); 14606 } 14607 } 14608 14609 cmdline_parse_inst_t cmd_tc_min_bw = { 14610 .f = cmd_tc_min_bw_parsed, 14611 .data = NULL, 14612 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 14613 .tokens = { 14614 (void *)&cmd_vf_tc_bw_set, 14615 (void *)&cmd_vf_tc_bw_tc, 14616 (void *)&cmd_vf_tc_bw_tx, 14617 (void *)&cmd_vf_tc_bw_min_bw, 14618 (void *)&cmd_vf_tc_bw_port_id, 14619 (void *)&cmd_vf_tc_bw_bw_list, 14620 NULL, 14621 }, 14622 }; 14623 14624 /* TC max bandwidth setting */ 14625 static void 14626 cmd_vf_tc_max_bw_parsed( 14627 void *parsed_result, 14628 __rte_unused struct cmdline *cl, 14629 __rte_unused void *data) 14630 { 14631 struct cmd_vf_tc_bw_result *res = parsed_result; 14632 int ret = -ENOTSUP; 14633 14634 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14635 return; 14636 14637 #ifdef RTE_NET_I40E 14638 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 14639 res->tc_no, res->bw); 14640 #endif 14641 14642 switch (ret) { 14643 case 0: 14644 break; 14645 case -EINVAL: 14646 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n", 14647 res->vf_id, res->tc_no, res->bw); 14648 break; 14649 case -ENODEV: 14650 printf("invalid port_id %d\n", res->port_id); 14651 break; 14652 case -ENOTSUP: 14653 printf("function not implemented\n"); 14654 break; 14655 default: 14656 printf("programming error: (%s)\n", strerror(-ret)); 14657 } 14658 } 14659 14660 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 14661 .f = cmd_vf_tc_max_bw_parsed, 14662 .data = NULL, 14663 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 14664 " <bandwidth>", 14665 .tokens = { 14666 (void *)&cmd_vf_tc_bw_set, 14667 (void *)&cmd_vf_tc_bw_vf, 14668 (void *)&cmd_vf_tc_bw_tc, 14669 (void *)&cmd_vf_tc_bw_tx, 14670 (void *)&cmd_vf_tc_bw_max_bw, 14671 (void *)&cmd_vf_tc_bw_port_id, 14672 (void *)&cmd_vf_tc_bw_vf_id, 14673 (void *)&cmd_vf_tc_bw_tc_no, 14674 (void *)&cmd_vf_tc_bw_bw, 14675 NULL, 14676 }, 14677 }; 14678 14679 /** Set VXLAN encapsulation details */ 14680 struct cmd_set_vxlan_result { 14681 cmdline_fixed_string_t set; 14682 cmdline_fixed_string_t vxlan; 14683 cmdline_fixed_string_t pos_token; 14684 cmdline_fixed_string_t ip_version; 14685 uint32_t vlan_present:1; 14686 uint32_t vni; 14687 uint16_t udp_src; 14688 uint16_t udp_dst; 14689 cmdline_ipaddr_t ip_src; 14690 cmdline_ipaddr_t ip_dst; 14691 uint16_t tci; 14692 uint8_t tos; 14693 uint8_t ttl; 14694 struct rte_ether_addr eth_src; 14695 struct rte_ether_addr eth_dst; 14696 }; 14697 14698 cmdline_parse_token_string_t cmd_set_vxlan_set = 14699 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 14700 cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 14701 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 14702 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl = 14703 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 14704 "vxlan-tos-ttl"); 14705 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 14706 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 14707 "vxlan-with-vlan"); 14708 cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 14709 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 14710 "ip-version"); 14711 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 14712 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 14713 "ipv4#ipv6"); 14714 cmdline_parse_token_string_t cmd_set_vxlan_vni = 14715 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 14716 "vni"); 14717 cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 14718 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32); 14719 cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 14720 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 14721 "udp-src"); 14722 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 14723 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16); 14724 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 14725 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 14726 "udp-dst"); 14727 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 14728 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16); 14729 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos = 14730 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 14731 "ip-tos"); 14732 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value = 14733 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8); 14734 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl = 14735 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 14736 "ip-ttl"); 14737 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value = 14738 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8); 14739 cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 14740 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 14741 "ip-src"); 14742 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 14743 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 14744 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 14745 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 14746 "ip-dst"); 14747 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 14748 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 14749 cmdline_parse_token_string_t cmd_set_vxlan_vlan = 14750 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 14751 "vlan-tci"); 14752 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 14753 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16); 14754 cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 14755 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 14756 "eth-src"); 14757 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 14758 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 14759 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 14760 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 14761 "eth-dst"); 14762 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 14763 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 14764 14765 static void cmd_set_vxlan_parsed(void *parsed_result, 14766 __rte_unused struct cmdline *cl, 14767 __rte_unused void *data) 14768 { 14769 struct cmd_set_vxlan_result *res = parsed_result; 14770 union { 14771 uint32_t vxlan_id; 14772 uint8_t vni[4]; 14773 } id = { 14774 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 14775 }; 14776 14777 vxlan_encap_conf.select_tos_ttl = 0; 14778 if (strcmp(res->vxlan, "vxlan") == 0) 14779 vxlan_encap_conf.select_vlan = 0; 14780 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 14781 vxlan_encap_conf.select_vlan = 1; 14782 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) { 14783 vxlan_encap_conf.select_vlan = 0; 14784 vxlan_encap_conf.select_tos_ttl = 1; 14785 } 14786 if (strcmp(res->ip_version, "ipv4") == 0) 14787 vxlan_encap_conf.select_ipv4 = 1; 14788 else if (strcmp(res->ip_version, "ipv6") == 0) 14789 vxlan_encap_conf.select_ipv4 = 0; 14790 else 14791 return; 14792 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 14793 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 14794 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 14795 vxlan_encap_conf.ip_tos = res->tos; 14796 vxlan_encap_conf.ip_ttl = res->ttl; 14797 if (vxlan_encap_conf.select_ipv4) { 14798 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 14799 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 14800 } else { 14801 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 14802 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 14803 } 14804 if (vxlan_encap_conf.select_vlan) 14805 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 14806 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 14807 RTE_ETHER_ADDR_LEN); 14808 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 14809 RTE_ETHER_ADDR_LEN); 14810 } 14811 14812 cmdline_parse_inst_t cmd_set_vxlan = { 14813 .f = cmd_set_vxlan_parsed, 14814 .data = NULL, 14815 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 14816 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 14817 " eth-src <eth-src> eth-dst <eth-dst>", 14818 .tokens = { 14819 (void *)&cmd_set_vxlan_set, 14820 (void *)&cmd_set_vxlan_vxlan, 14821 (void *)&cmd_set_vxlan_ip_version, 14822 (void *)&cmd_set_vxlan_ip_version_value, 14823 (void *)&cmd_set_vxlan_vni, 14824 (void *)&cmd_set_vxlan_vni_value, 14825 (void *)&cmd_set_vxlan_udp_src, 14826 (void *)&cmd_set_vxlan_udp_src_value, 14827 (void *)&cmd_set_vxlan_udp_dst, 14828 (void *)&cmd_set_vxlan_udp_dst_value, 14829 (void *)&cmd_set_vxlan_ip_src, 14830 (void *)&cmd_set_vxlan_ip_src_value, 14831 (void *)&cmd_set_vxlan_ip_dst, 14832 (void *)&cmd_set_vxlan_ip_dst_value, 14833 (void *)&cmd_set_vxlan_eth_src, 14834 (void *)&cmd_set_vxlan_eth_src_value, 14835 (void *)&cmd_set_vxlan_eth_dst, 14836 (void *)&cmd_set_vxlan_eth_dst_value, 14837 NULL, 14838 }, 14839 }; 14840 14841 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = { 14842 .f = cmd_set_vxlan_parsed, 14843 .data = NULL, 14844 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src" 14845 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>" 14846 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 14847 " eth-dst <eth-dst>", 14848 .tokens = { 14849 (void *)&cmd_set_vxlan_set, 14850 (void *)&cmd_set_vxlan_vxlan_tos_ttl, 14851 (void *)&cmd_set_vxlan_ip_version, 14852 (void *)&cmd_set_vxlan_ip_version_value, 14853 (void *)&cmd_set_vxlan_vni, 14854 (void *)&cmd_set_vxlan_vni_value, 14855 (void *)&cmd_set_vxlan_udp_src, 14856 (void *)&cmd_set_vxlan_udp_src_value, 14857 (void *)&cmd_set_vxlan_udp_dst, 14858 (void *)&cmd_set_vxlan_udp_dst_value, 14859 (void *)&cmd_set_vxlan_ip_tos, 14860 (void *)&cmd_set_vxlan_ip_tos_value, 14861 (void *)&cmd_set_vxlan_ip_ttl, 14862 (void *)&cmd_set_vxlan_ip_ttl_value, 14863 (void *)&cmd_set_vxlan_ip_src, 14864 (void *)&cmd_set_vxlan_ip_src_value, 14865 (void *)&cmd_set_vxlan_ip_dst, 14866 (void *)&cmd_set_vxlan_ip_dst_value, 14867 (void *)&cmd_set_vxlan_eth_src, 14868 (void *)&cmd_set_vxlan_eth_src_value, 14869 (void *)&cmd_set_vxlan_eth_dst, 14870 (void *)&cmd_set_vxlan_eth_dst_value, 14871 NULL, 14872 }, 14873 }; 14874 14875 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 14876 .f = cmd_set_vxlan_parsed, 14877 .data = NULL, 14878 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 14879 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 14880 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 14881 " <eth-dst>", 14882 .tokens = { 14883 (void *)&cmd_set_vxlan_set, 14884 (void *)&cmd_set_vxlan_vxlan_with_vlan, 14885 (void *)&cmd_set_vxlan_ip_version, 14886 (void *)&cmd_set_vxlan_ip_version_value, 14887 (void *)&cmd_set_vxlan_vni, 14888 (void *)&cmd_set_vxlan_vni_value, 14889 (void *)&cmd_set_vxlan_udp_src, 14890 (void *)&cmd_set_vxlan_udp_src_value, 14891 (void *)&cmd_set_vxlan_udp_dst, 14892 (void *)&cmd_set_vxlan_udp_dst_value, 14893 (void *)&cmd_set_vxlan_ip_src, 14894 (void *)&cmd_set_vxlan_ip_src_value, 14895 (void *)&cmd_set_vxlan_ip_dst, 14896 (void *)&cmd_set_vxlan_ip_dst_value, 14897 (void *)&cmd_set_vxlan_vlan, 14898 (void *)&cmd_set_vxlan_vlan_value, 14899 (void *)&cmd_set_vxlan_eth_src, 14900 (void *)&cmd_set_vxlan_eth_src_value, 14901 (void *)&cmd_set_vxlan_eth_dst, 14902 (void *)&cmd_set_vxlan_eth_dst_value, 14903 NULL, 14904 }, 14905 }; 14906 14907 /** Set NVGRE encapsulation details */ 14908 struct cmd_set_nvgre_result { 14909 cmdline_fixed_string_t set; 14910 cmdline_fixed_string_t nvgre; 14911 cmdline_fixed_string_t pos_token; 14912 cmdline_fixed_string_t ip_version; 14913 uint32_t tni; 14914 cmdline_ipaddr_t ip_src; 14915 cmdline_ipaddr_t ip_dst; 14916 uint16_t tci; 14917 struct rte_ether_addr eth_src; 14918 struct rte_ether_addr eth_dst; 14919 }; 14920 14921 cmdline_parse_token_string_t cmd_set_nvgre_set = 14922 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 14923 cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 14924 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 14925 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 14926 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 14927 "nvgre-with-vlan"); 14928 cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 14929 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 14930 "ip-version"); 14931 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 14932 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 14933 "ipv4#ipv6"); 14934 cmdline_parse_token_string_t cmd_set_nvgre_tni = 14935 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 14936 "tni"); 14937 cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 14938 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32); 14939 cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 14940 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 14941 "ip-src"); 14942 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 14943 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 14944 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 14945 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 14946 "ip-dst"); 14947 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 14948 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 14949 cmdline_parse_token_string_t cmd_set_nvgre_vlan = 14950 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 14951 "vlan-tci"); 14952 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 14953 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16); 14954 cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 14955 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 14956 "eth-src"); 14957 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 14958 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 14959 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 14960 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 14961 "eth-dst"); 14962 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 14963 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 14964 14965 static void cmd_set_nvgre_parsed(void *parsed_result, 14966 __rte_unused struct cmdline *cl, 14967 __rte_unused void *data) 14968 { 14969 struct cmd_set_nvgre_result *res = parsed_result; 14970 union { 14971 uint32_t nvgre_tni; 14972 uint8_t tni[4]; 14973 } id = { 14974 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 14975 }; 14976 14977 if (strcmp(res->nvgre, "nvgre") == 0) 14978 nvgre_encap_conf.select_vlan = 0; 14979 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 14980 nvgre_encap_conf.select_vlan = 1; 14981 if (strcmp(res->ip_version, "ipv4") == 0) 14982 nvgre_encap_conf.select_ipv4 = 1; 14983 else if (strcmp(res->ip_version, "ipv6") == 0) 14984 nvgre_encap_conf.select_ipv4 = 0; 14985 else 14986 return; 14987 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 14988 if (nvgre_encap_conf.select_ipv4) { 14989 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 14990 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 14991 } else { 14992 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 14993 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 14994 } 14995 if (nvgre_encap_conf.select_vlan) 14996 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 14997 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 14998 RTE_ETHER_ADDR_LEN); 14999 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15000 RTE_ETHER_ADDR_LEN); 15001 } 15002 15003 cmdline_parse_inst_t cmd_set_nvgre = { 15004 .f = cmd_set_nvgre_parsed, 15005 .data = NULL, 15006 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 15007 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15008 " eth-dst <eth-dst>", 15009 .tokens = { 15010 (void *)&cmd_set_nvgre_set, 15011 (void *)&cmd_set_nvgre_nvgre, 15012 (void *)&cmd_set_nvgre_ip_version, 15013 (void *)&cmd_set_nvgre_ip_version_value, 15014 (void *)&cmd_set_nvgre_tni, 15015 (void *)&cmd_set_nvgre_tni_value, 15016 (void *)&cmd_set_nvgre_ip_src, 15017 (void *)&cmd_set_nvgre_ip_src_value, 15018 (void *)&cmd_set_nvgre_ip_dst, 15019 (void *)&cmd_set_nvgre_ip_dst_value, 15020 (void *)&cmd_set_nvgre_eth_src, 15021 (void *)&cmd_set_nvgre_eth_src_value, 15022 (void *)&cmd_set_nvgre_eth_dst, 15023 (void *)&cmd_set_nvgre_eth_dst_value, 15024 NULL, 15025 }, 15026 }; 15027 15028 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 15029 .f = cmd_set_nvgre_parsed, 15030 .data = NULL, 15031 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 15032 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 15033 " eth-src <eth-src> eth-dst <eth-dst>", 15034 .tokens = { 15035 (void *)&cmd_set_nvgre_set, 15036 (void *)&cmd_set_nvgre_nvgre_with_vlan, 15037 (void *)&cmd_set_nvgre_ip_version, 15038 (void *)&cmd_set_nvgre_ip_version_value, 15039 (void *)&cmd_set_nvgre_tni, 15040 (void *)&cmd_set_nvgre_tni_value, 15041 (void *)&cmd_set_nvgre_ip_src, 15042 (void *)&cmd_set_nvgre_ip_src_value, 15043 (void *)&cmd_set_nvgre_ip_dst, 15044 (void *)&cmd_set_nvgre_ip_dst_value, 15045 (void *)&cmd_set_nvgre_vlan, 15046 (void *)&cmd_set_nvgre_vlan_value, 15047 (void *)&cmd_set_nvgre_eth_src, 15048 (void *)&cmd_set_nvgre_eth_src_value, 15049 (void *)&cmd_set_nvgre_eth_dst, 15050 (void *)&cmd_set_nvgre_eth_dst_value, 15051 NULL, 15052 }, 15053 }; 15054 15055 /** Set L2 encapsulation details */ 15056 struct cmd_set_l2_encap_result { 15057 cmdline_fixed_string_t set; 15058 cmdline_fixed_string_t l2_encap; 15059 cmdline_fixed_string_t pos_token; 15060 cmdline_fixed_string_t ip_version; 15061 uint32_t vlan_present:1; 15062 uint16_t tci; 15063 struct rte_ether_addr eth_src; 15064 struct rte_ether_addr eth_dst; 15065 }; 15066 15067 cmdline_parse_token_string_t cmd_set_l2_encap_set = 15068 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); 15069 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = 15070 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); 15071 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = 15072 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, 15073 "l2_encap-with-vlan"); 15074 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = 15075 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15076 "ip-version"); 15077 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = 15078 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, 15079 "ipv4#ipv6"); 15080 cmdline_parse_token_string_t cmd_set_l2_encap_vlan = 15081 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15082 "vlan-tci"); 15083 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = 15084 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16); 15085 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = 15086 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15087 "eth-src"); 15088 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = 15089 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); 15090 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = 15091 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15092 "eth-dst"); 15093 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = 15094 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); 15095 15096 static void cmd_set_l2_encap_parsed(void *parsed_result, 15097 __rte_unused struct cmdline *cl, 15098 __rte_unused void *data) 15099 { 15100 struct cmd_set_l2_encap_result *res = parsed_result; 15101 15102 if (strcmp(res->l2_encap, "l2_encap") == 0) 15103 l2_encap_conf.select_vlan = 0; 15104 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) 15105 l2_encap_conf.select_vlan = 1; 15106 if (strcmp(res->ip_version, "ipv4") == 0) 15107 l2_encap_conf.select_ipv4 = 1; 15108 else if (strcmp(res->ip_version, "ipv6") == 0) 15109 l2_encap_conf.select_ipv4 = 0; 15110 else 15111 return; 15112 if (l2_encap_conf.select_vlan) 15113 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15114 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, 15115 RTE_ETHER_ADDR_LEN); 15116 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15117 RTE_ETHER_ADDR_LEN); 15118 } 15119 15120 cmdline_parse_inst_t cmd_set_l2_encap = { 15121 .f = cmd_set_l2_encap_parsed, 15122 .data = NULL, 15123 .help_str = "set l2_encap ip-version ipv4|ipv6" 15124 " eth-src <eth-src> eth-dst <eth-dst>", 15125 .tokens = { 15126 (void *)&cmd_set_l2_encap_set, 15127 (void *)&cmd_set_l2_encap_l2_encap, 15128 (void *)&cmd_set_l2_encap_ip_version, 15129 (void *)&cmd_set_l2_encap_ip_version_value, 15130 (void *)&cmd_set_l2_encap_eth_src, 15131 (void *)&cmd_set_l2_encap_eth_src_value, 15132 (void *)&cmd_set_l2_encap_eth_dst, 15133 (void *)&cmd_set_l2_encap_eth_dst_value, 15134 NULL, 15135 }, 15136 }; 15137 15138 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { 15139 .f = cmd_set_l2_encap_parsed, 15140 .data = NULL, 15141 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" 15142 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 15143 .tokens = { 15144 (void *)&cmd_set_l2_encap_set, 15145 (void *)&cmd_set_l2_encap_l2_encap_with_vlan, 15146 (void *)&cmd_set_l2_encap_ip_version, 15147 (void *)&cmd_set_l2_encap_ip_version_value, 15148 (void *)&cmd_set_l2_encap_vlan, 15149 (void *)&cmd_set_l2_encap_vlan_value, 15150 (void *)&cmd_set_l2_encap_eth_src, 15151 (void *)&cmd_set_l2_encap_eth_src_value, 15152 (void *)&cmd_set_l2_encap_eth_dst, 15153 (void *)&cmd_set_l2_encap_eth_dst_value, 15154 NULL, 15155 }, 15156 }; 15157 15158 /** Set L2 decapsulation details */ 15159 struct cmd_set_l2_decap_result { 15160 cmdline_fixed_string_t set; 15161 cmdline_fixed_string_t l2_decap; 15162 cmdline_fixed_string_t pos_token; 15163 uint32_t vlan_present:1; 15164 }; 15165 15166 cmdline_parse_token_string_t cmd_set_l2_decap_set = 15167 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); 15168 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = 15169 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15170 "l2_decap"); 15171 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = 15172 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15173 "l2_decap-with-vlan"); 15174 15175 static void cmd_set_l2_decap_parsed(void *parsed_result, 15176 __rte_unused struct cmdline *cl, 15177 __rte_unused void *data) 15178 { 15179 struct cmd_set_l2_decap_result *res = parsed_result; 15180 15181 if (strcmp(res->l2_decap, "l2_decap") == 0) 15182 l2_decap_conf.select_vlan = 0; 15183 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) 15184 l2_decap_conf.select_vlan = 1; 15185 } 15186 15187 cmdline_parse_inst_t cmd_set_l2_decap = { 15188 .f = cmd_set_l2_decap_parsed, 15189 .data = NULL, 15190 .help_str = "set l2_decap", 15191 .tokens = { 15192 (void *)&cmd_set_l2_decap_set, 15193 (void *)&cmd_set_l2_decap_l2_decap, 15194 NULL, 15195 }, 15196 }; 15197 15198 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { 15199 .f = cmd_set_l2_decap_parsed, 15200 .data = NULL, 15201 .help_str = "set l2_decap-with-vlan", 15202 .tokens = { 15203 (void *)&cmd_set_l2_decap_set, 15204 (void *)&cmd_set_l2_decap_l2_decap_with_vlan, 15205 NULL, 15206 }, 15207 }; 15208 15209 /** Set MPLSoGRE encapsulation details */ 15210 struct cmd_set_mplsogre_encap_result { 15211 cmdline_fixed_string_t set; 15212 cmdline_fixed_string_t mplsogre; 15213 cmdline_fixed_string_t pos_token; 15214 cmdline_fixed_string_t ip_version; 15215 uint32_t vlan_present:1; 15216 uint32_t label; 15217 cmdline_ipaddr_t ip_src; 15218 cmdline_ipaddr_t ip_dst; 15219 uint16_t tci; 15220 struct rte_ether_addr eth_src; 15221 struct rte_ether_addr eth_dst; 15222 }; 15223 15224 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = 15225 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, 15226 "set"); 15227 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = 15228 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, 15229 "mplsogre_encap"); 15230 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = 15231 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15232 mplsogre, "mplsogre_encap-with-vlan"); 15233 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = 15234 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15235 pos_token, "ip-version"); 15236 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = 15237 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15238 ip_version, "ipv4#ipv6"); 15239 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = 15240 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15241 pos_token, "label"); 15242 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = 15243 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, 15244 UINT32); 15245 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = 15246 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15247 pos_token, "ip-src"); 15248 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = 15249 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); 15250 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = 15251 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15252 pos_token, "ip-dst"); 15253 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = 15254 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); 15255 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = 15256 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15257 pos_token, "vlan-tci"); 15258 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = 15259 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, 15260 UINT16); 15261 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = 15262 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15263 pos_token, "eth-src"); 15264 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = 15265 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15266 eth_src); 15267 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = 15268 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15269 pos_token, "eth-dst"); 15270 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = 15271 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15272 eth_dst); 15273 15274 static void cmd_set_mplsogre_encap_parsed(void *parsed_result, 15275 __rte_unused struct cmdline *cl, 15276 __rte_unused void *data) 15277 { 15278 struct cmd_set_mplsogre_encap_result *res = parsed_result; 15279 union { 15280 uint32_t mplsogre_label; 15281 uint8_t label[4]; 15282 } id = { 15283 .mplsogre_label = rte_cpu_to_be_32(res->label<<12), 15284 }; 15285 15286 if (strcmp(res->mplsogre, "mplsogre_encap") == 0) 15287 mplsogre_encap_conf.select_vlan = 0; 15288 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) 15289 mplsogre_encap_conf.select_vlan = 1; 15290 if (strcmp(res->ip_version, "ipv4") == 0) 15291 mplsogre_encap_conf.select_ipv4 = 1; 15292 else if (strcmp(res->ip_version, "ipv6") == 0) 15293 mplsogre_encap_conf.select_ipv4 = 0; 15294 else 15295 return; 15296 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3); 15297 if (mplsogre_encap_conf.select_ipv4) { 15298 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); 15299 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); 15300 } else { 15301 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); 15302 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); 15303 } 15304 if (mplsogre_encap_conf.select_vlan) 15305 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15306 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, 15307 RTE_ETHER_ADDR_LEN); 15308 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15309 RTE_ETHER_ADDR_LEN); 15310 } 15311 15312 cmdline_parse_inst_t cmd_set_mplsogre_encap = { 15313 .f = cmd_set_mplsogre_encap_parsed, 15314 .data = NULL, 15315 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" 15316 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15317 " eth-dst <eth-dst>", 15318 .tokens = { 15319 (void *)&cmd_set_mplsogre_encap_set, 15320 (void *)&cmd_set_mplsogre_encap_mplsogre_encap, 15321 (void *)&cmd_set_mplsogre_encap_ip_version, 15322 (void *)&cmd_set_mplsogre_encap_ip_version_value, 15323 (void *)&cmd_set_mplsogre_encap_label, 15324 (void *)&cmd_set_mplsogre_encap_label_value, 15325 (void *)&cmd_set_mplsogre_encap_ip_src, 15326 (void *)&cmd_set_mplsogre_encap_ip_src_value, 15327 (void *)&cmd_set_mplsogre_encap_ip_dst, 15328 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 15329 (void *)&cmd_set_mplsogre_encap_eth_src, 15330 (void *)&cmd_set_mplsogre_encap_eth_src_value, 15331 (void *)&cmd_set_mplsogre_encap_eth_dst, 15332 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 15333 NULL, 15334 }, 15335 }; 15336 15337 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { 15338 .f = cmd_set_mplsogre_encap_parsed, 15339 .data = NULL, 15340 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" 15341 " label <label> ip-src <ip-src> ip-dst <ip-dst>" 15342 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 15343 .tokens = { 15344 (void *)&cmd_set_mplsogre_encap_set, 15345 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, 15346 (void *)&cmd_set_mplsogre_encap_ip_version, 15347 (void *)&cmd_set_mplsogre_encap_ip_version_value, 15348 (void *)&cmd_set_mplsogre_encap_label, 15349 (void *)&cmd_set_mplsogre_encap_label_value, 15350 (void *)&cmd_set_mplsogre_encap_ip_src, 15351 (void *)&cmd_set_mplsogre_encap_ip_src_value, 15352 (void *)&cmd_set_mplsogre_encap_ip_dst, 15353 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 15354 (void *)&cmd_set_mplsogre_encap_vlan, 15355 (void *)&cmd_set_mplsogre_encap_vlan_value, 15356 (void *)&cmd_set_mplsogre_encap_eth_src, 15357 (void *)&cmd_set_mplsogre_encap_eth_src_value, 15358 (void *)&cmd_set_mplsogre_encap_eth_dst, 15359 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 15360 NULL, 15361 }, 15362 }; 15363 15364 /** Set MPLSoGRE decapsulation details */ 15365 struct cmd_set_mplsogre_decap_result { 15366 cmdline_fixed_string_t set; 15367 cmdline_fixed_string_t mplsogre; 15368 cmdline_fixed_string_t pos_token; 15369 cmdline_fixed_string_t ip_version; 15370 uint32_t vlan_present:1; 15371 }; 15372 15373 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = 15374 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, 15375 "set"); 15376 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = 15377 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, 15378 "mplsogre_decap"); 15379 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = 15380 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15381 mplsogre, "mplsogre_decap-with-vlan"); 15382 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = 15383 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15384 pos_token, "ip-version"); 15385 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = 15386 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15387 ip_version, "ipv4#ipv6"); 15388 15389 static void cmd_set_mplsogre_decap_parsed(void *parsed_result, 15390 __rte_unused struct cmdline *cl, 15391 __rte_unused void *data) 15392 { 15393 struct cmd_set_mplsogre_decap_result *res = parsed_result; 15394 15395 if (strcmp(res->mplsogre, "mplsogre_decap") == 0) 15396 mplsogre_decap_conf.select_vlan = 0; 15397 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) 15398 mplsogre_decap_conf.select_vlan = 1; 15399 if (strcmp(res->ip_version, "ipv4") == 0) 15400 mplsogre_decap_conf.select_ipv4 = 1; 15401 else if (strcmp(res->ip_version, "ipv6") == 0) 15402 mplsogre_decap_conf.select_ipv4 = 0; 15403 } 15404 15405 cmdline_parse_inst_t cmd_set_mplsogre_decap = { 15406 .f = cmd_set_mplsogre_decap_parsed, 15407 .data = NULL, 15408 .help_str = "set mplsogre_decap ip-version ipv4|ipv6", 15409 .tokens = { 15410 (void *)&cmd_set_mplsogre_decap_set, 15411 (void *)&cmd_set_mplsogre_decap_mplsogre_decap, 15412 (void *)&cmd_set_mplsogre_decap_ip_version, 15413 (void *)&cmd_set_mplsogre_decap_ip_version_value, 15414 NULL, 15415 }, 15416 }; 15417 15418 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { 15419 .f = cmd_set_mplsogre_decap_parsed, 15420 .data = NULL, 15421 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", 15422 .tokens = { 15423 (void *)&cmd_set_mplsogre_decap_set, 15424 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, 15425 (void *)&cmd_set_mplsogre_decap_ip_version, 15426 (void *)&cmd_set_mplsogre_decap_ip_version_value, 15427 NULL, 15428 }, 15429 }; 15430 15431 /** Set MPLSoUDP encapsulation details */ 15432 struct cmd_set_mplsoudp_encap_result { 15433 cmdline_fixed_string_t set; 15434 cmdline_fixed_string_t mplsoudp; 15435 cmdline_fixed_string_t pos_token; 15436 cmdline_fixed_string_t ip_version; 15437 uint32_t vlan_present:1; 15438 uint32_t label; 15439 uint16_t udp_src; 15440 uint16_t udp_dst; 15441 cmdline_ipaddr_t ip_src; 15442 cmdline_ipaddr_t ip_dst; 15443 uint16_t tci; 15444 struct rte_ether_addr eth_src; 15445 struct rte_ether_addr eth_dst; 15446 }; 15447 15448 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = 15449 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, 15450 "set"); 15451 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = 15452 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, 15453 "mplsoudp_encap"); 15454 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = 15455 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15456 mplsoudp, "mplsoudp_encap-with-vlan"); 15457 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = 15458 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15459 pos_token, "ip-version"); 15460 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = 15461 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15462 ip_version, "ipv4#ipv6"); 15463 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = 15464 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15465 pos_token, "label"); 15466 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = 15467 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, 15468 UINT32); 15469 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = 15470 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15471 pos_token, "udp-src"); 15472 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = 15473 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, 15474 UINT16); 15475 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = 15476 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15477 pos_token, "udp-dst"); 15478 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = 15479 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, 15480 UINT16); 15481 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = 15482 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15483 pos_token, "ip-src"); 15484 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = 15485 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); 15486 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = 15487 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15488 pos_token, "ip-dst"); 15489 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = 15490 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); 15491 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = 15492 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15493 pos_token, "vlan-tci"); 15494 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = 15495 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, 15496 UINT16); 15497 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = 15498 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15499 pos_token, "eth-src"); 15500 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = 15501 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15502 eth_src); 15503 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = 15504 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15505 pos_token, "eth-dst"); 15506 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = 15507 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15508 eth_dst); 15509 15510 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, 15511 __rte_unused struct cmdline *cl, 15512 __rte_unused void *data) 15513 { 15514 struct cmd_set_mplsoudp_encap_result *res = parsed_result; 15515 union { 15516 uint32_t mplsoudp_label; 15517 uint8_t label[4]; 15518 } id = { 15519 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12), 15520 }; 15521 15522 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) 15523 mplsoudp_encap_conf.select_vlan = 0; 15524 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) 15525 mplsoudp_encap_conf.select_vlan = 1; 15526 if (strcmp(res->ip_version, "ipv4") == 0) 15527 mplsoudp_encap_conf.select_ipv4 = 1; 15528 else if (strcmp(res->ip_version, "ipv6") == 0) 15529 mplsoudp_encap_conf.select_ipv4 = 0; 15530 else 15531 return; 15532 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3); 15533 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 15534 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 15535 if (mplsoudp_encap_conf.select_ipv4) { 15536 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); 15537 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); 15538 } else { 15539 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); 15540 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); 15541 } 15542 if (mplsoudp_encap_conf.select_vlan) 15543 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15544 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, 15545 RTE_ETHER_ADDR_LEN); 15546 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15547 RTE_ETHER_ADDR_LEN); 15548 } 15549 15550 cmdline_parse_inst_t cmd_set_mplsoudp_encap = { 15551 .f = cmd_set_mplsoudp_encap_parsed, 15552 .data = NULL, 15553 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" 15554 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" 15555 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", 15556 .tokens = { 15557 (void *)&cmd_set_mplsoudp_encap_set, 15558 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, 15559 (void *)&cmd_set_mplsoudp_encap_ip_version, 15560 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 15561 (void *)&cmd_set_mplsoudp_encap_label, 15562 (void *)&cmd_set_mplsoudp_encap_label_value, 15563 (void *)&cmd_set_mplsoudp_encap_udp_src, 15564 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 15565 (void *)&cmd_set_mplsoudp_encap_udp_dst, 15566 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 15567 (void *)&cmd_set_mplsoudp_encap_ip_src, 15568 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 15569 (void *)&cmd_set_mplsoudp_encap_ip_dst, 15570 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 15571 (void *)&cmd_set_mplsoudp_encap_eth_src, 15572 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 15573 (void *)&cmd_set_mplsoudp_encap_eth_dst, 15574 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 15575 NULL, 15576 }, 15577 }; 15578 15579 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { 15580 .f = cmd_set_mplsoudp_encap_parsed, 15581 .data = NULL, 15582 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" 15583 " label <label> udp-src <udp-src> udp-dst <udp-dst>" 15584 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 15585 " eth-src <eth-src> eth-dst <eth-dst>", 15586 .tokens = { 15587 (void *)&cmd_set_mplsoudp_encap_set, 15588 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, 15589 (void *)&cmd_set_mplsoudp_encap_ip_version, 15590 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 15591 (void *)&cmd_set_mplsoudp_encap_label, 15592 (void *)&cmd_set_mplsoudp_encap_label_value, 15593 (void *)&cmd_set_mplsoudp_encap_udp_src, 15594 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 15595 (void *)&cmd_set_mplsoudp_encap_udp_dst, 15596 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 15597 (void *)&cmd_set_mplsoudp_encap_ip_src, 15598 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 15599 (void *)&cmd_set_mplsoudp_encap_ip_dst, 15600 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 15601 (void *)&cmd_set_mplsoudp_encap_vlan, 15602 (void *)&cmd_set_mplsoudp_encap_vlan_value, 15603 (void *)&cmd_set_mplsoudp_encap_eth_src, 15604 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 15605 (void *)&cmd_set_mplsoudp_encap_eth_dst, 15606 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 15607 NULL, 15608 }, 15609 }; 15610 15611 /** Set MPLSoUDP decapsulation details */ 15612 struct cmd_set_mplsoudp_decap_result { 15613 cmdline_fixed_string_t set; 15614 cmdline_fixed_string_t mplsoudp; 15615 cmdline_fixed_string_t pos_token; 15616 cmdline_fixed_string_t ip_version; 15617 uint32_t vlan_present:1; 15618 }; 15619 15620 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = 15621 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, 15622 "set"); 15623 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = 15624 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, 15625 "mplsoudp_decap"); 15626 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = 15627 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 15628 mplsoudp, "mplsoudp_decap-with-vlan"); 15629 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = 15630 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 15631 pos_token, "ip-version"); 15632 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = 15633 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 15634 ip_version, "ipv4#ipv6"); 15635 15636 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, 15637 __rte_unused struct cmdline *cl, 15638 __rte_unused void *data) 15639 { 15640 struct cmd_set_mplsoudp_decap_result *res = parsed_result; 15641 15642 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) 15643 mplsoudp_decap_conf.select_vlan = 0; 15644 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) 15645 mplsoudp_decap_conf.select_vlan = 1; 15646 if (strcmp(res->ip_version, "ipv4") == 0) 15647 mplsoudp_decap_conf.select_ipv4 = 1; 15648 else if (strcmp(res->ip_version, "ipv6") == 0) 15649 mplsoudp_decap_conf.select_ipv4 = 0; 15650 } 15651 15652 cmdline_parse_inst_t cmd_set_mplsoudp_decap = { 15653 .f = cmd_set_mplsoudp_decap_parsed, 15654 .data = NULL, 15655 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", 15656 .tokens = { 15657 (void *)&cmd_set_mplsoudp_decap_set, 15658 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, 15659 (void *)&cmd_set_mplsoudp_decap_ip_version, 15660 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 15661 NULL, 15662 }, 15663 }; 15664 15665 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { 15666 .f = cmd_set_mplsoudp_decap_parsed, 15667 .data = NULL, 15668 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", 15669 .tokens = { 15670 (void *)&cmd_set_mplsoudp_decap_set, 15671 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, 15672 (void *)&cmd_set_mplsoudp_decap_ip_version, 15673 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 15674 NULL, 15675 }, 15676 }; 15677 15678 /* Strict link priority scheduling mode setting */ 15679 static void 15680 cmd_strict_link_prio_parsed( 15681 void *parsed_result, 15682 __rte_unused struct cmdline *cl, 15683 __rte_unused void *data) 15684 { 15685 struct cmd_vf_tc_bw_result *res = parsed_result; 15686 int ret = -ENOTSUP; 15687 15688 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15689 return; 15690 15691 #ifdef RTE_NET_I40E 15692 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 15693 #endif 15694 15695 switch (ret) { 15696 case 0: 15697 break; 15698 case -EINVAL: 15699 printf("invalid tc_bitmap 0x%x\n", res->tc_map); 15700 break; 15701 case -ENODEV: 15702 printf("invalid port_id %d\n", res->port_id); 15703 break; 15704 case -ENOTSUP: 15705 printf("function not implemented\n"); 15706 break; 15707 default: 15708 printf("programming error: (%s)\n", strerror(-ret)); 15709 } 15710 } 15711 15712 cmdline_parse_inst_t cmd_strict_link_prio = { 15713 .f = cmd_strict_link_prio_parsed, 15714 .data = NULL, 15715 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 15716 .tokens = { 15717 (void *)&cmd_vf_tc_bw_set, 15718 (void *)&cmd_vf_tc_bw_tx, 15719 (void *)&cmd_vf_tc_bw_strict_link_prio, 15720 (void *)&cmd_vf_tc_bw_port_id, 15721 (void *)&cmd_vf_tc_bw_tc_map, 15722 NULL, 15723 }, 15724 }; 15725 15726 /* Load dynamic device personalization*/ 15727 struct cmd_ddp_add_result { 15728 cmdline_fixed_string_t ddp; 15729 cmdline_fixed_string_t add; 15730 portid_t port_id; 15731 char filepath[]; 15732 }; 15733 15734 cmdline_parse_token_string_t cmd_ddp_add_ddp = 15735 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 15736 cmdline_parse_token_string_t cmd_ddp_add_add = 15737 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 15738 cmdline_parse_token_num_t cmd_ddp_add_port_id = 15739 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16); 15740 cmdline_parse_token_string_t cmd_ddp_add_filepath = 15741 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 15742 15743 static void 15744 cmd_ddp_add_parsed( 15745 void *parsed_result, 15746 __rte_unused struct cmdline *cl, 15747 __rte_unused void *data) 15748 { 15749 struct cmd_ddp_add_result *res = parsed_result; 15750 uint8_t *buff; 15751 uint32_t size; 15752 char *filepath; 15753 char *file_fld[2]; 15754 int file_num; 15755 int ret = -ENOTSUP; 15756 15757 if (!all_ports_stopped()) { 15758 printf("Please stop all ports first\n"); 15759 return; 15760 } 15761 15762 filepath = strdup(res->filepath); 15763 if (filepath == NULL) { 15764 printf("Failed to allocate memory\n"); 15765 return; 15766 } 15767 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 15768 15769 buff = open_file(file_fld[0], &size); 15770 if (!buff) { 15771 free((void *)filepath); 15772 return; 15773 } 15774 15775 #ifdef RTE_NET_I40E 15776 if (ret == -ENOTSUP) 15777 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 15778 buff, size, 15779 RTE_PMD_I40E_PKG_OP_WR_ADD); 15780 #endif 15781 15782 if (ret == -EEXIST) 15783 printf("Profile has already existed.\n"); 15784 else if (ret < 0) 15785 printf("Failed to load profile.\n"); 15786 else if (file_num == 2) 15787 save_file(file_fld[1], buff, size); 15788 15789 close_file(buff); 15790 free((void *)filepath); 15791 } 15792 15793 cmdline_parse_inst_t cmd_ddp_add = { 15794 .f = cmd_ddp_add_parsed, 15795 .data = NULL, 15796 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 15797 .tokens = { 15798 (void *)&cmd_ddp_add_ddp, 15799 (void *)&cmd_ddp_add_add, 15800 (void *)&cmd_ddp_add_port_id, 15801 (void *)&cmd_ddp_add_filepath, 15802 NULL, 15803 }, 15804 }; 15805 15806 /* Delete dynamic device personalization*/ 15807 struct cmd_ddp_del_result { 15808 cmdline_fixed_string_t ddp; 15809 cmdline_fixed_string_t del; 15810 portid_t port_id; 15811 char filepath[]; 15812 }; 15813 15814 cmdline_parse_token_string_t cmd_ddp_del_ddp = 15815 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 15816 cmdline_parse_token_string_t cmd_ddp_del_del = 15817 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 15818 cmdline_parse_token_num_t cmd_ddp_del_port_id = 15819 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16); 15820 cmdline_parse_token_string_t cmd_ddp_del_filepath = 15821 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 15822 15823 static void 15824 cmd_ddp_del_parsed( 15825 void *parsed_result, 15826 __rte_unused struct cmdline *cl, 15827 __rte_unused void *data) 15828 { 15829 struct cmd_ddp_del_result *res = parsed_result; 15830 uint8_t *buff; 15831 uint32_t size; 15832 int ret = -ENOTSUP; 15833 15834 if (!all_ports_stopped()) { 15835 printf("Please stop all ports first\n"); 15836 return; 15837 } 15838 15839 buff = open_file(res->filepath, &size); 15840 if (!buff) 15841 return; 15842 15843 #ifdef RTE_NET_I40E 15844 if (ret == -ENOTSUP) 15845 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 15846 buff, size, 15847 RTE_PMD_I40E_PKG_OP_WR_DEL); 15848 #endif 15849 15850 if (ret == -EACCES) 15851 printf("Profile does not exist.\n"); 15852 else if (ret < 0) 15853 printf("Failed to delete profile.\n"); 15854 15855 close_file(buff); 15856 } 15857 15858 cmdline_parse_inst_t cmd_ddp_del = { 15859 .f = cmd_ddp_del_parsed, 15860 .data = NULL, 15861 .help_str = "ddp del <port_id> <backup_profile_path>", 15862 .tokens = { 15863 (void *)&cmd_ddp_del_ddp, 15864 (void *)&cmd_ddp_del_del, 15865 (void *)&cmd_ddp_del_port_id, 15866 (void *)&cmd_ddp_del_filepath, 15867 NULL, 15868 }, 15869 }; 15870 15871 /* Get dynamic device personalization profile info */ 15872 struct cmd_ddp_info_result { 15873 cmdline_fixed_string_t ddp; 15874 cmdline_fixed_string_t get; 15875 cmdline_fixed_string_t info; 15876 char filepath[]; 15877 }; 15878 15879 cmdline_parse_token_string_t cmd_ddp_info_ddp = 15880 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 15881 cmdline_parse_token_string_t cmd_ddp_info_get = 15882 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 15883 cmdline_parse_token_string_t cmd_ddp_info_info = 15884 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 15885 cmdline_parse_token_string_t cmd_ddp_info_filepath = 15886 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 15887 15888 static void 15889 cmd_ddp_info_parsed( 15890 void *parsed_result, 15891 __rte_unused struct cmdline *cl, 15892 __rte_unused void *data) 15893 { 15894 struct cmd_ddp_info_result *res = parsed_result; 15895 uint8_t *pkg; 15896 uint32_t pkg_size; 15897 int ret = -ENOTSUP; 15898 #ifdef RTE_NET_I40E 15899 uint32_t i, j, n; 15900 uint8_t *buff; 15901 uint32_t buff_size = 0; 15902 struct rte_pmd_i40e_profile_info info; 15903 uint32_t dev_num = 0; 15904 struct rte_pmd_i40e_ddp_device_id *devs; 15905 uint32_t proto_num = 0; 15906 struct rte_pmd_i40e_proto_info *proto = NULL; 15907 uint32_t pctype_num = 0; 15908 struct rte_pmd_i40e_ptype_info *pctype; 15909 uint32_t ptype_num = 0; 15910 struct rte_pmd_i40e_ptype_info *ptype; 15911 uint8_t proto_id; 15912 15913 #endif 15914 15915 pkg = open_file(res->filepath, &pkg_size); 15916 if (!pkg) 15917 return; 15918 15919 #ifdef RTE_NET_I40E 15920 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15921 (uint8_t *)&info, sizeof(info), 15922 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 15923 if (!ret) { 15924 printf("Global Track id: 0x%x\n", info.track_id); 15925 printf("Global Version: %d.%d.%d.%d\n", 15926 info.version.major, 15927 info.version.minor, 15928 info.version.update, 15929 info.version.draft); 15930 printf("Global Package name: %s\n\n", info.name); 15931 } 15932 15933 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15934 (uint8_t *)&info, sizeof(info), 15935 RTE_PMD_I40E_PKG_INFO_HEADER); 15936 if (!ret) { 15937 printf("i40e Profile Track id: 0x%x\n", info.track_id); 15938 printf("i40e Profile Version: %d.%d.%d.%d\n", 15939 info.version.major, 15940 info.version.minor, 15941 info.version.update, 15942 info.version.draft); 15943 printf("i40e Profile name: %s\n\n", info.name); 15944 } 15945 15946 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15947 (uint8_t *)&buff_size, sizeof(buff_size), 15948 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 15949 if (!ret && buff_size) { 15950 buff = (uint8_t *)malloc(buff_size); 15951 if (buff) { 15952 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15953 buff, buff_size, 15954 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 15955 if (!ret) 15956 printf("Package Notes:\n%s\n\n", buff); 15957 free(buff); 15958 } 15959 } 15960 15961 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15962 (uint8_t *)&dev_num, sizeof(dev_num), 15963 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 15964 if (!ret && dev_num) { 15965 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 15966 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 15967 if (devs) { 15968 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15969 (uint8_t *)devs, buff_size, 15970 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 15971 if (!ret) { 15972 printf("List of supported devices:\n"); 15973 for (i = 0; i < dev_num; i++) { 15974 printf(" %04X:%04X %04X:%04X\n", 15975 devs[i].vendor_dev_id >> 16, 15976 devs[i].vendor_dev_id & 0xFFFF, 15977 devs[i].sub_vendor_dev_id >> 16, 15978 devs[i].sub_vendor_dev_id & 0xFFFF); 15979 } 15980 printf("\n"); 15981 } 15982 free(devs); 15983 } 15984 } 15985 15986 /* get information about protocols and packet types */ 15987 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15988 (uint8_t *)&proto_num, sizeof(proto_num), 15989 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 15990 if (ret || !proto_num) 15991 goto no_print_return; 15992 15993 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 15994 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 15995 if (!proto) 15996 goto no_print_return; 15997 15998 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 15999 buff_size, 16000 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 16001 if (!ret) { 16002 printf("List of used protocols:\n"); 16003 for (i = 0; i < proto_num; i++) 16004 printf(" %2u: %s\n", proto[i].proto_id, 16005 proto[i].name); 16006 printf("\n"); 16007 } 16008 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16009 (uint8_t *)&pctype_num, sizeof(pctype_num), 16010 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 16011 if (ret || !pctype_num) 16012 goto no_print_pctypes; 16013 16014 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16015 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16016 if (!pctype) 16017 goto no_print_pctypes; 16018 16019 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 16020 buff_size, 16021 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 16022 if (ret) { 16023 free(pctype); 16024 goto no_print_pctypes; 16025 } 16026 16027 printf("List of defined packet classification types:\n"); 16028 for (i = 0; i < pctype_num; i++) { 16029 printf(" %2u:", pctype[i].ptype_id); 16030 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16031 proto_id = pctype[i].protocols[j]; 16032 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16033 for (n = 0; n < proto_num; n++) { 16034 if (proto[n].proto_id == proto_id) { 16035 printf(" %s", proto[n].name); 16036 break; 16037 } 16038 } 16039 } 16040 } 16041 printf("\n"); 16042 } 16043 printf("\n"); 16044 free(pctype); 16045 16046 no_print_pctypes: 16047 16048 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 16049 sizeof(ptype_num), 16050 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 16051 if (ret || !ptype_num) 16052 goto no_print_return; 16053 16054 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16055 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16056 if (!ptype) 16057 goto no_print_return; 16058 16059 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 16060 buff_size, 16061 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 16062 if (ret) { 16063 free(ptype); 16064 goto no_print_return; 16065 } 16066 printf("List of defined packet types:\n"); 16067 for (i = 0; i < ptype_num; i++) { 16068 printf(" %2u:", ptype[i].ptype_id); 16069 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16070 proto_id = ptype[i].protocols[j]; 16071 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16072 for (n = 0; n < proto_num; n++) { 16073 if (proto[n].proto_id == proto_id) { 16074 printf(" %s", proto[n].name); 16075 break; 16076 } 16077 } 16078 } 16079 } 16080 printf("\n"); 16081 } 16082 free(ptype); 16083 printf("\n"); 16084 16085 ret = 0; 16086 no_print_return: 16087 if (proto) 16088 free(proto); 16089 #endif 16090 if (ret == -ENOTSUP) 16091 printf("Function not supported in PMD driver\n"); 16092 close_file(pkg); 16093 } 16094 16095 cmdline_parse_inst_t cmd_ddp_get_info = { 16096 .f = cmd_ddp_info_parsed, 16097 .data = NULL, 16098 .help_str = "ddp get info <profile_path>", 16099 .tokens = { 16100 (void *)&cmd_ddp_info_ddp, 16101 (void *)&cmd_ddp_info_get, 16102 (void *)&cmd_ddp_info_info, 16103 (void *)&cmd_ddp_info_filepath, 16104 NULL, 16105 }, 16106 }; 16107 16108 /* Get dynamic device personalization profile info list*/ 16109 #define PROFILE_INFO_SIZE 48 16110 #define MAX_PROFILE_NUM 16 16111 16112 struct cmd_ddp_get_list_result { 16113 cmdline_fixed_string_t ddp; 16114 cmdline_fixed_string_t get; 16115 cmdline_fixed_string_t list; 16116 portid_t port_id; 16117 }; 16118 16119 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 16120 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 16121 cmdline_parse_token_string_t cmd_ddp_get_list_get = 16122 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 16123 cmdline_parse_token_string_t cmd_ddp_get_list_list = 16124 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 16125 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 16126 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16); 16127 16128 static void 16129 cmd_ddp_get_list_parsed( 16130 __rte_unused void *parsed_result, 16131 __rte_unused struct cmdline *cl, 16132 __rte_unused void *data) 16133 { 16134 #ifdef RTE_NET_I40E 16135 struct cmd_ddp_get_list_result *res = parsed_result; 16136 struct rte_pmd_i40e_profile_list *p_list; 16137 struct rte_pmd_i40e_profile_info *p_info; 16138 uint32_t p_num; 16139 uint32_t size; 16140 uint32_t i; 16141 #endif 16142 int ret = -ENOTSUP; 16143 16144 #ifdef RTE_NET_I40E 16145 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 16146 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 16147 if (!p_list) { 16148 printf("%s: Failed to malloc buffer\n", __func__); 16149 return; 16150 } 16151 16152 if (ret == -ENOTSUP) 16153 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 16154 (uint8_t *)p_list, size); 16155 16156 if (!ret) { 16157 p_num = p_list->p_count; 16158 printf("Profile number is: %d\n\n", p_num); 16159 16160 for (i = 0; i < p_num; i++) { 16161 p_info = &p_list->p_info[i]; 16162 printf("Profile %d:\n", i); 16163 printf("Track id: 0x%x\n", p_info->track_id); 16164 printf("Version: %d.%d.%d.%d\n", 16165 p_info->version.major, 16166 p_info->version.minor, 16167 p_info->version.update, 16168 p_info->version.draft); 16169 printf("Profile name: %s\n\n", p_info->name); 16170 } 16171 } 16172 16173 free(p_list); 16174 #endif 16175 16176 if (ret < 0) 16177 printf("Failed to get ddp list\n"); 16178 } 16179 16180 cmdline_parse_inst_t cmd_ddp_get_list = { 16181 .f = cmd_ddp_get_list_parsed, 16182 .data = NULL, 16183 .help_str = "ddp get list <port_id>", 16184 .tokens = { 16185 (void *)&cmd_ddp_get_list_ddp, 16186 (void *)&cmd_ddp_get_list_get, 16187 (void *)&cmd_ddp_get_list_list, 16188 (void *)&cmd_ddp_get_list_port_id, 16189 NULL, 16190 }, 16191 }; 16192 16193 /* Configure input set */ 16194 struct cmd_cfg_input_set_result { 16195 cmdline_fixed_string_t port; 16196 cmdline_fixed_string_t cfg; 16197 portid_t port_id; 16198 cmdline_fixed_string_t pctype; 16199 uint8_t pctype_id; 16200 cmdline_fixed_string_t inset_type; 16201 cmdline_fixed_string_t opt; 16202 cmdline_fixed_string_t field; 16203 uint8_t field_idx; 16204 }; 16205 16206 static void 16207 cmd_cfg_input_set_parsed( 16208 __rte_unused void *parsed_result, 16209 __rte_unused struct cmdline *cl, 16210 __rte_unused void *data) 16211 { 16212 #ifdef RTE_NET_I40E 16213 struct cmd_cfg_input_set_result *res = parsed_result; 16214 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16215 struct rte_pmd_i40e_inset inset; 16216 #endif 16217 int ret = -ENOTSUP; 16218 16219 if (!all_ports_stopped()) { 16220 printf("Please stop all ports first\n"); 16221 return; 16222 } 16223 16224 #ifdef RTE_NET_I40E 16225 if (!strcmp(res->inset_type, "hash_inset")) 16226 inset_type = INSET_HASH; 16227 else if (!strcmp(res->inset_type, "fdir_inset")) 16228 inset_type = INSET_FDIR; 16229 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 16230 inset_type = INSET_FDIR_FLX; 16231 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 16232 &inset, inset_type); 16233 if (ret) { 16234 printf("Failed to get input set.\n"); 16235 return; 16236 } 16237 16238 if (!strcmp(res->opt, "get")) { 16239 ret = rte_pmd_i40e_inset_field_get(inset.inset, 16240 res->field_idx); 16241 if (ret) 16242 printf("Field index %d is enabled.\n", res->field_idx); 16243 else 16244 printf("Field index %d is disabled.\n", res->field_idx); 16245 return; 16246 } else if (!strcmp(res->opt, "set")) 16247 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 16248 res->field_idx); 16249 else if (!strcmp(res->opt, "clear")) 16250 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 16251 res->field_idx); 16252 if (ret) { 16253 printf("Failed to configure input set field.\n"); 16254 return; 16255 } 16256 16257 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 16258 &inset, inset_type); 16259 if (ret) { 16260 printf("Failed to set input set.\n"); 16261 return; 16262 } 16263 #endif 16264 16265 if (ret == -ENOTSUP) 16266 printf("Function not supported\n"); 16267 } 16268 16269 cmdline_parse_token_string_t cmd_cfg_input_set_port = 16270 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16271 port, "port"); 16272 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 16273 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16274 cfg, "config"); 16275 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 16276 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16277 port_id, UINT16); 16278 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 16279 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16280 pctype, "pctype"); 16281 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 16282 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16283 pctype_id, UINT8); 16284 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 16285 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16286 inset_type, 16287 "hash_inset#fdir_inset#fdir_flx_inset"); 16288 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 16289 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16290 opt, "get#set#clear"); 16291 cmdline_parse_token_string_t cmd_cfg_input_set_field = 16292 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16293 field, "field"); 16294 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 16295 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16296 field_idx, UINT8); 16297 16298 cmdline_parse_inst_t cmd_cfg_input_set = { 16299 .f = cmd_cfg_input_set_parsed, 16300 .data = NULL, 16301 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 16302 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 16303 .tokens = { 16304 (void *)&cmd_cfg_input_set_port, 16305 (void *)&cmd_cfg_input_set_cfg, 16306 (void *)&cmd_cfg_input_set_port_id, 16307 (void *)&cmd_cfg_input_set_pctype, 16308 (void *)&cmd_cfg_input_set_pctype_id, 16309 (void *)&cmd_cfg_input_set_inset_type, 16310 (void *)&cmd_cfg_input_set_opt, 16311 (void *)&cmd_cfg_input_set_field, 16312 (void *)&cmd_cfg_input_set_field_idx, 16313 NULL, 16314 }, 16315 }; 16316 16317 /* Clear input set */ 16318 struct cmd_clear_input_set_result { 16319 cmdline_fixed_string_t port; 16320 cmdline_fixed_string_t cfg; 16321 portid_t port_id; 16322 cmdline_fixed_string_t pctype; 16323 uint8_t pctype_id; 16324 cmdline_fixed_string_t inset_type; 16325 cmdline_fixed_string_t clear; 16326 cmdline_fixed_string_t all; 16327 }; 16328 16329 static void 16330 cmd_clear_input_set_parsed( 16331 __rte_unused void *parsed_result, 16332 __rte_unused struct cmdline *cl, 16333 __rte_unused void *data) 16334 { 16335 #ifdef RTE_NET_I40E 16336 struct cmd_clear_input_set_result *res = parsed_result; 16337 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16338 struct rte_pmd_i40e_inset inset; 16339 #endif 16340 int ret = -ENOTSUP; 16341 16342 if (!all_ports_stopped()) { 16343 printf("Please stop all ports first\n"); 16344 return; 16345 } 16346 16347 #ifdef RTE_NET_I40E 16348 if (!strcmp(res->inset_type, "hash_inset")) 16349 inset_type = INSET_HASH; 16350 else if (!strcmp(res->inset_type, "fdir_inset")) 16351 inset_type = INSET_FDIR; 16352 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 16353 inset_type = INSET_FDIR_FLX; 16354 16355 memset(&inset, 0, sizeof(inset)); 16356 16357 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 16358 &inset, inset_type); 16359 if (ret) { 16360 printf("Failed to clear input set.\n"); 16361 return; 16362 } 16363 16364 #endif 16365 16366 if (ret == -ENOTSUP) 16367 printf("Function not supported\n"); 16368 } 16369 16370 cmdline_parse_token_string_t cmd_clear_input_set_port = 16371 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16372 port, "port"); 16373 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 16374 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16375 cfg, "config"); 16376 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 16377 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 16378 port_id, UINT16); 16379 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 16380 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16381 pctype, "pctype"); 16382 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 16383 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 16384 pctype_id, UINT8); 16385 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 16386 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16387 inset_type, 16388 "hash_inset#fdir_inset#fdir_flx_inset"); 16389 cmdline_parse_token_string_t cmd_clear_input_set_clear = 16390 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16391 clear, "clear"); 16392 cmdline_parse_token_string_t cmd_clear_input_set_all = 16393 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16394 all, "all"); 16395 16396 cmdline_parse_inst_t cmd_clear_input_set = { 16397 .f = cmd_clear_input_set_parsed, 16398 .data = NULL, 16399 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 16400 "fdir_inset|fdir_flx_inset clear all", 16401 .tokens = { 16402 (void *)&cmd_clear_input_set_port, 16403 (void *)&cmd_clear_input_set_cfg, 16404 (void *)&cmd_clear_input_set_port_id, 16405 (void *)&cmd_clear_input_set_pctype, 16406 (void *)&cmd_clear_input_set_pctype_id, 16407 (void *)&cmd_clear_input_set_inset_type, 16408 (void *)&cmd_clear_input_set_clear, 16409 (void *)&cmd_clear_input_set_all, 16410 NULL, 16411 }, 16412 }; 16413 16414 /* show vf stats */ 16415 16416 /* Common result structure for show vf stats */ 16417 struct cmd_show_vf_stats_result { 16418 cmdline_fixed_string_t show; 16419 cmdline_fixed_string_t vf; 16420 cmdline_fixed_string_t stats; 16421 portid_t port_id; 16422 uint16_t vf_id; 16423 }; 16424 16425 /* Common CLI fields show vf stats*/ 16426 cmdline_parse_token_string_t cmd_show_vf_stats_show = 16427 TOKEN_STRING_INITIALIZER 16428 (struct cmd_show_vf_stats_result, 16429 show, "show"); 16430 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 16431 TOKEN_STRING_INITIALIZER 16432 (struct cmd_show_vf_stats_result, 16433 vf, "vf"); 16434 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 16435 TOKEN_STRING_INITIALIZER 16436 (struct cmd_show_vf_stats_result, 16437 stats, "stats"); 16438 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 16439 TOKEN_NUM_INITIALIZER 16440 (struct cmd_show_vf_stats_result, 16441 port_id, UINT16); 16442 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 16443 TOKEN_NUM_INITIALIZER 16444 (struct cmd_show_vf_stats_result, 16445 vf_id, UINT16); 16446 16447 static void 16448 cmd_show_vf_stats_parsed( 16449 void *parsed_result, 16450 __rte_unused struct cmdline *cl, 16451 __rte_unused void *data) 16452 { 16453 struct cmd_show_vf_stats_result *res = parsed_result; 16454 struct rte_eth_stats stats; 16455 int ret = -ENOTSUP; 16456 static const char *nic_stats_border = "########################"; 16457 16458 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16459 return; 16460 16461 memset(&stats, 0, sizeof(stats)); 16462 16463 #ifdef RTE_NET_I40E 16464 if (ret == -ENOTSUP) 16465 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 16466 res->vf_id, 16467 &stats); 16468 #endif 16469 #ifdef RTE_NET_BNXT 16470 if (ret == -ENOTSUP) 16471 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 16472 res->vf_id, 16473 &stats); 16474 #endif 16475 16476 switch (ret) { 16477 case 0: 16478 break; 16479 case -EINVAL: 16480 printf("invalid vf_id %d\n", res->vf_id); 16481 break; 16482 case -ENODEV: 16483 printf("invalid port_id %d\n", res->port_id); 16484 break; 16485 case -ENOTSUP: 16486 printf("function not implemented\n"); 16487 break; 16488 default: 16489 printf("programming error: (%s)\n", strerror(-ret)); 16490 } 16491 16492 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 16493 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 16494 16495 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 16496 "%-"PRIu64"\n", 16497 stats.ipackets, stats.imissed, stats.ibytes); 16498 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 16499 printf(" RX-nombuf: %-10"PRIu64"\n", 16500 stats.rx_nombuf); 16501 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 16502 "%-"PRIu64"\n", 16503 stats.opackets, stats.oerrors, stats.obytes); 16504 16505 printf(" %s############################%s\n", 16506 nic_stats_border, nic_stats_border); 16507 } 16508 16509 cmdline_parse_inst_t cmd_show_vf_stats = { 16510 .f = cmd_show_vf_stats_parsed, 16511 .data = NULL, 16512 .help_str = "show vf stats <port_id> <vf_id>", 16513 .tokens = { 16514 (void *)&cmd_show_vf_stats_show, 16515 (void *)&cmd_show_vf_stats_vf, 16516 (void *)&cmd_show_vf_stats_stats, 16517 (void *)&cmd_show_vf_stats_port_id, 16518 (void *)&cmd_show_vf_stats_vf_id, 16519 NULL, 16520 }, 16521 }; 16522 16523 /* clear vf stats */ 16524 16525 /* Common result structure for clear vf stats */ 16526 struct cmd_clear_vf_stats_result { 16527 cmdline_fixed_string_t clear; 16528 cmdline_fixed_string_t vf; 16529 cmdline_fixed_string_t stats; 16530 portid_t port_id; 16531 uint16_t vf_id; 16532 }; 16533 16534 /* Common CLI fields clear vf stats*/ 16535 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 16536 TOKEN_STRING_INITIALIZER 16537 (struct cmd_clear_vf_stats_result, 16538 clear, "clear"); 16539 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 16540 TOKEN_STRING_INITIALIZER 16541 (struct cmd_clear_vf_stats_result, 16542 vf, "vf"); 16543 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 16544 TOKEN_STRING_INITIALIZER 16545 (struct cmd_clear_vf_stats_result, 16546 stats, "stats"); 16547 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 16548 TOKEN_NUM_INITIALIZER 16549 (struct cmd_clear_vf_stats_result, 16550 port_id, UINT16); 16551 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 16552 TOKEN_NUM_INITIALIZER 16553 (struct cmd_clear_vf_stats_result, 16554 vf_id, UINT16); 16555 16556 static void 16557 cmd_clear_vf_stats_parsed( 16558 void *parsed_result, 16559 __rte_unused struct cmdline *cl, 16560 __rte_unused void *data) 16561 { 16562 struct cmd_clear_vf_stats_result *res = parsed_result; 16563 int ret = -ENOTSUP; 16564 16565 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16566 return; 16567 16568 #ifdef RTE_NET_I40E 16569 if (ret == -ENOTSUP) 16570 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 16571 res->vf_id); 16572 #endif 16573 #ifdef RTE_NET_BNXT 16574 if (ret == -ENOTSUP) 16575 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 16576 res->vf_id); 16577 #endif 16578 16579 switch (ret) { 16580 case 0: 16581 break; 16582 case -EINVAL: 16583 printf("invalid vf_id %d\n", res->vf_id); 16584 break; 16585 case -ENODEV: 16586 printf("invalid port_id %d\n", res->port_id); 16587 break; 16588 case -ENOTSUP: 16589 printf("function not implemented\n"); 16590 break; 16591 default: 16592 printf("programming error: (%s)\n", strerror(-ret)); 16593 } 16594 } 16595 16596 cmdline_parse_inst_t cmd_clear_vf_stats = { 16597 .f = cmd_clear_vf_stats_parsed, 16598 .data = NULL, 16599 .help_str = "clear vf stats <port_id> <vf_id>", 16600 .tokens = { 16601 (void *)&cmd_clear_vf_stats_clear, 16602 (void *)&cmd_clear_vf_stats_vf, 16603 (void *)&cmd_clear_vf_stats_stats, 16604 (void *)&cmd_clear_vf_stats_port_id, 16605 (void *)&cmd_clear_vf_stats_vf_id, 16606 NULL, 16607 }, 16608 }; 16609 16610 /* port config pctype mapping reset */ 16611 16612 /* Common result structure for port config pctype mapping reset */ 16613 struct cmd_pctype_mapping_reset_result { 16614 cmdline_fixed_string_t port; 16615 cmdline_fixed_string_t config; 16616 portid_t port_id; 16617 cmdline_fixed_string_t pctype; 16618 cmdline_fixed_string_t mapping; 16619 cmdline_fixed_string_t reset; 16620 }; 16621 16622 /* Common CLI fields for port config pctype mapping reset*/ 16623 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 16624 TOKEN_STRING_INITIALIZER 16625 (struct cmd_pctype_mapping_reset_result, 16626 port, "port"); 16627 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 16628 TOKEN_STRING_INITIALIZER 16629 (struct cmd_pctype_mapping_reset_result, 16630 config, "config"); 16631 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 16632 TOKEN_NUM_INITIALIZER 16633 (struct cmd_pctype_mapping_reset_result, 16634 port_id, UINT16); 16635 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 16636 TOKEN_STRING_INITIALIZER 16637 (struct cmd_pctype_mapping_reset_result, 16638 pctype, "pctype"); 16639 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 16640 TOKEN_STRING_INITIALIZER 16641 (struct cmd_pctype_mapping_reset_result, 16642 mapping, "mapping"); 16643 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 16644 TOKEN_STRING_INITIALIZER 16645 (struct cmd_pctype_mapping_reset_result, 16646 reset, "reset"); 16647 16648 static void 16649 cmd_pctype_mapping_reset_parsed( 16650 void *parsed_result, 16651 __rte_unused struct cmdline *cl, 16652 __rte_unused void *data) 16653 { 16654 struct cmd_pctype_mapping_reset_result *res = parsed_result; 16655 int ret = -ENOTSUP; 16656 16657 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16658 return; 16659 16660 #ifdef RTE_NET_I40E 16661 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 16662 #endif 16663 16664 switch (ret) { 16665 case 0: 16666 break; 16667 case -ENODEV: 16668 printf("invalid port_id %d\n", res->port_id); 16669 break; 16670 case -ENOTSUP: 16671 printf("function not implemented\n"); 16672 break; 16673 default: 16674 printf("programming error: (%s)\n", strerror(-ret)); 16675 } 16676 } 16677 16678 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 16679 .f = cmd_pctype_mapping_reset_parsed, 16680 .data = NULL, 16681 .help_str = "port config <port_id> pctype mapping reset", 16682 .tokens = { 16683 (void *)&cmd_pctype_mapping_reset_port, 16684 (void *)&cmd_pctype_mapping_reset_config, 16685 (void *)&cmd_pctype_mapping_reset_port_id, 16686 (void *)&cmd_pctype_mapping_reset_pctype, 16687 (void *)&cmd_pctype_mapping_reset_mapping, 16688 (void *)&cmd_pctype_mapping_reset_reset, 16689 NULL, 16690 }, 16691 }; 16692 16693 /* show port pctype mapping */ 16694 16695 /* Common result structure for show port pctype mapping */ 16696 struct cmd_pctype_mapping_get_result { 16697 cmdline_fixed_string_t show; 16698 cmdline_fixed_string_t port; 16699 portid_t port_id; 16700 cmdline_fixed_string_t pctype; 16701 cmdline_fixed_string_t mapping; 16702 }; 16703 16704 /* Common CLI fields for pctype mapping get */ 16705 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 16706 TOKEN_STRING_INITIALIZER 16707 (struct cmd_pctype_mapping_get_result, 16708 show, "show"); 16709 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 16710 TOKEN_STRING_INITIALIZER 16711 (struct cmd_pctype_mapping_get_result, 16712 port, "port"); 16713 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 16714 TOKEN_NUM_INITIALIZER 16715 (struct cmd_pctype_mapping_get_result, 16716 port_id, UINT16); 16717 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 16718 TOKEN_STRING_INITIALIZER 16719 (struct cmd_pctype_mapping_get_result, 16720 pctype, "pctype"); 16721 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 16722 TOKEN_STRING_INITIALIZER 16723 (struct cmd_pctype_mapping_get_result, 16724 mapping, "mapping"); 16725 16726 static void 16727 cmd_pctype_mapping_get_parsed( 16728 void *parsed_result, 16729 __rte_unused struct cmdline *cl, 16730 __rte_unused void *data) 16731 { 16732 struct cmd_pctype_mapping_get_result *res = parsed_result; 16733 int ret = -ENOTSUP; 16734 #ifdef RTE_NET_I40E 16735 struct rte_pmd_i40e_flow_type_mapping 16736 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 16737 int i, j, first_pctype; 16738 #endif 16739 16740 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16741 return; 16742 16743 #ifdef RTE_NET_I40E 16744 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 16745 #endif 16746 16747 switch (ret) { 16748 case 0: 16749 break; 16750 case -ENODEV: 16751 printf("invalid port_id %d\n", res->port_id); 16752 return; 16753 case -ENOTSUP: 16754 printf("function not implemented\n"); 16755 return; 16756 default: 16757 printf("programming error: (%s)\n", strerror(-ret)); 16758 return; 16759 } 16760 16761 #ifdef RTE_NET_I40E 16762 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 16763 if (mapping[i].pctype != 0ULL) { 16764 first_pctype = 1; 16765 16766 printf("pctype: "); 16767 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 16768 if (mapping[i].pctype & (1ULL << j)) { 16769 printf(first_pctype ? 16770 "%02d" : ",%02d", j); 16771 first_pctype = 0; 16772 } 16773 } 16774 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 16775 } 16776 } 16777 #endif 16778 } 16779 16780 cmdline_parse_inst_t cmd_pctype_mapping_get = { 16781 .f = cmd_pctype_mapping_get_parsed, 16782 .data = NULL, 16783 .help_str = "show port <port_id> pctype mapping", 16784 .tokens = { 16785 (void *)&cmd_pctype_mapping_get_show, 16786 (void *)&cmd_pctype_mapping_get_port, 16787 (void *)&cmd_pctype_mapping_get_port_id, 16788 (void *)&cmd_pctype_mapping_get_pctype, 16789 (void *)&cmd_pctype_mapping_get_mapping, 16790 NULL, 16791 }, 16792 }; 16793 16794 /* port config pctype mapping update */ 16795 16796 /* Common result structure for port config pctype mapping update */ 16797 struct cmd_pctype_mapping_update_result { 16798 cmdline_fixed_string_t port; 16799 cmdline_fixed_string_t config; 16800 portid_t port_id; 16801 cmdline_fixed_string_t pctype; 16802 cmdline_fixed_string_t mapping; 16803 cmdline_fixed_string_t update; 16804 cmdline_fixed_string_t pctype_list; 16805 uint16_t flow_type; 16806 }; 16807 16808 /* Common CLI fields for pctype mapping update*/ 16809 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 16810 TOKEN_STRING_INITIALIZER 16811 (struct cmd_pctype_mapping_update_result, 16812 port, "port"); 16813 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 16814 TOKEN_STRING_INITIALIZER 16815 (struct cmd_pctype_mapping_update_result, 16816 config, "config"); 16817 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 16818 TOKEN_NUM_INITIALIZER 16819 (struct cmd_pctype_mapping_update_result, 16820 port_id, UINT16); 16821 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 16822 TOKEN_STRING_INITIALIZER 16823 (struct cmd_pctype_mapping_update_result, 16824 pctype, "pctype"); 16825 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 16826 TOKEN_STRING_INITIALIZER 16827 (struct cmd_pctype_mapping_update_result, 16828 mapping, "mapping"); 16829 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 16830 TOKEN_STRING_INITIALIZER 16831 (struct cmd_pctype_mapping_update_result, 16832 update, "update"); 16833 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 16834 TOKEN_STRING_INITIALIZER 16835 (struct cmd_pctype_mapping_update_result, 16836 pctype_list, NULL); 16837 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 16838 TOKEN_NUM_INITIALIZER 16839 (struct cmd_pctype_mapping_update_result, 16840 flow_type, UINT16); 16841 16842 static void 16843 cmd_pctype_mapping_update_parsed( 16844 void *parsed_result, 16845 __rte_unused struct cmdline *cl, 16846 __rte_unused void *data) 16847 { 16848 struct cmd_pctype_mapping_update_result *res = parsed_result; 16849 int ret = -ENOTSUP; 16850 #ifdef RTE_NET_I40E 16851 struct rte_pmd_i40e_flow_type_mapping mapping; 16852 unsigned int i; 16853 unsigned int nb_item; 16854 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 16855 #endif 16856 16857 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16858 return; 16859 16860 #ifdef RTE_NET_I40E 16861 nb_item = parse_item_list(res->pctype_list, "pctypes", 16862 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 16863 mapping.flow_type = res->flow_type; 16864 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 16865 mapping.pctype |= (1ULL << pctype_list[i]); 16866 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 16867 &mapping, 16868 1, 16869 0); 16870 #endif 16871 16872 switch (ret) { 16873 case 0: 16874 break; 16875 case -EINVAL: 16876 printf("invalid pctype or flow type\n"); 16877 break; 16878 case -ENODEV: 16879 printf("invalid port_id %d\n", res->port_id); 16880 break; 16881 case -ENOTSUP: 16882 printf("function not implemented\n"); 16883 break; 16884 default: 16885 printf("programming error: (%s)\n", strerror(-ret)); 16886 } 16887 } 16888 16889 cmdline_parse_inst_t cmd_pctype_mapping_update = { 16890 .f = cmd_pctype_mapping_update_parsed, 16891 .data = NULL, 16892 .help_str = "port config <port_id> pctype mapping update" 16893 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 16894 .tokens = { 16895 (void *)&cmd_pctype_mapping_update_port, 16896 (void *)&cmd_pctype_mapping_update_config, 16897 (void *)&cmd_pctype_mapping_update_port_id, 16898 (void *)&cmd_pctype_mapping_update_pctype, 16899 (void *)&cmd_pctype_mapping_update_mapping, 16900 (void *)&cmd_pctype_mapping_update_update, 16901 (void *)&cmd_pctype_mapping_update_pc_type, 16902 (void *)&cmd_pctype_mapping_update_flow_type, 16903 NULL, 16904 }, 16905 }; 16906 16907 /* ptype mapping get */ 16908 16909 /* Common result structure for ptype mapping get */ 16910 struct cmd_ptype_mapping_get_result { 16911 cmdline_fixed_string_t ptype; 16912 cmdline_fixed_string_t mapping; 16913 cmdline_fixed_string_t get; 16914 portid_t port_id; 16915 uint8_t valid_only; 16916 }; 16917 16918 /* Common CLI fields for ptype mapping get */ 16919 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 16920 TOKEN_STRING_INITIALIZER 16921 (struct cmd_ptype_mapping_get_result, 16922 ptype, "ptype"); 16923 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 16924 TOKEN_STRING_INITIALIZER 16925 (struct cmd_ptype_mapping_get_result, 16926 mapping, "mapping"); 16927 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 16928 TOKEN_STRING_INITIALIZER 16929 (struct cmd_ptype_mapping_get_result, 16930 get, "get"); 16931 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 16932 TOKEN_NUM_INITIALIZER 16933 (struct cmd_ptype_mapping_get_result, 16934 port_id, UINT16); 16935 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 16936 TOKEN_NUM_INITIALIZER 16937 (struct cmd_ptype_mapping_get_result, 16938 valid_only, UINT8); 16939 16940 static void 16941 cmd_ptype_mapping_get_parsed( 16942 void *parsed_result, 16943 __rte_unused struct cmdline *cl, 16944 __rte_unused void *data) 16945 { 16946 struct cmd_ptype_mapping_get_result *res = parsed_result; 16947 int ret = -ENOTSUP; 16948 #ifdef RTE_NET_I40E 16949 int max_ptype_num = 256; 16950 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 16951 uint16_t count; 16952 int i; 16953 #endif 16954 16955 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16956 return; 16957 16958 #ifdef RTE_NET_I40E 16959 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 16960 mapping, 16961 max_ptype_num, 16962 &count, 16963 res->valid_only); 16964 #endif 16965 16966 switch (ret) { 16967 case 0: 16968 break; 16969 case -ENODEV: 16970 printf("invalid port_id %d\n", res->port_id); 16971 break; 16972 case -ENOTSUP: 16973 printf("function not implemented\n"); 16974 break; 16975 default: 16976 printf("programming error: (%s)\n", strerror(-ret)); 16977 } 16978 16979 #ifdef RTE_NET_I40E 16980 if (!ret) { 16981 for (i = 0; i < count; i++) 16982 printf("%3d\t0x%08x\n", 16983 mapping[i].hw_ptype, mapping[i].sw_ptype); 16984 } 16985 #endif 16986 } 16987 16988 cmdline_parse_inst_t cmd_ptype_mapping_get = { 16989 .f = cmd_ptype_mapping_get_parsed, 16990 .data = NULL, 16991 .help_str = "ptype mapping get <port_id> <valid_only>", 16992 .tokens = { 16993 (void *)&cmd_ptype_mapping_get_ptype, 16994 (void *)&cmd_ptype_mapping_get_mapping, 16995 (void *)&cmd_ptype_mapping_get_get, 16996 (void *)&cmd_ptype_mapping_get_port_id, 16997 (void *)&cmd_ptype_mapping_get_valid_only, 16998 NULL, 16999 }, 17000 }; 17001 17002 /* ptype mapping replace */ 17003 17004 /* Common result structure for ptype mapping replace */ 17005 struct cmd_ptype_mapping_replace_result { 17006 cmdline_fixed_string_t ptype; 17007 cmdline_fixed_string_t mapping; 17008 cmdline_fixed_string_t replace; 17009 portid_t port_id; 17010 uint32_t target; 17011 uint8_t mask; 17012 uint32_t pkt_type; 17013 }; 17014 17015 /* Common CLI fields for ptype mapping replace */ 17016 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 17017 TOKEN_STRING_INITIALIZER 17018 (struct cmd_ptype_mapping_replace_result, 17019 ptype, "ptype"); 17020 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 17021 TOKEN_STRING_INITIALIZER 17022 (struct cmd_ptype_mapping_replace_result, 17023 mapping, "mapping"); 17024 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 17025 TOKEN_STRING_INITIALIZER 17026 (struct cmd_ptype_mapping_replace_result, 17027 replace, "replace"); 17028 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 17029 TOKEN_NUM_INITIALIZER 17030 (struct cmd_ptype_mapping_replace_result, 17031 port_id, UINT16); 17032 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 17033 TOKEN_NUM_INITIALIZER 17034 (struct cmd_ptype_mapping_replace_result, 17035 target, UINT32); 17036 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 17037 TOKEN_NUM_INITIALIZER 17038 (struct cmd_ptype_mapping_replace_result, 17039 mask, UINT8); 17040 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 17041 TOKEN_NUM_INITIALIZER 17042 (struct cmd_ptype_mapping_replace_result, 17043 pkt_type, UINT32); 17044 17045 static void 17046 cmd_ptype_mapping_replace_parsed( 17047 void *parsed_result, 17048 __rte_unused struct cmdline *cl, 17049 __rte_unused void *data) 17050 { 17051 struct cmd_ptype_mapping_replace_result *res = parsed_result; 17052 int ret = -ENOTSUP; 17053 17054 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17055 return; 17056 17057 #ifdef RTE_NET_I40E 17058 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 17059 res->target, 17060 res->mask, 17061 res->pkt_type); 17062 #endif 17063 17064 switch (ret) { 17065 case 0: 17066 break; 17067 case -EINVAL: 17068 printf("invalid ptype 0x%8x or 0x%8x\n", 17069 res->target, res->pkt_type); 17070 break; 17071 case -ENODEV: 17072 printf("invalid port_id %d\n", res->port_id); 17073 break; 17074 case -ENOTSUP: 17075 printf("function not implemented\n"); 17076 break; 17077 default: 17078 printf("programming error: (%s)\n", strerror(-ret)); 17079 } 17080 } 17081 17082 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 17083 .f = cmd_ptype_mapping_replace_parsed, 17084 .data = NULL, 17085 .help_str = 17086 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 17087 .tokens = { 17088 (void *)&cmd_ptype_mapping_replace_ptype, 17089 (void *)&cmd_ptype_mapping_replace_mapping, 17090 (void *)&cmd_ptype_mapping_replace_replace, 17091 (void *)&cmd_ptype_mapping_replace_port_id, 17092 (void *)&cmd_ptype_mapping_replace_target, 17093 (void *)&cmd_ptype_mapping_replace_mask, 17094 (void *)&cmd_ptype_mapping_replace_pkt_type, 17095 NULL, 17096 }, 17097 }; 17098 17099 /* ptype mapping reset */ 17100 17101 /* Common result structure for ptype mapping reset */ 17102 struct cmd_ptype_mapping_reset_result { 17103 cmdline_fixed_string_t ptype; 17104 cmdline_fixed_string_t mapping; 17105 cmdline_fixed_string_t reset; 17106 portid_t port_id; 17107 }; 17108 17109 /* Common CLI fields for ptype mapping reset*/ 17110 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 17111 TOKEN_STRING_INITIALIZER 17112 (struct cmd_ptype_mapping_reset_result, 17113 ptype, "ptype"); 17114 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 17115 TOKEN_STRING_INITIALIZER 17116 (struct cmd_ptype_mapping_reset_result, 17117 mapping, "mapping"); 17118 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 17119 TOKEN_STRING_INITIALIZER 17120 (struct cmd_ptype_mapping_reset_result, 17121 reset, "reset"); 17122 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 17123 TOKEN_NUM_INITIALIZER 17124 (struct cmd_ptype_mapping_reset_result, 17125 port_id, UINT16); 17126 17127 static void 17128 cmd_ptype_mapping_reset_parsed( 17129 void *parsed_result, 17130 __rte_unused struct cmdline *cl, 17131 __rte_unused void *data) 17132 { 17133 struct cmd_ptype_mapping_reset_result *res = parsed_result; 17134 int ret = -ENOTSUP; 17135 17136 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17137 return; 17138 17139 #ifdef RTE_NET_I40E 17140 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 17141 #endif 17142 17143 switch (ret) { 17144 case 0: 17145 break; 17146 case -ENODEV: 17147 printf("invalid port_id %d\n", res->port_id); 17148 break; 17149 case -ENOTSUP: 17150 printf("function not implemented\n"); 17151 break; 17152 default: 17153 printf("programming error: (%s)\n", strerror(-ret)); 17154 } 17155 } 17156 17157 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 17158 .f = cmd_ptype_mapping_reset_parsed, 17159 .data = NULL, 17160 .help_str = "ptype mapping reset <port_id>", 17161 .tokens = { 17162 (void *)&cmd_ptype_mapping_reset_ptype, 17163 (void *)&cmd_ptype_mapping_reset_mapping, 17164 (void *)&cmd_ptype_mapping_reset_reset, 17165 (void *)&cmd_ptype_mapping_reset_port_id, 17166 NULL, 17167 }, 17168 }; 17169 17170 /* ptype mapping update */ 17171 17172 /* Common result structure for ptype mapping update */ 17173 struct cmd_ptype_mapping_update_result { 17174 cmdline_fixed_string_t ptype; 17175 cmdline_fixed_string_t mapping; 17176 cmdline_fixed_string_t reset; 17177 portid_t port_id; 17178 uint8_t hw_ptype; 17179 uint32_t sw_ptype; 17180 }; 17181 17182 /* Common CLI fields for ptype mapping update*/ 17183 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 17184 TOKEN_STRING_INITIALIZER 17185 (struct cmd_ptype_mapping_update_result, 17186 ptype, "ptype"); 17187 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 17188 TOKEN_STRING_INITIALIZER 17189 (struct cmd_ptype_mapping_update_result, 17190 mapping, "mapping"); 17191 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 17192 TOKEN_STRING_INITIALIZER 17193 (struct cmd_ptype_mapping_update_result, 17194 reset, "update"); 17195 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 17196 TOKEN_NUM_INITIALIZER 17197 (struct cmd_ptype_mapping_update_result, 17198 port_id, UINT16); 17199 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 17200 TOKEN_NUM_INITIALIZER 17201 (struct cmd_ptype_mapping_update_result, 17202 hw_ptype, UINT8); 17203 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 17204 TOKEN_NUM_INITIALIZER 17205 (struct cmd_ptype_mapping_update_result, 17206 sw_ptype, UINT32); 17207 17208 static void 17209 cmd_ptype_mapping_update_parsed( 17210 void *parsed_result, 17211 __rte_unused struct cmdline *cl, 17212 __rte_unused void *data) 17213 { 17214 struct cmd_ptype_mapping_update_result *res = parsed_result; 17215 int ret = -ENOTSUP; 17216 #ifdef RTE_NET_I40E 17217 struct rte_pmd_i40e_ptype_mapping mapping; 17218 #endif 17219 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17220 return; 17221 17222 #ifdef RTE_NET_I40E 17223 mapping.hw_ptype = res->hw_ptype; 17224 mapping.sw_ptype = res->sw_ptype; 17225 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 17226 &mapping, 17227 1, 17228 0); 17229 #endif 17230 17231 switch (ret) { 17232 case 0: 17233 break; 17234 case -EINVAL: 17235 printf("invalid ptype 0x%8x\n", res->sw_ptype); 17236 break; 17237 case -ENODEV: 17238 printf("invalid port_id %d\n", res->port_id); 17239 break; 17240 case -ENOTSUP: 17241 printf("function not implemented\n"); 17242 break; 17243 default: 17244 printf("programming error: (%s)\n", strerror(-ret)); 17245 } 17246 } 17247 17248 cmdline_parse_inst_t cmd_ptype_mapping_update = { 17249 .f = cmd_ptype_mapping_update_parsed, 17250 .data = NULL, 17251 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 17252 .tokens = { 17253 (void *)&cmd_ptype_mapping_update_ptype, 17254 (void *)&cmd_ptype_mapping_update_mapping, 17255 (void *)&cmd_ptype_mapping_update_update, 17256 (void *)&cmd_ptype_mapping_update_port_id, 17257 (void *)&cmd_ptype_mapping_update_hw_ptype, 17258 (void *)&cmd_ptype_mapping_update_sw_ptype, 17259 NULL, 17260 }, 17261 }; 17262 17263 /* Common result structure for file commands */ 17264 struct cmd_cmdfile_result { 17265 cmdline_fixed_string_t load; 17266 cmdline_fixed_string_t filename; 17267 }; 17268 17269 /* Common CLI fields for file commands */ 17270 cmdline_parse_token_string_t cmd_load_cmdfile = 17271 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 17272 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 17273 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 17274 17275 static void 17276 cmd_load_from_file_parsed( 17277 void *parsed_result, 17278 __rte_unused struct cmdline *cl, 17279 __rte_unused void *data) 17280 { 17281 struct cmd_cmdfile_result *res = parsed_result; 17282 17283 cmdline_read_from_file(res->filename); 17284 } 17285 17286 cmdline_parse_inst_t cmd_load_from_file = { 17287 .f = cmd_load_from_file_parsed, 17288 .data = NULL, 17289 .help_str = "load <filename>", 17290 .tokens = { 17291 (void *)&cmd_load_cmdfile, 17292 (void *)&cmd_load_cmdfile_filename, 17293 NULL, 17294 }, 17295 }; 17296 17297 /* Get Rx offloads capabilities */ 17298 struct cmd_rx_offload_get_capa_result { 17299 cmdline_fixed_string_t show; 17300 cmdline_fixed_string_t port; 17301 portid_t port_id; 17302 cmdline_fixed_string_t rx_offload; 17303 cmdline_fixed_string_t capabilities; 17304 }; 17305 17306 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 17307 TOKEN_STRING_INITIALIZER 17308 (struct cmd_rx_offload_get_capa_result, 17309 show, "show"); 17310 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 17311 TOKEN_STRING_INITIALIZER 17312 (struct cmd_rx_offload_get_capa_result, 17313 port, "port"); 17314 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 17315 TOKEN_NUM_INITIALIZER 17316 (struct cmd_rx_offload_get_capa_result, 17317 port_id, UINT16); 17318 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 17319 TOKEN_STRING_INITIALIZER 17320 (struct cmd_rx_offload_get_capa_result, 17321 rx_offload, "rx_offload"); 17322 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 17323 TOKEN_STRING_INITIALIZER 17324 (struct cmd_rx_offload_get_capa_result, 17325 capabilities, "capabilities"); 17326 17327 static void 17328 print_rx_offloads(uint64_t offloads) 17329 { 17330 uint64_t single_offload; 17331 int begin; 17332 int end; 17333 int bit; 17334 17335 if (offloads == 0) 17336 return; 17337 17338 begin = __builtin_ctzll(offloads); 17339 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 17340 17341 single_offload = 1ULL << begin; 17342 for (bit = begin; bit < end; bit++) { 17343 if (offloads & single_offload) 17344 printf(" %s", 17345 rte_eth_dev_rx_offload_name(single_offload)); 17346 single_offload <<= 1; 17347 } 17348 } 17349 17350 static void 17351 cmd_rx_offload_get_capa_parsed( 17352 void *parsed_result, 17353 __rte_unused struct cmdline *cl, 17354 __rte_unused void *data) 17355 { 17356 struct cmd_rx_offload_get_capa_result *res = parsed_result; 17357 struct rte_eth_dev_info dev_info; 17358 portid_t port_id = res->port_id; 17359 uint64_t queue_offloads; 17360 uint64_t port_offloads; 17361 int ret; 17362 17363 ret = eth_dev_info_get_print_err(port_id, &dev_info); 17364 if (ret != 0) 17365 return; 17366 17367 queue_offloads = dev_info.rx_queue_offload_capa; 17368 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 17369 17370 printf("Rx Offloading Capabilities of port %d :\n", port_id); 17371 printf(" Per Queue :"); 17372 print_rx_offloads(queue_offloads); 17373 17374 printf("\n"); 17375 printf(" Per Port :"); 17376 print_rx_offloads(port_offloads); 17377 printf("\n\n"); 17378 } 17379 17380 cmdline_parse_inst_t cmd_rx_offload_get_capa = { 17381 .f = cmd_rx_offload_get_capa_parsed, 17382 .data = NULL, 17383 .help_str = "show port <port_id> rx_offload capabilities", 17384 .tokens = { 17385 (void *)&cmd_rx_offload_get_capa_show, 17386 (void *)&cmd_rx_offload_get_capa_port, 17387 (void *)&cmd_rx_offload_get_capa_port_id, 17388 (void *)&cmd_rx_offload_get_capa_rx_offload, 17389 (void *)&cmd_rx_offload_get_capa_capabilities, 17390 NULL, 17391 } 17392 }; 17393 17394 /* Get Rx offloads configuration */ 17395 struct cmd_rx_offload_get_configuration_result { 17396 cmdline_fixed_string_t show; 17397 cmdline_fixed_string_t port; 17398 portid_t port_id; 17399 cmdline_fixed_string_t rx_offload; 17400 cmdline_fixed_string_t configuration; 17401 }; 17402 17403 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 17404 TOKEN_STRING_INITIALIZER 17405 (struct cmd_rx_offload_get_configuration_result, 17406 show, "show"); 17407 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 17408 TOKEN_STRING_INITIALIZER 17409 (struct cmd_rx_offload_get_configuration_result, 17410 port, "port"); 17411 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 17412 TOKEN_NUM_INITIALIZER 17413 (struct cmd_rx_offload_get_configuration_result, 17414 port_id, UINT16); 17415 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 17416 TOKEN_STRING_INITIALIZER 17417 (struct cmd_rx_offload_get_configuration_result, 17418 rx_offload, "rx_offload"); 17419 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 17420 TOKEN_STRING_INITIALIZER 17421 (struct cmd_rx_offload_get_configuration_result, 17422 configuration, "configuration"); 17423 17424 static void 17425 cmd_rx_offload_get_configuration_parsed( 17426 void *parsed_result, 17427 __rte_unused struct cmdline *cl, 17428 __rte_unused void *data) 17429 { 17430 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 17431 struct rte_eth_dev_info dev_info; 17432 portid_t port_id = res->port_id; 17433 struct rte_port *port = &ports[port_id]; 17434 uint64_t port_offloads; 17435 uint64_t queue_offloads; 17436 uint16_t nb_rx_queues; 17437 int q; 17438 int ret; 17439 17440 printf("Rx Offloading Configuration of port %d :\n", port_id); 17441 17442 port_offloads = port->dev_conf.rxmode.offloads; 17443 printf(" Port :"); 17444 print_rx_offloads(port_offloads); 17445 printf("\n"); 17446 17447 ret = eth_dev_info_get_print_err(port_id, &dev_info); 17448 if (ret != 0) 17449 return; 17450 17451 nb_rx_queues = dev_info.nb_rx_queues; 17452 for (q = 0; q < nb_rx_queues; q++) { 17453 queue_offloads = port->rx_conf[q].offloads; 17454 printf(" Queue[%2d] :", q); 17455 print_rx_offloads(queue_offloads); 17456 printf("\n"); 17457 } 17458 printf("\n"); 17459 } 17460 17461 cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 17462 .f = cmd_rx_offload_get_configuration_parsed, 17463 .data = NULL, 17464 .help_str = "show port <port_id> rx_offload configuration", 17465 .tokens = { 17466 (void *)&cmd_rx_offload_get_configuration_show, 17467 (void *)&cmd_rx_offload_get_configuration_port, 17468 (void *)&cmd_rx_offload_get_configuration_port_id, 17469 (void *)&cmd_rx_offload_get_configuration_rx_offload, 17470 (void *)&cmd_rx_offload_get_configuration_configuration, 17471 NULL, 17472 } 17473 }; 17474 17475 /* Enable/Disable a per port offloading */ 17476 struct cmd_config_per_port_rx_offload_result { 17477 cmdline_fixed_string_t port; 17478 cmdline_fixed_string_t config; 17479 portid_t port_id; 17480 cmdline_fixed_string_t rx_offload; 17481 cmdline_fixed_string_t offload; 17482 cmdline_fixed_string_t on_off; 17483 }; 17484 17485 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 17486 TOKEN_STRING_INITIALIZER 17487 (struct cmd_config_per_port_rx_offload_result, 17488 port, "port"); 17489 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 17490 TOKEN_STRING_INITIALIZER 17491 (struct cmd_config_per_port_rx_offload_result, 17492 config, "config"); 17493 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 17494 TOKEN_NUM_INITIALIZER 17495 (struct cmd_config_per_port_rx_offload_result, 17496 port_id, UINT16); 17497 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 17498 TOKEN_STRING_INITIALIZER 17499 (struct cmd_config_per_port_rx_offload_result, 17500 rx_offload, "rx_offload"); 17501 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 17502 TOKEN_STRING_INITIALIZER 17503 (struct cmd_config_per_port_rx_offload_result, 17504 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 17505 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 17506 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 17507 "scatter#buffer_split#timestamp#security#" 17508 "keep_crc#rss_hash"); 17509 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 17510 TOKEN_STRING_INITIALIZER 17511 (struct cmd_config_per_port_rx_offload_result, 17512 on_off, "on#off"); 17513 17514 static uint64_t 17515 search_rx_offload(const char *name) 17516 { 17517 uint64_t single_offload; 17518 const char *single_name; 17519 int found = 0; 17520 unsigned int bit; 17521 17522 single_offload = 1; 17523 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 17524 single_name = rte_eth_dev_rx_offload_name(single_offload); 17525 if (!strcasecmp(single_name, name)) { 17526 found = 1; 17527 break; 17528 } 17529 single_offload <<= 1; 17530 } 17531 17532 if (found) 17533 return single_offload; 17534 17535 return 0; 17536 } 17537 17538 static void 17539 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 17540 __rte_unused struct cmdline *cl, 17541 __rte_unused void *data) 17542 { 17543 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 17544 portid_t port_id = res->port_id; 17545 struct rte_eth_dev_info dev_info; 17546 struct rte_port *port = &ports[port_id]; 17547 uint64_t single_offload; 17548 uint16_t nb_rx_queues; 17549 int q; 17550 int ret; 17551 17552 if (port->port_status != RTE_PORT_STOPPED) { 17553 printf("Error: Can't config offload when Port %d " 17554 "is not stopped\n", port_id); 17555 return; 17556 } 17557 17558 single_offload = search_rx_offload(res->offload); 17559 if (single_offload == 0) { 17560 printf("Unknown offload name: %s\n", res->offload); 17561 return; 17562 } 17563 17564 ret = eth_dev_info_get_print_err(port_id, &dev_info); 17565 if (ret != 0) 17566 return; 17567 17568 nb_rx_queues = dev_info.nb_rx_queues; 17569 if (!strcmp(res->on_off, "on")) { 17570 port->dev_conf.rxmode.offloads |= single_offload; 17571 for (q = 0; q < nb_rx_queues; q++) 17572 port->rx_conf[q].offloads |= single_offload; 17573 } else { 17574 port->dev_conf.rxmode.offloads &= ~single_offload; 17575 for (q = 0; q < nb_rx_queues; q++) 17576 port->rx_conf[q].offloads &= ~single_offload; 17577 } 17578 17579 cmd_reconfig_device_queue(port_id, 1, 1); 17580 } 17581 17582 cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 17583 .f = cmd_config_per_port_rx_offload_parsed, 17584 .data = NULL, 17585 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 17586 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 17587 "macsec_strip|header_split|vlan_filter|vlan_extend|" 17588 "jumbo_frame|scatter|buffer_split|timestamp|security|" 17589 "keep_crc|rss_hash on|off", 17590 .tokens = { 17591 (void *)&cmd_config_per_port_rx_offload_result_port, 17592 (void *)&cmd_config_per_port_rx_offload_result_config, 17593 (void *)&cmd_config_per_port_rx_offload_result_port_id, 17594 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 17595 (void *)&cmd_config_per_port_rx_offload_result_offload, 17596 (void *)&cmd_config_per_port_rx_offload_result_on_off, 17597 NULL, 17598 } 17599 }; 17600 17601 /* Enable/Disable a per queue offloading */ 17602 struct cmd_config_per_queue_rx_offload_result { 17603 cmdline_fixed_string_t port; 17604 portid_t port_id; 17605 cmdline_fixed_string_t rxq; 17606 uint16_t queue_id; 17607 cmdline_fixed_string_t rx_offload; 17608 cmdline_fixed_string_t offload; 17609 cmdline_fixed_string_t on_off; 17610 }; 17611 17612 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 17613 TOKEN_STRING_INITIALIZER 17614 (struct cmd_config_per_queue_rx_offload_result, 17615 port, "port"); 17616 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 17617 TOKEN_NUM_INITIALIZER 17618 (struct cmd_config_per_queue_rx_offload_result, 17619 port_id, UINT16); 17620 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 17621 TOKEN_STRING_INITIALIZER 17622 (struct cmd_config_per_queue_rx_offload_result, 17623 rxq, "rxq"); 17624 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 17625 TOKEN_NUM_INITIALIZER 17626 (struct cmd_config_per_queue_rx_offload_result, 17627 queue_id, UINT16); 17628 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 17629 TOKEN_STRING_INITIALIZER 17630 (struct cmd_config_per_queue_rx_offload_result, 17631 rx_offload, "rx_offload"); 17632 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 17633 TOKEN_STRING_INITIALIZER 17634 (struct cmd_config_per_queue_rx_offload_result, 17635 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 17636 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 17637 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 17638 "scatter#buffer_split#timestamp#security#keep_crc"); 17639 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 17640 TOKEN_STRING_INITIALIZER 17641 (struct cmd_config_per_queue_rx_offload_result, 17642 on_off, "on#off"); 17643 17644 static void 17645 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 17646 __rte_unused struct cmdline *cl, 17647 __rte_unused void *data) 17648 { 17649 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 17650 struct rte_eth_dev_info dev_info; 17651 portid_t port_id = res->port_id; 17652 uint16_t queue_id = res->queue_id; 17653 struct rte_port *port = &ports[port_id]; 17654 uint64_t single_offload; 17655 int ret; 17656 17657 if (port->port_status != RTE_PORT_STOPPED) { 17658 printf("Error: Can't config offload when Port %d " 17659 "is not stopped\n", port_id); 17660 return; 17661 } 17662 17663 ret = eth_dev_info_get_print_err(port_id, &dev_info); 17664 if (ret != 0) 17665 return; 17666 17667 if (queue_id >= dev_info.nb_rx_queues) { 17668 printf("Error: input queue_id should be 0 ... " 17669 "%d\n", dev_info.nb_rx_queues - 1); 17670 return; 17671 } 17672 17673 single_offload = search_rx_offload(res->offload); 17674 if (single_offload == 0) { 17675 printf("Unknown offload name: %s\n", res->offload); 17676 return; 17677 } 17678 17679 if (!strcmp(res->on_off, "on")) 17680 port->rx_conf[queue_id].offloads |= single_offload; 17681 else 17682 port->rx_conf[queue_id].offloads &= ~single_offload; 17683 17684 cmd_reconfig_device_queue(port_id, 1, 1); 17685 } 17686 17687 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 17688 .f = cmd_config_per_queue_rx_offload_parsed, 17689 .data = NULL, 17690 .help_str = "port <port_id> rxq <queue_id> rx_offload " 17691 "vlan_strip|ipv4_cksum|" 17692 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 17693 "macsec_strip|header_split|vlan_filter|vlan_extend|" 17694 "jumbo_frame|scatter|buffer_split|timestamp|security|" 17695 "keep_crc on|off", 17696 .tokens = { 17697 (void *)&cmd_config_per_queue_rx_offload_result_port, 17698 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 17699 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 17700 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 17701 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 17702 (void *)&cmd_config_per_queue_rx_offload_result_offload, 17703 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 17704 NULL, 17705 } 17706 }; 17707 17708 /* Get Tx offloads capabilities */ 17709 struct cmd_tx_offload_get_capa_result { 17710 cmdline_fixed_string_t show; 17711 cmdline_fixed_string_t port; 17712 portid_t port_id; 17713 cmdline_fixed_string_t tx_offload; 17714 cmdline_fixed_string_t capabilities; 17715 }; 17716 17717 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 17718 TOKEN_STRING_INITIALIZER 17719 (struct cmd_tx_offload_get_capa_result, 17720 show, "show"); 17721 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 17722 TOKEN_STRING_INITIALIZER 17723 (struct cmd_tx_offload_get_capa_result, 17724 port, "port"); 17725 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 17726 TOKEN_NUM_INITIALIZER 17727 (struct cmd_tx_offload_get_capa_result, 17728 port_id, UINT16); 17729 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 17730 TOKEN_STRING_INITIALIZER 17731 (struct cmd_tx_offload_get_capa_result, 17732 tx_offload, "tx_offload"); 17733 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 17734 TOKEN_STRING_INITIALIZER 17735 (struct cmd_tx_offload_get_capa_result, 17736 capabilities, "capabilities"); 17737 17738 static void 17739 print_tx_offloads(uint64_t offloads) 17740 { 17741 uint64_t single_offload; 17742 int begin; 17743 int end; 17744 int bit; 17745 17746 if (offloads == 0) 17747 return; 17748 17749 begin = __builtin_ctzll(offloads); 17750 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 17751 17752 single_offload = 1ULL << begin; 17753 for (bit = begin; bit < end; bit++) { 17754 if (offloads & single_offload) 17755 printf(" %s", 17756 rte_eth_dev_tx_offload_name(single_offload)); 17757 single_offload <<= 1; 17758 } 17759 } 17760 17761 static void 17762 cmd_tx_offload_get_capa_parsed( 17763 void *parsed_result, 17764 __rte_unused struct cmdline *cl, 17765 __rte_unused void *data) 17766 { 17767 struct cmd_tx_offload_get_capa_result *res = parsed_result; 17768 struct rte_eth_dev_info dev_info; 17769 portid_t port_id = res->port_id; 17770 uint64_t queue_offloads; 17771 uint64_t port_offloads; 17772 int ret; 17773 17774 ret = eth_dev_info_get_print_err(port_id, &dev_info); 17775 if (ret != 0) 17776 return; 17777 17778 queue_offloads = dev_info.tx_queue_offload_capa; 17779 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 17780 17781 printf("Tx Offloading Capabilities of port %d :\n", port_id); 17782 printf(" Per Queue :"); 17783 print_tx_offloads(queue_offloads); 17784 17785 printf("\n"); 17786 printf(" Per Port :"); 17787 print_tx_offloads(port_offloads); 17788 printf("\n\n"); 17789 } 17790 17791 cmdline_parse_inst_t cmd_tx_offload_get_capa = { 17792 .f = cmd_tx_offload_get_capa_parsed, 17793 .data = NULL, 17794 .help_str = "show port <port_id> tx_offload capabilities", 17795 .tokens = { 17796 (void *)&cmd_tx_offload_get_capa_show, 17797 (void *)&cmd_tx_offload_get_capa_port, 17798 (void *)&cmd_tx_offload_get_capa_port_id, 17799 (void *)&cmd_tx_offload_get_capa_tx_offload, 17800 (void *)&cmd_tx_offload_get_capa_capabilities, 17801 NULL, 17802 } 17803 }; 17804 17805 /* Get Tx offloads configuration */ 17806 struct cmd_tx_offload_get_configuration_result { 17807 cmdline_fixed_string_t show; 17808 cmdline_fixed_string_t port; 17809 portid_t port_id; 17810 cmdline_fixed_string_t tx_offload; 17811 cmdline_fixed_string_t configuration; 17812 }; 17813 17814 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 17815 TOKEN_STRING_INITIALIZER 17816 (struct cmd_tx_offload_get_configuration_result, 17817 show, "show"); 17818 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 17819 TOKEN_STRING_INITIALIZER 17820 (struct cmd_tx_offload_get_configuration_result, 17821 port, "port"); 17822 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 17823 TOKEN_NUM_INITIALIZER 17824 (struct cmd_tx_offload_get_configuration_result, 17825 port_id, UINT16); 17826 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 17827 TOKEN_STRING_INITIALIZER 17828 (struct cmd_tx_offload_get_configuration_result, 17829 tx_offload, "tx_offload"); 17830 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 17831 TOKEN_STRING_INITIALIZER 17832 (struct cmd_tx_offload_get_configuration_result, 17833 configuration, "configuration"); 17834 17835 static void 17836 cmd_tx_offload_get_configuration_parsed( 17837 void *parsed_result, 17838 __rte_unused struct cmdline *cl, 17839 __rte_unused void *data) 17840 { 17841 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 17842 struct rte_eth_dev_info dev_info; 17843 portid_t port_id = res->port_id; 17844 struct rte_port *port = &ports[port_id]; 17845 uint64_t port_offloads; 17846 uint64_t queue_offloads; 17847 uint16_t nb_tx_queues; 17848 int q; 17849 int ret; 17850 17851 printf("Tx Offloading Configuration of port %d :\n", port_id); 17852 17853 port_offloads = port->dev_conf.txmode.offloads; 17854 printf(" Port :"); 17855 print_tx_offloads(port_offloads); 17856 printf("\n"); 17857 17858 ret = eth_dev_info_get_print_err(port_id, &dev_info); 17859 if (ret != 0) 17860 return; 17861 17862 nb_tx_queues = dev_info.nb_tx_queues; 17863 for (q = 0; q < nb_tx_queues; q++) { 17864 queue_offloads = port->tx_conf[q].offloads; 17865 printf(" Queue[%2d] :", q); 17866 print_tx_offloads(queue_offloads); 17867 printf("\n"); 17868 } 17869 printf("\n"); 17870 } 17871 17872 cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 17873 .f = cmd_tx_offload_get_configuration_parsed, 17874 .data = NULL, 17875 .help_str = "show port <port_id> tx_offload configuration", 17876 .tokens = { 17877 (void *)&cmd_tx_offload_get_configuration_show, 17878 (void *)&cmd_tx_offload_get_configuration_port, 17879 (void *)&cmd_tx_offload_get_configuration_port_id, 17880 (void *)&cmd_tx_offload_get_configuration_tx_offload, 17881 (void *)&cmd_tx_offload_get_configuration_configuration, 17882 NULL, 17883 } 17884 }; 17885 17886 /* Enable/Disable a per port offloading */ 17887 struct cmd_config_per_port_tx_offload_result { 17888 cmdline_fixed_string_t port; 17889 cmdline_fixed_string_t config; 17890 portid_t port_id; 17891 cmdline_fixed_string_t tx_offload; 17892 cmdline_fixed_string_t offload; 17893 cmdline_fixed_string_t on_off; 17894 }; 17895 17896 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 17897 TOKEN_STRING_INITIALIZER 17898 (struct cmd_config_per_port_tx_offload_result, 17899 port, "port"); 17900 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 17901 TOKEN_STRING_INITIALIZER 17902 (struct cmd_config_per_port_tx_offload_result, 17903 config, "config"); 17904 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 17905 TOKEN_NUM_INITIALIZER 17906 (struct cmd_config_per_port_tx_offload_result, 17907 port_id, UINT16); 17908 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 17909 TOKEN_STRING_INITIALIZER 17910 (struct cmd_config_per_port_tx_offload_result, 17911 tx_offload, "tx_offload"); 17912 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 17913 TOKEN_STRING_INITIALIZER 17914 (struct cmd_config_per_port_tx_offload_result, 17915 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 17916 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 17917 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 17918 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 17919 "mt_lockfree#multi_segs#mbuf_fast_free#security#" 17920 "send_on_timestamp"); 17921 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = 17922 TOKEN_STRING_INITIALIZER 17923 (struct cmd_config_per_port_tx_offload_result, 17924 on_off, "on#off"); 17925 17926 static uint64_t 17927 search_tx_offload(const char *name) 17928 { 17929 uint64_t single_offload; 17930 const char *single_name; 17931 int found = 0; 17932 unsigned int bit; 17933 17934 single_offload = 1; 17935 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 17936 single_name = rte_eth_dev_tx_offload_name(single_offload); 17937 if (single_name == NULL) 17938 break; 17939 if (!strcasecmp(single_name, name)) { 17940 found = 1; 17941 break; 17942 } else if (!strcasecmp(single_name, "UNKNOWN")) 17943 break; 17944 single_offload <<= 1; 17945 } 17946 17947 if (found) 17948 return single_offload; 17949 17950 return 0; 17951 } 17952 17953 static void 17954 cmd_config_per_port_tx_offload_parsed(void *parsed_result, 17955 __rte_unused struct cmdline *cl, 17956 __rte_unused void *data) 17957 { 17958 struct cmd_config_per_port_tx_offload_result *res = parsed_result; 17959 portid_t port_id = res->port_id; 17960 struct rte_eth_dev_info dev_info; 17961 struct rte_port *port = &ports[port_id]; 17962 uint64_t single_offload; 17963 uint16_t nb_tx_queues; 17964 int q; 17965 int ret; 17966 17967 if (port->port_status != RTE_PORT_STOPPED) { 17968 printf("Error: Can't config offload when Port %d " 17969 "is not stopped\n", port_id); 17970 return; 17971 } 17972 17973 single_offload = search_tx_offload(res->offload); 17974 if (single_offload == 0) { 17975 printf("Unknown offload name: %s\n", res->offload); 17976 return; 17977 } 17978 17979 ret = eth_dev_info_get_print_err(port_id, &dev_info); 17980 if (ret != 0) 17981 return; 17982 17983 nb_tx_queues = dev_info.nb_tx_queues; 17984 if (!strcmp(res->on_off, "on")) { 17985 port->dev_conf.txmode.offloads |= single_offload; 17986 for (q = 0; q < nb_tx_queues; q++) 17987 port->tx_conf[q].offloads |= single_offload; 17988 } else { 17989 port->dev_conf.txmode.offloads &= ~single_offload; 17990 for (q = 0; q < nb_tx_queues; q++) 17991 port->tx_conf[q].offloads &= ~single_offload; 17992 } 17993 17994 cmd_reconfig_device_queue(port_id, 1, 1); 17995 } 17996 17997 cmdline_parse_inst_t cmd_config_per_port_tx_offload = { 17998 .f = cmd_config_per_port_tx_offload_parsed, 17999 .data = NULL, 18000 .help_str = "port config <port_id> tx_offload " 18001 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18002 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18003 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18004 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18005 "mt_lockfree|multi_segs|mbuf_fast_free|security|" 18006 "send_on_timestamp on|off", 18007 .tokens = { 18008 (void *)&cmd_config_per_port_tx_offload_result_port, 18009 (void *)&cmd_config_per_port_tx_offload_result_config, 18010 (void *)&cmd_config_per_port_tx_offload_result_port_id, 18011 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 18012 (void *)&cmd_config_per_port_tx_offload_result_offload, 18013 (void *)&cmd_config_per_port_tx_offload_result_on_off, 18014 NULL, 18015 } 18016 }; 18017 18018 /* Enable/Disable a per queue offloading */ 18019 struct cmd_config_per_queue_tx_offload_result { 18020 cmdline_fixed_string_t port; 18021 portid_t port_id; 18022 cmdline_fixed_string_t txq; 18023 uint16_t queue_id; 18024 cmdline_fixed_string_t tx_offload; 18025 cmdline_fixed_string_t offload; 18026 cmdline_fixed_string_t on_off; 18027 }; 18028 18029 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 18030 TOKEN_STRING_INITIALIZER 18031 (struct cmd_config_per_queue_tx_offload_result, 18032 port, "port"); 18033 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 18034 TOKEN_NUM_INITIALIZER 18035 (struct cmd_config_per_queue_tx_offload_result, 18036 port_id, UINT16); 18037 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 18038 TOKEN_STRING_INITIALIZER 18039 (struct cmd_config_per_queue_tx_offload_result, 18040 txq, "txq"); 18041 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 18042 TOKEN_NUM_INITIALIZER 18043 (struct cmd_config_per_queue_tx_offload_result, 18044 queue_id, UINT16); 18045 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 18046 TOKEN_STRING_INITIALIZER 18047 (struct cmd_config_per_queue_tx_offload_result, 18048 tx_offload, "tx_offload"); 18049 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 18050 TOKEN_STRING_INITIALIZER 18051 (struct cmd_config_per_queue_tx_offload_result, 18052 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18053 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18054 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18055 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18056 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 18057 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 18058 TOKEN_STRING_INITIALIZER 18059 (struct cmd_config_per_queue_tx_offload_result, 18060 on_off, "on#off"); 18061 18062 static void 18063 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 18064 __rte_unused struct cmdline *cl, 18065 __rte_unused void *data) 18066 { 18067 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 18068 struct rte_eth_dev_info dev_info; 18069 portid_t port_id = res->port_id; 18070 uint16_t queue_id = res->queue_id; 18071 struct rte_port *port = &ports[port_id]; 18072 uint64_t single_offload; 18073 int ret; 18074 18075 if (port->port_status != RTE_PORT_STOPPED) { 18076 printf("Error: Can't config offload when Port %d " 18077 "is not stopped\n", port_id); 18078 return; 18079 } 18080 18081 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18082 if (ret != 0) 18083 return; 18084 18085 if (queue_id >= dev_info.nb_tx_queues) { 18086 printf("Error: input queue_id should be 0 ... " 18087 "%d\n", dev_info.nb_tx_queues - 1); 18088 return; 18089 } 18090 18091 single_offload = search_tx_offload(res->offload); 18092 if (single_offload == 0) { 18093 printf("Unknown offload name: %s\n", res->offload); 18094 return; 18095 } 18096 18097 if (!strcmp(res->on_off, "on")) 18098 port->tx_conf[queue_id].offloads |= single_offload; 18099 else 18100 port->tx_conf[queue_id].offloads &= ~single_offload; 18101 18102 cmd_reconfig_device_queue(port_id, 1, 1); 18103 } 18104 18105 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 18106 .f = cmd_config_per_queue_tx_offload_parsed, 18107 .data = NULL, 18108 .help_str = "port <port_id> txq <queue_id> tx_offload " 18109 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18110 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18111 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18112 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18113 "mt_lockfree|multi_segs|mbuf_fast_free|security " 18114 "on|off", 18115 .tokens = { 18116 (void *)&cmd_config_per_queue_tx_offload_result_port, 18117 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 18118 (void *)&cmd_config_per_queue_tx_offload_result_txq, 18119 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 18120 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 18121 (void *)&cmd_config_per_queue_tx_offload_result_offload, 18122 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 18123 NULL, 18124 } 18125 }; 18126 18127 /* *** configure tx_metadata for specific port *** */ 18128 struct cmd_config_tx_metadata_specific_result { 18129 cmdline_fixed_string_t port; 18130 cmdline_fixed_string_t keyword; 18131 uint16_t port_id; 18132 cmdline_fixed_string_t item; 18133 uint32_t value; 18134 }; 18135 18136 static void 18137 cmd_config_tx_metadata_specific_parsed(void *parsed_result, 18138 __rte_unused struct cmdline *cl, 18139 __rte_unused void *data) 18140 { 18141 struct cmd_config_tx_metadata_specific_result *res = parsed_result; 18142 18143 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 18144 return; 18145 ports[res->port_id].tx_metadata = res->value; 18146 /* Add/remove callback to insert valid metadata in every Tx packet. */ 18147 if (ports[res->port_id].tx_metadata) 18148 add_tx_md_callback(res->port_id); 18149 else 18150 remove_tx_md_callback(res->port_id); 18151 rte_flow_dynf_metadata_register(); 18152 } 18153 18154 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = 18155 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18156 port, "port"); 18157 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = 18158 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18159 keyword, "config"); 18160 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = 18161 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18162 port_id, UINT16); 18163 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = 18164 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18165 item, "tx_metadata"); 18166 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = 18167 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18168 value, UINT32); 18169 18170 cmdline_parse_inst_t cmd_config_tx_metadata_specific = { 18171 .f = cmd_config_tx_metadata_specific_parsed, 18172 .data = NULL, 18173 .help_str = "port config <port_id> tx_metadata <value>", 18174 .tokens = { 18175 (void *)&cmd_config_tx_metadata_specific_port, 18176 (void *)&cmd_config_tx_metadata_specific_keyword, 18177 (void *)&cmd_config_tx_metadata_specific_id, 18178 (void *)&cmd_config_tx_metadata_specific_item, 18179 (void *)&cmd_config_tx_metadata_specific_value, 18180 NULL, 18181 }, 18182 }; 18183 18184 /* *** set dynf *** */ 18185 struct cmd_config_tx_dynf_specific_result { 18186 cmdline_fixed_string_t port; 18187 cmdline_fixed_string_t keyword; 18188 uint16_t port_id; 18189 cmdline_fixed_string_t item; 18190 cmdline_fixed_string_t name; 18191 cmdline_fixed_string_t value; 18192 }; 18193 18194 static void 18195 cmd_config_dynf_specific_parsed(void *parsed_result, 18196 __rte_unused struct cmdline *cl, 18197 __rte_unused void *data) 18198 { 18199 struct cmd_config_tx_dynf_specific_result *res = parsed_result; 18200 struct rte_mbuf_dynflag desc_flag; 18201 int flag; 18202 uint64_t old_port_flags; 18203 18204 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 18205 return; 18206 flag = rte_mbuf_dynflag_lookup(res->name, NULL); 18207 if (flag <= 0) { 18208 if (strlcpy(desc_flag.name, res->name, 18209 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) { 18210 printf("Flag name too long\n"); 18211 return; 18212 } 18213 desc_flag.flags = 0; 18214 flag = rte_mbuf_dynflag_register(&desc_flag); 18215 if (flag < 0) { 18216 printf("Can't register flag\n"); 18217 return; 18218 } 18219 strcpy(dynf_names[flag], desc_flag.name); 18220 } 18221 old_port_flags = ports[res->port_id].mbuf_dynf; 18222 if (!strcmp(res->value, "set")) { 18223 ports[res->port_id].mbuf_dynf |= 1UL << flag; 18224 if (old_port_flags == 0) 18225 add_tx_dynf_callback(res->port_id); 18226 } else { 18227 ports[res->port_id].mbuf_dynf &= ~(1UL << flag); 18228 if (ports[res->port_id].mbuf_dynf == 0) 18229 remove_tx_dynf_callback(res->port_id); 18230 } 18231 } 18232 18233 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port = 18234 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 18235 keyword, "port"); 18236 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword = 18237 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 18238 keyword, "config"); 18239 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id = 18240 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 18241 port_id, UINT16); 18242 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item = 18243 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 18244 item, "dynf"); 18245 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name = 18246 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 18247 name, NULL); 18248 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value = 18249 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 18250 value, "set#clear"); 18251 18252 cmdline_parse_inst_t cmd_config_tx_dynf_specific = { 18253 .f = cmd_config_dynf_specific_parsed, 18254 .data = NULL, 18255 .help_str = "port config <port id> dynf <name> set|clear", 18256 .tokens = { 18257 (void *)&cmd_config_tx_dynf_specific_port, 18258 (void *)&cmd_config_tx_dynf_specific_keyword, 18259 (void *)&cmd_config_tx_dynf_specific_port_id, 18260 (void *)&cmd_config_tx_dynf_specific_item, 18261 (void *)&cmd_config_tx_dynf_specific_name, 18262 (void *)&cmd_config_tx_dynf_specific_value, 18263 NULL, 18264 }, 18265 }; 18266 18267 /* *** display tx_metadata per port configuration *** */ 18268 struct cmd_show_tx_metadata_result { 18269 cmdline_fixed_string_t cmd_show; 18270 cmdline_fixed_string_t cmd_port; 18271 cmdline_fixed_string_t cmd_keyword; 18272 portid_t cmd_pid; 18273 }; 18274 18275 static void 18276 cmd_show_tx_metadata_parsed(void *parsed_result, 18277 __rte_unused struct cmdline *cl, 18278 __rte_unused void *data) 18279 { 18280 struct cmd_show_tx_metadata_result *res = parsed_result; 18281 18282 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 18283 printf("invalid port id %u\n", res->cmd_pid); 18284 return; 18285 } 18286 if (!strcmp(res->cmd_keyword, "tx_metadata")) { 18287 printf("Port %u tx_metadata: %u\n", res->cmd_pid, 18288 ports[res->cmd_pid].tx_metadata); 18289 } 18290 } 18291 18292 cmdline_parse_token_string_t cmd_show_tx_metadata_show = 18293 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18294 cmd_show, "show"); 18295 cmdline_parse_token_string_t cmd_show_tx_metadata_port = 18296 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18297 cmd_port, "port"); 18298 cmdline_parse_token_num_t cmd_show_tx_metadata_pid = 18299 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, 18300 cmd_pid, UINT16); 18301 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = 18302 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18303 cmd_keyword, "tx_metadata"); 18304 18305 cmdline_parse_inst_t cmd_show_tx_metadata = { 18306 .f = cmd_show_tx_metadata_parsed, 18307 .data = NULL, 18308 .help_str = "show port <port_id> tx_metadata", 18309 .tokens = { 18310 (void *)&cmd_show_tx_metadata_show, 18311 (void *)&cmd_show_tx_metadata_port, 18312 (void *)&cmd_show_tx_metadata_pid, 18313 (void *)&cmd_show_tx_metadata_keyword, 18314 NULL, 18315 }, 18316 }; 18317 18318 /* *** show fec capability per port configuration *** */ 18319 struct cmd_show_fec_capability_result { 18320 cmdline_fixed_string_t cmd_show; 18321 cmdline_fixed_string_t cmd_port; 18322 cmdline_fixed_string_t cmd_fec; 18323 cmdline_fixed_string_t cmd_keyword; 18324 portid_t cmd_pid; 18325 }; 18326 18327 static void 18328 cmd_show_fec_capability_parsed(void *parsed_result, 18329 __rte_unused struct cmdline *cl, 18330 __rte_unused void *data) 18331 { 18332 #define FEC_CAP_NUM 2 18333 struct cmd_show_fec_capability_result *res = parsed_result; 18334 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM]; 18335 unsigned int num = FEC_CAP_NUM; 18336 unsigned int ret_num; 18337 int ret; 18338 18339 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 18340 printf("Invalid port id %u\n", res->cmd_pid); 18341 return; 18342 } 18343 18344 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num); 18345 if (ret == -ENOTSUP) { 18346 printf("Function not implemented\n"); 18347 return; 18348 } else if (ret < 0) { 18349 printf("Get FEC capability failed\n"); 18350 return; 18351 } 18352 18353 ret_num = (unsigned int)ret; 18354 show_fec_capability(ret_num, speed_fec_capa); 18355 } 18356 18357 cmdline_parse_token_string_t cmd_show_fec_capability_show = 18358 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 18359 cmd_show, "show"); 18360 cmdline_parse_token_string_t cmd_show_fec_capability_port = 18361 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 18362 cmd_port, "port"); 18363 cmdline_parse_token_num_t cmd_show_fec_capability_pid = 18364 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result, 18365 cmd_pid, UINT16); 18366 cmdline_parse_token_string_t cmd_show_fec_capability_fec = 18367 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 18368 cmd_fec, "fec"); 18369 cmdline_parse_token_string_t cmd_show_fec_capability_keyword = 18370 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 18371 cmd_keyword, "capabilities"); 18372 18373 cmdline_parse_inst_t cmd_show_capability = { 18374 .f = cmd_show_fec_capability_parsed, 18375 .data = NULL, 18376 .help_str = "show port <port_id> fec capabilities", 18377 .tokens = { 18378 (void *)&cmd_show_fec_capability_show, 18379 (void *)&cmd_show_fec_capability_port, 18380 (void *)&cmd_show_fec_capability_pid, 18381 (void *)&cmd_show_fec_capability_fec, 18382 (void *)&cmd_show_fec_capability_keyword, 18383 NULL, 18384 }, 18385 }; 18386 18387 /* *** show fec mode per port configuration *** */ 18388 struct cmd_show_fec_metadata_result { 18389 cmdline_fixed_string_t cmd_show; 18390 cmdline_fixed_string_t cmd_port; 18391 cmdline_fixed_string_t cmd_keyword; 18392 portid_t cmd_pid; 18393 }; 18394 18395 static void 18396 cmd_show_fec_mode_parsed(void *parsed_result, 18397 __rte_unused struct cmdline *cl, 18398 __rte_unused void *data) 18399 { 18400 #define FEC_NAME_SIZE 16 18401 struct cmd_show_fec_metadata_result *res = parsed_result; 18402 uint32_t mode; 18403 char buf[FEC_NAME_SIZE]; 18404 int ret; 18405 18406 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 18407 printf("Invalid port id %u\n", res->cmd_pid); 18408 return; 18409 } 18410 ret = rte_eth_fec_get(res->cmd_pid, &mode); 18411 if (ret == -ENOTSUP) { 18412 printf("Function not implemented\n"); 18413 return; 18414 } else if (ret < 0) { 18415 printf("Get FEC mode failed\n"); 18416 return; 18417 } 18418 18419 switch (mode) { 18420 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC): 18421 strlcpy(buf, "off", sizeof(buf)); 18422 break; 18423 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO): 18424 strlcpy(buf, "auto", sizeof(buf)); 18425 break; 18426 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER): 18427 strlcpy(buf, "baser", sizeof(buf)); 18428 break; 18429 case RTE_ETH_FEC_MODE_CAPA_MASK(RS): 18430 strlcpy(buf, "rs", sizeof(buf)); 18431 break; 18432 default: 18433 return; 18434 } 18435 18436 printf("%s\n", buf); 18437 } 18438 18439 cmdline_parse_token_string_t cmd_show_fec_mode_show = 18440 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 18441 cmd_show, "show"); 18442 cmdline_parse_token_string_t cmd_show_fec_mode_port = 18443 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 18444 cmd_port, "port"); 18445 cmdline_parse_token_num_t cmd_show_fec_mode_pid = 18446 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result, 18447 cmd_pid, UINT16); 18448 cmdline_parse_token_string_t cmd_show_fec_mode_keyword = 18449 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 18450 cmd_keyword, "fec_mode"); 18451 18452 cmdline_parse_inst_t cmd_show_fec_mode = { 18453 .f = cmd_show_fec_mode_parsed, 18454 .data = NULL, 18455 .help_str = "show port <port_id> fec_mode", 18456 .tokens = { 18457 (void *)&cmd_show_fec_mode_show, 18458 (void *)&cmd_show_fec_mode_port, 18459 (void *)&cmd_show_fec_mode_pid, 18460 (void *)&cmd_show_fec_mode_keyword, 18461 NULL, 18462 }, 18463 }; 18464 18465 /* *** set fec mode per port configuration *** */ 18466 struct cmd_set_port_fec_mode { 18467 cmdline_fixed_string_t set; 18468 cmdline_fixed_string_t port; 18469 portid_t port_id; 18470 cmdline_fixed_string_t fec_mode; 18471 cmdline_fixed_string_t fec_value; 18472 }; 18473 18474 /* Common CLI fields for set fec mode */ 18475 cmdline_parse_token_string_t cmd_set_port_fec_mode_set = 18476 TOKEN_STRING_INITIALIZER 18477 (struct cmd_set_port_fec_mode, 18478 set, "set"); 18479 cmdline_parse_token_string_t cmd_set_port_fec_mode_port = 18480 TOKEN_STRING_INITIALIZER 18481 (struct cmd_set_port_fec_mode, 18482 port, "port"); 18483 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id = 18484 TOKEN_NUM_INITIALIZER 18485 (struct cmd_set_port_fec_mode, 18486 port_id, UINT16); 18487 cmdline_parse_token_string_t cmd_set_port_fec_mode_str = 18488 TOKEN_STRING_INITIALIZER 18489 (struct cmd_set_port_fec_mode, 18490 fec_mode, "fec_mode"); 18491 cmdline_parse_token_string_t cmd_set_port_fec_mode_value = 18492 TOKEN_STRING_INITIALIZER 18493 (struct cmd_set_port_fec_mode, 18494 fec_value, NULL); 18495 18496 static void 18497 cmd_set_port_fec_mode_parsed( 18498 void *parsed_result, 18499 __rte_unused struct cmdline *cl, 18500 __rte_unused void *data) 18501 { 18502 struct cmd_set_port_fec_mode *res = parsed_result; 18503 uint16_t port_id = res->port_id; 18504 uint32_t mode; 18505 int ret; 18506 18507 ret = parse_fec_mode(res->fec_value, &mode); 18508 if (ret < 0) { 18509 printf("Unknown fec mode: %s for Port %d\n", res->fec_value, 18510 port_id); 18511 return; 18512 } 18513 18514 ret = rte_eth_fec_set(port_id, mode); 18515 if (ret == -ENOTSUP) { 18516 printf("Function not implemented\n"); 18517 return; 18518 } else if (ret < 0) { 18519 printf("Set FEC mode failed\n"); 18520 return; 18521 } 18522 } 18523 18524 cmdline_parse_inst_t cmd_set_fec_mode = { 18525 .f = cmd_set_port_fec_mode_parsed, 18526 .data = NULL, 18527 .help_str = "set port <port_id> fec_mode auto|off|rs|baser", 18528 .tokens = { 18529 (void *)&cmd_set_port_fec_mode_set, 18530 (void *)&cmd_set_port_fec_mode_port, 18531 (void *)&cmd_set_port_fec_mode_port_id, 18532 (void *)&cmd_set_port_fec_mode_str, 18533 (void *)&cmd_set_port_fec_mode_value, 18534 NULL, 18535 }, 18536 }; 18537 18538 /* show port supported ptypes */ 18539 18540 /* Common result structure for show port ptypes */ 18541 struct cmd_show_port_supported_ptypes_result { 18542 cmdline_fixed_string_t show; 18543 cmdline_fixed_string_t port; 18544 portid_t port_id; 18545 cmdline_fixed_string_t ptypes; 18546 }; 18547 18548 /* Common CLI fields for show port ptypes */ 18549 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show = 18550 TOKEN_STRING_INITIALIZER 18551 (struct cmd_show_port_supported_ptypes_result, 18552 show, "show"); 18553 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port = 18554 TOKEN_STRING_INITIALIZER 18555 (struct cmd_show_port_supported_ptypes_result, 18556 port, "port"); 18557 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id = 18558 TOKEN_NUM_INITIALIZER 18559 (struct cmd_show_port_supported_ptypes_result, 18560 port_id, UINT16); 18561 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes = 18562 TOKEN_STRING_INITIALIZER 18563 (struct cmd_show_port_supported_ptypes_result, 18564 ptypes, "ptypes"); 18565 18566 static void 18567 cmd_show_port_supported_ptypes_parsed( 18568 void *parsed_result, 18569 __rte_unused struct cmdline *cl, 18570 __rte_unused void *data) 18571 { 18572 #define RSVD_PTYPE_MASK 0xf0000000 18573 #define MAX_PTYPES_PER_LAYER 16 18574 #define LTYPE_NAMESIZE 32 18575 #define PTYPE_NAMESIZE 256 18576 struct cmd_show_port_supported_ptypes_result *res = parsed_result; 18577 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE]; 18578 uint32_t ptype_mask = RTE_PTYPE_L2_MASK; 18579 uint32_t ptypes[MAX_PTYPES_PER_LAYER]; 18580 uint16_t port_id = res->port_id; 18581 int ret, i; 18582 18583 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0); 18584 if (ret < 0) 18585 return; 18586 18587 while (ptype_mask != RSVD_PTYPE_MASK) { 18588 18589 switch (ptype_mask) { 18590 case RTE_PTYPE_L2_MASK: 18591 strlcpy(ltype, "L2", sizeof(ltype)); 18592 break; 18593 case RTE_PTYPE_L3_MASK: 18594 strlcpy(ltype, "L3", sizeof(ltype)); 18595 break; 18596 case RTE_PTYPE_L4_MASK: 18597 strlcpy(ltype, "L4", sizeof(ltype)); 18598 break; 18599 case RTE_PTYPE_TUNNEL_MASK: 18600 strlcpy(ltype, "Tunnel", sizeof(ltype)); 18601 break; 18602 case RTE_PTYPE_INNER_L2_MASK: 18603 strlcpy(ltype, "Inner L2", sizeof(ltype)); 18604 break; 18605 case RTE_PTYPE_INNER_L3_MASK: 18606 strlcpy(ltype, "Inner L3", sizeof(ltype)); 18607 break; 18608 case RTE_PTYPE_INNER_L4_MASK: 18609 strlcpy(ltype, "Inner L4", sizeof(ltype)); 18610 break; 18611 default: 18612 return; 18613 } 18614 18615 ret = rte_eth_dev_get_supported_ptypes(res->port_id, 18616 ptype_mask, ptypes, 18617 MAX_PTYPES_PER_LAYER); 18618 18619 if (ret > 0) 18620 printf("Supported %s ptypes:\n", ltype); 18621 else 18622 printf("%s ptypes unsupported\n", ltype); 18623 18624 for (i = 0; i < ret; ++i) { 18625 rte_get_ptype_name(ptypes[i], buf, sizeof(buf)); 18626 printf("%s\n", buf); 18627 } 18628 18629 ptype_mask <<= 4; 18630 } 18631 } 18632 18633 cmdline_parse_inst_t cmd_show_port_supported_ptypes = { 18634 .f = cmd_show_port_supported_ptypes_parsed, 18635 .data = NULL, 18636 .help_str = "show port <port_id> ptypes", 18637 .tokens = { 18638 (void *)&cmd_show_port_supported_ptypes_show, 18639 (void *)&cmd_show_port_supported_ptypes_port, 18640 (void *)&cmd_show_port_supported_ptypes_port_id, 18641 (void *)&cmd_show_port_supported_ptypes_ptypes, 18642 NULL, 18643 }, 18644 }; 18645 18646 /* *** display rx/tx descriptor status *** */ 18647 struct cmd_show_rx_tx_desc_status_result { 18648 cmdline_fixed_string_t cmd_show; 18649 cmdline_fixed_string_t cmd_port; 18650 cmdline_fixed_string_t cmd_keyword; 18651 cmdline_fixed_string_t cmd_desc; 18652 cmdline_fixed_string_t cmd_status; 18653 portid_t cmd_pid; 18654 portid_t cmd_qid; 18655 portid_t cmd_did; 18656 }; 18657 18658 static void 18659 cmd_show_rx_tx_desc_status_parsed(void *parsed_result, 18660 __rte_unused struct cmdline *cl, 18661 __rte_unused void *data) 18662 { 18663 struct cmd_show_rx_tx_desc_status_result *res = parsed_result; 18664 int rc; 18665 18666 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 18667 printf("invalid port id %u\n", res->cmd_pid); 18668 return; 18669 } 18670 18671 if (!strcmp(res->cmd_keyword, "rxq")) { 18672 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid, 18673 res->cmd_did); 18674 if (rc < 0) { 18675 printf("Invalid queueid = %d\n", res->cmd_qid); 18676 return; 18677 } 18678 if (rc == RTE_ETH_RX_DESC_AVAIL) 18679 printf("Desc status = AVAILABLE\n"); 18680 else if (rc == RTE_ETH_RX_DESC_DONE) 18681 printf("Desc status = DONE\n"); 18682 else 18683 printf("Desc status = UNAVAILABLE\n"); 18684 } else if (!strcmp(res->cmd_keyword, "txq")) { 18685 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid, 18686 res->cmd_did); 18687 if (rc < 0) { 18688 printf("Invalid queueid = %d\n", res->cmd_qid); 18689 return; 18690 } 18691 if (rc == RTE_ETH_TX_DESC_FULL) 18692 printf("Desc status = FULL\n"); 18693 else if (rc == RTE_ETH_TX_DESC_DONE) 18694 printf("Desc status = DONE\n"); 18695 else 18696 printf("Desc status = UNAVAILABLE\n"); 18697 } 18698 } 18699 18700 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show = 18701 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 18702 cmd_show, "show"); 18703 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port = 18704 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 18705 cmd_port, "port"); 18706 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid = 18707 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 18708 cmd_pid, UINT16); 18709 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword = 18710 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 18711 cmd_keyword, "rxq#txq"); 18712 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid = 18713 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 18714 cmd_qid, UINT16); 18715 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc = 18716 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 18717 cmd_desc, "desc"); 18718 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did = 18719 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 18720 cmd_did, UINT16); 18721 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status = 18722 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 18723 cmd_status, "status"); 18724 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = { 18725 .f = cmd_show_rx_tx_desc_status_parsed, 18726 .data = NULL, 18727 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> " 18728 "status", 18729 .tokens = { 18730 (void *)&cmd_show_rx_tx_desc_status_show, 18731 (void *)&cmd_show_rx_tx_desc_status_port, 18732 (void *)&cmd_show_rx_tx_desc_status_pid, 18733 (void *)&cmd_show_rx_tx_desc_status_keyword, 18734 (void *)&cmd_show_rx_tx_desc_status_qid, 18735 (void *)&cmd_show_rx_tx_desc_status_desc, 18736 (void *)&cmd_show_rx_tx_desc_status_did, 18737 (void *)&cmd_show_rx_tx_desc_status_status, 18738 NULL, 18739 }, 18740 }; 18741 18742 /* Common result structure for set port ptypes */ 18743 struct cmd_set_port_ptypes_result { 18744 cmdline_fixed_string_t set; 18745 cmdline_fixed_string_t port; 18746 portid_t port_id; 18747 cmdline_fixed_string_t ptype_mask; 18748 uint32_t mask; 18749 }; 18750 18751 /* Common CLI fields for set port ptypes */ 18752 cmdline_parse_token_string_t cmd_set_port_ptypes_set = 18753 TOKEN_STRING_INITIALIZER 18754 (struct cmd_set_port_ptypes_result, 18755 set, "set"); 18756 cmdline_parse_token_string_t cmd_set_port_ptypes_port = 18757 TOKEN_STRING_INITIALIZER 18758 (struct cmd_set_port_ptypes_result, 18759 port, "port"); 18760 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id = 18761 TOKEN_NUM_INITIALIZER 18762 (struct cmd_set_port_ptypes_result, 18763 port_id, UINT16); 18764 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str = 18765 TOKEN_STRING_INITIALIZER 18766 (struct cmd_set_port_ptypes_result, 18767 ptype_mask, "ptype_mask"); 18768 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 = 18769 TOKEN_NUM_INITIALIZER 18770 (struct cmd_set_port_ptypes_result, 18771 mask, UINT32); 18772 18773 static void 18774 cmd_set_port_ptypes_parsed( 18775 void *parsed_result, 18776 __rte_unused struct cmdline *cl, 18777 __rte_unused void *data) 18778 { 18779 struct cmd_set_port_ptypes_result *res = parsed_result; 18780 #define PTYPE_NAMESIZE 256 18781 char ptype_name[PTYPE_NAMESIZE]; 18782 uint16_t port_id = res->port_id; 18783 uint32_t ptype_mask = res->mask; 18784 int ret, i; 18785 18786 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK, 18787 NULL, 0); 18788 if (ret <= 0) { 18789 printf("Port %d doesn't support any ptypes.\n", port_id); 18790 return; 18791 } 18792 18793 uint32_t ptypes[ret]; 18794 18795 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); 18796 if (ret < 0) { 18797 printf("Unable to set requested ptypes for Port %d\n", port_id); 18798 return; 18799 } 18800 18801 printf("Successfully set following ptypes for Port %d\n", port_id); 18802 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) { 18803 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name)); 18804 printf("%s\n", ptype_name); 18805 } 18806 18807 clear_ptypes = false; 18808 } 18809 18810 cmdline_parse_inst_t cmd_set_port_ptypes = { 18811 .f = cmd_set_port_ptypes_parsed, 18812 .data = NULL, 18813 .help_str = "set port <port_id> ptype_mask <mask>", 18814 .tokens = { 18815 (void *)&cmd_set_port_ptypes_set, 18816 (void *)&cmd_set_port_ptypes_port, 18817 (void *)&cmd_set_port_ptypes_port_id, 18818 (void *)&cmd_set_port_ptypes_mask_str, 18819 (void *)&cmd_set_port_ptypes_mask_u32, 18820 NULL, 18821 }, 18822 }; 18823 18824 /* *** display mac addresses added to a port *** */ 18825 struct cmd_showport_macs_result { 18826 cmdline_fixed_string_t cmd_show; 18827 cmdline_fixed_string_t cmd_port; 18828 cmdline_fixed_string_t cmd_keyword; 18829 portid_t cmd_pid; 18830 }; 18831 18832 static void 18833 cmd_showport_macs_parsed(void *parsed_result, 18834 __rte_unused struct cmdline *cl, 18835 __rte_unused void *data) 18836 { 18837 struct cmd_showport_macs_result *res = parsed_result; 18838 18839 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN)) 18840 return; 18841 18842 if (!strcmp(res->cmd_keyword, "macs")) 18843 show_macs(res->cmd_pid); 18844 else if (!strcmp(res->cmd_keyword, "mcast_macs")) 18845 show_mcast_macs(res->cmd_pid); 18846 } 18847 18848 cmdline_parse_token_string_t cmd_showport_macs_show = 18849 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 18850 cmd_show, "show"); 18851 cmdline_parse_token_string_t cmd_showport_macs_port = 18852 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 18853 cmd_port, "port"); 18854 cmdline_parse_token_num_t cmd_showport_macs_pid = 18855 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result, 18856 cmd_pid, UINT16); 18857 cmdline_parse_token_string_t cmd_showport_macs_keyword = 18858 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 18859 cmd_keyword, "macs#mcast_macs"); 18860 18861 cmdline_parse_inst_t cmd_showport_macs = { 18862 .f = cmd_showport_macs_parsed, 18863 .data = NULL, 18864 .help_str = "show port <port_id> macs|mcast_macs", 18865 .tokens = { 18866 (void *)&cmd_showport_macs_show, 18867 (void *)&cmd_showport_macs_port, 18868 (void *)&cmd_showport_macs_pid, 18869 (void *)&cmd_showport_macs_keyword, 18870 NULL, 18871 }, 18872 }; 18873 18874 /* ******************************************************************************** */ 18875 18876 /* list of instructions */ 18877 cmdline_parse_ctx_t main_ctx[] = { 18878 (cmdline_parse_inst_t *)&cmd_help_brief, 18879 (cmdline_parse_inst_t *)&cmd_help_long, 18880 (cmdline_parse_inst_t *)&cmd_quit, 18881 (cmdline_parse_inst_t *)&cmd_load_from_file, 18882 (cmdline_parse_inst_t *)&cmd_showport, 18883 (cmdline_parse_inst_t *)&cmd_showqueue, 18884 (cmdline_parse_inst_t *)&cmd_showeeprom, 18885 (cmdline_parse_inst_t *)&cmd_showportall, 18886 (cmdline_parse_inst_t *)&cmd_showdevice, 18887 (cmdline_parse_inst_t *)&cmd_showcfg, 18888 (cmdline_parse_inst_t *)&cmd_showfwdall, 18889 (cmdline_parse_inst_t *)&cmd_start, 18890 (cmdline_parse_inst_t *)&cmd_start_tx_first, 18891 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 18892 (cmdline_parse_inst_t *)&cmd_set_link_up, 18893 (cmdline_parse_inst_t *)&cmd_set_link_down, 18894 (cmdline_parse_inst_t *)&cmd_reset, 18895 (cmdline_parse_inst_t *)&cmd_set_numbers, 18896 (cmdline_parse_inst_t *)&cmd_set_log, 18897 (cmdline_parse_inst_t *)&cmd_set_rxoffs, 18898 (cmdline_parse_inst_t *)&cmd_set_rxpkts, 18899 (cmdline_parse_inst_t *)&cmd_set_txpkts, 18900 (cmdline_parse_inst_t *)&cmd_set_txsplit, 18901 (cmdline_parse_inst_t *)&cmd_set_txtimes, 18902 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 18903 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 18904 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 18905 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 18906 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 18907 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 18908 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 18909 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 18910 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 18911 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 18912 (cmdline_parse_inst_t *)&cmd_set_link_check, 18913 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 18914 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 18915 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 18916 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 18917 #ifdef RTE_NET_BOND 18918 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 18919 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 18920 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 18921 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 18922 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 18923 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 18924 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 18925 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 18926 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 18927 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 18928 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 18929 #endif 18930 (cmdline_parse_inst_t *)&cmd_vlan_offload, 18931 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 18932 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 18933 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 18934 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 18935 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 18936 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 18937 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 18938 (cmdline_parse_inst_t *)&cmd_csum_set, 18939 (cmdline_parse_inst_t *)&cmd_csum_show, 18940 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 18941 (cmdline_parse_inst_t *)&cmd_tso_set, 18942 (cmdline_parse_inst_t *)&cmd_tso_show, 18943 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 18944 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 18945 (cmdline_parse_inst_t *)&cmd_gro_enable, 18946 (cmdline_parse_inst_t *)&cmd_gro_flush, 18947 (cmdline_parse_inst_t *)&cmd_gro_show, 18948 (cmdline_parse_inst_t *)&cmd_gso_enable, 18949 (cmdline_parse_inst_t *)&cmd_gso_size, 18950 (cmdline_parse_inst_t *)&cmd_gso_show, 18951 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 18952 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 18953 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 18954 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 18955 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 18956 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 18957 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 18958 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 18959 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 18960 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 18961 (cmdline_parse_inst_t *)&cmd_config_dcb, 18962 (cmdline_parse_inst_t *)&cmd_read_reg, 18963 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 18964 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 18965 (cmdline_parse_inst_t *)&cmd_write_reg, 18966 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 18967 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 18968 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 18969 (cmdline_parse_inst_t *)&cmd_stop, 18970 (cmdline_parse_inst_t *)&cmd_mac_addr, 18971 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 18972 (cmdline_parse_inst_t *)&cmd_set_qmap, 18973 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 18974 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles, 18975 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats, 18976 (cmdline_parse_inst_t *)&cmd_operate_port, 18977 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 18978 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 18979 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 18980 (cmdline_parse_inst_t *)&cmd_operate_detach_device, 18981 (cmdline_parse_inst_t *)&cmd_set_port_setup_on, 18982 (cmdline_parse_inst_t *)&cmd_config_speed_all, 18983 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 18984 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 18985 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 18986 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 18987 (cmdline_parse_inst_t *)&cmd_config_mtu, 18988 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 18989 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size, 18990 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 18991 (cmdline_parse_inst_t *)&cmd_config_rss, 18992 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 18993 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 18994 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 18995 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 18996 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 18997 (cmdline_parse_inst_t *)&cmd_showport_reta, 18998 (cmdline_parse_inst_t *)&cmd_showport_macs, 18999 (cmdline_parse_inst_t *)&cmd_config_burst, 19000 (cmdline_parse_inst_t *)&cmd_config_thresh, 19001 (cmdline_parse_inst_t *)&cmd_config_threshold, 19002 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 19003 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 19004 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 19005 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 19006 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 19007 (cmdline_parse_inst_t *)&cmd_global_config, 19008 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 19009 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 19010 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 19011 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 19012 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 19013 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 19014 (cmdline_parse_inst_t *)&cmd_dump, 19015 (cmdline_parse_inst_t *)&cmd_dump_one, 19016 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director, 19017 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director, 19018 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, 19019 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director, 19020 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director, 19021 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director, 19022 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 19023 (cmdline_parse_inst_t *)&cmd_flush_flow_director, 19024 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 19025 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 19026 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 19027 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, 19028 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 19029 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port, 19030 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port, 19031 (cmdline_parse_inst_t *)&cmd_get_hash_global_config, 19032 (cmdline_parse_inst_t *)&cmd_set_hash_global_config, 19033 (cmdline_parse_inst_t *)&cmd_set_hash_input_set, 19034 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set, 19035 (cmdline_parse_inst_t *)&cmd_flow, 19036 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 19037 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 19038 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 19039 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 19040 (cmdline_parse_inst_t *)&cmd_create_port_meter, 19041 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 19042 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 19043 (cmdline_parse_inst_t *)&cmd_del_port_meter, 19044 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 19045 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 19046 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, 19047 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 19048 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 19049 (cmdline_parse_inst_t *)&cmd_mcast_addr, 19050 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all, 19051 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific, 19052 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all, 19053 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific, 19054 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en, 19055 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis, 19056 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis, 19057 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis, 19058 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add, 19059 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del, 19060 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 19061 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 19062 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 19063 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 19064 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 19065 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 19066 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 19067 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 19068 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 19069 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 19070 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 19071 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 19072 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 19073 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 19074 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 19075 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 19076 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 19077 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 19078 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 19079 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 19080 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 19081 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 19082 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 19083 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 19084 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 19085 (cmdline_parse_inst_t *)&cmd_set_vxlan, 19086 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl, 19087 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 19088 (cmdline_parse_inst_t *)&cmd_set_nvgre, 19089 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 19090 (cmdline_parse_inst_t *)&cmd_set_l2_encap, 19091 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, 19092 (cmdline_parse_inst_t *)&cmd_set_l2_decap, 19093 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, 19094 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, 19095 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, 19096 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, 19097 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, 19098 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, 19099 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, 19100 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, 19101 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, 19102 (cmdline_parse_inst_t *)&cmd_ddp_add, 19103 (cmdline_parse_inst_t *)&cmd_ddp_del, 19104 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 19105 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 19106 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 19107 (cmdline_parse_inst_t *)&cmd_clear_input_set, 19108 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 19109 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 19110 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes, 19111 (cmdline_parse_inst_t *)&cmd_set_port_ptypes, 19112 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 19113 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 19114 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 19115 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 19116 19117 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 19118 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 19119 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 19120 (cmdline_parse_inst_t *)&cmd_queue_region, 19121 (cmdline_parse_inst_t *)&cmd_region_flowtype, 19122 (cmdline_parse_inst_t *)&cmd_user_priority_region, 19123 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 19124 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 19125 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 19126 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 19127 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 19128 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 19129 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 19130 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 19131 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 19132 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 19133 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 19134 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 19135 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 19136 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 19137 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 19138 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode, 19139 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 19140 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 19141 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 19142 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 19143 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 19144 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 19145 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, 19146 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, 19147 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, 19148 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 19149 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 19150 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 19151 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 19152 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 19153 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 19154 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 19155 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 19156 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 19157 #ifdef RTE_LIB_BPF 19158 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 19159 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 19160 #endif 19161 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, 19162 (cmdline_parse_inst_t *)&cmd_show_tx_metadata, 19163 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status, 19164 (cmdline_parse_inst_t *)&cmd_set_raw, 19165 (cmdline_parse_inst_t *)&cmd_show_set_raw, 19166 (cmdline_parse_inst_t *)&cmd_show_set_raw_all, 19167 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific, 19168 (cmdline_parse_inst_t *)&cmd_show_fec_mode, 19169 (cmdline_parse_inst_t *)&cmd_set_fec_mode, 19170 (cmdline_parse_inst_t *)&cmd_show_capability, 19171 NULL, 19172 }; 19173 19174 /* read cmdline commands from file */ 19175 void 19176 cmdline_read_from_file(const char *filename) 19177 { 19178 struct cmdline *cl; 19179 19180 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 19181 if (cl == NULL) { 19182 printf("Failed to create file based cmdline context: %s\n", 19183 filename); 19184 return; 19185 } 19186 19187 cmdline_interact(cl); 19188 cmdline_quit(cl); 19189 19190 cmdline_free(cl); 19191 19192 printf("Read CLI commands from %s\n", filename); 19193 } 19194 19195 /* prompt function, called from main on MAIN lcore */ 19196 void 19197 prompt(void) 19198 { 19199 /* initialize non-constant commands */ 19200 cmd_set_fwd_mode_init(); 19201 cmd_set_fwd_retry_mode_init(); 19202 19203 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 19204 if (testpmd_cl == NULL) 19205 return; 19206 cmdline_interact(testpmd_cl); 19207 cmdline_stdin_exit(testpmd_cl); 19208 } 19209 19210 void 19211 prompt_exit(void) 19212 { 19213 if (testpmd_cl != NULL) 19214 cmdline_quit(testpmd_cl); 19215 } 19216 19217 static void 19218 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 19219 { 19220 if (id == (portid_t)RTE_PORT_ALL) { 19221 portid_t pid; 19222 19223 RTE_ETH_FOREACH_DEV(pid) { 19224 /* check if need_reconfig has been set to 1 */ 19225 if (ports[pid].need_reconfig == 0) 19226 ports[pid].need_reconfig = dev; 19227 /* check if need_reconfig_queues has been set to 1 */ 19228 if (ports[pid].need_reconfig_queues == 0) 19229 ports[pid].need_reconfig_queues = queue; 19230 } 19231 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 19232 /* check if need_reconfig has been set to 1 */ 19233 if (ports[id].need_reconfig == 0) 19234 ports[id].need_reconfig = dev; 19235 /* check if need_reconfig_queues has been set to 1 */ 19236 if (ports[id].need_reconfig_queues == 0) 19237 ports[id].need_reconfig_queues = queue; 19238 } 19239 } 19240