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|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) (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 "ddp add (port_id) (profile_path[,backup_profile_path])\n" 654 " Load a profile package on a port\n\n" 655 656 "ddp del (port_id) (backup_profile_path)\n" 657 " Delete a profile package from a port\n\n" 658 659 "ptype mapping get (port_id) (valid_only)\n" 660 " Get ptype mapping on a port\n\n" 661 662 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n" 663 " Replace target with the pkt_type in ptype mapping\n\n" 664 665 "ptype mapping reset (port_id)\n" 666 " Reset ptype mapping on a port\n\n" 667 668 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" 669 " Update a ptype mapping item on a port\n\n" 670 671 "set port (port_id) ptype_mask (ptype_mask)\n" 672 " set packet types classification for a specific port\n\n" 673 674 "set port (port_id) queue-region region_id (value) " 675 "queue_start_index (value) queue_num (value)\n" 676 " Set a queue region on a port\n\n" 677 678 "set port (port_id) queue-region region_id (value) " 679 "flowtype (value)\n" 680 " Set a flowtype region index on a port\n\n" 681 682 "set port (port_id) queue-region UP (value) region_id (value)\n" 683 " Set the mapping of User Priority to " 684 "queue region on a port\n\n" 685 686 "set port (port_id) queue-region flush (on|off)\n" 687 " flush all queue region related configuration\n\n" 688 689 "show port meter cap (port_id)\n" 690 " Show port meter capability information\n\n" 691 692 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n" 693 " meter profile add - srtcm rfc 2697\n\n" 694 695 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n" 696 " meter profile add - trtcm rfc 2698\n\n" 697 698 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n" 699 " meter profile add - trtcm rfc 4115\n\n" 700 701 "del port meter profile (port_id) (profile_id)\n" 702 " meter profile delete\n\n" 703 704 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" 705 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n" 706 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 707 "(dscp_tbl_entry63)]\n" 708 " meter create\n\n" 709 710 "enable port meter (port_id) (mtr_id)\n" 711 " meter enable\n\n" 712 713 "disable port meter (port_id) (mtr_id)\n" 714 " meter disable\n\n" 715 716 "del port meter (port_id) (mtr_id)\n" 717 " meter delete\n\n" 718 719 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 720 " meter update meter profile\n\n" 721 722 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 723 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 724 " update meter dscp table entries\n\n" 725 726 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 727 "(action0) [(action1) (action2)]\n" 728 " meter update policer action\n\n" 729 730 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 731 " meter update stats\n\n" 732 733 "show port (port_id) queue-region\n" 734 " show all queue region related configuration info\n\n" 735 736 "set port (port_id) fec_mode auto|off|rs|baser\n" 737 " set fec mode for a specific port\n\n" 738 739 , list_pkt_forwarding_modes() 740 ); 741 } 742 743 if (show_all || !strcmp(res->section, "ports")) { 744 745 cmdline_printf( 746 cl, 747 "\n" 748 "Port Operations:\n" 749 "----------------\n\n" 750 751 "port start (port_id|all)\n" 752 " Start all ports or port_id.\n\n" 753 754 "port stop (port_id|all)\n" 755 " Stop all ports or port_id.\n\n" 756 757 "port close (port_id|all)\n" 758 " Close all ports or port_id.\n\n" 759 760 "port reset (port_id|all)\n" 761 " Reset all ports or port_id.\n\n" 762 763 "port attach (ident)\n" 764 " Attach physical or virtual dev by pci address or virtual device name\n\n" 765 766 "port detach (port_id)\n" 767 " Detach physical or virtual dev by port_id\n\n" 768 769 "port config (port_id|all)" 770 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)" 771 " duplex (half|full|auto)\n" 772 " Set speed and duplex for all ports or port_id\n\n" 773 774 "port config (port_id|all) loopback (mode)\n" 775 " Set loopback mode for all ports or port_id\n\n" 776 777 "port config all (rxq|txq|rxd|txd) (value)\n" 778 " Set number for rxq/txq/rxd/txd.\n\n" 779 780 "port config all max-pkt-len (value)\n" 781 " Set the max packet length.\n\n" 782 783 "port config all max-lro-pkt-size (value)\n" 784 " Set the max LRO aggregated packet size.\n\n" 785 786 "port config all drop-en (on|off)\n" 787 " Enable or disable packet drop on all RX queues of all ports when no " 788 "receive buffers available.\n\n" 789 790 "port config all rss (all|default|ip|tcp|udp|sctp|" 791 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|" 792 "level-outer|level-inner|<flowtype_id>)\n" 793 " Set the RSS mode.\n\n" 794 795 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 796 " Set the RSS redirection table.\n\n" 797 798 "port config (port_id) dcb vt (on|off) (traffic_class)" 799 " pfc (on|off)\n" 800 " Set the DCB mode.\n\n" 801 802 "port config all burst (value)\n" 803 " Set the number of packets per burst.\n\n" 804 805 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 806 " (value)\n" 807 " Set the ring prefetch/host/writeback threshold" 808 " for tx/rx queue.\n\n" 809 810 "port config all (txfreet|txrst|rxfreet) (value)\n" 811 " Set free threshold for rx/tx, or set" 812 " tx rs bit threshold.\n\n" 813 "port config mtu X value\n" 814 " Set the MTU of port X to a given value\n\n" 815 816 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n" 817 " Set a rx/tx queue's ring size configuration, the new" 818 " value will take effect after command that (re-)start the port" 819 " or command that setup the specific queue\n\n" 820 821 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 822 " Start/stop a rx/tx queue of port X. Only take effect" 823 " when port X is started\n\n" 824 825 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n" 826 " Switch on/off a deferred start of port X rx/tx queue. Only" 827 " take effect when port X is stopped.\n\n" 828 829 "port (port_id) (rxq|txq) (queue_id) setup\n" 830 " Setup a rx/tx queue of port X.\n\n" 831 832 "port config (port_id) pctype mapping reset\n" 833 " Reset flow type to pctype mapping on a port\n\n" 834 835 "port config (port_id) pctype mapping update" 836 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 837 " Update a flow type to pctype mapping item on a port\n\n" 838 839 "port config (port_id) pctype (pctype_id) hash_inset|" 840 "fdir_inset|fdir_flx_inset get|set|clear field\n" 841 " (field_idx)\n" 842 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n" 843 844 "port config (port_id) pctype (pctype_id) hash_inset|" 845 "fdir_inset|fdir_flx_inset clear all" 846 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n" 847 848 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n" 849 " Add/remove UDP tunnel port for tunneling offload\n\n" 850 851 "port config <port_id> rx_offload vlan_strip|" 852 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 853 "outer_ipv4_cksum|macsec_strip|header_split|" 854 "vlan_filter|vlan_extend|jumbo_frame|scatter|" 855 "buffer_split|timestamp|security|keep_crc on|off\n" 856 " Enable or disable a per port Rx offloading" 857 " on all Rx queues of a port\n\n" 858 859 "port (port_id) rxq (queue_id) rx_offload vlan_strip|" 860 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 861 "outer_ipv4_cksum|macsec_strip|header_split|" 862 "vlan_filter|vlan_extend|jumbo_frame|scatter|" 863 "buffer_split|timestamp|security|keep_crc on|off\n" 864 " Enable or disable a per queue Rx offloading" 865 " only on a specific Rx queue\n\n" 866 867 "port config (port_id) tx_offload vlan_insert|" 868 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 869 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 870 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|" 871 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|" 872 "security on|off\n" 873 " Enable or disable a per port Tx offloading" 874 " on all Tx queues of a port\n\n" 875 876 "port (port_id) txq (queue_id) tx_offload vlan_insert|" 877 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 878 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 879 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert" 880 "|mt_lockfree|multi_segs|mbuf_fast_free|security" 881 " on|off\n" 882 " Enable or disable a per queue Tx offloading" 883 " only on a specific Tx queue\n\n" 884 885 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n" 886 " Load an eBPF program as a callback" 887 " for particular RX/TX queue\n\n" 888 889 "bpf-unload rx|tx (port) (queue)\n" 890 " Unload previously loaded eBPF program" 891 " for particular RX/TX queue\n\n" 892 893 "port config (port_id) tx_metadata (value)\n" 894 " Set Tx metadata value per port. Testpmd will add this value" 895 " to any Tx packet sent from this port\n\n" 896 897 "port config (port_id) dynf (name) set|clear\n" 898 " Register a dynf and Set/clear this flag on Tx. " 899 "Testpmd will set this value to any Tx packet " 900 "sent from this port\n\n" 901 ); 902 } 903 904 if (show_all || !strcmp(res->section, "registers")) { 905 906 cmdline_printf( 907 cl, 908 "\n" 909 "Registers:\n" 910 "----------\n\n" 911 912 "read reg (port_id) (address)\n" 913 " Display value of a port register.\n\n" 914 915 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 916 " Display a port register bit field.\n\n" 917 918 "read regbit (port_id) (address) (bit_x)\n" 919 " Display a single port register bit.\n\n" 920 921 "write reg (port_id) (address) (value)\n" 922 " Set value of a port register.\n\n" 923 924 "write regfield (port_id) (address) (bit_x) (bit_y)" 925 " (value)\n" 926 " Set bit field of a port register.\n\n" 927 928 "write regbit (port_id) (address) (bit_x) (value)\n" 929 " Set single bit value of a port register.\n\n" 930 ); 931 } 932 if (show_all || !strcmp(res->section, "filters")) { 933 934 cmdline_printf( 935 cl, 936 "\n" 937 "filters:\n" 938 "--------\n\n" 939 940 #ifdef RTE_NET_I40E 941 "flow_director_filter (port_id) mode raw (add|del|update)" 942 " flow (flow_id) (drop|fwd) queue (queue_id)" 943 " fd_id (fd_id_value) packet (packet file name)\n" 944 " Add/Del a raw type flow director filter.\n\n" 945 #endif 946 947 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 948 " src_mask (ipv4_src) (ipv6_src) (src_port)" 949 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 950 " Set flow director IP mask.\n\n" 951 952 "flow_director_mask (port_id) mode MAC-VLAN" 953 " vlan (vlan_value)\n" 954 " Set flow director MAC-VLAN mask.\n\n" 955 956 "flow_director_mask (port_id) mode Tunnel" 957 " vlan (vlan_value) mac (mac_value)" 958 " tunnel-type (tunnel_type_value)" 959 " tunnel-id (tunnel_id_value)\n" 960 " Set flow director Tunnel mask.\n\n" 961 962 "flow_director_flex_payload (port_id)" 963 " (raw|l2|l3|l4) (config)\n" 964 " Configure flex payload selection.\n\n" 965 966 "flow validate {port_id}" 967 " [group {group_id}] [priority {level}]" 968 " [ingress] [egress]" 969 " pattern {item} [/ {item} [...]] / end" 970 " actions {action} [/ {action} [...]] / end\n" 971 " Check whether a flow rule can be created.\n\n" 972 973 "flow create {port_id}" 974 " [group {group_id}] [priority {level}]" 975 " [ingress] [egress]" 976 " pattern {item} [/ {item} [...]] / end" 977 " actions {action} [/ {action} [...]] / end\n" 978 " Create a flow rule.\n\n" 979 980 "flow destroy {port_id} rule {rule_id} [...]\n" 981 " Destroy specific flow rules.\n\n" 982 983 "flow flush {port_id}\n" 984 " Destroy all flow rules.\n\n" 985 986 "flow query {port_id} {rule_id} {action}\n" 987 " Query an existing flow rule.\n\n" 988 989 "flow list {port_id} [group {group_id}] [...]\n" 990 " List existing flow rules sorted by priority," 991 " filtered by group identifiers.\n\n" 992 993 "flow isolate {port_id} {boolean}\n" 994 " Restrict ingress traffic to the defined" 995 " flow rules\n\n" 996 997 "flow aged {port_id} [destroy]\n" 998 " List and destroy aged flows" 999 " flow rules\n\n" 1000 1001 "flow shared_action {port_id} create" 1002 " [action_id {shared_action_id}]" 1003 " [ingress] [egress]" 1004 " action {action} / end\n" 1005 " Create shared action.\n\n" 1006 1007 "flow shared_action {port_id} update" 1008 " {shared_action_id} action {action} / end\n" 1009 " Update shared action.\n\n" 1010 1011 "flow shared_action {port_id} destroy" 1012 " action_id {shared_action_id} [...]\n" 1013 " Destroy specific shared actions.\n\n" 1014 1015 "flow shared_action {port_id} query" 1016 " {shared_action_id}\n" 1017 " Query an existing shared action.\n\n" 1018 1019 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" 1020 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" 1021 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n" 1022 " Configure the VXLAN encapsulation for flows.\n\n" 1023 1024 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)" 1025 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)" 1026 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)" 1027 " eth-dst (eth-dst)\n" 1028 " Configure the VXLAN encapsulation for flows.\n\n" 1029 1030 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src" 1031 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)" 1032 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)" 1033 " eth-dst (eth-dst)\n" 1034 " Configure the VXLAN encapsulation for flows.\n\n" 1035 1036 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src" 1037 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst" 1038 " (eth-dst)\n" 1039 " Configure the NVGRE encapsulation for flows.\n\n" 1040 1041 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)" 1042 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)" 1043 " eth-src (eth-src) eth-dst (eth-dst)\n" 1044 " Configure the NVGRE encapsulation for flows.\n\n" 1045 1046 "set raw_encap {flow items}\n" 1047 " Configure the encapsulation with raw data.\n\n" 1048 1049 "set raw_decap {flow items}\n" 1050 " Configure the decapsulation with raw data.\n\n" 1051 1052 ); 1053 } 1054 1055 if (show_all || !strcmp(res->section, "traffic_management")) { 1056 cmdline_printf( 1057 cl, 1058 "\n" 1059 "Traffic Management:\n" 1060 "--------------\n" 1061 "show port tm cap (port_id)\n" 1062 " Display the port TM capability.\n\n" 1063 1064 "show port tm level cap (port_id) (level_id)\n" 1065 " Display the port TM hierarchical level capability.\n\n" 1066 1067 "show port tm node cap (port_id) (node_id)\n" 1068 " Display the port TM node capability.\n\n" 1069 1070 "show port tm node type (port_id) (node_id)\n" 1071 " Display the port TM node type.\n\n" 1072 1073 "show port tm node stats (port_id) (node_id) (clear)\n" 1074 " Display the port TM node stats.\n\n" 1075 1076 "add port tm node shaper profile (port_id) (shaper_profile_id)" 1077 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)" 1078 " (packet_length_adjust) (packet_mode)\n" 1079 " Add port tm node private shaper profile.\n\n" 1080 1081 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 1082 " Delete port tm node private shaper profile.\n\n" 1083 1084 "add port tm node shared shaper (port_id) (shared_shaper_id)" 1085 " (shaper_profile_id)\n" 1086 " Add/update port tm node shared shaper.\n\n" 1087 1088 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 1089 " Delete port tm node shared shaper.\n\n" 1090 1091 "set port tm node shaper profile (port_id) (node_id)" 1092 " (shaper_profile_id)\n" 1093 " Set port tm node shaper profile.\n\n" 1094 1095 "add port tm node wred profile (port_id) (wred_profile_id)" 1096 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 1097 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 1098 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 1099 " Add port tm node wred profile.\n\n" 1100 1101 "del port tm node wred profile (port_id) (wred_profile_id)\n" 1102 " Delete port tm node wred profile.\n\n" 1103 1104 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 1105 " (priority) (weight) (level_id) (shaper_profile_id)" 1106 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1107 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1108 " Add port tm nonleaf node.\n\n" 1109 1110 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)" 1111 " (priority) (weight) (level_id) (shaper_profile_id)" 1112 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1113 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1114 " Add port tm nonleaf node with pkt mode enabled.\n\n" 1115 1116 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 1117 " (priority) (weight) (level_id) (shaper_profile_id)" 1118 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 1119 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1120 " Add port tm leaf node.\n\n" 1121 1122 "del port tm node (port_id) (node_id)\n" 1123 " Delete port tm node.\n\n" 1124 1125 "set port tm node parent (port_id) (node_id) (parent_node_id)" 1126 " (priority) (weight)\n" 1127 " Set port tm node parent.\n\n" 1128 1129 "suspend port tm node (port_id) (node_id)" 1130 " Suspend tm node.\n\n" 1131 1132 "resume port tm node (port_id) (node_id)" 1133 " Resume tm node.\n\n" 1134 1135 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 1136 " Commit tm hierarchy.\n\n" 1137 1138 "set port tm mark ip_ecn (port) (green) (yellow)" 1139 " (red)\n" 1140 " Enables/Disables the traffic management marking" 1141 " for IP ECN (Explicit Congestion Notification)" 1142 " packets on a given port\n\n" 1143 1144 "set port tm mark ip_dscp (port) (green) (yellow)" 1145 " (red)\n" 1146 " Enables/Disables the traffic management marking" 1147 " on the port for IP dscp packets\n\n" 1148 1149 "set port tm mark vlan_dei (port) (green) (yellow)" 1150 " (red)\n" 1151 " Enables/Disables the traffic management marking" 1152 " on the port for VLAN packets with DEI enabled\n\n" 1153 ); 1154 } 1155 1156 if (show_all || !strcmp(res->section, "devices")) { 1157 cmdline_printf( 1158 cl, 1159 "\n" 1160 "Device Operations:\n" 1161 "--------------\n" 1162 "device detach (identifier)\n" 1163 " Detach device by identifier.\n\n" 1164 ); 1165 } 1166 1167 } 1168 1169 cmdline_parse_token_string_t cmd_help_long_help = 1170 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1171 1172 cmdline_parse_token_string_t cmd_help_long_section = 1173 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1174 "all#control#display#config#" 1175 "ports#registers#filters#traffic_management#devices"); 1176 1177 cmdline_parse_inst_t cmd_help_long = { 1178 .f = cmd_help_long_parsed, 1179 .data = NULL, 1180 .help_str = "help all|control|display|config|ports|register|" 1181 "filters|traffic_management|devices: " 1182 "Show help", 1183 .tokens = { 1184 (void *)&cmd_help_long_help, 1185 (void *)&cmd_help_long_section, 1186 NULL, 1187 }, 1188 }; 1189 1190 1191 /* *** start/stop/close all ports *** */ 1192 struct cmd_operate_port_result { 1193 cmdline_fixed_string_t keyword; 1194 cmdline_fixed_string_t name; 1195 cmdline_fixed_string_t value; 1196 }; 1197 1198 static void cmd_operate_port_parsed(void *parsed_result, 1199 __rte_unused struct cmdline *cl, 1200 __rte_unused void *data) 1201 { 1202 struct cmd_operate_port_result *res = parsed_result; 1203 1204 if (!strcmp(res->name, "start")) 1205 start_port(RTE_PORT_ALL); 1206 else if (!strcmp(res->name, "stop")) 1207 stop_port(RTE_PORT_ALL); 1208 else if (!strcmp(res->name, "close")) 1209 close_port(RTE_PORT_ALL); 1210 else if (!strcmp(res->name, "reset")) 1211 reset_port(RTE_PORT_ALL); 1212 else 1213 printf("Unknown parameter\n"); 1214 } 1215 1216 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1217 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1218 "port"); 1219 cmdline_parse_token_string_t cmd_operate_port_all_port = 1220 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1221 "start#stop#close#reset"); 1222 cmdline_parse_token_string_t cmd_operate_port_all_all = 1223 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1224 1225 cmdline_parse_inst_t cmd_operate_port = { 1226 .f = cmd_operate_port_parsed, 1227 .data = NULL, 1228 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports", 1229 .tokens = { 1230 (void *)&cmd_operate_port_all_cmd, 1231 (void *)&cmd_operate_port_all_port, 1232 (void *)&cmd_operate_port_all_all, 1233 NULL, 1234 }, 1235 }; 1236 1237 /* *** start/stop/close specific port *** */ 1238 struct cmd_operate_specific_port_result { 1239 cmdline_fixed_string_t keyword; 1240 cmdline_fixed_string_t name; 1241 uint8_t value; 1242 }; 1243 1244 static void cmd_operate_specific_port_parsed(void *parsed_result, 1245 __rte_unused struct cmdline *cl, 1246 __rte_unused void *data) 1247 { 1248 struct cmd_operate_specific_port_result *res = parsed_result; 1249 1250 if (!strcmp(res->name, "start")) 1251 start_port(res->value); 1252 else if (!strcmp(res->name, "stop")) 1253 stop_port(res->value); 1254 else if (!strcmp(res->name, "close")) 1255 close_port(res->value); 1256 else if (!strcmp(res->name, "reset")) 1257 reset_port(res->value); 1258 else 1259 printf("Unknown parameter\n"); 1260 } 1261 1262 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1263 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1264 keyword, "port"); 1265 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1266 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1267 name, "start#stop#close#reset"); 1268 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1269 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1270 value, RTE_UINT8); 1271 1272 cmdline_parse_inst_t cmd_operate_specific_port = { 1273 .f = cmd_operate_specific_port_parsed, 1274 .data = NULL, 1275 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id", 1276 .tokens = { 1277 (void *)&cmd_operate_specific_port_cmd, 1278 (void *)&cmd_operate_specific_port_port, 1279 (void *)&cmd_operate_specific_port_id, 1280 NULL, 1281 }, 1282 }; 1283 1284 /* *** enable port setup (after attach) via iterator or event *** */ 1285 struct cmd_set_port_setup_on_result { 1286 cmdline_fixed_string_t set; 1287 cmdline_fixed_string_t port; 1288 cmdline_fixed_string_t setup; 1289 cmdline_fixed_string_t on; 1290 cmdline_fixed_string_t mode; 1291 }; 1292 1293 static void cmd_set_port_setup_on_parsed(void *parsed_result, 1294 __rte_unused struct cmdline *cl, 1295 __rte_unused void *data) 1296 { 1297 struct cmd_set_port_setup_on_result *res = parsed_result; 1298 1299 if (strcmp(res->mode, "event") == 0) 1300 setup_on_probe_event = true; 1301 else if (strcmp(res->mode, "iterator") == 0) 1302 setup_on_probe_event = false; 1303 else 1304 printf("Unknown mode\n"); 1305 } 1306 1307 cmdline_parse_token_string_t cmd_set_port_setup_on_set = 1308 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1309 set, "set"); 1310 cmdline_parse_token_string_t cmd_set_port_setup_on_port = 1311 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1312 port, "port"); 1313 cmdline_parse_token_string_t cmd_set_port_setup_on_setup = 1314 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1315 setup, "setup"); 1316 cmdline_parse_token_string_t cmd_set_port_setup_on_on = 1317 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1318 on, "on"); 1319 cmdline_parse_token_string_t cmd_set_port_setup_on_mode = 1320 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1321 mode, "iterator#event"); 1322 1323 cmdline_parse_inst_t cmd_set_port_setup_on = { 1324 .f = cmd_set_port_setup_on_parsed, 1325 .data = NULL, 1326 .help_str = "set port setup on iterator|event", 1327 .tokens = { 1328 (void *)&cmd_set_port_setup_on_set, 1329 (void *)&cmd_set_port_setup_on_port, 1330 (void *)&cmd_set_port_setup_on_setup, 1331 (void *)&cmd_set_port_setup_on_on, 1332 (void *)&cmd_set_port_setup_on_mode, 1333 NULL, 1334 }, 1335 }; 1336 1337 /* *** attach a specified port *** */ 1338 struct cmd_operate_attach_port_result { 1339 cmdline_fixed_string_t port; 1340 cmdline_fixed_string_t keyword; 1341 cmdline_multi_string_t identifier; 1342 }; 1343 1344 static void cmd_operate_attach_port_parsed(void *parsed_result, 1345 __rte_unused struct cmdline *cl, 1346 __rte_unused void *data) 1347 { 1348 struct cmd_operate_attach_port_result *res = parsed_result; 1349 1350 if (!strcmp(res->keyword, "attach")) 1351 attach_port(res->identifier); 1352 else 1353 printf("Unknown parameter\n"); 1354 } 1355 1356 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1357 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1358 port, "port"); 1359 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1360 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1361 keyword, "attach"); 1362 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1363 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1364 identifier, TOKEN_STRING_MULTI); 1365 1366 cmdline_parse_inst_t cmd_operate_attach_port = { 1367 .f = cmd_operate_attach_port_parsed, 1368 .data = NULL, 1369 .help_str = "port attach <identifier>: " 1370 "(identifier: pci address or virtual dev name)", 1371 .tokens = { 1372 (void *)&cmd_operate_attach_port_port, 1373 (void *)&cmd_operate_attach_port_keyword, 1374 (void *)&cmd_operate_attach_port_identifier, 1375 NULL, 1376 }, 1377 }; 1378 1379 /* *** detach a specified port *** */ 1380 struct cmd_operate_detach_port_result { 1381 cmdline_fixed_string_t port; 1382 cmdline_fixed_string_t keyword; 1383 portid_t port_id; 1384 }; 1385 1386 static void cmd_operate_detach_port_parsed(void *parsed_result, 1387 __rte_unused struct cmdline *cl, 1388 __rte_unused void *data) 1389 { 1390 struct cmd_operate_detach_port_result *res = parsed_result; 1391 1392 if (!strcmp(res->keyword, "detach")) { 1393 RTE_ETH_VALID_PORTID_OR_RET(res->port_id); 1394 detach_port_device(res->port_id); 1395 } else { 1396 printf("Unknown parameter\n"); 1397 } 1398 } 1399 1400 cmdline_parse_token_string_t cmd_operate_detach_port_port = 1401 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1402 port, "port"); 1403 cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1404 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1405 keyword, "detach"); 1406 cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1407 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1408 port_id, RTE_UINT16); 1409 1410 cmdline_parse_inst_t cmd_operate_detach_port = { 1411 .f = cmd_operate_detach_port_parsed, 1412 .data = NULL, 1413 .help_str = "port detach <port_id>", 1414 .tokens = { 1415 (void *)&cmd_operate_detach_port_port, 1416 (void *)&cmd_operate_detach_port_keyword, 1417 (void *)&cmd_operate_detach_port_port_id, 1418 NULL, 1419 }, 1420 }; 1421 1422 /* *** detach device by identifier *** */ 1423 struct cmd_operate_detach_device_result { 1424 cmdline_fixed_string_t device; 1425 cmdline_fixed_string_t keyword; 1426 cmdline_fixed_string_t identifier; 1427 }; 1428 1429 static void cmd_operate_detach_device_parsed(void *parsed_result, 1430 __rte_unused struct cmdline *cl, 1431 __rte_unused void *data) 1432 { 1433 struct cmd_operate_detach_device_result *res = parsed_result; 1434 1435 if (!strcmp(res->keyword, "detach")) 1436 detach_devargs(res->identifier); 1437 else 1438 printf("Unknown parameter\n"); 1439 } 1440 1441 cmdline_parse_token_string_t cmd_operate_detach_device_device = 1442 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1443 device, "device"); 1444 cmdline_parse_token_string_t cmd_operate_detach_device_keyword = 1445 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1446 keyword, "detach"); 1447 cmdline_parse_token_string_t cmd_operate_detach_device_identifier = 1448 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1449 identifier, NULL); 1450 1451 cmdline_parse_inst_t cmd_operate_detach_device = { 1452 .f = cmd_operate_detach_device_parsed, 1453 .data = NULL, 1454 .help_str = "device detach <identifier>:" 1455 "(identifier: pci address or virtual dev name)", 1456 .tokens = { 1457 (void *)&cmd_operate_detach_device_device, 1458 (void *)&cmd_operate_detach_device_keyword, 1459 (void *)&cmd_operate_detach_device_identifier, 1460 NULL, 1461 }, 1462 }; 1463 /* *** configure speed for all ports *** */ 1464 struct cmd_config_speed_all { 1465 cmdline_fixed_string_t port; 1466 cmdline_fixed_string_t keyword; 1467 cmdline_fixed_string_t all; 1468 cmdline_fixed_string_t item1; 1469 cmdline_fixed_string_t item2; 1470 cmdline_fixed_string_t value1; 1471 cmdline_fixed_string_t value2; 1472 }; 1473 1474 static int 1475 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1476 { 1477 1478 int duplex; 1479 1480 if (!strcmp(duplexstr, "half")) { 1481 duplex = ETH_LINK_HALF_DUPLEX; 1482 } else if (!strcmp(duplexstr, "full")) { 1483 duplex = ETH_LINK_FULL_DUPLEX; 1484 } else if (!strcmp(duplexstr, "auto")) { 1485 duplex = ETH_LINK_FULL_DUPLEX; 1486 } else { 1487 printf("Unknown duplex parameter\n"); 1488 return -1; 1489 } 1490 1491 if (!strcmp(speedstr, "10")) { 1492 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1493 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M; 1494 } else if (!strcmp(speedstr, "100")) { 1495 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1496 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M; 1497 } else { 1498 if (duplex != ETH_LINK_FULL_DUPLEX) { 1499 printf("Invalid speed/duplex parameters\n"); 1500 return -1; 1501 } 1502 if (!strcmp(speedstr, "1000")) { 1503 *speed = ETH_LINK_SPEED_1G; 1504 } else if (!strcmp(speedstr, "10000")) { 1505 *speed = ETH_LINK_SPEED_10G; 1506 } else if (!strcmp(speedstr, "25000")) { 1507 *speed = ETH_LINK_SPEED_25G; 1508 } else if (!strcmp(speedstr, "40000")) { 1509 *speed = ETH_LINK_SPEED_40G; 1510 } else if (!strcmp(speedstr, "50000")) { 1511 *speed = ETH_LINK_SPEED_50G; 1512 } else if (!strcmp(speedstr, "100000")) { 1513 *speed = ETH_LINK_SPEED_100G; 1514 } else if (!strcmp(speedstr, "200000")) { 1515 *speed = ETH_LINK_SPEED_200G; 1516 } else if (!strcmp(speedstr, "auto")) { 1517 *speed = ETH_LINK_SPEED_AUTONEG; 1518 } else { 1519 printf("Unknown speed parameter\n"); 1520 return -1; 1521 } 1522 } 1523 1524 return 0; 1525 } 1526 1527 static void 1528 cmd_config_speed_all_parsed(void *parsed_result, 1529 __rte_unused struct cmdline *cl, 1530 __rte_unused void *data) 1531 { 1532 struct cmd_config_speed_all *res = parsed_result; 1533 uint32_t link_speed; 1534 portid_t pid; 1535 1536 if (!all_ports_stopped()) { 1537 printf("Please stop all ports first\n"); 1538 return; 1539 } 1540 1541 if (parse_and_check_speed_duplex(res->value1, res->value2, 1542 &link_speed) < 0) 1543 return; 1544 1545 RTE_ETH_FOREACH_DEV(pid) { 1546 ports[pid].dev_conf.link_speeds = link_speed; 1547 } 1548 1549 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1550 } 1551 1552 cmdline_parse_token_string_t cmd_config_speed_all_port = 1553 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1554 cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1555 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1556 "config"); 1557 cmdline_parse_token_string_t cmd_config_speed_all_all = 1558 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1559 cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1560 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1561 cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1562 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1563 "10#100#1000#10000#25000#40000#50000#100000#200000#auto"); 1564 cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1565 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1566 cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1567 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1568 "half#full#auto"); 1569 1570 cmdline_parse_inst_t cmd_config_speed_all = { 1571 .f = cmd_config_speed_all_parsed, 1572 .data = NULL, 1573 .help_str = "port config all speed " 1574 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex " 1575 "half|full|auto", 1576 .tokens = { 1577 (void *)&cmd_config_speed_all_port, 1578 (void *)&cmd_config_speed_all_keyword, 1579 (void *)&cmd_config_speed_all_all, 1580 (void *)&cmd_config_speed_all_item1, 1581 (void *)&cmd_config_speed_all_value1, 1582 (void *)&cmd_config_speed_all_item2, 1583 (void *)&cmd_config_speed_all_value2, 1584 NULL, 1585 }, 1586 }; 1587 1588 /* *** configure speed for specific port *** */ 1589 struct cmd_config_speed_specific { 1590 cmdline_fixed_string_t port; 1591 cmdline_fixed_string_t keyword; 1592 portid_t id; 1593 cmdline_fixed_string_t item1; 1594 cmdline_fixed_string_t item2; 1595 cmdline_fixed_string_t value1; 1596 cmdline_fixed_string_t value2; 1597 }; 1598 1599 static void 1600 cmd_config_speed_specific_parsed(void *parsed_result, 1601 __rte_unused struct cmdline *cl, 1602 __rte_unused void *data) 1603 { 1604 struct cmd_config_speed_specific *res = parsed_result; 1605 uint32_t link_speed; 1606 1607 if (!all_ports_stopped()) { 1608 printf("Please stop all ports first\n"); 1609 return; 1610 } 1611 1612 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1613 return; 1614 1615 if (parse_and_check_speed_duplex(res->value1, res->value2, 1616 &link_speed) < 0) 1617 return; 1618 1619 ports[res->id].dev_conf.link_speeds = link_speed; 1620 1621 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1622 } 1623 1624 1625 cmdline_parse_token_string_t cmd_config_speed_specific_port = 1626 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1627 "port"); 1628 cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1629 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1630 "config"); 1631 cmdline_parse_token_num_t cmd_config_speed_specific_id = 1632 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16); 1633 cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1634 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1635 "speed"); 1636 cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1637 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1638 "10#100#1000#10000#25000#40000#50000#100000#200000#auto"); 1639 cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1640 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1641 "duplex"); 1642 cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1643 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1644 "half#full#auto"); 1645 1646 cmdline_parse_inst_t cmd_config_speed_specific = { 1647 .f = cmd_config_speed_specific_parsed, 1648 .data = NULL, 1649 .help_str = "port config <port_id> speed " 1650 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex " 1651 "half|full|auto", 1652 .tokens = { 1653 (void *)&cmd_config_speed_specific_port, 1654 (void *)&cmd_config_speed_specific_keyword, 1655 (void *)&cmd_config_speed_specific_id, 1656 (void *)&cmd_config_speed_specific_item1, 1657 (void *)&cmd_config_speed_specific_value1, 1658 (void *)&cmd_config_speed_specific_item2, 1659 (void *)&cmd_config_speed_specific_value2, 1660 NULL, 1661 }, 1662 }; 1663 1664 /* *** configure loopback for all ports *** */ 1665 struct cmd_config_loopback_all { 1666 cmdline_fixed_string_t port; 1667 cmdline_fixed_string_t keyword; 1668 cmdline_fixed_string_t all; 1669 cmdline_fixed_string_t item; 1670 uint32_t mode; 1671 }; 1672 1673 static void 1674 cmd_config_loopback_all_parsed(void *parsed_result, 1675 __rte_unused struct cmdline *cl, 1676 __rte_unused void *data) 1677 { 1678 struct cmd_config_loopback_all *res = parsed_result; 1679 portid_t pid; 1680 1681 if (!all_ports_stopped()) { 1682 printf("Please stop all ports first\n"); 1683 return; 1684 } 1685 1686 RTE_ETH_FOREACH_DEV(pid) { 1687 ports[pid].dev_conf.lpbk_mode = res->mode; 1688 } 1689 1690 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1691 } 1692 1693 cmdline_parse_token_string_t cmd_config_loopback_all_port = 1694 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port"); 1695 cmdline_parse_token_string_t cmd_config_loopback_all_keyword = 1696 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword, 1697 "config"); 1698 cmdline_parse_token_string_t cmd_config_loopback_all_all = 1699 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all"); 1700 cmdline_parse_token_string_t cmd_config_loopback_all_item = 1701 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item, 1702 "loopback"); 1703 cmdline_parse_token_num_t cmd_config_loopback_all_mode = 1704 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32); 1705 1706 cmdline_parse_inst_t cmd_config_loopback_all = { 1707 .f = cmd_config_loopback_all_parsed, 1708 .data = NULL, 1709 .help_str = "port config all loopback <mode>", 1710 .tokens = { 1711 (void *)&cmd_config_loopback_all_port, 1712 (void *)&cmd_config_loopback_all_keyword, 1713 (void *)&cmd_config_loopback_all_all, 1714 (void *)&cmd_config_loopback_all_item, 1715 (void *)&cmd_config_loopback_all_mode, 1716 NULL, 1717 }, 1718 }; 1719 1720 /* *** configure loopback for specific port *** */ 1721 struct cmd_config_loopback_specific { 1722 cmdline_fixed_string_t port; 1723 cmdline_fixed_string_t keyword; 1724 uint16_t port_id; 1725 cmdline_fixed_string_t item; 1726 uint32_t mode; 1727 }; 1728 1729 static void 1730 cmd_config_loopback_specific_parsed(void *parsed_result, 1731 __rte_unused struct cmdline *cl, 1732 __rte_unused void *data) 1733 { 1734 struct cmd_config_loopback_specific *res = parsed_result; 1735 1736 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 1737 return; 1738 1739 if (!port_is_stopped(res->port_id)) { 1740 printf("Please stop port %u first\n", res->port_id); 1741 return; 1742 } 1743 1744 ports[res->port_id].dev_conf.lpbk_mode = res->mode; 1745 1746 cmd_reconfig_device_queue(res->port_id, 1, 1); 1747 } 1748 1749 1750 cmdline_parse_token_string_t cmd_config_loopback_specific_port = 1751 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port, 1752 "port"); 1753 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword = 1754 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword, 1755 "config"); 1756 cmdline_parse_token_num_t cmd_config_loopback_specific_id = 1757 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id, 1758 RTE_UINT16); 1759 cmdline_parse_token_string_t cmd_config_loopback_specific_item = 1760 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item, 1761 "loopback"); 1762 cmdline_parse_token_num_t cmd_config_loopback_specific_mode = 1763 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode, 1764 RTE_UINT32); 1765 1766 cmdline_parse_inst_t cmd_config_loopback_specific = { 1767 .f = cmd_config_loopback_specific_parsed, 1768 .data = NULL, 1769 .help_str = "port config <port_id> loopback <mode>", 1770 .tokens = { 1771 (void *)&cmd_config_loopback_specific_port, 1772 (void *)&cmd_config_loopback_specific_keyword, 1773 (void *)&cmd_config_loopback_specific_id, 1774 (void *)&cmd_config_loopback_specific_item, 1775 (void *)&cmd_config_loopback_specific_mode, 1776 NULL, 1777 }, 1778 }; 1779 1780 /* *** configure txq/rxq, txd/rxd *** */ 1781 struct cmd_config_rx_tx { 1782 cmdline_fixed_string_t port; 1783 cmdline_fixed_string_t keyword; 1784 cmdline_fixed_string_t all; 1785 cmdline_fixed_string_t name; 1786 uint16_t value; 1787 }; 1788 1789 static void 1790 cmd_config_rx_tx_parsed(void *parsed_result, 1791 __rte_unused struct cmdline *cl, 1792 __rte_unused void *data) 1793 { 1794 struct cmd_config_rx_tx *res = parsed_result; 1795 1796 if (!all_ports_stopped()) { 1797 printf("Please stop all ports first\n"); 1798 return; 1799 } 1800 if (!strcmp(res->name, "rxq")) { 1801 if (!res->value && !nb_txq) { 1802 printf("Warning: Either rx or tx queues should be non zero\n"); 1803 return; 1804 } 1805 if (check_nb_rxq(res->value) != 0) 1806 return; 1807 nb_rxq = res->value; 1808 } 1809 else if (!strcmp(res->name, "txq")) { 1810 if (!res->value && !nb_rxq) { 1811 printf("Warning: Either rx or tx queues should be non zero\n"); 1812 return; 1813 } 1814 if (check_nb_txq(res->value) != 0) 1815 return; 1816 nb_txq = res->value; 1817 } 1818 else if (!strcmp(res->name, "rxd")) { 1819 if (check_nb_rxd(res->value) != 0) 1820 return; 1821 nb_rxd = res->value; 1822 } else if (!strcmp(res->name, "txd")) { 1823 if (check_nb_txd(res->value) != 0) 1824 return; 1825 1826 nb_txd = res->value; 1827 } else { 1828 printf("Unknown parameter\n"); 1829 return; 1830 } 1831 1832 fwd_config_setup(); 1833 1834 init_port_config(); 1835 1836 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1837 } 1838 1839 cmdline_parse_token_string_t cmd_config_rx_tx_port = 1840 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1841 cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1842 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1843 cmdline_parse_token_string_t cmd_config_rx_tx_all = 1844 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1845 cmdline_parse_token_string_t cmd_config_rx_tx_name = 1846 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1847 "rxq#txq#rxd#txd"); 1848 cmdline_parse_token_num_t cmd_config_rx_tx_value = 1849 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16); 1850 1851 cmdline_parse_inst_t cmd_config_rx_tx = { 1852 .f = cmd_config_rx_tx_parsed, 1853 .data = NULL, 1854 .help_str = "port config all rxq|txq|rxd|txd <value>", 1855 .tokens = { 1856 (void *)&cmd_config_rx_tx_port, 1857 (void *)&cmd_config_rx_tx_keyword, 1858 (void *)&cmd_config_rx_tx_all, 1859 (void *)&cmd_config_rx_tx_name, 1860 (void *)&cmd_config_rx_tx_value, 1861 NULL, 1862 }, 1863 }; 1864 1865 /* *** config max packet length *** */ 1866 struct cmd_config_max_pkt_len_result { 1867 cmdline_fixed_string_t port; 1868 cmdline_fixed_string_t keyword; 1869 cmdline_fixed_string_t all; 1870 cmdline_fixed_string_t name; 1871 uint32_t value; 1872 }; 1873 1874 static void 1875 cmd_config_max_pkt_len_parsed(void *parsed_result, 1876 __rte_unused struct cmdline *cl, 1877 __rte_unused void *data) 1878 { 1879 struct cmd_config_max_pkt_len_result *res = parsed_result; 1880 uint32_t max_rx_pkt_len_backup = 0; 1881 portid_t pid; 1882 int ret; 1883 1884 if (!all_ports_stopped()) { 1885 printf("Please stop all ports first\n"); 1886 return; 1887 } 1888 1889 RTE_ETH_FOREACH_DEV(pid) { 1890 struct rte_port *port = &ports[pid]; 1891 1892 if (!strcmp(res->name, "max-pkt-len")) { 1893 if (res->value < RTE_ETHER_MIN_LEN) { 1894 printf("max-pkt-len can not be less than %d\n", 1895 RTE_ETHER_MIN_LEN); 1896 return; 1897 } 1898 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len) 1899 return; 1900 1901 ret = eth_dev_info_get_print_err(pid, &port->dev_info); 1902 if (ret != 0) { 1903 printf("rte_eth_dev_info_get() failed for port %u\n", 1904 pid); 1905 return; 1906 } 1907 1908 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len; 1909 1910 port->dev_conf.rxmode.max_rx_pkt_len = res->value; 1911 if (update_jumbo_frame_offload(pid) != 0) 1912 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup; 1913 } else { 1914 printf("Unknown parameter\n"); 1915 return; 1916 } 1917 } 1918 1919 init_port_config(); 1920 1921 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1922 } 1923 1924 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 1925 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 1926 "port"); 1927 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 1928 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 1929 "config"); 1930 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 1931 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 1932 "all"); 1933 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 1934 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 1935 "max-pkt-len"); 1936 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 1937 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 1938 RTE_UINT32); 1939 1940 cmdline_parse_inst_t cmd_config_max_pkt_len = { 1941 .f = cmd_config_max_pkt_len_parsed, 1942 .data = NULL, 1943 .help_str = "port config all max-pkt-len <value>", 1944 .tokens = { 1945 (void *)&cmd_config_max_pkt_len_port, 1946 (void *)&cmd_config_max_pkt_len_keyword, 1947 (void *)&cmd_config_max_pkt_len_all, 1948 (void *)&cmd_config_max_pkt_len_name, 1949 (void *)&cmd_config_max_pkt_len_value, 1950 NULL, 1951 }, 1952 }; 1953 1954 /* *** config max LRO aggregated packet size *** */ 1955 struct cmd_config_max_lro_pkt_size_result { 1956 cmdline_fixed_string_t port; 1957 cmdline_fixed_string_t keyword; 1958 cmdline_fixed_string_t all; 1959 cmdline_fixed_string_t name; 1960 uint32_t value; 1961 }; 1962 1963 static void 1964 cmd_config_max_lro_pkt_size_parsed(void *parsed_result, 1965 __rte_unused struct cmdline *cl, 1966 __rte_unused void *data) 1967 { 1968 struct cmd_config_max_lro_pkt_size_result *res = parsed_result; 1969 portid_t pid; 1970 1971 if (!all_ports_stopped()) { 1972 printf("Please stop all ports first\n"); 1973 return; 1974 } 1975 1976 RTE_ETH_FOREACH_DEV(pid) { 1977 struct rte_port *port = &ports[pid]; 1978 1979 if (!strcmp(res->name, "max-lro-pkt-size")) { 1980 if (res->value == 1981 port->dev_conf.rxmode.max_lro_pkt_size) 1982 return; 1983 1984 port->dev_conf.rxmode.max_lro_pkt_size = res->value; 1985 } else { 1986 printf("Unknown parameter\n"); 1987 return; 1988 } 1989 } 1990 1991 init_port_config(); 1992 1993 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1994 } 1995 1996 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port = 1997 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 1998 port, "port"); 1999 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword = 2000 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2001 keyword, "config"); 2002 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all = 2003 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2004 all, "all"); 2005 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name = 2006 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2007 name, "max-lro-pkt-size"); 2008 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value = 2009 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2010 value, RTE_UINT32); 2011 2012 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = { 2013 .f = cmd_config_max_lro_pkt_size_parsed, 2014 .data = NULL, 2015 .help_str = "port config all max-lro-pkt-size <value>", 2016 .tokens = { 2017 (void *)&cmd_config_max_lro_pkt_size_port, 2018 (void *)&cmd_config_max_lro_pkt_size_keyword, 2019 (void *)&cmd_config_max_lro_pkt_size_all, 2020 (void *)&cmd_config_max_lro_pkt_size_name, 2021 (void *)&cmd_config_max_lro_pkt_size_value, 2022 NULL, 2023 }, 2024 }; 2025 2026 /* *** configure port MTU *** */ 2027 struct cmd_config_mtu_result { 2028 cmdline_fixed_string_t port; 2029 cmdline_fixed_string_t keyword; 2030 cmdline_fixed_string_t mtu; 2031 portid_t port_id; 2032 uint16_t value; 2033 }; 2034 2035 static void 2036 cmd_config_mtu_parsed(void *parsed_result, 2037 __rte_unused struct cmdline *cl, 2038 __rte_unused void *data) 2039 { 2040 struct cmd_config_mtu_result *res = parsed_result; 2041 2042 if (res->value < RTE_ETHER_MIN_LEN) { 2043 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN); 2044 return; 2045 } 2046 port_mtu_set(res->port_id, res->value); 2047 } 2048 2049 cmdline_parse_token_string_t cmd_config_mtu_port = 2050 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 2051 "port"); 2052 cmdline_parse_token_string_t cmd_config_mtu_keyword = 2053 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2054 "config"); 2055 cmdline_parse_token_string_t cmd_config_mtu_mtu = 2056 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2057 "mtu"); 2058 cmdline_parse_token_num_t cmd_config_mtu_port_id = 2059 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, 2060 RTE_UINT16); 2061 cmdline_parse_token_num_t cmd_config_mtu_value = 2062 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, 2063 RTE_UINT16); 2064 2065 cmdline_parse_inst_t cmd_config_mtu = { 2066 .f = cmd_config_mtu_parsed, 2067 .data = NULL, 2068 .help_str = "port config mtu <port_id> <value>", 2069 .tokens = { 2070 (void *)&cmd_config_mtu_port, 2071 (void *)&cmd_config_mtu_keyword, 2072 (void *)&cmd_config_mtu_mtu, 2073 (void *)&cmd_config_mtu_port_id, 2074 (void *)&cmd_config_mtu_value, 2075 NULL, 2076 }, 2077 }; 2078 2079 /* *** configure rx mode *** */ 2080 struct cmd_config_rx_mode_flag { 2081 cmdline_fixed_string_t port; 2082 cmdline_fixed_string_t keyword; 2083 cmdline_fixed_string_t all; 2084 cmdline_fixed_string_t name; 2085 cmdline_fixed_string_t value; 2086 }; 2087 2088 static void 2089 cmd_config_rx_mode_flag_parsed(void *parsed_result, 2090 __rte_unused struct cmdline *cl, 2091 __rte_unused void *data) 2092 { 2093 struct cmd_config_rx_mode_flag *res = parsed_result; 2094 2095 if (!all_ports_stopped()) { 2096 printf("Please stop all ports first\n"); 2097 return; 2098 } 2099 2100 if (!strcmp(res->name, "drop-en")) { 2101 if (!strcmp(res->value, "on")) 2102 rx_drop_en = 1; 2103 else if (!strcmp(res->value, "off")) 2104 rx_drop_en = 0; 2105 else { 2106 printf("Unknown parameter\n"); 2107 return; 2108 } 2109 } else { 2110 printf("Unknown parameter\n"); 2111 return; 2112 } 2113 2114 init_port_config(); 2115 2116 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2117 } 2118 2119 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 2120 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 2121 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 2122 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 2123 "config"); 2124 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 2125 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 2126 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 2127 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 2128 "drop-en"); 2129 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 2130 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 2131 "on#off"); 2132 2133 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 2134 .f = cmd_config_rx_mode_flag_parsed, 2135 .data = NULL, 2136 .help_str = "port config all drop-en on|off", 2137 .tokens = { 2138 (void *)&cmd_config_rx_mode_flag_port, 2139 (void *)&cmd_config_rx_mode_flag_keyword, 2140 (void *)&cmd_config_rx_mode_flag_all, 2141 (void *)&cmd_config_rx_mode_flag_name, 2142 (void *)&cmd_config_rx_mode_flag_value, 2143 NULL, 2144 }, 2145 }; 2146 2147 /* *** configure rss *** */ 2148 struct cmd_config_rss { 2149 cmdline_fixed_string_t port; 2150 cmdline_fixed_string_t keyword; 2151 cmdline_fixed_string_t all; 2152 cmdline_fixed_string_t name; 2153 cmdline_fixed_string_t value; 2154 }; 2155 2156 static void 2157 cmd_config_rss_parsed(void *parsed_result, 2158 __rte_unused struct cmdline *cl, 2159 __rte_unused void *data) 2160 { 2161 struct cmd_config_rss *res = parsed_result; 2162 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2163 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2164 int use_default = 0; 2165 int all_updated = 1; 2166 int diag; 2167 uint16_t i; 2168 int ret; 2169 2170 if (!strcmp(res->value, "all")) 2171 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP | 2172 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP | 2173 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP | 2174 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU | 2175 ETH_RSS_ECPRI; 2176 else if (!strcmp(res->value, "eth")) 2177 rss_conf.rss_hf = ETH_RSS_ETH; 2178 else if (!strcmp(res->value, "vlan")) 2179 rss_conf.rss_hf = ETH_RSS_VLAN; 2180 else if (!strcmp(res->value, "ip")) 2181 rss_conf.rss_hf = ETH_RSS_IP; 2182 else if (!strcmp(res->value, "udp")) 2183 rss_conf.rss_hf = ETH_RSS_UDP; 2184 else if (!strcmp(res->value, "tcp")) 2185 rss_conf.rss_hf = ETH_RSS_TCP; 2186 else if (!strcmp(res->value, "sctp")) 2187 rss_conf.rss_hf = ETH_RSS_SCTP; 2188 else if (!strcmp(res->value, "ether")) 2189 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 2190 else if (!strcmp(res->value, "port")) 2191 rss_conf.rss_hf = ETH_RSS_PORT; 2192 else if (!strcmp(res->value, "vxlan")) 2193 rss_conf.rss_hf = ETH_RSS_VXLAN; 2194 else if (!strcmp(res->value, "geneve")) 2195 rss_conf.rss_hf = ETH_RSS_GENEVE; 2196 else if (!strcmp(res->value, "nvgre")) 2197 rss_conf.rss_hf = ETH_RSS_NVGRE; 2198 else if (!strcmp(res->value, "l3-pre32")) 2199 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32; 2200 else if (!strcmp(res->value, "l3-pre40")) 2201 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40; 2202 else if (!strcmp(res->value, "l3-pre48")) 2203 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48; 2204 else if (!strcmp(res->value, "l3-pre56")) 2205 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56; 2206 else if (!strcmp(res->value, "l3-pre64")) 2207 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64; 2208 else if (!strcmp(res->value, "l3-pre96")) 2209 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96; 2210 else if (!strcmp(res->value, "l3-src-only")) 2211 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY; 2212 else if (!strcmp(res->value, "l3-dst-only")) 2213 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY; 2214 else if (!strcmp(res->value, "l4-src-only")) 2215 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY; 2216 else if (!strcmp(res->value, "l4-dst-only")) 2217 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY; 2218 else if (!strcmp(res->value, "l2-src-only")) 2219 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY; 2220 else if (!strcmp(res->value, "l2-dst-only")) 2221 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY; 2222 else if (!strcmp(res->value, "l2tpv3")) 2223 rss_conf.rss_hf = ETH_RSS_L2TPV3; 2224 else if (!strcmp(res->value, "esp")) 2225 rss_conf.rss_hf = ETH_RSS_ESP; 2226 else if (!strcmp(res->value, "ah")) 2227 rss_conf.rss_hf = ETH_RSS_AH; 2228 else if (!strcmp(res->value, "pfcp")) 2229 rss_conf.rss_hf = ETH_RSS_PFCP; 2230 else if (!strcmp(res->value, "pppoe")) 2231 rss_conf.rss_hf = ETH_RSS_PPPOE; 2232 else if (!strcmp(res->value, "gtpu")) 2233 rss_conf.rss_hf = ETH_RSS_GTPU; 2234 else if (!strcmp(res->value, "ecpri")) 2235 rss_conf.rss_hf = ETH_RSS_ECPRI; 2236 else if (!strcmp(res->value, "mpls")) 2237 rss_conf.rss_hf = ETH_RSS_MPLS; 2238 else if (!strcmp(res->value, "none")) 2239 rss_conf.rss_hf = 0; 2240 else if (!strcmp(res->value, "level-default")) { 2241 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2242 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT); 2243 } else if (!strcmp(res->value, "level-outer")) { 2244 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2245 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST); 2246 } else if (!strcmp(res->value, "level-inner")) { 2247 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2248 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST); 2249 } else if (!strcmp(res->value, "default")) 2250 use_default = 1; 2251 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 2252 atoi(res->value) < 64) 2253 rss_conf.rss_hf = 1ULL << atoi(res->value); 2254 else { 2255 printf("Unknown parameter\n"); 2256 return; 2257 } 2258 rss_conf.rss_key = NULL; 2259 /* Update global configuration for RSS types. */ 2260 RTE_ETH_FOREACH_DEV(i) { 2261 struct rte_eth_rss_conf local_rss_conf; 2262 2263 ret = eth_dev_info_get_print_err(i, &dev_info); 2264 if (ret != 0) 2265 return; 2266 2267 if (use_default) 2268 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2269 2270 local_rss_conf = rss_conf; 2271 local_rss_conf.rss_hf = rss_conf.rss_hf & 2272 dev_info.flow_type_rss_offloads; 2273 if (local_rss_conf.rss_hf != rss_conf.rss_hf) { 2274 printf("Port %u modified RSS hash function based on hardware support," 2275 "requested:%#"PRIx64" configured:%#"PRIx64"\n", 2276 i, rss_conf.rss_hf, local_rss_conf.rss_hf); 2277 } 2278 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf); 2279 if (diag < 0) { 2280 all_updated = 0; 2281 printf("Configuration of RSS hash at ethernet port %d " 2282 "failed with error (%d): %s.\n", 2283 i, -diag, strerror(-diag)); 2284 } 2285 } 2286 if (all_updated && !use_default) { 2287 rss_hf = rss_conf.rss_hf; 2288 printf("rss_hf %#"PRIx64"\n", rss_hf); 2289 } 2290 } 2291 2292 cmdline_parse_token_string_t cmd_config_rss_port = 2293 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2294 cmdline_parse_token_string_t cmd_config_rss_keyword = 2295 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2296 cmdline_parse_token_string_t cmd_config_rss_all = 2297 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2298 cmdline_parse_token_string_t cmd_config_rss_name = 2299 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2300 cmdline_parse_token_string_t cmd_config_rss_value = 2301 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2302 2303 cmdline_parse_inst_t cmd_config_rss = { 2304 .f = cmd_config_rss_parsed, 2305 .data = NULL, 2306 .help_str = "port config all rss " 2307 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|" 2308 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|" 2309 "level-outer|level-inner|<flowtype_id>", 2310 .tokens = { 2311 (void *)&cmd_config_rss_port, 2312 (void *)&cmd_config_rss_keyword, 2313 (void *)&cmd_config_rss_all, 2314 (void *)&cmd_config_rss_name, 2315 (void *)&cmd_config_rss_value, 2316 NULL, 2317 }, 2318 }; 2319 2320 /* *** configure rss hash key *** */ 2321 struct cmd_config_rss_hash_key { 2322 cmdline_fixed_string_t port; 2323 cmdline_fixed_string_t config; 2324 portid_t port_id; 2325 cmdline_fixed_string_t rss_hash_key; 2326 cmdline_fixed_string_t rss_type; 2327 cmdline_fixed_string_t key; 2328 }; 2329 2330 static uint8_t 2331 hexa_digit_to_value(char hexa_digit) 2332 { 2333 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2334 return (uint8_t) (hexa_digit - '0'); 2335 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2336 return (uint8_t) ((hexa_digit - 'a') + 10); 2337 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2338 return (uint8_t) ((hexa_digit - 'A') + 10); 2339 /* Invalid hexa digit */ 2340 return 0xFF; 2341 } 2342 2343 static uint8_t 2344 parse_and_check_key_hexa_digit(char *key, int idx) 2345 { 2346 uint8_t hexa_v; 2347 2348 hexa_v = hexa_digit_to_value(key[idx]); 2349 if (hexa_v == 0xFF) 2350 printf("invalid key: character %c at position %d is not a " 2351 "valid hexa digit\n", key[idx], idx); 2352 return hexa_v; 2353 } 2354 2355 static void 2356 cmd_config_rss_hash_key_parsed(void *parsed_result, 2357 __rte_unused struct cmdline *cl, 2358 __rte_unused void *data) 2359 { 2360 struct cmd_config_rss_hash_key *res = parsed_result; 2361 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2362 uint8_t xdgt0; 2363 uint8_t xdgt1; 2364 int i; 2365 struct rte_eth_dev_info dev_info; 2366 uint8_t hash_key_size; 2367 uint32_t key_len; 2368 int ret; 2369 2370 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2371 if (ret != 0) 2372 return; 2373 2374 if (dev_info.hash_key_size > 0 && 2375 dev_info.hash_key_size <= sizeof(hash_key)) 2376 hash_key_size = dev_info.hash_key_size; 2377 else { 2378 printf("dev_info did not provide a valid hash key size\n"); 2379 return; 2380 } 2381 /* Check the length of the RSS hash key */ 2382 key_len = strlen(res->key); 2383 if (key_len != (hash_key_size * 2)) { 2384 printf("key length: %d invalid - key must be a string of %d" 2385 " hexa-decimal numbers\n", 2386 (int) key_len, hash_key_size * 2); 2387 return; 2388 } 2389 /* Translate RSS hash key into binary representation */ 2390 for (i = 0; i < hash_key_size; i++) { 2391 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2392 if (xdgt0 == 0xFF) 2393 return; 2394 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2395 if (xdgt1 == 0xFF) 2396 return; 2397 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2398 } 2399 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2400 hash_key_size); 2401 } 2402 2403 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2404 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2405 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2406 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2407 "config"); 2408 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2409 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, 2410 RTE_UINT16); 2411 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2412 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2413 rss_hash_key, "rss-hash-key"); 2414 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2415 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2416 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2417 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2418 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2419 "ipv6-tcp-ex#ipv6-udp-ex#" 2420 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#" 2421 "l2-src-only#l2-dst-only#s-vlan#c-vlan#" 2422 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri"); 2423 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2424 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2425 2426 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2427 .f = cmd_config_rss_hash_key_parsed, 2428 .data = NULL, 2429 .help_str = "port config <port_id> rss-hash-key " 2430 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2431 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2432 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|" 2433 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|" 2434 "l2-src-only|l2-dst-only|s-vlan|c-vlan|" 2435 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri " 2436 "<string of hex digits (variable length, NIC dependent)>", 2437 .tokens = { 2438 (void *)&cmd_config_rss_hash_key_port, 2439 (void *)&cmd_config_rss_hash_key_config, 2440 (void *)&cmd_config_rss_hash_key_port_id, 2441 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2442 (void *)&cmd_config_rss_hash_key_rss_type, 2443 (void *)&cmd_config_rss_hash_key_value, 2444 NULL, 2445 }, 2446 }; 2447 2448 /* *** configure port rxq/txq ring size *** */ 2449 struct cmd_config_rxtx_ring_size { 2450 cmdline_fixed_string_t port; 2451 cmdline_fixed_string_t config; 2452 portid_t portid; 2453 cmdline_fixed_string_t rxtxq; 2454 uint16_t qid; 2455 cmdline_fixed_string_t rsize; 2456 uint16_t size; 2457 }; 2458 2459 static void 2460 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2461 __rte_unused struct cmdline *cl, 2462 __rte_unused void *data) 2463 { 2464 struct cmd_config_rxtx_ring_size *res = parsed_result; 2465 struct rte_port *port; 2466 uint8_t isrx; 2467 2468 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2469 return; 2470 2471 if (res->portid == (portid_t)RTE_PORT_ALL) { 2472 printf("Invalid port id\n"); 2473 return; 2474 } 2475 2476 port = &ports[res->portid]; 2477 2478 if (!strcmp(res->rxtxq, "rxq")) 2479 isrx = 1; 2480 else if (!strcmp(res->rxtxq, "txq")) 2481 isrx = 0; 2482 else { 2483 printf("Unknown parameter\n"); 2484 return; 2485 } 2486 2487 if (isrx && rx_queue_id_is_invalid(res->qid)) 2488 return; 2489 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2490 return; 2491 2492 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2493 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n", 2494 rx_free_thresh); 2495 return; 2496 } 2497 2498 if (isrx) 2499 port->nb_rx_desc[res->qid] = res->size; 2500 else 2501 port->nb_tx_desc[res->qid] = res->size; 2502 2503 cmd_reconfig_device_queue(res->portid, 0, 1); 2504 } 2505 2506 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2507 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2508 port, "port"); 2509 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2510 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2511 config, "config"); 2512 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2513 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2514 portid, RTE_UINT16); 2515 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2516 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2517 rxtxq, "rxq#txq"); 2518 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2519 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2520 qid, RTE_UINT16); 2521 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2522 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2523 rsize, "ring_size"); 2524 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2525 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2526 size, RTE_UINT16); 2527 2528 cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2529 .f = cmd_config_rxtx_ring_size_parsed, 2530 .data = NULL, 2531 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2532 .tokens = { 2533 (void *)&cmd_config_rxtx_ring_size_port, 2534 (void *)&cmd_config_rxtx_ring_size_config, 2535 (void *)&cmd_config_rxtx_ring_size_portid, 2536 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2537 (void *)&cmd_config_rxtx_ring_size_qid, 2538 (void *)&cmd_config_rxtx_ring_size_rsize, 2539 (void *)&cmd_config_rxtx_ring_size_size, 2540 NULL, 2541 }, 2542 }; 2543 2544 /* *** configure port rxq/txq start/stop *** */ 2545 struct cmd_config_rxtx_queue { 2546 cmdline_fixed_string_t port; 2547 portid_t portid; 2548 cmdline_fixed_string_t rxtxq; 2549 uint16_t qid; 2550 cmdline_fixed_string_t opname; 2551 }; 2552 2553 static void 2554 cmd_config_rxtx_queue_parsed(void *parsed_result, 2555 __rte_unused struct cmdline *cl, 2556 __rte_unused void *data) 2557 { 2558 struct cmd_config_rxtx_queue *res = parsed_result; 2559 uint8_t isrx; 2560 uint8_t isstart; 2561 int ret = 0; 2562 2563 if (test_done == 0) { 2564 printf("Please stop forwarding first\n"); 2565 return; 2566 } 2567 2568 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2569 return; 2570 2571 if (port_is_started(res->portid) != 1) { 2572 printf("Please start port %u first\n", res->portid); 2573 return; 2574 } 2575 2576 if (!strcmp(res->rxtxq, "rxq")) 2577 isrx = 1; 2578 else if (!strcmp(res->rxtxq, "txq")) 2579 isrx = 0; 2580 else { 2581 printf("Unknown parameter\n"); 2582 return; 2583 } 2584 2585 if (isrx && rx_queue_id_is_invalid(res->qid)) 2586 return; 2587 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2588 return; 2589 2590 if (!strcmp(res->opname, "start")) 2591 isstart = 1; 2592 else if (!strcmp(res->opname, "stop")) 2593 isstart = 0; 2594 else { 2595 printf("Unknown parameter\n"); 2596 return; 2597 } 2598 2599 if (isstart && isrx) 2600 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2601 else if (!isstart && isrx) 2602 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2603 else if (isstart && !isrx) 2604 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2605 else 2606 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2607 2608 if (ret == -ENOTSUP) 2609 printf("Function not supported in PMD driver\n"); 2610 } 2611 2612 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2613 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2614 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2615 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16); 2616 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2617 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2618 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2619 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16); 2620 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2621 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2622 "start#stop"); 2623 2624 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2625 .f = cmd_config_rxtx_queue_parsed, 2626 .data = NULL, 2627 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2628 .tokens = { 2629 (void *)&cmd_config_rxtx_queue_port, 2630 (void *)&cmd_config_rxtx_queue_portid, 2631 (void *)&cmd_config_rxtx_queue_rxtxq, 2632 (void *)&cmd_config_rxtx_queue_qid, 2633 (void *)&cmd_config_rxtx_queue_opname, 2634 NULL, 2635 }, 2636 }; 2637 2638 /* *** configure port rxq/txq deferred start on/off *** */ 2639 struct cmd_config_deferred_start_rxtx_queue { 2640 cmdline_fixed_string_t port; 2641 portid_t port_id; 2642 cmdline_fixed_string_t rxtxq; 2643 uint16_t qid; 2644 cmdline_fixed_string_t opname; 2645 cmdline_fixed_string_t state; 2646 }; 2647 2648 static void 2649 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, 2650 __rte_unused struct cmdline *cl, 2651 __rte_unused void *data) 2652 { 2653 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; 2654 struct rte_port *port; 2655 uint8_t isrx; 2656 uint8_t ison; 2657 uint8_t needreconfig = 0; 2658 2659 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 2660 return; 2661 2662 if (port_is_started(res->port_id) != 0) { 2663 printf("Please stop port %u first\n", res->port_id); 2664 return; 2665 } 2666 2667 port = &ports[res->port_id]; 2668 2669 isrx = !strcmp(res->rxtxq, "rxq"); 2670 2671 if (isrx && rx_queue_id_is_invalid(res->qid)) 2672 return; 2673 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2674 return; 2675 2676 ison = !strcmp(res->state, "on"); 2677 2678 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) { 2679 port->rx_conf[res->qid].rx_deferred_start = ison; 2680 needreconfig = 1; 2681 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) { 2682 port->tx_conf[res->qid].tx_deferred_start = ison; 2683 needreconfig = 1; 2684 } 2685 2686 if (needreconfig) 2687 cmd_reconfig_device_queue(res->port_id, 0, 1); 2688 } 2689 2690 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = 2691 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2692 port, "port"); 2693 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = 2694 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2695 port_id, RTE_UINT16); 2696 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = 2697 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2698 rxtxq, "rxq#txq"); 2699 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = 2700 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2701 qid, RTE_UINT16); 2702 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = 2703 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2704 opname, "deferred_start"); 2705 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = 2706 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2707 state, "on#off"); 2708 2709 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { 2710 .f = cmd_config_deferred_start_rxtx_queue_parsed, 2711 .data = NULL, 2712 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", 2713 .tokens = { 2714 (void *)&cmd_config_deferred_start_rxtx_queue_port, 2715 (void *)&cmd_config_deferred_start_rxtx_queue_port_id, 2716 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, 2717 (void *)&cmd_config_deferred_start_rxtx_queue_qid, 2718 (void *)&cmd_config_deferred_start_rxtx_queue_opname, 2719 (void *)&cmd_config_deferred_start_rxtx_queue_state, 2720 NULL, 2721 }, 2722 }; 2723 2724 /* *** configure port rxq/txq setup *** */ 2725 struct cmd_setup_rxtx_queue { 2726 cmdline_fixed_string_t port; 2727 portid_t portid; 2728 cmdline_fixed_string_t rxtxq; 2729 uint16_t qid; 2730 cmdline_fixed_string_t setup; 2731 }; 2732 2733 /* Common CLI fields for queue setup */ 2734 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2735 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2736 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2737 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16); 2738 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2739 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2740 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2741 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16); 2742 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2743 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2744 2745 static void 2746 cmd_setup_rxtx_queue_parsed( 2747 void *parsed_result, 2748 __rte_unused struct cmdline *cl, 2749 __rte_unused void *data) 2750 { 2751 struct cmd_setup_rxtx_queue *res = parsed_result; 2752 struct rte_port *port; 2753 struct rte_mempool *mp; 2754 unsigned int socket_id; 2755 uint8_t isrx = 0; 2756 int ret; 2757 2758 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2759 return; 2760 2761 if (res->portid == (portid_t)RTE_PORT_ALL) { 2762 printf("Invalid port id\n"); 2763 return; 2764 } 2765 2766 if (!strcmp(res->rxtxq, "rxq")) 2767 isrx = 1; 2768 else if (!strcmp(res->rxtxq, "txq")) 2769 isrx = 0; 2770 else { 2771 printf("Unknown parameter\n"); 2772 return; 2773 } 2774 2775 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2776 printf("Invalid rx queue\n"); 2777 return; 2778 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2779 printf("Invalid tx queue\n"); 2780 return; 2781 } 2782 2783 port = &ports[res->portid]; 2784 if (isrx) { 2785 socket_id = rxring_numa[res->portid]; 2786 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2787 socket_id = port->socket_id; 2788 2789 mp = mbuf_pool_find(socket_id, 0); 2790 if (mp == NULL) { 2791 printf("Failed to setup RX queue: " 2792 "No mempool allocation" 2793 " on the socket %d\n", 2794 rxring_numa[res->portid]); 2795 return; 2796 } 2797 ret = rx_queue_setup(res->portid, 2798 res->qid, 2799 port->nb_rx_desc[res->qid], 2800 socket_id, 2801 &port->rx_conf[res->qid], 2802 mp); 2803 if (ret) 2804 printf("Failed to setup RX queue\n"); 2805 } else { 2806 socket_id = txring_numa[res->portid]; 2807 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2808 socket_id = port->socket_id; 2809 2810 ret = rte_eth_tx_queue_setup(res->portid, 2811 res->qid, 2812 port->nb_tx_desc[res->qid], 2813 socket_id, 2814 &port->tx_conf[res->qid]); 2815 if (ret) 2816 printf("Failed to setup TX queue\n"); 2817 } 2818 } 2819 2820 cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2821 .f = cmd_setup_rxtx_queue_parsed, 2822 .data = NULL, 2823 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2824 .tokens = { 2825 (void *)&cmd_setup_rxtx_queue_port, 2826 (void *)&cmd_setup_rxtx_queue_portid, 2827 (void *)&cmd_setup_rxtx_queue_rxtxq, 2828 (void *)&cmd_setup_rxtx_queue_qid, 2829 (void *)&cmd_setup_rxtx_queue_setup, 2830 NULL, 2831 }, 2832 }; 2833 2834 2835 /* *** Configure RSS RETA *** */ 2836 struct cmd_config_rss_reta { 2837 cmdline_fixed_string_t port; 2838 cmdline_fixed_string_t keyword; 2839 portid_t port_id; 2840 cmdline_fixed_string_t name; 2841 cmdline_fixed_string_t list_name; 2842 cmdline_fixed_string_t list_of_items; 2843 }; 2844 2845 static int 2846 parse_reta_config(const char *str, 2847 struct rte_eth_rss_reta_entry64 *reta_conf, 2848 uint16_t nb_entries) 2849 { 2850 int i; 2851 unsigned size; 2852 uint16_t hash_index, idx, shift; 2853 uint16_t nb_queue; 2854 char s[256]; 2855 const char *p, *p0 = str; 2856 char *end; 2857 enum fieldnames { 2858 FLD_HASH_INDEX = 0, 2859 FLD_QUEUE, 2860 _NUM_FLD 2861 }; 2862 unsigned long int_fld[_NUM_FLD]; 2863 char *str_fld[_NUM_FLD]; 2864 2865 while ((p = strchr(p0,'(')) != NULL) { 2866 ++p; 2867 if((p0 = strchr(p,')')) == NULL) 2868 return -1; 2869 2870 size = p0 - p; 2871 if(size >= sizeof(s)) 2872 return -1; 2873 2874 snprintf(s, sizeof(s), "%.*s", size, p); 2875 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2876 return -1; 2877 for (i = 0; i < _NUM_FLD; i++) { 2878 errno = 0; 2879 int_fld[i] = strtoul(str_fld[i], &end, 0); 2880 if (errno != 0 || end == str_fld[i] || 2881 int_fld[i] > 65535) 2882 return -1; 2883 } 2884 2885 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2886 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2887 2888 if (hash_index >= nb_entries) { 2889 printf("Invalid RETA hash index=%d\n", hash_index); 2890 return -1; 2891 } 2892 2893 idx = hash_index / RTE_RETA_GROUP_SIZE; 2894 shift = hash_index % RTE_RETA_GROUP_SIZE; 2895 reta_conf[idx].mask |= (1ULL << shift); 2896 reta_conf[idx].reta[shift] = nb_queue; 2897 } 2898 2899 return 0; 2900 } 2901 2902 static void 2903 cmd_set_rss_reta_parsed(void *parsed_result, 2904 __rte_unused struct cmdline *cl, 2905 __rte_unused void *data) 2906 { 2907 int ret; 2908 struct rte_eth_dev_info dev_info; 2909 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2910 struct cmd_config_rss_reta *res = parsed_result; 2911 2912 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2913 if (ret != 0) 2914 return; 2915 2916 if (dev_info.reta_size == 0) { 2917 printf("Redirection table size is 0 which is " 2918 "invalid for RSS\n"); 2919 return; 2920 } else 2921 printf("The reta size of port %d is %u\n", 2922 res->port_id, dev_info.reta_size); 2923 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 2924 printf("Currently do not support more than %u entries of " 2925 "redirection table\n", ETH_RSS_RETA_SIZE_512); 2926 return; 2927 } 2928 2929 memset(reta_conf, 0, sizeof(reta_conf)); 2930 if (!strcmp(res->list_name, "reta")) { 2931 if (parse_reta_config(res->list_of_items, reta_conf, 2932 dev_info.reta_size)) { 2933 printf("Invalid RSS Redirection Table " 2934 "config entered\n"); 2935 return; 2936 } 2937 ret = rte_eth_dev_rss_reta_update(res->port_id, 2938 reta_conf, dev_info.reta_size); 2939 if (ret != 0) 2940 printf("Bad redirection table parameter, " 2941 "return code = %d \n", ret); 2942 } 2943 } 2944 2945 cmdline_parse_token_string_t cmd_config_rss_reta_port = 2946 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 2947 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 2948 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 2949 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 2950 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16); 2951 cmdline_parse_token_string_t cmd_config_rss_reta_name = 2952 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 2953 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 2954 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 2955 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 2956 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 2957 NULL); 2958 cmdline_parse_inst_t cmd_config_rss_reta = { 2959 .f = cmd_set_rss_reta_parsed, 2960 .data = NULL, 2961 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 2962 .tokens = { 2963 (void *)&cmd_config_rss_reta_port, 2964 (void *)&cmd_config_rss_reta_keyword, 2965 (void *)&cmd_config_rss_reta_port_id, 2966 (void *)&cmd_config_rss_reta_name, 2967 (void *)&cmd_config_rss_reta_list_name, 2968 (void *)&cmd_config_rss_reta_list_of_items, 2969 NULL, 2970 }, 2971 }; 2972 2973 /* *** SHOW PORT RETA INFO *** */ 2974 struct cmd_showport_reta { 2975 cmdline_fixed_string_t show; 2976 cmdline_fixed_string_t port; 2977 portid_t port_id; 2978 cmdline_fixed_string_t rss; 2979 cmdline_fixed_string_t reta; 2980 uint16_t size; 2981 cmdline_fixed_string_t list_of_items; 2982 }; 2983 2984 static int 2985 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 2986 uint16_t nb_entries, 2987 char *str) 2988 { 2989 uint32_t size; 2990 const char *p, *p0 = str; 2991 char s[256]; 2992 char *end; 2993 char *str_fld[8]; 2994 uint16_t i; 2995 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 2996 RTE_RETA_GROUP_SIZE; 2997 int ret; 2998 2999 p = strchr(p0, '('); 3000 if (p == NULL) 3001 return -1; 3002 p++; 3003 p0 = strchr(p, ')'); 3004 if (p0 == NULL) 3005 return -1; 3006 size = p0 - p; 3007 if (size >= sizeof(s)) { 3008 printf("The string size exceeds the internal buffer size\n"); 3009 return -1; 3010 } 3011 snprintf(s, sizeof(s), "%.*s", size, p); 3012 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 3013 if (ret <= 0 || ret != num) { 3014 printf("The bits of masks do not match the number of " 3015 "reta entries: %u\n", num); 3016 return -1; 3017 } 3018 for (i = 0; i < ret; i++) 3019 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 3020 3021 return 0; 3022 } 3023 3024 static void 3025 cmd_showport_reta_parsed(void *parsed_result, 3026 __rte_unused struct cmdline *cl, 3027 __rte_unused void *data) 3028 { 3029 struct cmd_showport_reta *res = parsed_result; 3030 struct rte_eth_rss_reta_entry64 reta_conf[8]; 3031 struct rte_eth_dev_info dev_info; 3032 uint16_t max_reta_size; 3033 int ret; 3034 3035 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 3036 if (ret != 0) 3037 return; 3038 3039 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 3040 if (res->size == 0 || res->size > max_reta_size) { 3041 printf("Invalid redirection table size: %u (1-%u)\n", 3042 res->size, max_reta_size); 3043 return; 3044 } 3045 3046 memset(reta_conf, 0, sizeof(reta_conf)); 3047 if (showport_parse_reta_config(reta_conf, res->size, 3048 res->list_of_items) < 0) { 3049 printf("Invalid string: %s for reta masks\n", 3050 res->list_of_items); 3051 return; 3052 } 3053 port_rss_reta_info(res->port_id, reta_conf, res->size); 3054 } 3055 3056 cmdline_parse_token_string_t cmd_showport_reta_show = 3057 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 3058 cmdline_parse_token_string_t cmd_showport_reta_port = 3059 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 3060 cmdline_parse_token_num_t cmd_showport_reta_port_id = 3061 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16); 3062 cmdline_parse_token_string_t cmd_showport_reta_rss = 3063 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 3064 cmdline_parse_token_string_t cmd_showport_reta_reta = 3065 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 3066 cmdline_parse_token_num_t cmd_showport_reta_size = 3067 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16); 3068 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 3069 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 3070 list_of_items, NULL); 3071 3072 cmdline_parse_inst_t cmd_showport_reta = { 3073 .f = cmd_showport_reta_parsed, 3074 .data = NULL, 3075 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 3076 .tokens = { 3077 (void *)&cmd_showport_reta_show, 3078 (void *)&cmd_showport_reta_port, 3079 (void *)&cmd_showport_reta_port_id, 3080 (void *)&cmd_showport_reta_rss, 3081 (void *)&cmd_showport_reta_reta, 3082 (void *)&cmd_showport_reta_size, 3083 (void *)&cmd_showport_reta_list_of_items, 3084 NULL, 3085 }, 3086 }; 3087 3088 /* *** Show RSS hash configuration *** */ 3089 struct cmd_showport_rss_hash { 3090 cmdline_fixed_string_t show; 3091 cmdline_fixed_string_t port; 3092 portid_t port_id; 3093 cmdline_fixed_string_t rss_hash; 3094 cmdline_fixed_string_t rss_type; 3095 cmdline_fixed_string_t key; /* optional argument */ 3096 }; 3097 3098 static void cmd_showport_rss_hash_parsed(void *parsed_result, 3099 __rte_unused struct cmdline *cl, 3100 void *show_rss_key) 3101 { 3102 struct cmd_showport_rss_hash *res = parsed_result; 3103 3104 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); 3105 } 3106 3107 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 3108 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 3109 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 3110 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 3111 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 3112 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, 3113 RTE_UINT16); 3114 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 3115 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 3116 "rss-hash"); 3117 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 3118 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 3119 3120 cmdline_parse_inst_t cmd_showport_rss_hash = { 3121 .f = cmd_showport_rss_hash_parsed, 3122 .data = NULL, 3123 .help_str = "show port <port_id> rss-hash", 3124 .tokens = { 3125 (void *)&cmd_showport_rss_hash_show, 3126 (void *)&cmd_showport_rss_hash_port, 3127 (void *)&cmd_showport_rss_hash_port_id, 3128 (void *)&cmd_showport_rss_hash_rss_hash, 3129 NULL, 3130 }, 3131 }; 3132 3133 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 3134 .f = cmd_showport_rss_hash_parsed, 3135 .data = (void *)1, 3136 .help_str = "show port <port_id> rss-hash key", 3137 .tokens = { 3138 (void *)&cmd_showport_rss_hash_show, 3139 (void *)&cmd_showport_rss_hash_port, 3140 (void *)&cmd_showport_rss_hash_port_id, 3141 (void *)&cmd_showport_rss_hash_rss_hash, 3142 (void *)&cmd_showport_rss_hash_rss_key, 3143 NULL, 3144 }, 3145 }; 3146 3147 /* *** Configure DCB *** */ 3148 struct cmd_config_dcb { 3149 cmdline_fixed_string_t port; 3150 cmdline_fixed_string_t config; 3151 portid_t port_id; 3152 cmdline_fixed_string_t dcb; 3153 cmdline_fixed_string_t vt; 3154 cmdline_fixed_string_t vt_en; 3155 uint8_t num_tcs; 3156 cmdline_fixed_string_t pfc; 3157 cmdline_fixed_string_t pfc_en; 3158 }; 3159 3160 static void 3161 cmd_config_dcb_parsed(void *parsed_result, 3162 __rte_unused struct cmdline *cl, 3163 __rte_unused void *data) 3164 { 3165 struct cmd_config_dcb *res = parsed_result; 3166 portid_t port_id = res->port_id; 3167 struct rte_port *port; 3168 uint8_t pfc_en; 3169 int ret; 3170 3171 port = &ports[port_id]; 3172 /** Check if the port is not started **/ 3173 if (port->port_status != RTE_PORT_STOPPED) { 3174 printf("Please stop port %d first\n", port_id); 3175 return; 3176 } 3177 3178 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 3179 printf("The invalid number of traffic class," 3180 " only 4 or 8 allowed.\n"); 3181 return; 3182 } 3183 3184 if (nb_fwd_lcores < res->num_tcs) { 3185 printf("nb_cores shouldn't be less than number of TCs.\n"); 3186 return; 3187 } 3188 if (!strncmp(res->pfc_en, "on", 2)) 3189 pfc_en = 1; 3190 else 3191 pfc_en = 0; 3192 3193 /* DCB in VT mode */ 3194 if (!strncmp(res->vt_en, "on", 2)) 3195 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 3196 (enum rte_eth_nb_tcs)res->num_tcs, 3197 pfc_en); 3198 else 3199 ret = init_port_dcb_config(port_id, DCB_ENABLED, 3200 (enum rte_eth_nb_tcs)res->num_tcs, 3201 pfc_en); 3202 3203 3204 if (ret != 0) { 3205 printf("Cannot initialize network ports.\n"); 3206 return; 3207 } 3208 3209 cmd_reconfig_device_queue(port_id, 1, 1); 3210 } 3211 3212 cmdline_parse_token_string_t cmd_config_dcb_port = 3213 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 3214 cmdline_parse_token_string_t cmd_config_dcb_config = 3215 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 3216 cmdline_parse_token_num_t cmd_config_dcb_port_id = 3217 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16); 3218 cmdline_parse_token_string_t cmd_config_dcb_dcb = 3219 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 3220 cmdline_parse_token_string_t cmd_config_dcb_vt = 3221 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 3222 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 3223 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 3224 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 3225 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8); 3226 cmdline_parse_token_string_t cmd_config_dcb_pfc= 3227 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 3228 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 3229 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 3230 3231 cmdline_parse_inst_t cmd_config_dcb = { 3232 .f = cmd_config_dcb_parsed, 3233 .data = NULL, 3234 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 3235 .tokens = { 3236 (void *)&cmd_config_dcb_port, 3237 (void *)&cmd_config_dcb_config, 3238 (void *)&cmd_config_dcb_port_id, 3239 (void *)&cmd_config_dcb_dcb, 3240 (void *)&cmd_config_dcb_vt, 3241 (void *)&cmd_config_dcb_vt_en, 3242 (void *)&cmd_config_dcb_num_tcs, 3243 (void *)&cmd_config_dcb_pfc, 3244 (void *)&cmd_config_dcb_pfc_en, 3245 NULL, 3246 }, 3247 }; 3248 3249 /* *** configure number of packets per burst *** */ 3250 struct cmd_config_burst { 3251 cmdline_fixed_string_t port; 3252 cmdline_fixed_string_t keyword; 3253 cmdline_fixed_string_t all; 3254 cmdline_fixed_string_t name; 3255 uint16_t value; 3256 }; 3257 3258 static void 3259 cmd_config_burst_parsed(void *parsed_result, 3260 __rte_unused struct cmdline *cl, 3261 __rte_unused void *data) 3262 { 3263 struct cmd_config_burst *res = parsed_result; 3264 struct rte_eth_dev_info dev_info; 3265 uint16_t rec_nb_pkts; 3266 int ret; 3267 3268 if (!all_ports_stopped()) { 3269 printf("Please stop all ports first\n"); 3270 return; 3271 } 3272 3273 if (!strcmp(res->name, "burst")) { 3274 if (res->value == 0) { 3275 /* If user gives a value of zero, query the PMD for 3276 * its recommended Rx burst size. Testpmd uses a single 3277 * size for all ports, so assume all ports are the same 3278 * NIC model and use the values from Port 0. 3279 */ 3280 ret = eth_dev_info_get_print_err(0, &dev_info); 3281 if (ret != 0) 3282 return; 3283 3284 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 3285 3286 if (rec_nb_pkts == 0) { 3287 printf("PMD does not recommend a burst size.\n" 3288 "User provided value must be between" 3289 " 1 and %d\n", MAX_PKT_BURST); 3290 return; 3291 } else if (rec_nb_pkts > MAX_PKT_BURST) { 3292 printf("PMD recommended burst size of %d" 3293 " exceeds maximum value of %d\n", 3294 rec_nb_pkts, MAX_PKT_BURST); 3295 return; 3296 } 3297 printf("Using PMD-provided burst value of %d\n", 3298 rec_nb_pkts); 3299 nb_pkt_per_burst = rec_nb_pkts; 3300 } else if (res->value > MAX_PKT_BURST) { 3301 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST); 3302 return; 3303 } else 3304 nb_pkt_per_burst = res->value; 3305 } else { 3306 printf("Unknown parameter\n"); 3307 return; 3308 } 3309 3310 init_port_config(); 3311 3312 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3313 } 3314 3315 cmdline_parse_token_string_t cmd_config_burst_port = 3316 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3317 cmdline_parse_token_string_t cmd_config_burst_keyword = 3318 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3319 cmdline_parse_token_string_t cmd_config_burst_all = 3320 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3321 cmdline_parse_token_string_t cmd_config_burst_name = 3322 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3323 cmdline_parse_token_num_t cmd_config_burst_value = 3324 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16); 3325 3326 cmdline_parse_inst_t cmd_config_burst = { 3327 .f = cmd_config_burst_parsed, 3328 .data = NULL, 3329 .help_str = "port config all burst <value>", 3330 .tokens = { 3331 (void *)&cmd_config_burst_port, 3332 (void *)&cmd_config_burst_keyword, 3333 (void *)&cmd_config_burst_all, 3334 (void *)&cmd_config_burst_name, 3335 (void *)&cmd_config_burst_value, 3336 NULL, 3337 }, 3338 }; 3339 3340 /* *** configure rx/tx queues *** */ 3341 struct cmd_config_thresh { 3342 cmdline_fixed_string_t port; 3343 cmdline_fixed_string_t keyword; 3344 cmdline_fixed_string_t all; 3345 cmdline_fixed_string_t name; 3346 uint8_t value; 3347 }; 3348 3349 static void 3350 cmd_config_thresh_parsed(void *parsed_result, 3351 __rte_unused struct cmdline *cl, 3352 __rte_unused void *data) 3353 { 3354 struct cmd_config_thresh *res = parsed_result; 3355 3356 if (!all_ports_stopped()) { 3357 printf("Please stop all ports first\n"); 3358 return; 3359 } 3360 3361 if (!strcmp(res->name, "txpt")) 3362 tx_pthresh = res->value; 3363 else if(!strcmp(res->name, "txht")) 3364 tx_hthresh = res->value; 3365 else if(!strcmp(res->name, "txwt")) 3366 tx_wthresh = res->value; 3367 else if(!strcmp(res->name, "rxpt")) 3368 rx_pthresh = res->value; 3369 else if(!strcmp(res->name, "rxht")) 3370 rx_hthresh = res->value; 3371 else if(!strcmp(res->name, "rxwt")) 3372 rx_wthresh = res->value; 3373 else { 3374 printf("Unknown parameter\n"); 3375 return; 3376 } 3377 3378 init_port_config(); 3379 3380 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3381 } 3382 3383 cmdline_parse_token_string_t cmd_config_thresh_port = 3384 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3385 cmdline_parse_token_string_t cmd_config_thresh_keyword = 3386 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3387 cmdline_parse_token_string_t cmd_config_thresh_all = 3388 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3389 cmdline_parse_token_string_t cmd_config_thresh_name = 3390 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3391 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3392 cmdline_parse_token_num_t cmd_config_thresh_value = 3393 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8); 3394 3395 cmdline_parse_inst_t cmd_config_thresh = { 3396 .f = cmd_config_thresh_parsed, 3397 .data = NULL, 3398 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3399 .tokens = { 3400 (void *)&cmd_config_thresh_port, 3401 (void *)&cmd_config_thresh_keyword, 3402 (void *)&cmd_config_thresh_all, 3403 (void *)&cmd_config_thresh_name, 3404 (void *)&cmd_config_thresh_value, 3405 NULL, 3406 }, 3407 }; 3408 3409 /* *** configure free/rs threshold *** */ 3410 struct cmd_config_threshold { 3411 cmdline_fixed_string_t port; 3412 cmdline_fixed_string_t keyword; 3413 cmdline_fixed_string_t all; 3414 cmdline_fixed_string_t name; 3415 uint16_t value; 3416 }; 3417 3418 static void 3419 cmd_config_threshold_parsed(void *parsed_result, 3420 __rte_unused struct cmdline *cl, 3421 __rte_unused void *data) 3422 { 3423 struct cmd_config_threshold *res = parsed_result; 3424 3425 if (!all_ports_stopped()) { 3426 printf("Please stop all ports first\n"); 3427 return; 3428 } 3429 3430 if (!strcmp(res->name, "txfreet")) 3431 tx_free_thresh = res->value; 3432 else if (!strcmp(res->name, "txrst")) 3433 tx_rs_thresh = res->value; 3434 else if (!strcmp(res->name, "rxfreet")) 3435 rx_free_thresh = res->value; 3436 else { 3437 printf("Unknown parameter\n"); 3438 return; 3439 } 3440 3441 init_port_config(); 3442 3443 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3444 } 3445 3446 cmdline_parse_token_string_t cmd_config_threshold_port = 3447 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3448 cmdline_parse_token_string_t cmd_config_threshold_keyword = 3449 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3450 "config"); 3451 cmdline_parse_token_string_t cmd_config_threshold_all = 3452 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3453 cmdline_parse_token_string_t cmd_config_threshold_name = 3454 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3455 "txfreet#txrst#rxfreet"); 3456 cmdline_parse_token_num_t cmd_config_threshold_value = 3457 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16); 3458 3459 cmdline_parse_inst_t cmd_config_threshold = { 3460 .f = cmd_config_threshold_parsed, 3461 .data = NULL, 3462 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3463 .tokens = { 3464 (void *)&cmd_config_threshold_port, 3465 (void *)&cmd_config_threshold_keyword, 3466 (void *)&cmd_config_threshold_all, 3467 (void *)&cmd_config_threshold_name, 3468 (void *)&cmd_config_threshold_value, 3469 NULL, 3470 }, 3471 }; 3472 3473 /* *** stop *** */ 3474 struct cmd_stop_result { 3475 cmdline_fixed_string_t stop; 3476 }; 3477 3478 static void cmd_stop_parsed(__rte_unused void *parsed_result, 3479 __rte_unused struct cmdline *cl, 3480 __rte_unused void *data) 3481 { 3482 stop_packet_forwarding(); 3483 } 3484 3485 cmdline_parse_token_string_t cmd_stop_stop = 3486 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3487 3488 cmdline_parse_inst_t cmd_stop = { 3489 .f = cmd_stop_parsed, 3490 .data = NULL, 3491 .help_str = "stop: Stop packet forwarding", 3492 .tokens = { 3493 (void *)&cmd_stop_stop, 3494 NULL, 3495 }, 3496 }; 3497 3498 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3499 3500 unsigned int 3501 parse_item_list(char* str, const char* item_name, unsigned int max_items, 3502 unsigned int *parsed_items, int check_unique_values) 3503 { 3504 unsigned int nb_item; 3505 unsigned int value; 3506 unsigned int i; 3507 unsigned int j; 3508 int value_ok; 3509 char c; 3510 3511 /* 3512 * First parse all items in the list and store their value. 3513 */ 3514 value = 0; 3515 nb_item = 0; 3516 value_ok = 0; 3517 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3518 c = str[i]; 3519 if ((c >= '0') && (c <= '9')) { 3520 value = (unsigned int) (value * 10 + (c - '0')); 3521 value_ok = 1; 3522 continue; 3523 } 3524 if (c != ',') { 3525 printf("character %c is not a decimal digit\n", c); 3526 return 0; 3527 } 3528 if (! value_ok) { 3529 printf("No valid value before comma\n"); 3530 return 0; 3531 } 3532 if (nb_item < max_items) { 3533 parsed_items[nb_item] = value; 3534 value_ok = 0; 3535 value = 0; 3536 } 3537 nb_item++; 3538 } 3539 if (nb_item >= max_items) { 3540 printf("Number of %s = %u > %u (maximum items)\n", 3541 item_name, nb_item + 1, max_items); 3542 return 0; 3543 } 3544 parsed_items[nb_item++] = value; 3545 if (! check_unique_values) 3546 return nb_item; 3547 3548 /* 3549 * Then, check that all values in the list are differents. 3550 * No optimization here... 3551 */ 3552 for (i = 0; i < nb_item; i++) { 3553 for (j = i + 1; j < nb_item; j++) { 3554 if (parsed_items[j] == parsed_items[i]) { 3555 printf("duplicated %s %u at index %u and %u\n", 3556 item_name, parsed_items[i], i, j); 3557 return 0; 3558 } 3559 } 3560 } 3561 return nb_item; 3562 } 3563 3564 struct cmd_set_list_result { 3565 cmdline_fixed_string_t cmd_keyword; 3566 cmdline_fixed_string_t list_name; 3567 cmdline_fixed_string_t list_of_items; 3568 }; 3569 3570 static void cmd_set_list_parsed(void *parsed_result, 3571 __rte_unused struct cmdline *cl, 3572 __rte_unused void *data) 3573 { 3574 struct cmd_set_list_result *res; 3575 union { 3576 unsigned int lcorelist[RTE_MAX_LCORE]; 3577 unsigned int portlist[RTE_MAX_ETHPORTS]; 3578 } parsed_items; 3579 unsigned int nb_item; 3580 3581 if (test_done == 0) { 3582 printf("Please stop forwarding first\n"); 3583 return; 3584 } 3585 3586 res = parsed_result; 3587 if (!strcmp(res->list_name, "corelist")) { 3588 nb_item = parse_item_list(res->list_of_items, "core", 3589 RTE_MAX_LCORE, 3590 parsed_items.lcorelist, 1); 3591 if (nb_item > 0) { 3592 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3593 fwd_config_setup(); 3594 } 3595 return; 3596 } 3597 if (!strcmp(res->list_name, "portlist")) { 3598 nb_item = parse_item_list(res->list_of_items, "port", 3599 RTE_MAX_ETHPORTS, 3600 parsed_items.portlist, 1); 3601 if (nb_item > 0) { 3602 set_fwd_ports_list(parsed_items.portlist, nb_item); 3603 fwd_config_setup(); 3604 } 3605 } 3606 } 3607 3608 cmdline_parse_token_string_t cmd_set_list_keyword = 3609 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3610 "set"); 3611 cmdline_parse_token_string_t cmd_set_list_name = 3612 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3613 "corelist#portlist"); 3614 cmdline_parse_token_string_t cmd_set_list_of_items = 3615 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3616 NULL); 3617 3618 cmdline_parse_inst_t cmd_set_fwd_list = { 3619 .f = cmd_set_list_parsed, 3620 .data = NULL, 3621 .help_str = "set corelist|portlist <list0[,list1]*>", 3622 .tokens = { 3623 (void *)&cmd_set_list_keyword, 3624 (void *)&cmd_set_list_name, 3625 (void *)&cmd_set_list_of_items, 3626 NULL, 3627 }, 3628 }; 3629 3630 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3631 3632 struct cmd_setmask_result { 3633 cmdline_fixed_string_t set; 3634 cmdline_fixed_string_t mask; 3635 uint64_t hexavalue; 3636 }; 3637 3638 static void cmd_set_mask_parsed(void *parsed_result, 3639 __rte_unused struct cmdline *cl, 3640 __rte_unused void *data) 3641 { 3642 struct cmd_setmask_result *res = parsed_result; 3643 3644 if (test_done == 0) { 3645 printf("Please stop forwarding first\n"); 3646 return; 3647 } 3648 if (!strcmp(res->mask, "coremask")) { 3649 set_fwd_lcores_mask(res->hexavalue); 3650 fwd_config_setup(); 3651 } else if (!strcmp(res->mask, "portmask")) { 3652 set_fwd_ports_mask(res->hexavalue); 3653 fwd_config_setup(); 3654 } 3655 } 3656 3657 cmdline_parse_token_string_t cmd_setmask_set = 3658 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3659 cmdline_parse_token_string_t cmd_setmask_mask = 3660 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3661 "coremask#portmask"); 3662 cmdline_parse_token_num_t cmd_setmask_value = 3663 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64); 3664 3665 cmdline_parse_inst_t cmd_set_fwd_mask = { 3666 .f = cmd_set_mask_parsed, 3667 .data = NULL, 3668 .help_str = "set coremask|portmask <hexadecimal value>", 3669 .tokens = { 3670 (void *)&cmd_setmask_set, 3671 (void *)&cmd_setmask_mask, 3672 (void *)&cmd_setmask_value, 3673 NULL, 3674 }, 3675 }; 3676 3677 /* 3678 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3679 */ 3680 struct cmd_set_result { 3681 cmdline_fixed_string_t set; 3682 cmdline_fixed_string_t what; 3683 uint16_t value; 3684 }; 3685 3686 static void cmd_set_parsed(void *parsed_result, 3687 __rte_unused struct cmdline *cl, 3688 __rte_unused void *data) 3689 { 3690 struct cmd_set_result *res = parsed_result; 3691 if (!strcmp(res->what, "nbport")) { 3692 set_fwd_ports_number(res->value); 3693 fwd_config_setup(); 3694 } else if (!strcmp(res->what, "nbcore")) { 3695 set_fwd_lcores_number(res->value); 3696 fwd_config_setup(); 3697 } else if (!strcmp(res->what, "burst")) 3698 set_nb_pkt_per_burst(res->value); 3699 else if (!strcmp(res->what, "verbose")) 3700 set_verbose_level(res->value); 3701 } 3702 3703 cmdline_parse_token_string_t cmd_set_set = 3704 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3705 cmdline_parse_token_string_t cmd_set_what = 3706 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3707 "nbport#nbcore#burst#verbose"); 3708 cmdline_parse_token_num_t cmd_set_value = 3709 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16); 3710 3711 cmdline_parse_inst_t cmd_set_numbers = { 3712 .f = cmd_set_parsed, 3713 .data = NULL, 3714 .help_str = "set nbport|nbcore|burst|verbose <value>", 3715 .tokens = { 3716 (void *)&cmd_set_set, 3717 (void *)&cmd_set_what, 3718 (void *)&cmd_set_value, 3719 NULL, 3720 }, 3721 }; 3722 3723 /* *** SET LOG LEVEL CONFIGURATION *** */ 3724 3725 struct cmd_set_log_result { 3726 cmdline_fixed_string_t set; 3727 cmdline_fixed_string_t log; 3728 cmdline_fixed_string_t type; 3729 uint32_t level; 3730 }; 3731 3732 static void 3733 cmd_set_log_parsed(void *parsed_result, 3734 __rte_unused struct cmdline *cl, 3735 __rte_unused void *data) 3736 { 3737 struct cmd_set_log_result *res; 3738 int ret; 3739 3740 res = parsed_result; 3741 if (!strcmp(res->type, "global")) 3742 rte_log_set_global_level(res->level); 3743 else { 3744 ret = rte_log_set_level_regexp(res->type, res->level); 3745 if (ret < 0) 3746 printf("Unable to set log level\n"); 3747 } 3748 } 3749 3750 cmdline_parse_token_string_t cmd_set_log_set = 3751 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3752 cmdline_parse_token_string_t cmd_set_log_log = 3753 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3754 cmdline_parse_token_string_t cmd_set_log_type = 3755 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3756 cmdline_parse_token_num_t cmd_set_log_level = 3757 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32); 3758 3759 cmdline_parse_inst_t cmd_set_log = { 3760 .f = cmd_set_log_parsed, 3761 .data = NULL, 3762 .help_str = "set log global|<type> <level>", 3763 .tokens = { 3764 (void *)&cmd_set_log_set, 3765 (void *)&cmd_set_log_log, 3766 (void *)&cmd_set_log_type, 3767 (void *)&cmd_set_log_level, 3768 NULL, 3769 }, 3770 }; 3771 3772 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */ 3773 3774 struct cmd_set_rxoffs_result { 3775 cmdline_fixed_string_t cmd_keyword; 3776 cmdline_fixed_string_t rxoffs; 3777 cmdline_fixed_string_t seg_offsets; 3778 }; 3779 3780 static void 3781 cmd_set_rxoffs_parsed(void *parsed_result, 3782 __rte_unused struct cmdline *cl, 3783 __rte_unused void *data) 3784 { 3785 struct cmd_set_rxoffs_result *res; 3786 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT]; 3787 unsigned int nb_segs; 3788 3789 res = parsed_result; 3790 nb_segs = parse_item_list(res->seg_offsets, "segment offsets", 3791 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0); 3792 if (nb_segs > 0) 3793 set_rx_pkt_offsets(seg_offsets, nb_segs); 3794 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1); 3795 } 3796 3797 cmdline_parse_token_string_t cmd_set_rxoffs_keyword = 3798 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3799 cmd_keyword, "set"); 3800 cmdline_parse_token_string_t cmd_set_rxoffs_name = 3801 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3802 rxoffs, "rxoffs"); 3803 cmdline_parse_token_string_t cmd_set_rxoffs_offsets = 3804 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3805 seg_offsets, NULL); 3806 3807 cmdline_parse_inst_t cmd_set_rxoffs = { 3808 .f = cmd_set_rxoffs_parsed, 3809 .data = NULL, 3810 .help_str = "set rxoffs <len0[,len1]*>", 3811 .tokens = { 3812 (void *)&cmd_set_rxoffs_keyword, 3813 (void *)&cmd_set_rxoffs_name, 3814 (void *)&cmd_set_rxoffs_offsets, 3815 NULL, 3816 }, 3817 }; 3818 3819 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */ 3820 3821 struct cmd_set_rxpkts_result { 3822 cmdline_fixed_string_t cmd_keyword; 3823 cmdline_fixed_string_t rxpkts; 3824 cmdline_fixed_string_t seg_lengths; 3825 }; 3826 3827 static void 3828 cmd_set_rxpkts_parsed(void *parsed_result, 3829 __rte_unused struct cmdline *cl, 3830 __rte_unused void *data) 3831 { 3832 struct cmd_set_rxpkts_result *res; 3833 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT]; 3834 unsigned int nb_segs; 3835 3836 res = parsed_result; 3837 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3838 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0); 3839 if (nb_segs > 0) 3840 set_rx_pkt_segments(seg_lengths, nb_segs); 3841 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1); 3842 } 3843 3844 cmdline_parse_token_string_t cmd_set_rxpkts_keyword = 3845 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3846 cmd_keyword, "set"); 3847 cmdline_parse_token_string_t cmd_set_rxpkts_name = 3848 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3849 rxpkts, "rxpkts"); 3850 cmdline_parse_token_string_t cmd_set_rxpkts_lengths = 3851 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3852 seg_lengths, NULL); 3853 3854 cmdline_parse_inst_t cmd_set_rxpkts = { 3855 .f = cmd_set_rxpkts_parsed, 3856 .data = NULL, 3857 .help_str = "set rxpkts <len0[,len1]*>", 3858 .tokens = { 3859 (void *)&cmd_set_rxpkts_keyword, 3860 (void *)&cmd_set_rxpkts_name, 3861 (void *)&cmd_set_rxpkts_lengths, 3862 NULL, 3863 }, 3864 }; 3865 3866 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3867 3868 struct cmd_set_txpkts_result { 3869 cmdline_fixed_string_t cmd_keyword; 3870 cmdline_fixed_string_t txpkts; 3871 cmdline_fixed_string_t seg_lengths; 3872 }; 3873 3874 static void 3875 cmd_set_txpkts_parsed(void *parsed_result, 3876 __rte_unused struct cmdline *cl, 3877 __rte_unused void *data) 3878 { 3879 struct cmd_set_txpkts_result *res; 3880 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3881 unsigned int nb_segs; 3882 3883 res = parsed_result; 3884 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3885 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3886 if (nb_segs > 0) 3887 set_tx_pkt_segments(seg_lengths, nb_segs); 3888 } 3889 3890 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 3891 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3892 cmd_keyword, "set"); 3893 cmdline_parse_token_string_t cmd_set_txpkts_name = 3894 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3895 txpkts, "txpkts"); 3896 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 3897 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3898 seg_lengths, NULL); 3899 3900 cmdline_parse_inst_t cmd_set_txpkts = { 3901 .f = cmd_set_txpkts_parsed, 3902 .data = NULL, 3903 .help_str = "set txpkts <len0[,len1]*>", 3904 .tokens = { 3905 (void *)&cmd_set_txpkts_keyword, 3906 (void *)&cmd_set_txpkts_name, 3907 (void *)&cmd_set_txpkts_lengths, 3908 NULL, 3909 }, 3910 }; 3911 3912 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 3913 3914 struct cmd_set_txsplit_result { 3915 cmdline_fixed_string_t cmd_keyword; 3916 cmdline_fixed_string_t txsplit; 3917 cmdline_fixed_string_t mode; 3918 }; 3919 3920 static void 3921 cmd_set_txsplit_parsed(void *parsed_result, 3922 __rte_unused struct cmdline *cl, 3923 __rte_unused void *data) 3924 { 3925 struct cmd_set_txsplit_result *res; 3926 3927 res = parsed_result; 3928 set_tx_pkt_split(res->mode); 3929 } 3930 3931 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 3932 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3933 cmd_keyword, "set"); 3934 cmdline_parse_token_string_t cmd_set_txsplit_name = 3935 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3936 txsplit, "txsplit"); 3937 cmdline_parse_token_string_t cmd_set_txsplit_mode = 3938 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3939 mode, NULL); 3940 3941 cmdline_parse_inst_t cmd_set_txsplit = { 3942 .f = cmd_set_txsplit_parsed, 3943 .data = NULL, 3944 .help_str = "set txsplit on|off|rand", 3945 .tokens = { 3946 (void *)&cmd_set_txsplit_keyword, 3947 (void *)&cmd_set_txsplit_name, 3948 (void *)&cmd_set_txsplit_mode, 3949 NULL, 3950 }, 3951 }; 3952 3953 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */ 3954 3955 struct cmd_set_txtimes_result { 3956 cmdline_fixed_string_t cmd_keyword; 3957 cmdline_fixed_string_t txtimes; 3958 cmdline_fixed_string_t tx_times; 3959 }; 3960 3961 static void 3962 cmd_set_txtimes_parsed(void *parsed_result, 3963 __rte_unused struct cmdline *cl, 3964 __rte_unused void *data) 3965 { 3966 struct cmd_set_txtimes_result *res; 3967 unsigned int tx_times[2] = {0, 0}; 3968 unsigned int n_times; 3969 3970 res = parsed_result; 3971 n_times = parse_item_list(res->tx_times, "tx times", 3972 2, tx_times, 0); 3973 if (n_times == 2) 3974 set_tx_pkt_times(tx_times); 3975 } 3976 3977 cmdline_parse_token_string_t cmd_set_txtimes_keyword = 3978 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 3979 cmd_keyword, "set"); 3980 cmdline_parse_token_string_t cmd_set_txtimes_name = 3981 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 3982 txtimes, "txtimes"); 3983 cmdline_parse_token_string_t cmd_set_txtimes_value = 3984 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 3985 tx_times, NULL); 3986 3987 cmdline_parse_inst_t cmd_set_txtimes = { 3988 .f = cmd_set_txtimes_parsed, 3989 .data = NULL, 3990 .help_str = "set txtimes <inter_burst>,<intra_burst>", 3991 .tokens = { 3992 (void *)&cmd_set_txtimes_keyword, 3993 (void *)&cmd_set_txtimes_name, 3994 (void *)&cmd_set_txtimes_value, 3995 NULL, 3996 }, 3997 }; 3998 3999 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 4000 struct cmd_rx_vlan_filter_all_result { 4001 cmdline_fixed_string_t rx_vlan; 4002 cmdline_fixed_string_t what; 4003 cmdline_fixed_string_t all; 4004 portid_t port_id; 4005 }; 4006 4007 static void 4008 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 4009 __rte_unused struct cmdline *cl, 4010 __rte_unused void *data) 4011 { 4012 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 4013 4014 if (!strcmp(res->what, "add")) 4015 rx_vlan_all_filter_set(res->port_id, 1); 4016 else 4017 rx_vlan_all_filter_set(res->port_id, 0); 4018 } 4019 4020 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 4021 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4022 rx_vlan, "rx_vlan"); 4023 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 4024 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4025 what, "add#rm"); 4026 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 4027 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4028 all, "all"); 4029 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 4030 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4031 port_id, RTE_UINT16); 4032 4033 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 4034 .f = cmd_rx_vlan_filter_all_parsed, 4035 .data = NULL, 4036 .help_str = "rx_vlan add|rm all <port_id>: " 4037 "Add/Remove all identifiers to/from the set of VLAN " 4038 "identifiers filtered by a port", 4039 .tokens = { 4040 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 4041 (void *)&cmd_rx_vlan_filter_all_what, 4042 (void *)&cmd_rx_vlan_filter_all_all, 4043 (void *)&cmd_rx_vlan_filter_all_portid, 4044 NULL, 4045 }, 4046 }; 4047 4048 /* *** VLAN OFFLOAD SET ON A PORT *** */ 4049 struct cmd_vlan_offload_result { 4050 cmdline_fixed_string_t vlan; 4051 cmdline_fixed_string_t set; 4052 cmdline_fixed_string_t vlan_type; 4053 cmdline_fixed_string_t what; 4054 cmdline_fixed_string_t on; 4055 cmdline_fixed_string_t port_id; 4056 }; 4057 4058 static void 4059 cmd_vlan_offload_parsed(void *parsed_result, 4060 __rte_unused struct cmdline *cl, 4061 __rte_unused void *data) 4062 { 4063 int on; 4064 struct cmd_vlan_offload_result *res = parsed_result; 4065 char *str; 4066 int i, len = 0; 4067 portid_t port_id = 0; 4068 unsigned int tmp; 4069 4070 str = res->port_id; 4071 len = strnlen(str, STR_TOKEN_SIZE); 4072 i = 0; 4073 /* Get port_id first */ 4074 while(i < len){ 4075 if(str[i] == ',') 4076 break; 4077 4078 i++; 4079 } 4080 str[i]='\0'; 4081 tmp = strtoul(str, NULL, 0); 4082 /* If port_id greater that what portid_t can represent, return */ 4083 if(tmp >= RTE_MAX_ETHPORTS) 4084 return; 4085 port_id = (portid_t)tmp; 4086 4087 if (!strcmp(res->on, "on")) 4088 on = 1; 4089 else 4090 on = 0; 4091 4092 if (!strcmp(res->what, "strip")) 4093 rx_vlan_strip_set(port_id, on); 4094 else if(!strcmp(res->what, "stripq")){ 4095 uint16_t queue_id = 0; 4096 4097 /* No queue_id, return */ 4098 if(i + 1 >= len) { 4099 printf("must specify (port,queue_id)\n"); 4100 return; 4101 } 4102 tmp = strtoul(str + i + 1, NULL, 0); 4103 /* If queue_id greater that what 16-bits can represent, return */ 4104 if(tmp > 0xffff) 4105 return; 4106 4107 queue_id = (uint16_t)tmp; 4108 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 4109 } 4110 else if (!strcmp(res->what, "filter")) 4111 rx_vlan_filter_set(port_id, on); 4112 else if (!strcmp(res->what, "qinq_strip")) 4113 rx_vlan_qinq_strip_set(port_id, on); 4114 else 4115 vlan_extend_set(port_id, on); 4116 4117 return; 4118 } 4119 4120 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 4121 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4122 vlan, "vlan"); 4123 cmdline_parse_token_string_t cmd_vlan_offload_set = 4124 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4125 set, "set"); 4126 cmdline_parse_token_string_t cmd_vlan_offload_what = 4127 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4128 what, "strip#filter#qinq_strip#extend#stripq"); 4129 cmdline_parse_token_string_t cmd_vlan_offload_on = 4130 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4131 on, "on#off"); 4132 cmdline_parse_token_string_t cmd_vlan_offload_portid = 4133 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4134 port_id, NULL); 4135 4136 cmdline_parse_inst_t cmd_vlan_offload = { 4137 .f = cmd_vlan_offload_parsed, 4138 .data = NULL, 4139 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off " 4140 "<port_id[,queue_id]>: " 4141 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides", 4142 .tokens = { 4143 (void *)&cmd_vlan_offload_vlan, 4144 (void *)&cmd_vlan_offload_set, 4145 (void *)&cmd_vlan_offload_what, 4146 (void *)&cmd_vlan_offload_on, 4147 (void *)&cmd_vlan_offload_portid, 4148 NULL, 4149 }, 4150 }; 4151 4152 /* *** VLAN TPID SET ON A PORT *** */ 4153 struct cmd_vlan_tpid_result { 4154 cmdline_fixed_string_t vlan; 4155 cmdline_fixed_string_t set; 4156 cmdline_fixed_string_t vlan_type; 4157 cmdline_fixed_string_t what; 4158 uint16_t tp_id; 4159 portid_t port_id; 4160 }; 4161 4162 static void 4163 cmd_vlan_tpid_parsed(void *parsed_result, 4164 __rte_unused struct cmdline *cl, 4165 __rte_unused void *data) 4166 { 4167 struct cmd_vlan_tpid_result *res = parsed_result; 4168 enum rte_vlan_type vlan_type; 4169 4170 if (!strcmp(res->vlan_type, "inner")) 4171 vlan_type = ETH_VLAN_TYPE_INNER; 4172 else if (!strcmp(res->vlan_type, "outer")) 4173 vlan_type = ETH_VLAN_TYPE_OUTER; 4174 else { 4175 printf("Unknown vlan type\n"); 4176 return; 4177 } 4178 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 4179 } 4180 4181 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 4182 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4183 vlan, "vlan"); 4184 cmdline_parse_token_string_t cmd_vlan_tpid_set = 4185 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4186 set, "set"); 4187 cmdline_parse_token_string_t cmd_vlan_type = 4188 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4189 vlan_type, "inner#outer"); 4190 cmdline_parse_token_string_t cmd_vlan_tpid_what = 4191 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4192 what, "tpid"); 4193 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 4194 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4195 tp_id, RTE_UINT16); 4196 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 4197 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4198 port_id, RTE_UINT16); 4199 4200 cmdline_parse_inst_t cmd_vlan_tpid = { 4201 .f = cmd_vlan_tpid_parsed, 4202 .data = NULL, 4203 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 4204 "Set the VLAN Ether type", 4205 .tokens = { 4206 (void *)&cmd_vlan_tpid_vlan, 4207 (void *)&cmd_vlan_tpid_set, 4208 (void *)&cmd_vlan_type, 4209 (void *)&cmd_vlan_tpid_what, 4210 (void *)&cmd_vlan_tpid_tpid, 4211 (void *)&cmd_vlan_tpid_portid, 4212 NULL, 4213 }, 4214 }; 4215 4216 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 4217 struct cmd_rx_vlan_filter_result { 4218 cmdline_fixed_string_t rx_vlan; 4219 cmdline_fixed_string_t what; 4220 uint16_t vlan_id; 4221 portid_t port_id; 4222 }; 4223 4224 static void 4225 cmd_rx_vlan_filter_parsed(void *parsed_result, 4226 __rte_unused struct cmdline *cl, 4227 __rte_unused void *data) 4228 { 4229 struct cmd_rx_vlan_filter_result *res = parsed_result; 4230 4231 if (!strcmp(res->what, "add")) 4232 rx_vft_set(res->port_id, res->vlan_id, 1); 4233 else 4234 rx_vft_set(res->port_id, res->vlan_id, 0); 4235 } 4236 4237 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 4238 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4239 rx_vlan, "rx_vlan"); 4240 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 4241 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4242 what, "add#rm"); 4243 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 4244 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4245 vlan_id, RTE_UINT16); 4246 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 4247 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4248 port_id, RTE_UINT16); 4249 4250 cmdline_parse_inst_t cmd_rx_vlan_filter = { 4251 .f = cmd_rx_vlan_filter_parsed, 4252 .data = NULL, 4253 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 4254 "Add/Remove a VLAN identifier to/from the set of VLAN " 4255 "identifiers filtered by a port", 4256 .tokens = { 4257 (void *)&cmd_rx_vlan_filter_rx_vlan, 4258 (void *)&cmd_rx_vlan_filter_what, 4259 (void *)&cmd_rx_vlan_filter_vlanid, 4260 (void *)&cmd_rx_vlan_filter_portid, 4261 NULL, 4262 }, 4263 }; 4264 4265 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4266 struct cmd_tx_vlan_set_result { 4267 cmdline_fixed_string_t tx_vlan; 4268 cmdline_fixed_string_t set; 4269 portid_t port_id; 4270 uint16_t vlan_id; 4271 }; 4272 4273 static void 4274 cmd_tx_vlan_set_parsed(void *parsed_result, 4275 __rte_unused struct cmdline *cl, 4276 __rte_unused void *data) 4277 { 4278 struct cmd_tx_vlan_set_result *res = parsed_result; 4279 4280 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4281 return; 4282 4283 if (!port_is_stopped(res->port_id)) { 4284 printf("Please stop port %d first\n", res->port_id); 4285 return; 4286 } 4287 4288 tx_vlan_set(res->port_id, res->vlan_id); 4289 4290 cmd_reconfig_device_queue(res->port_id, 1, 1); 4291 } 4292 4293 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 4294 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4295 tx_vlan, "tx_vlan"); 4296 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 4297 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4298 set, "set"); 4299 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 4300 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4301 port_id, RTE_UINT16); 4302 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 4303 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4304 vlan_id, RTE_UINT16); 4305 4306 cmdline_parse_inst_t cmd_tx_vlan_set = { 4307 .f = cmd_tx_vlan_set_parsed, 4308 .data = NULL, 4309 .help_str = "tx_vlan set <port_id> <vlan_id>: " 4310 "Enable hardware insertion of a single VLAN header " 4311 "with a given TAG Identifier in packets sent on a port", 4312 .tokens = { 4313 (void *)&cmd_tx_vlan_set_tx_vlan, 4314 (void *)&cmd_tx_vlan_set_set, 4315 (void *)&cmd_tx_vlan_set_portid, 4316 (void *)&cmd_tx_vlan_set_vlanid, 4317 NULL, 4318 }, 4319 }; 4320 4321 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 4322 struct cmd_tx_vlan_set_qinq_result { 4323 cmdline_fixed_string_t tx_vlan; 4324 cmdline_fixed_string_t set; 4325 portid_t port_id; 4326 uint16_t vlan_id; 4327 uint16_t vlan_id_outer; 4328 }; 4329 4330 static void 4331 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 4332 __rte_unused struct cmdline *cl, 4333 __rte_unused void *data) 4334 { 4335 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 4336 4337 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4338 return; 4339 4340 if (!port_is_stopped(res->port_id)) { 4341 printf("Please stop port %d first\n", res->port_id); 4342 return; 4343 } 4344 4345 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 4346 4347 cmd_reconfig_device_queue(res->port_id, 1, 1); 4348 } 4349 4350 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 4351 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4352 tx_vlan, "tx_vlan"); 4353 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 4354 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4355 set, "set"); 4356 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 4357 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4358 port_id, RTE_UINT16); 4359 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 4360 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4361 vlan_id, RTE_UINT16); 4362 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 4363 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4364 vlan_id_outer, RTE_UINT16); 4365 4366 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 4367 .f = cmd_tx_vlan_set_qinq_parsed, 4368 .data = NULL, 4369 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 4370 "Enable hardware insertion of double VLAN header " 4371 "with given TAG Identifiers in packets sent on a port", 4372 .tokens = { 4373 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 4374 (void *)&cmd_tx_vlan_set_qinq_set, 4375 (void *)&cmd_tx_vlan_set_qinq_portid, 4376 (void *)&cmd_tx_vlan_set_qinq_vlanid, 4377 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 4378 NULL, 4379 }, 4380 }; 4381 4382 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 4383 struct cmd_tx_vlan_set_pvid_result { 4384 cmdline_fixed_string_t tx_vlan; 4385 cmdline_fixed_string_t set; 4386 cmdline_fixed_string_t pvid; 4387 portid_t port_id; 4388 uint16_t vlan_id; 4389 cmdline_fixed_string_t mode; 4390 }; 4391 4392 static void 4393 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 4394 __rte_unused struct cmdline *cl, 4395 __rte_unused void *data) 4396 { 4397 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 4398 4399 if (strcmp(res->mode, "on") == 0) 4400 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 4401 else 4402 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 4403 } 4404 4405 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 4406 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4407 tx_vlan, "tx_vlan"); 4408 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 4409 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4410 set, "set"); 4411 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 4412 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4413 pvid, "pvid"); 4414 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 4415 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4416 port_id, RTE_UINT16); 4417 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 4418 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4419 vlan_id, RTE_UINT16); 4420 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 4421 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4422 mode, "on#off"); 4423 4424 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 4425 .f = cmd_tx_vlan_set_pvid_parsed, 4426 .data = NULL, 4427 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 4428 .tokens = { 4429 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 4430 (void *)&cmd_tx_vlan_set_pvid_set, 4431 (void *)&cmd_tx_vlan_set_pvid_pvid, 4432 (void *)&cmd_tx_vlan_set_pvid_port_id, 4433 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 4434 (void *)&cmd_tx_vlan_set_pvid_mode, 4435 NULL, 4436 }, 4437 }; 4438 4439 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4440 struct cmd_tx_vlan_reset_result { 4441 cmdline_fixed_string_t tx_vlan; 4442 cmdline_fixed_string_t reset; 4443 portid_t port_id; 4444 }; 4445 4446 static void 4447 cmd_tx_vlan_reset_parsed(void *parsed_result, 4448 __rte_unused struct cmdline *cl, 4449 __rte_unused void *data) 4450 { 4451 struct cmd_tx_vlan_reset_result *res = parsed_result; 4452 4453 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4454 return; 4455 4456 if (!port_is_stopped(res->port_id)) { 4457 printf("Please stop port %d first\n", res->port_id); 4458 return; 4459 } 4460 4461 tx_vlan_reset(res->port_id); 4462 4463 cmd_reconfig_device_queue(res->port_id, 1, 1); 4464 } 4465 4466 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4467 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4468 tx_vlan, "tx_vlan"); 4469 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4470 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4471 reset, "reset"); 4472 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4473 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4474 port_id, RTE_UINT16); 4475 4476 cmdline_parse_inst_t cmd_tx_vlan_reset = { 4477 .f = cmd_tx_vlan_reset_parsed, 4478 .data = NULL, 4479 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4480 "VLAN header in packets sent on a port", 4481 .tokens = { 4482 (void *)&cmd_tx_vlan_reset_tx_vlan, 4483 (void *)&cmd_tx_vlan_reset_reset, 4484 (void *)&cmd_tx_vlan_reset_portid, 4485 NULL, 4486 }, 4487 }; 4488 4489 4490 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4491 struct cmd_csum_result { 4492 cmdline_fixed_string_t csum; 4493 cmdline_fixed_string_t mode; 4494 cmdline_fixed_string_t proto; 4495 cmdline_fixed_string_t hwsw; 4496 portid_t port_id; 4497 }; 4498 4499 static void 4500 csum_show(int port_id) 4501 { 4502 struct rte_eth_dev_info dev_info; 4503 uint64_t tx_offloads; 4504 int ret; 4505 4506 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4507 printf("Parse tunnel is %s\n", 4508 (ports[port_id].parse_tunnel) ? "on" : "off"); 4509 printf("IP checksum offload is %s\n", 4510 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4511 printf("UDP checksum offload is %s\n", 4512 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4513 printf("TCP checksum offload is %s\n", 4514 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4515 printf("SCTP checksum offload is %s\n", 4516 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4517 printf("Outer-Ip checksum offload is %s\n", 4518 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4519 printf("Outer-Udp checksum offload is %s\n", 4520 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); 4521 4522 /* display warnings if configuration is not supported by the NIC */ 4523 ret = eth_dev_info_get_print_err(port_id, &dev_info); 4524 if (ret != 0) 4525 return; 4526 4527 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 4528 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4529 printf("Warning: hardware IP checksum enabled but not " 4530 "supported by port %d\n", port_id); 4531 } 4532 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 4533 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 4534 printf("Warning: hardware UDP checksum enabled but not " 4535 "supported by port %d\n", port_id); 4536 } 4537 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 4538 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 4539 printf("Warning: hardware TCP checksum enabled but not " 4540 "supported by port %d\n", port_id); 4541 } 4542 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 4543 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4544 printf("Warning: hardware SCTP checksum enabled but not " 4545 "supported by port %d\n", port_id); 4546 } 4547 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4548 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4549 printf("Warning: hardware outer IP checksum enabled but not " 4550 "supported by port %d\n", port_id); 4551 } 4552 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) && 4553 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) 4554 == 0) { 4555 printf("Warning: hardware outer UDP checksum enabled but not " 4556 "supported by port %d\n", port_id); 4557 } 4558 } 4559 4560 static void 4561 cmd_config_queue_tx_offloads(struct rte_port *port) 4562 { 4563 int k; 4564 4565 /* Apply queue tx offloads configuration */ 4566 for (k = 0; k < port->dev_info.max_rx_queues; k++) 4567 port->tx_conf[k].offloads = 4568 port->dev_conf.txmode.offloads; 4569 } 4570 4571 static void 4572 cmd_csum_parsed(void *parsed_result, 4573 __rte_unused struct cmdline *cl, 4574 __rte_unused void *data) 4575 { 4576 struct cmd_csum_result *res = parsed_result; 4577 int hw = 0; 4578 uint64_t csum_offloads = 0; 4579 struct rte_eth_dev_info dev_info; 4580 int ret; 4581 4582 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4583 printf("invalid port %d\n", res->port_id); 4584 return; 4585 } 4586 if (!port_is_stopped(res->port_id)) { 4587 printf("Please stop port %d first\n", res->port_id); 4588 return; 4589 } 4590 4591 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4592 if (ret != 0) 4593 return; 4594 4595 if (!strcmp(res->mode, "set")) { 4596 4597 if (!strcmp(res->hwsw, "hw")) 4598 hw = 1; 4599 4600 if (!strcmp(res->proto, "ip")) { 4601 if (hw == 0 || (dev_info.tx_offload_capa & 4602 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 4603 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 4604 } else { 4605 printf("IP checksum offload is not supported " 4606 "by port %u\n", res->port_id); 4607 } 4608 } else if (!strcmp(res->proto, "udp")) { 4609 if (hw == 0 || (dev_info.tx_offload_capa & 4610 DEV_TX_OFFLOAD_UDP_CKSUM)) { 4611 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 4612 } else { 4613 printf("UDP checksum offload is not supported " 4614 "by port %u\n", res->port_id); 4615 } 4616 } else if (!strcmp(res->proto, "tcp")) { 4617 if (hw == 0 || (dev_info.tx_offload_capa & 4618 DEV_TX_OFFLOAD_TCP_CKSUM)) { 4619 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 4620 } else { 4621 printf("TCP checksum offload is not supported " 4622 "by port %u\n", res->port_id); 4623 } 4624 } else if (!strcmp(res->proto, "sctp")) { 4625 if (hw == 0 || (dev_info.tx_offload_capa & 4626 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 4627 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 4628 } else { 4629 printf("SCTP checksum offload is not supported " 4630 "by port %u\n", res->port_id); 4631 } 4632 } else if (!strcmp(res->proto, "outer-ip")) { 4633 if (hw == 0 || (dev_info.tx_offload_capa & 4634 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4635 csum_offloads |= 4636 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4637 } else { 4638 printf("Outer IP checksum offload is not " 4639 "supported by port %u\n", res->port_id); 4640 } 4641 } else if (!strcmp(res->proto, "outer-udp")) { 4642 if (hw == 0 || (dev_info.tx_offload_capa & 4643 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) { 4644 csum_offloads |= 4645 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; 4646 } else { 4647 printf("Outer UDP checksum offload is not " 4648 "supported by port %u\n", res->port_id); 4649 } 4650 } 4651 4652 if (hw) { 4653 ports[res->port_id].dev_conf.txmode.offloads |= 4654 csum_offloads; 4655 } else { 4656 ports[res->port_id].dev_conf.txmode.offloads &= 4657 (~csum_offloads); 4658 } 4659 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4660 } 4661 csum_show(res->port_id); 4662 4663 cmd_reconfig_device_queue(res->port_id, 1, 1); 4664 } 4665 4666 cmdline_parse_token_string_t cmd_csum_csum = 4667 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4668 csum, "csum"); 4669 cmdline_parse_token_string_t cmd_csum_mode = 4670 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4671 mode, "set"); 4672 cmdline_parse_token_string_t cmd_csum_proto = 4673 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4674 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); 4675 cmdline_parse_token_string_t cmd_csum_hwsw = 4676 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4677 hwsw, "hw#sw"); 4678 cmdline_parse_token_num_t cmd_csum_portid = 4679 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4680 port_id, RTE_UINT16); 4681 4682 cmdline_parse_inst_t cmd_csum_set = { 4683 .f = cmd_csum_parsed, 4684 .data = NULL, 4685 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: " 4686 "Enable/Disable hardware calculation of L3/L4 checksum when " 4687 "using csum forward engine", 4688 .tokens = { 4689 (void *)&cmd_csum_csum, 4690 (void *)&cmd_csum_mode, 4691 (void *)&cmd_csum_proto, 4692 (void *)&cmd_csum_hwsw, 4693 (void *)&cmd_csum_portid, 4694 NULL, 4695 }, 4696 }; 4697 4698 cmdline_parse_token_string_t cmd_csum_mode_show = 4699 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4700 mode, "show"); 4701 4702 cmdline_parse_inst_t cmd_csum_show = { 4703 .f = cmd_csum_parsed, 4704 .data = NULL, 4705 .help_str = "csum show <port_id>: Show checksum offload configuration", 4706 .tokens = { 4707 (void *)&cmd_csum_csum, 4708 (void *)&cmd_csum_mode_show, 4709 (void *)&cmd_csum_portid, 4710 NULL, 4711 }, 4712 }; 4713 4714 /* Enable/disable tunnel parsing */ 4715 struct cmd_csum_tunnel_result { 4716 cmdline_fixed_string_t csum; 4717 cmdline_fixed_string_t parse; 4718 cmdline_fixed_string_t onoff; 4719 portid_t port_id; 4720 }; 4721 4722 static void 4723 cmd_csum_tunnel_parsed(void *parsed_result, 4724 __rte_unused struct cmdline *cl, 4725 __rte_unused void *data) 4726 { 4727 struct cmd_csum_tunnel_result *res = parsed_result; 4728 4729 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4730 return; 4731 4732 if (!strcmp(res->onoff, "on")) 4733 ports[res->port_id].parse_tunnel = 1; 4734 else 4735 ports[res->port_id].parse_tunnel = 0; 4736 4737 csum_show(res->port_id); 4738 } 4739 4740 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4741 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4742 csum, "csum"); 4743 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4744 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4745 parse, "parse-tunnel"); 4746 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4747 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4748 onoff, "on#off"); 4749 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4750 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4751 port_id, RTE_UINT16); 4752 4753 cmdline_parse_inst_t cmd_csum_tunnel = { 4754 .f = cmd_csum_tunnel_parsed, 4755 .data = NULL, 4756 .help_str = "csum parse-tunnel on|off <port_id>: " 4757 "Enable/Disable parsing of tunnels for csum engine", 4758 .tokens = { 4759 (void *)&cmd_csum_tunnel_csum, 4760 (void *)&cmd_csum_tunnel_parse, 4761 (void *)&cmd_csum_tunnel_onoff, 4762 (void *)&cmd_csum_tunnel_portid, 4763 NULL, 4764 }, 4765 }; 4766 4767 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4768 struct cmd_tso_set_result { 4769 cmdline_fixed_string_t tso; 4770 cmdline_fixed_string_t mode; 4771 uint16_t tso_segsz; 4772 portid_t port_id; 4773 }; 4774 4775 static void 4776 cmd_tso_set_parsed(void *parsed_result, 4777 __rte_unused struct cmdline *cl, 4778 __rte_unused void *data) 4779 { 4780 struct cmd_tso_set_result *res = parsed_result; 4781 struct rte_eth_dev_info dev_info; 4782 int ret; 4783 4784 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4785 return; 4786 if (!port_is_stopped(res->port_id)) { 4787 printf("Please stop port %d first\n", res->port_id); 4788 return; 4789 } 4790 4791 if (!strcmp(res->mode, "set")) 4792 ports[res->port_id].tso_segsz = res->tso_segsz; 4793 4794 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4795 if (ret != 0) 4796 return; 4797 4798 if ((ports[res->port_id].tso_segsz != 0) && 4799 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4800 printf("Error: TSO is not supported by port %d\n", 4801 res->port_id); 4802 return; 4803 } 4804 4805 if (ports[res->port_id].tso_segsz == 0) { 4806 ports[res->port_id].dev_conf.txmode.offloads &= 4807 ~DEV_TX_OFFLOAD_TCP_TSO; 4808 printf("TSO for non-tunneled packets is disabled\n"); 4809 } else { 4810 ports[res->port_id].dev_conf.txmode.offloads |= 4811 DEV_TX_OFFLOAD_TCP_TSO; 4812 printf("TSO segment size for non-tunneled packets is %d\n", 4813 ports[res->port_id].tso_segsz); 4814 } 4815 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4816 4817 /* display warnings if configuration is not supported by the NIC */ 4818 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4819 if (ret != 0) 4820 return; 4821 4822 if ((ports[res->port_id].tso_segsz != 0) && 4823 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4824 printf("Warning: TSO enabled but not " 4825 "supported by port %d\n", res->port_id); 4826 } 4827 4828 cmd_reconfig_device_queue(res->port_id, 1, 1); 4829 } 4830 4831 cmdline_parse_token_string_t cmd_tso_set_tso = 4832 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4833 tso, "tso"); 4834 cmdline_parse_token_string_t cmd_tso_set_mode = 4835 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4836 mode, "set"); 4837 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4838 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4839 tso_segsz, RTE_UINT16); 4840 cmdline_parse_token_num_t cmd_tso_set_portid = 4841 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4842 port_id, RTE_UINT16); 4843 4844 cmdline_parse_inst_t cmd_tso_set = { 4845 .f = cmd_tso_set_parsed, 4846 .data = NULL, 4847 .help_str = "tso set <tso_segsz> <port_id>: " 4848 "Set TSO segment size of non-tunneled packets for csum engine " 4849 "(0 to disable)", 4850 .tokens = { 4851 (void *)&cmd_tso_set_tso, 4852 (void *)&cmd_tso_set_mode, 4853 (void *)&cmd_tso_set_tso_segsz, 4854 (void *)&cmd_tso_set_portid, 4855 NULL, 4856 }, 4857 }; 4858 4859 cmdline_parse_token_string_t cmd_tso_show_mode = 4860 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4861 mode, "show"); 4862 4863 4864 cmdline_parse_inst_t cmd_tso_show = { 4865 .f = cmd_tso_set_parsed, 4866 .data = NULL, 4867 .help_str = "tso show <port_id>: " 4868 "Show TSO segment size of non-tunneled packets for csum engine", 4869 .tokens = { 4870 (void *)&cmd_tso_set_tso, 4871 (void *)&cmd_tso_show_mode, 4872 (void *)&cmd_tso_set_portid, 4873 NULL, 4874 }, 4875 }; 4876 4877 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 4878 struct cmd_tunnel_tso_set_result { 4879 cmdline_fixed_string_t tso; 4880 cmdline_fixed_string_t mode; 4881 uint16_t tso_segsz; 4882 portid_t port_id; 4883 }; 4884 4885 static struct rte_eth_dev_info 4886 check_tunnel_tso_nic_support(portid_t port_id) 4887 { 4888 struct rte_eth_dev_info dev_info; 4889 4890 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0) 4891 return dev_info; 4892 4893 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 4894 printf("Warning: VXLAN TUNNEL TSO not supported therefore " 4895 "not enabled for port %d\n", port_id); 4896 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 4897 printf("Warning: GRE TUNNEL TSO not supported therefore " 4898 "not enabled for port %d\n", port_id); 4899 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 4900 printf("Warning: IPIP TUNNEL TSO not supported therefore " 4901 "not enabled for port %d\n", port_id); 4902 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 4903 printf("Warning: GENEVE TUNNEL TSO not supported therefore " 4904 "not enabled for port %d\n", port_id); 4905 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO)) 4906 printf("Warning: IP TUNNEL TSO not supported therefore " 4907 "not enabled for port %d\n", port_id); 4908 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO)) 4909 printf("Warning: UDP TUNNEL TSO not supported therefore " 4910 "not enabled for port %d\n", port_id); 4911 return dev_info; 4912 } 4913 4914 static void 4915 cmd_tunnel_tso_set_parsed(void *parsed_result, 4916 __rte_unused struct cmdline *cl, 4917 __rte_unused void *data) 4918 { 4919 struct cmd_tunnel_tso_set_result *res = parsed_result; 4920 struct rte_eth_dev_info dev_info; 4921 4922 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4923 return; 4924 if (!port_is_stopped(res->port_id)) { 4925 printf("Please stop port %d first\n", res->port_id); 4926 return; 4927 } 4928 4929 if (!strcmp(res->mode, "set")) 4930 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 4931 4932 dev_info = check_tunnel_tso_nic_support(res->port_id); 4933 if (ports[res->port_id].tunnel_tso_segsz == 0) { 4934 ports[res->port_id].dev_conf.txmode.offloads &= 4935 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4936 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4937 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4938 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4939 DEV_TX_OFFLOAD_IP_TNL_TSO | 4940 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4941 printf("TSO for tunneled packets is disabled\n"); 4942 } else { 4943 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4944 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4945 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4946 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4947 DEV_TX_OFFLOAD_IP_TNL_TSO | 4948 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4949 4950 ports[res->port_id].dev_conf.txmode.offloads |= 4951 (tso_offloads & dev_info.tx_offload_capa); 4952 printf("TSO segment size for tunneled packets is %d\n", 4953 ports[res->port_id].tunnel_tso_segsz); 4954 4955 /* Below conditions are needed to make it work: 4956 * (1) tunnel TSO is supported by the NIC; 4957 * (2) "csum parse_tunnel" must be set so that tunneled pkts 4958 * are recognized; 4959 * (3) for tunneled pkts with outer L3 of IPv4, 4960 * "csum set outer-ip" must be set to hw, because after tso, 4961 * total_len of outer IP header is changed, and the checksum 4962 * of outer IP header calculated by sw should be wrong; that 4963 * is not necessary for IPv6 tunneled pkts because there's no 4964 * checksum in IP header anymore. 4965 */ 4966 4967 if (!ports[res->port_id].parse_tunnel) 4968 printf("Warning: csum parse_tunnel must be set " 4969 "so that tunneled packets are recognized\n"); 4970 if (!(ports[res->port_id].dev_conf.txmode.offloads & 4971 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 4972 printf("Warning: csum set outer-ip must be set to hw " 4973 "if outer L3 is IPv4; not necessary for IPv6\n"); 4974 } 4975 4976 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4977 cmd_reconfig_device_queue(res->port_id, 1, 1); 4978 } 4979 4980 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 4981 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4982 tso, "tunnel_tso"); 4983 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 4984 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4985 mode, "set"); 4986 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 4987 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4988 tso_segsz, RTE_UINT16); 4989 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 4990 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4991 port_id, RTE_UINT16); 4992 4993 cmdline_parse_inst_t cmd_tunnel_tso_set = { 4994 .f = cmd_tunnel_tso_set_parsed, 4995 .data = NULL, 4996 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 4997 "Set TSO segment size of tunneled packets for csum engine " 4998 "(0 to disable)", 4999 .tokens = { 5000 (void *)&cmd_tunnel_tso_set_tso, 5001 (void *)&cmd_tunnel_tso_set_mode, 5002 (void *)&cmd_tunnel_tso_set_tso_segsz, 5003 (void *)&cmd_tunnel_tso_set_portid, 5004 NULL, 5005 }, 5006 }; 5007 5008 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 5009 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5010 mode, "show"); 5011 5012 5013 cmdline_parse_inst_t cmd_tunnel_tso_show = { 5014 .f = cmd_tunnel_tso_set_parsed, 5015 .data = NULL, 5016 .help_str = "tunnel_tso show <port_id> " 5017 "Show TSO segment size of tunneled packets for csum engine", 5018 .tokens = { 5019 (void *)&cmd_tunnel_tso_set_tso, 5020 (void *)&cmd_tunnel_tso_show_mode, 5021 (void *)&cmd_tunnel_tso_set_portid, 5022 NULL, 5023 }, 5024 }; 5025 5026 /* *** SET GRO FOR A PORT *** */ 5027 struct cmd_gro_enable_result { 5028 cmdline_fixed_string_t cmd_set; 5029 cmdline_fixed_string_t cmd_port; 5030 cmdline_fixed_string_t cmd_keyword; 5031 cmdline_fixed_string_t cmd_onoff; 5032 portid_t cmd_pid; 5033 }; 5034 5035 static void 5036 cmd_gro_enable_parsed(void *parsed_result, 5037 __rte_unused struct cmdline *cl, 5038 __rte_unused void *data) 5039 { 5040 struct cmd_gro_enable_result *res; 5041 5042 res = parsed_result; 5043 if (!strcmp(res->cmd_keyword, "gro")) 5044 setup_gro(res->cmd_onoff, res->cmd_pid); 5045 } 5046 5047 cmdline_parse_token_string_t cmd_gro_enable_set = 5048 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5049 cmd_set, "set"); 5050 cmdline_parse_token_string_t cmd_gro_enable_port = 5051 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5052 cmd_keyword, "port"); 5053 cmdline_parse_token_num_t cmd_gro_enable_pid = 5054 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 5055 cmd_pid, RTE_UINT16); 5056 cmdline_parse_token_string_t cmd_gro_enable_keyword = 5057 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5058 cmd_keyword, "gro"); 5059 cmdline_parse_token_string_t cmd_gro_enable_onoff = 5060 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5061 cmd_onoff, "on#off"); 5062 5063 cmdline_parse_inst_t cmd_gro_enable = { 5064 .f = cmd_gro_enable_parsed, 5065 .data = NULL, 5066 .help_str = "set port <port_id> gro on|off", 5067 .tokens = { 5068 (void *)&cmd_gro_enable_set, 5069 (void *)&cmd_gro_enable_port, 5070 (void *)&cmd_gro_enable_pid, 5071 (void *)&cmd_gro_enable_keyword, 5072 (void *)&cmd_gro_enable_onoff, 5073 NULL, 5074 }, 5075 }; 5076 5077 /* *** DISPLAY GRO CONFIGURATION *** */ 5078 struct cmd_gro_show_result { 5079 cmdline_fixed_string_t cmd_show; 5080 cmdline_fixed_string_t cmd_port; 5081 cmdline_fixed_string_t cmd_keyword; 5082 portid_t cmd_pid; 5083 }; 5084 5085 static void 5086 cmd_gro_show_parsed(void *parsed_result, 5087 __rte_unused struct cmdline *cl, 5088 __rte_unused void *data) 5089 { 5090 struct cmd_gro_show_result *res; 5091 5092 res = parsed_result; 5093 if (!strcmp(res->cmd_keyword, "gro")) 5094 show_gro(res->cmd_pid); 5095 } 5096 5097 cmdline_parse_token_string_t cmd_gro_show_show = 5098 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5099 cmd_show, "show"); 5100 cmdline_parse_token_string_t cmd_gro_show_port = 5101 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5102 cmd_port, "port"); 5103 cmdline_parse_token_num_t cmd_gro_show_pid = 5104 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 5105 cmd_pid, RTE_UINT16); 5106 cmdline_parse_token_string_t cmd_gro_show_keyword = 5107 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5108 cmd_keyword, "gro"); 5109 5110 cmdline_parse_inst_t cmd_gro_show = { 5111 .f = cmd_gro_show_parsed, 5112 .data = NULL, 5113 .help_str = "show port <port_id> gro", 5114 .tokens = { 5115 (void *)&cmd_gro_show_show, 5116 (void *)&cmd_gro_show_port, 5117 (void *)&cmd_gro_show_pid, 5118 (void *)&cmd_gro_show_keyword, 5119 NULL, 5120 }, 5121 }; 5122 5123 /* *** SET FLUSH CYCLES FOR GRO *** */ 5124 struct cmd_gro_flush_result { 5125 cmdline_fixed_string_t cmd_set; 5126 cmdline_fixed_string_t cmd_keyword; 5127 cmdline_fixed_string_t cmd_flush; 5128 uint8_t cmd_cycles; 5129 }; 5130 5131 static void 5132 cmd_gro_flush_parsed(void *parsed_result, 5133 __rte_unused struct cmdline *cl, 5134 __rte_unused void *data) 5135 { 5136 struct cmd_gro_flush_result *res; 5137 5138 res = parsed_result; 5139 if ((!strcmp(res->cmd_keyword, "gro")) && 5140 (!strcmp(res->cmd_flush, "flush"))) 5141 setup_gro_flush_cycles(res->cmd_cycles); 5142 } 5143 5144 cmdline_parse_token_string_t cmd_gro_flush_set = 5145 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5146 cmd_set, "set"); 5147 cmdline_parse_token_string_t cmd_gro_flush_keyword = 5148 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5149 cmd_keyword, "gro"); 5150 cmdline_parse_token_string_t cmd_gro_flush_flush = 5151 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5152 cmd_flush, "flush"); 5153 cmdline_parse_token_num_t cmd_gro_flush_cycles = 5154 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 5155 cmd_cycles, RTE_UINT8); 5156 5157 cmdline_parse_inst_t cmd_gro_flush = { 5158 .f = cmd_gro_flush_parsed, 5159 .data = NULL, 5160 .help_str = "set gro flush <cycles>", 5161 .tokens = { 5162 (void *)&cmd_gro_flush_set, 5163 (void *)&cmd_gro_flush_keyword, 5164 (void *)&cmd_gro_flush_flush, 5165 (void *)&cmd_gro_flush_cycles, 5166 NULL, 5167 }, 5168 }; 5169 5170 /* *** ENABLE/DISABLE GSO *** */ 5171 struct cmd_gso_enable_result { 5172 cmdline_fixed_string_t cmd_set; 5173 cmdline_fixed_string_t cmd_port; 5174 cmdline_fixed_string_t cmd_keyword; 5175 cmdline_fixed_string_t cmd_mode; 5176 portid_t cmd_pid; 5177 }; 5178 5179 static void 5180 cmd_gso_enable_parsed(void *parsed_result, 5181 __rte_unused struct cmdline *cl, 5182 __rte_unused void *data) 5183 { 5184 struct cmd_gso_enable_result *res; 5185 5186 res = parsed_result; 5187 if (!strcmp(res->cmd_keyword, "gso")) 5188 setup_gso(res->cmd_mode, res->cmd_pid); 5189 } 5190 5191 cmdline_parse_token_string_t cmd_gso_enable_set = 5192 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5193 cmd_set, "set"); 5194 cmdline_parse_token_string_t cmd_gso_enable_port = 5195 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5196 cmd_port, "port"); 5197 cmdline_parse_token_string_t cmd_gso_enable_keyword = 5198 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5199 cmd_keyword, "gso"); 5200 cmdline_parse_token_string_t cmd_gso_enable_mode = 5201 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5202 cmd_mode, "on#off"); 5203 cmdline_parse_token_num_t cmd_gso_enable_pid = 5204 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 5205 cmd_pid, RTE_UINT16); 5206 5207 cmdline_parse_inst_t cmd_gso_enable = { 5208 .f = cmd_gso_enable_parsed, 5209 .data = NULL, 5210 .help_str = "set port <port_id> gso on|off", 5211 .tokens = { 5212 (void *)&cmd_gso_enable_set, 5213 (void *)&cmd_gso_enable_port, 5214 (void *)&cmd_gso_enable_pid, 5215 (void *)&cmd_gso_enable_keyword, 5216 (void *)&cmd_gso_enable_mode, 5217 NULL, 5218 }, 5219 }; 5220 5221 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 5222 struct cmd_gso_size_result { 5223 cmdline_fixed_string_t cmd_set; 5224 cmdline_fixed_string_t cmd_keyword; 5225 cmdline_fixed_string_t cmd_segsz; 5226 uint16_t cmd_size; 5227 }; 5228 5229 static void 5230 cmd_gso_size_parsed(void *parsed_result, 5231 __rte_unused struct cmdline *cl, 5232 __rte_unused void *data) 5233 { 5234 struct cmd_gso_size_result *res = parsed_result; 5235 5236 if (test_done == 0) { 5237 printf("Before setting GSO segsz, please first" 5238 " stop forwarding\n"); 5239 return; 5240 } 5241 5242 if (!strcmp(res->cmd_keyword, "gso") && 5243 !strcmp(res->cmd_segsz, "segsz")) { 5244 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 5245 printf("gso_size should be larger than %zu." 5246 " Please input a legal value\n", 5247 RTE_GSO_SEG_SIZE_MIN); 5248 else 5249 gso_max_segment_size = res->cmd_size; 5250 } 5251 } 5252 5253 cmdline_parse_token_string_t cmd_gso_size_set = 5254 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5255 cmd_set, "set"); 5256 cmdline_parse_token_string_t cmd_gso_size_keyword = 5257 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5258 cmd_keyword, "gso"); 5259 cmdline_parse_token_string_t cmd_gso_size_segsz = 5260 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5261 cmd_segsz, "segsz"); 5262 cmdline_parse_token_num_t cmd_gso_size_size = 5263 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 5264 cmd_size, RTE_UINT16); 5265 5266 cmdline_parse_inst_t cmd_gso_size = { 5267 .f = cmd_gso_size_parsed, 5268 .data = NULL, 5269 .help_str = "set gso segsz <length>", 5270 .tokens = { 5271 (void *)&cmd_gso_size_set, 5272 (void *)&cmd_gso_size_keyword, 5273 (void *)&cmd_gso_size_segsz, 5274 (void *)&cmd_gso_size_size, 5275 NULL, 5276 }, 5277 }; 5278 5279 /* *** SHOW GSO CONFIGURATION *** */ 5280 struct cmd_gso_show_result { 5281 cmdline_fixed_string_t cmd_show; 5282 cmdline_fixed_string_t cmd_port; 5283 cmdline_fixed_string_t cmd_keyword; 5284 portid_t cmd_pid; 5285 }; 5286 5287 static void 5288 cmd_gso_show_parsed(void *parsed_result, 5289 __rte_unused struct cmdline *cl, 5290 __rte_unused void *data) 5291 { 5292 struct cmd_gso_show_result *res = parsed_result; 5293 5294 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 5295 printf("invalid port id %u\n", res->cmd_pid); 5296 return; 5297 } 5298 if (!strcmp(res->cmd_keyword, "gso")) { 5299 if (gso_ports[res->cmd_pid].enable) { 5300 printf("Max GSO'd packet size: %uB\n" 5301 "Supported GSO types: TCP/IPv4, " 5302 "UDP/IPv4, VxLAN with inner " 5303 "TCP/IPv4 packet, GRE with inner " 5304 "TCP/IPv4 packet\n", 5305 gso_max_segment_size); 5306 } else 5307 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 5308 } 5309 } 5310 5311 cmdline_parse_token_string_t cmd_gso_show_show = 5312 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5313 cmd_show, "show"); 5314 cmdline_parse_token_string_t cmd_gso_show_port = 5315 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5316 cmd_port, "port"); 5317 cmdline_parse_token_string_t cmd_gso_show_keyword = 5318 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5319 cmd_keyword, "gso"); 5320 cmdline_parse_token_num_t cmd_gso_show_pid = 5321 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 5322 cmd_pid, RTE_UINT16); 5323 5324 cmdline_parse_inst_t cmd_gso_show = { 5325 .f = cmd_gso_show_parsed, 5326 .data = NULL, 5327 .help_str = "show port <port_id> gso", 5328 .tokens = { 5329 (void *)&cmd_gso_show_show, 5330 (void *)&cmd_gso_show_port, 5331 (void *)&cmd_gso_show_pid, 5332 (void *)&cmd_gso_show_keyword, 5333 NULL, 5334 }, 5335 }; 5336 5337 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 5338 struct cmd_set_flush_rx { 5339 cmdline_fixed_string_t set; 5340 cmdline_fixed_string_t flush_rx; 5341 cmdline_fixed_string_t mode; 5342 }; 5343 5344 static void 5345 cmd_set_flush_rx_parsed(void *parsed_result, 5346 __rte_unused struct cmdline *cl, 5347 __rte_unused void *data) 5348 { 5349 struct cmd_set_flush_rx *res = parsed_result; 5350 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5351 } 5352 5353 cmdline_parse_token_string_t cmd_setflushrx_set = 5354 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5355 set, "set"); 5356 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 5357 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5358 flush_rx, "flush_rx"); 5359 cmdline_parse_token_string_t cmd_setflushrx_mode = 5360 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5361 mode, "on#off"); 5362 5363 5364 cmdline_parse_inst_t cmd_set_flush_rx = { 5365 .f = cmd_set_flush_rx_parsed, 5366 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 5367 .data = NULL, 5368 .tokens = { 5369 (void *)&cmd_setflushrx_set, 5370 (void *)&cmd_setflushrx_flush_rx, 5371 (void *)&cmd_setflushrx_mode, 5372 NULL, 5373 }, 5374 }; 5375 5376 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 5377 struct cmd_set_link_check { 5378 cmdline_fixed_string_t set; 5379 cmdline_fixed_string_t link_check; 5380 cmdline_fixed_string_t mode; 5381 }; 5382 5383 static void 5384 cmd_set_link_check_parsed(void *parsed_result, 5385 __rte_unused struct cmdline *cl, 5386 __rte_unused void *data) 5387 { 5388 struct cmd_set_link_check *res = parsed_result; 5389 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5390 } 5391 5392 cmdline_parse_token_string_t cmd_setlinkcheck_set = 5393 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5394 set, "set"); 5395 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 5396 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5397 link_check, "link_check"); 5398 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 5399 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5400 mode, "on#off"); 5401 5402 5403 cmdline_parse_inst_t cmd_set_link_check = { 5404 .f = cmd_set_link_check_parsed, 5405 .help_str = "set link_check on|off: Enable/Disable link status check " 5406 "when starting/stopping a port", 5407 .data = NULL, 5408 .tokens = { 5409 (void *)&cmd_setlinkcheck_set, 5410 (void *)&cmd_setlinkcheck_link_check, 5411 (void *)&cmd_setlinkcheck_mode, 5412 NULL, 5413 }, 5414 }; 5415 5416 /* *** SET NIC BYPASS MODE *** */ 5417 struct cmd_set_bypass_mode_result { 5418 cmdline_fixed_string_t set; 5419 cmdline_fixed_string_t bypass; 5420 cmdline_fixed_string_t mode; 5421 cmdline_fixed_string_t value; 5422 portid_t port_id; 5423 }; 5424 5425 static void 5426 cmd_set_bypass_mode_parsed(void *parsed_result, 5427 __rte_unused struct cmdline *cl, 5428 __rte_unused void *data) 5429 { 5430 struct cmd_set_bypass_mode_result *res = parsed_result; 5431 portid_t port_id = res->port_id; 5432 int32_t rc = -EINVAL; 5433 5434 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5435 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5436 5437 if (!strcmp(res->value, "bypass")) 5438 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5439 else if (!strcmp(res->value, "isolate")) 5440 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5441 else 5442 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5443 5444 /* Set the bypass mode for the relevant port. */ 5445 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 5446 #endif 5447 if (rc != 0) 5448 printf("\t Failed to set bypass mode for port = %d.\n", port_id); 5449 } 5450 5451 cmdline_parse_token_string_t cmd_setbypass_mode_set = 5452 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5453 set, "set"); 5454 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 5455 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5456 bypass, "bypass"); 5457 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 5458 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5459 mode, "mode"); 5460 cmdline_parse_token_string_t cmd_setbypass_mode_value = 5461 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5462 value, "normal#bypass#isolate"); 5463 cmdline_parse_token_num_t cmd_setbypass_mode_port = 5464 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 5465 port_id, RTE_UINT16); 5466 5467 cmdline_parse_inst_t cmd_set_bypass_mode = { 5468 .f = cmd_set_bypass_mode_parsed, 5469 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 5470 "Set the NIC bypass mode for port_id", 5471 .data = NULL, 5472 .tokens = { 5473 (void *)&cmd_setbypass_mode_set, 5474 (void *)&cmd_setbypass_mode_bypass, 5475 (void *)&cmd_setbypass_mode_mode, 5476 (void *)&cmd_setbypass_mode_value, 5477 (void *)&cmd_setbypass_mode_port, 5478 NULL, 5479 }, 5480 }; 5481 5482 /* *** SET NIC BYPASS EVENT *** */ 5483 struct cmd_set_bypass_event_result { 5484 cmdline_fixed_string_t set; 5485 cmdline_fixed_string_t bypass; 5486 cmdline_fixed_string_t event; 5487 cmdline_fixed_string_t event_value; 5488 cmdline_fixed_string_t mode; 5489 cmdline_fixed_string_t mode_value; 5490 portid_t port_id; 5491 }; 5492 5493 static void 5494 cmd_set_bypass_event_parsed(void *parsed_result, 5495 __rte_unused struct cmdline *cl, 5496 __rte_unused void *data) 5497 { 5498 int32_t rc = -EINVAL; 5499 struct cmd_set_bypass_event_result *res = parsed_result; 5500 portid_t port_id = res->port_id; 5501 5502 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5503 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5504 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5505 5506 if (!strcmp(res->event_value, "timeout")) 5507 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 5508 else if (!strcmp(res->event_value, "os_on")) 5509 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 5510 else if (!strcmp(res->event_value, "os_off")) 5511 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 5512 else if (!strcmp(res->event_value, "power_on")) 5513 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 5514 else if (!strcmp(res->event_value, "power_off")) 5515 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 5516 else 5517 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5518 5519 if (!strcmp(res->mode_value, "bypass")) 5520 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5521 else if (!strcmp(res->mode_value, "isolate")) 5522 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5523 else 5524 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5525 5526 /* Set the watchdog timeout. */ 5527 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 5528 5529 rc = -EINVAL; 5530 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 5531 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 5532 bypass_timeout); 5533 } 5534 if (rc != 0) { 5535 printf("Failed to set timeout value %u " 5536 "for port %d, errto code: %d.\n", 5537 bypass_timeout, port_id, rc); 5538 } 5539 } 5540 5541 /* Set the bypass event to transition to bypass mode. */ 5542 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 5543 bypass_mode); 5544 #endif 5545 5546 if (rc != 0) 5547 printf("\t Failed to set bypass event for port = %d.\n", 5548 port_id); 5549 } 5550 5551 cmdline_parse_token_string_t cmd_setbypass_event_set = 5552 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5553 set, "set"); 5554 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 5555 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5556 bypass, "bypass"); 5557 cmdline_parse_token_string_t cmd_setbypass_event_event = 5558 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5559 event, "event"); 5560 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 5561 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5562 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 5563 cmdline_parse_token_string_t cmd_setbypass_event_mode = 5564 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5565 mode, "mode"); 5566 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 5567 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5568 mode_value, "normal#bypass#isolate"); 5569 cmdline_parse_token_num_t cmd_setbypass_event_port = 5570 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 5571 port_id, RTE_UINT16); 5572 5573 cmdline_parse_inst_t cmd_set_bypass_event = { 5574 .f = cmd_set_bypass_event_parsed, 5575 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 5576 "power_off mode normal|bypass|isolate <port_id>: " 5577 "Set the NIC bypass event mode for port_id", 5578 .data = NULL, 5579 .tokens = { 5580 (void *)&cmd_setbypass_event_set, 5581 (void *)&cmd_setbypass_event_bypass, 5582 (void *)&cmd_setbypass_event_event, 5583 (void *)&cmd_setbypass_event_event_value, 5584 (void *)&cmd_setbypass_event_mode, 5585 (void *)&cmd_setbypass_event_mode_value, 5586 (void *)&cmd_setbypass_event_port, 5587 NULL, 5588 }, 5589 }; 5590 5591 5592 /* *** SET NIC BYPASS TIMEOUT *** */ 5593 struct cmd_set_bypass_timeout_result { 5594 cmdline_fixed_string_t set; 5595 cmdline_fixed_string_t bypass; 5596 cmdline_fixed_string_t timeout; 5597 cmdline_fixed_string_t value; 5598 }; 5599 5600 static void 5601 cmd_set_bypass_timeout_parsed(void *parsed_result, 5602 __rte_unused struct cmdline *cl, 5603 __rte_unused void *data) 5604 { 5605 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 5606 5607 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5608 if (!strcmp(res->value, "1.5")) 5609 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 5610 else if (!strcmp(res->value, "2")) 5611 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 5612 else if (!strcmp(res->value, "3")) 5613 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 5614 else if (!strcmp(res->value, "4")) 5615 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 5616 else if (!strcmp(res->value, "8")) 5617 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 5618 else if (!strcmp(res->value, "16")) 5619 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 5620 else if (!strcmp(res->value, "32")) 5621 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 5622 else 5623 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5624 #endif 5625 } 5626 5627 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 5628 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5629 set, "set"); 5630 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 5631 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5632 bypass, "bypass"); 5633 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 5634 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5635 timeout, "timeout"); 5636 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 5637 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5638 value, "0#1.5#2#3#4#8#16#32"); 5639 5640 cmdline_parse_inst_t cmd_set_bypass_timeout = { 5641 .f = cmd_set_bypass_timeout_parsed, 5642 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 5643 "Set the NIC bypass watchdog timeout in seconds", 5644 .data = NULL, 5645 .tokens = { 5646 (void *)&cmd_setbypass_timeout_set, 5647 (void *)&cmd_setbypass_timeout_bypass, 5648 (void *)&cmd_setbypass_timeout_timeout, 5649 (void *)&cmd_setbypass_timeout_value, 5650 NULL, 5651 }, 5652 }; 5653 5654 /* *** SHOW NIC BYPASS MODE *** */ 5655 struct cmd_show_bypass_config_result { 5656 cmdline_fixed_string_t show; 5657 cmdline_fixed_string_t bypass; 5658 cmdline_fixed_string_t config; 5659 portid_t port_id; 5660 }; 5661 5662 static void 5663 cmd_show_bypass_config_parsed(void *parsed_result, 5664 __rte_unused struct cmdline *cl, 5665 __rte_unused void *data) 5666 { 5667 struct cmd_show_bypass_config_result *res = parsed_result; 5668 portid_t port_id = res->port_id; 5669 int rc = -EINVAL; 5670 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5671 uint32_t event_mode; 5672 uint32_t bypass_mode; 5673 uint32_t timeout = bypass_timeout; 5674 unsigned int i; 5675 5676 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 5677 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 5678 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 5679 {"UNKNOWN", "normal", "bypass", "isolate"}; 5680 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 5681 "NONE", 5682 "OS/board on", 5683 "power supply on", 5684 "OS/board off", 5685 "power supply off", 5686 "timeout"}; 5687 5688 /* Display the bypass mode.*/ 5689 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 5690 printf("\tFailed to get bypass mode for port = %d\n", port_id); 5691 return; 5692 } 5693 else { 5694 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 5695 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5696 5697 printf("\tbypass mode = %s\n", modes[bypass_mode]); 5698 } 5699 5700 /* Display the bypass timeout.*/ 5701 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 5702 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5703 5704 printf("\tbypass timeout = %s\n", timeouts[timeout]); 5705 5706 /* Display the bypass events and associated modes. */ 5707 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) { 5708 5709 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 5710 printf("\tFailed to get bypass mode for event = %s\n", 5711 events[i]); 5712 } else { 5713 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 5714 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5715 5716 printf("\tbypass event: %-16s = %s\n", events[i], 5717 modes[event_mode]); 5718 } 5719 } 5720 #endif 5721 if (rc != 0) 5722 printf("\tFailed to get bypass configuration for port = %d\n", 5723 port_id); 5724 } 5725 5726 cmdline_parse_token_string_t cmd_showbypass_config_show = 5727 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5728 show, "show"); 5729 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 5730 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5731 bypass, "bypass"); 5732 cmdline_parse_token_string_t cmd_showbypass_config_config = 5733 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5734 config, "config"); 5735 cmdline_parse_token_num_t cmd_showbypass_config_port = 5736 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 5737 port_id, RTE_UINT16); 5738 5739 cmdline_parse_inst_t cmd_show_bypass_config = { 5740 .f = cmd_show_bypass_config_parsed, 5741 .help_str = "show bypass config <port_id>: " 5742 "Show the NIC bypass config for port_id", 5743 .data = NULL, 5744 .tokens = { 5745 (void *)&cmd_showbypass_config_show, 5746 (void *)&cmd_showbypass_config_bypass, 5747 (void *)&cmd_showbypass_config_config, 5748 (void *)&cmd_showbypass_config_port, 5749 NULL, 5750 }, 5751 }; 5752 5753 #ifdef RTE_NET_BOND 5754 /* *** SET BONDING MODE *** */ 5755 struct cmd_set_bonding_mode_result { 5756 cmdline_fixed_string_t set; 5757 cmdline_fixed_string_t bonding; 5758 cmdline_fixed_string_t mode; 5759 uint8_t value; 5760 portid_t port_id; 5761 }; 5762 5763 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5764 __rte_unused struct cmdline *cl, 5765 __rte_unused void *data) 5766 { 5767 struct cmd_set_bonding_mode_result *res = parsed_result; 5768 portid_t port_id = res->port_id; 5769 5770 /* Set the bonding mode for the relevant port. */ 5771 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5772 printf("\t Failed to set bonding mode for port = %d.\n", port_id); 5773 } 5774 5775 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5776 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5777 set, "set"); 5778 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5779 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5780 bonding, "bonding"); 5781 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5782 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5783 mode, "mode"); 5784 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5785 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5786 value, RTE_UINT8); 5787 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5788 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5789 port_id, RTE_UINT16); 5790 5791 cmdline_parse_inst_t cmd_set_bonding_mode = { 5792 .f = cmd_set_bonding_mode_parsed, 5793 .help_str = "set bonding mode <mode_value> <port_id>: " 5794 "Set the bonding mode for port_id", 5795 .data = NULL, 5796 .tokens = { 5797 (void *) &cmd_setbonding_mode_set, 5798 (void *) &cmd_setbonding_mode_bonding, 5799 (void *) &cmd_setbonding_mode_mode, 5800 (void *) &cmd_setbonding_mode_value, 5801 (void *) &cmd_setbonding_mode_port, 5802 NULL 5803 } 5804 }; 5805 5806 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5807 struct cmd_set_bonding_lacp_dedicated_queues_result { 5808 cmdline_fixed_string_t set; 5809 cmdline_fixed_string_t bonding; 5810 cmdline_fixed_string_t lacp; 5811 cmdline_fixed_string_t dedicated_queues; 5812 portid_t port_id; 5813 cmdline_fixed_string_t mode; 5814 }; 5815 5816 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5817 __rte_unused struct cmdline *cl, 5818 __rte_unused void *data) 5819 { 5820 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5821 portid_t port_id = res->port_id; 5822 struct rte_port *port; 5823 5824 port = &ports[port_id]; 5825 5826 /** Check if the port is not started **/ 5827 if (port->port_status != RTE_PORT_STOPPED) { 5828 printf("Please stop port %d first\n", port_id); 5829 return; 5830 } 5831 5832 if (!strcmp(res->mode, "enable")) { 5833 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5834 printf("Dedicate queues for LACP control packets" 5835 " enabled\n"); 5836 else 5837 printf("Enabling dedicate queues for LACP control " 5838 "packets on port %d failed\n", port_id); 5839 } else if (!strcmp(res->mode, "disable")) { 5840 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5841 printf("Dedicated queues for LACP control packets " 5842 "disabled\n"); 5843 else 5844 printf("Disabling dedicated queues for LACP control " 5845 "traffic on port %d failed\n", port_id); 5846 } 5847 } 5848 5849 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 5850 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5851 set, "set"); 5852 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 5853 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5854 bonding, "bonding"); 5855 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 5856 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5857 lacp, "lacp"); 5858 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 5859 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5860 dedicated_queues, "dedicated_queues"); 5861 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 5862 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5863 port_id, RTE_UINT16); 5864 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 5865 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5866 mode, "enable#disable"); 5867 5868 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 5869 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 5870 .help_str = "set bonding lacp dedicated_queues <port_id> " 5871 "enable|disable: " 5872 "Enable/disable dedicated queues for LACP control traffic for port_id", 5873 .data = NULL, 5874 .tokens = { 5875 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 5876 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 5877 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 5878 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 5879 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 5880 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 5881 NULL 5882 } 5883 }; 5884 5885 /* *** SET BALANCE XMIT POLICY *** */ 5886 struct cmd_set_bonding_balance_xmit_policy_result { 5887 cmdline_fixed_string_t set; 5888 cmdline_fixed_string_t bonding; 5889 cmdline_fixed_string_t balance_xmit_policy; 5890 portid_t port_id; 5891 cmdline_fixed_string_t policy; 5892 }; 5893 5894 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 5895 __rte_unused struct cmdline *cl, 5896 __rte_unused void *data) 5897 { 5898 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 5899 portid_t port_id = res->port_id; 5900 uint8_t policy; 5901 5902 if (!strcmp(res->policy, "l2")) { 5903 policy = BALANCE_XMIT_POLICY_LAYER2; 5904 } else if (!strcmp(res->policy, "l23")) { 5905 policy = BALANCE_XMIT_POLICY_LAYER23; 5906 } else if (!strcmp(res->policy, "l34")) { 5907 policy = BALANCE_XMIT_POLICY_LAYER34; 5908 } else { 5909 printf("\t Invalid xmit policy selection"); 5910 return; 5911 } 5912 5913 /* Set the bonding mode for the relevant port. */ 5914 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 5915 printf("\t Failed to set bonding balance xmit policy for port = %d.\n", 5916 port_id); 5917 } 5918 } 5919 5920 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 5921 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5922 set, "set"); 5923 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 5924 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5925 bonding, "bonding"); 5926 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 5927 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5928 balance_xmit_policy, "balance_xmit_policy"); 5929 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 5930 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5931 port_id, RTE_UINT16); 5932 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 5933 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5934 policy, "l2#l23#l34"); 5935 5936 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 5937 .f = cmd_set_bonding_balance_xmit_policy_parsed, 5938 .help_str = "set bonding balance_xmit_policy <port_id> " 5939 "l2|l23|l34: " 5940 "Set the bonding balance_xmit_policy for port_id", 5941 .data = NULL, 5942 .tokens = { 5943 (void *)&cmd_setbonding_balance_xmit_policy_set, 5944 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 5945 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 5946 (void *)&cmd_setbonding_balance_xmit_policy_port, 5947 (void *)&cmd_setbonding_balance_xmit_policy_policy, 5948 NULL 5949 } 5950 }; 5951 5952 /* *** SHOW NIC BONDING CONFIGURATION *** */ 5953 struct cmd_show_bonding_config_result { 5954 cmdline_fixed_string_t show; 5955 cmdline_fixed_string_t bonding; 5956 cmdline_fixed_string_t config; 5957 portid_t port_id; 5958 }; 5959 5960 static void cmd_show_bonding_config_parsed(void *parsed_result, 5961 __rte_unused struct cmdline *cl, 5962 __rte_unused void *data) 5963 { 5964 struct cmd_show_bonding_config_result *res = parsed_result; 5965 int bonding_mode, agg_mode; 5966 portid_t slaves[RTE_MAX_ETHPORTS]; 5967 int num_slaves, num_active_slaves; 5968 int primary_id; 5969 int i; 5970 portid_t port_id = res->port_id; 5971 5972 /* Display the bonding mode.*/ 5973 bonding_mode = rte_eth_bond_mode_get(port_id); 5974 if (bonding_mode < 0) { 5975 printf("\tFailed to get bonding mode for port = %d\n", port_id); 5976 return; 5977 } else 5978 printf("\tBonding mode: %d\n", bonding_mode); 5979 5980 if (bonding_mode == BONDING_MODE_BALANCE) { 5981 int balance_xmit_policy; 5982 5983 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 5984 if (balance_xmit_policy < 0) { 5985 printf("\tFailed to get balance xmit policy for port = %d\n", 5986 port_id); 5987 return; 5988 } else { 5989 printf("\tBalance Xmit Policy: "); 5990 5991 switch (balance_xmit_policy) { 5992 case BALANCE_XMIT_POLICY_LAYER2: 5993 printf("BALANCE_XMIT_POLICY_LAYER2"); 5994 break; 5995 case BALANCE_XMIT_POLICY_LAYER23: 5996 printf("BALANCE_XMIT_POLICY_LAYER23"); 5997 break; 5998 case BALANCE_XMIT_POLICY_LAYER34: 5999 printf("BALANCE_XMIT_POLICY_LAYER34"); 6000 break; 6001 } 6002 printf("\n"); 6003 } 6004 } 6005 6006 if (bonding_mode == BONDING_MODE_8023AD) { 6007 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 6008 printf("\tIEEE802.3AD Aggregator Mode: "); 6009 switch (agg_mode) { 6010 case AGG_BANDWIDTH: 6011 printf("bandwidth"); 6012 break; 6013 case AGG_STABLE: 6014 printf("stable"); 6015 break; 6016 case AGG_COUNT: 6017 printf("count"); 6018 break; 6019 } 6020 printf("\n"); 6021 } 6022 6023 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 6024 6025 if (num_slaves < 0) { 6026 printf("\tFailed to get slave list for port = %d\n", port_id); 6027 return; 6028 } 6029 if (num_slaves > 0) { 6030 printf("\tSlaves (%d): [", num_slaves); 6031 for (i = 0; i < num_slaves - 1; i++) 6032 printf("%d ", slaves[i]); 6033 6034 printf("%d]\n", slaves[num_slaves - 1]); 6035 } else { 6036 printf("\tSlaves: []\n"); 6037 6038 } 6039 6040 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 6041 RTE_MAX_ETHPORTS); 6042 6043 if (num_active_slaves < 0) { 6044 printf("\tFailed to get active slave list for port = %d\n", port_id); 6045 return; 6046 } 6047 if (num_active_slaves > 0) { 6048 printf("\tActive Slaves (%d): [", num_active_slaves); 6049 for (i = 0; i < num_active_slaves - 1; i++) 6050 printf("%d ", slaves[i]); 6051 6052 printf("%d]\n", slaves[num_active_slaves - 1]); 6053 6054 } else { 6055 printf("\tActive Slaves: []\n"); 6056 6057 } 6058 6059 primary_id = rte_eth_bond_primary_get(port_id); 6060 if (primary_id < 0) { 6061 printf("\tFailed to get primary slave for port = %d\n", port_id); 6062 return; 6063 } else 6064 printf("\tPrimary: [%d]\n", primary_id); 6065 6066 } 6067 6068 cmdline_parse_token_string_t cmd_showbonding_config_show = 6069 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6070 show, "show"); 6071 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 6072 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6073 bonding, "bonding"); 6074 cmdline_parse_token_string_t cmd_showbonding_config_config = 6075 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6076 config, "config"); 6077 cmdline_parse_token_num_t cmd_showbonding_config_port = 6078 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 6079 port_id, RTE_UINT16); 6080 6081 cmdline_parse_inst_t cmd_show_bonding_config = { 6082 .f = cmd_show_bonding_config_parsed, 6083 .help_str = "show bonding config <port_id>: " 6084 "Show the bonding config for port_id", 6085 .data = NULL, 6086 .tokens = { 6087 (void *)&cmd_showbonding_config_show, 6088 (void *)&cmd_showbonding_config_bonding, 6089 (void *)&cmd_showbonding_config_config, 6090 (void *)&cmd_showbonding_config_port, 6091 NULL 6092 } 6093 }; 6094 6095 /* *** SET BONDING PRIMARY *** */ 6096 struct cmd_set_bonding_primary_result { 6097 cmdline_fixed_string_t set; 6098 cmdline_fixed_string_t bonding; 6099 cmdline_fixed_string_t primary; 6100 portid_t slave_id; 6101 portid_t port_id; 6102 }; 6103 6104 static void cmd_set_bonding_primary_parsed(void *parsed_result, 6105 __rte_unused struct cmdline *cl, 6106 __rte_unused void *data) 6107 { 6108 struct cmd_set_bonding_primary_result *res = parsed_result; 6109 portid_t master_port_id = res->port_id; 6110 portid_t slave_port_id = res->slave_id; 6111 6112 /* Set the primary slave for a bonded device. */ 6113 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 6114 printf("\t Failed to set primary slave for port = %d.\n", 6115 master_port_id); 6116 return; 6117 } 6118 init_port_config(); 6119 } 6120 6121 cmdline_parse_token_string_t cmd_setbonding_primary_set = 6122 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6123 set, "set"); 6124 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 6125 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6126 bonding, "bonding"); 6127 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 6128 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6129 primary, "primary"); 6130 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 6131 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6132 slave_id, RTE_UINT16); 6133 cmdline_parse_token_num_t cmd_setbonding_primary_port = 6134 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6135 port_id, RTE_UINT16); 6136 6137 cmdline_parse_inst_t cmd_set_bonding_primary = { 6138 .f = cmd_set_bonding_primary_parsed, 6139 .help_str = "set bonding primary <slave_id> <port_id>: " 6140 "Set the primary slave for port_id", 6141 .data = NULL, 6142 .tokens = { 6143 (void *)&cmd_setbonding_primary_set, 6144 (void *)&cmd_setbonding_primary_bonding, 6145 (void *)&cmd_setbonding_primary_primary, 6146 (void *)&cmd_setbonding_primary_slave, 6147 (void *)&cmd_setbonding_primary_port, 6148 NULL 6149 } 6150 }; 6151 6152 /* *** ADD SLAVE *** */ 6153 struct cmd_add_bonding_slave_result { 6154 cmdline_fixed_string_t add; 6155 cmdline_fixed_string_t bonding; 6156 cmdline_fixed_string_t slave; 6157 portid_t slave_id; 6158 portid_t port_id; 6159 }; 6160 6161 static void cmd_add_bonding_slave_parsed(void *parsed_result, 6162 __rte_unused struct cmdline *cl, 6163 __rte_unused void *data) 6164 { 6165 struct cmd_add_bonding_slave_result *res = parsed_result; 6166 portid_t master_port_id = res->port_id; 6167 portid_t slave_port_id = res->slave_id; 6168 6169 /* add the slave for a bonded device. */ 6170 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 6171 printf("\t Failed to add slave %d to master port = %d.\n", 6172 slave_port_id, master_port_id); 6173 return; 6174 } 6175 init_port_config(); 6176 set_port_slave_flag(slave_port_id); 6177 } 6178 6179 cmdline_parse_token_string_t cmd_addbonding_slave_add = 6180 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6181 add, "add"); 6182 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 6183 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6184 bonding, "bonding"); 6185 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 6186 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6187 slave, "slave"); 6188 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 6189 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6190 slave_id, RTE_UINT16); 6191 cmdline_parse_token_num_t cmd_addbonding_slave_port = 6192 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6193 port_id, RTE_UINT16); 6194 6195 cmdline_parse_inst_t cmd_add_bonding_slave = { 6196 .f = cmd_add_bonding_slave_parsed, 6197 .help_str = "add bonding slave <slave_id> <port_id>: " 6198 "Add a slave device to a bonded device", 6199 .data = NULL, 6200 .tokens = { 6201 (void *)&cmd_addbonding_slave_add, 6202 (void *)&cmd_addbonding_slave_bonding, 6203 (void *)&cmd_addbonding_slave_slave, 6204 (void *)&cmd_addbonding_slave_slaveid, 6205 (void *)&cmd_addbonding_slave_port, 6206 NULL 6207 } 6208 }; 6209 6210 /* *** REMOVE SLAVE *** */ 6211 struct cmd_remove_bonding_slave_result { 6212 cmdline_fixed_string_t remove; 6213 cmdline_fixed_string_t bonding; 6214 cmdline_fixed_string_t slave; 6215 portid_t slave_id; 6216 portid_t port_id; 6217 }; 6218 6219 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 6220 __rte_unused struct cmdline *cl, 6221 __rte_unused void *data) 6222 { 6223 struct cmd_remove_bonding_slave_result *res = parsed_result; 6224 portid_t master_port_id = res->port_id; 6225 portid_t slave_port_id = res->slave_id; 6226 6227 /* remove the slave from a bonded device. */ 6228 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 6229 printf("\t Failed to remove slave %d from master port = %d.\n", 6230 slave_port_id, master_port_id); 6231 return; 6232 } 6233 init_port_config(); 6234 clear_port_slave_flag(slave_port_id); 6235 } 6236 6237 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 6238 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6239 remove, "remove"); 6240 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 6241 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6242 bonding, "bonding"); 6243 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 6244 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6245 slave, "slave"); 6246 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 6247 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6248 slave_id, RTE_UINT16); 6249 cmdline_parse_token_num_t cmd_removebonding_slave_port = 6250 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6251 port_id, RTE_UINT16); 6252 6253 cmdline_parse_inst_t cmd_remove_bonding_slave = { 6254 .f = cmd_remove_bonding_slave_parsed, 6255 .help_str = "remove bonding slave <slave_id> <port_id>: " 6256 "Remove a slave device from a bonded device", 6257 .data = NULL, 6258 .tokens = { 6259 (void *)&cmd_removebonding_slave_remove, 6260 (void *)&cmd_removebonding_slave_bonding, 6261 (void *)&cmd_removebonding_slave_slave, 6262 (void *)&cmd_removebonding_slave_slaveid, 6263 (void *)&cmd_removebonding_slave_port, 6264 NULL 6265 } 6266 }; 6267 6268 /* *** CREATE BONDED DEVICE *** */ 6269 struct cmd_create_bonded_device_result { 6270 cmdline_fixed_string_t create; 6271 cmdline_fixed_string_t bonded; 6272 cmdline_fixed_string_t device; 6273 uint8_t mode; 6274 uint8_t socket; 6275 }; 6276 6277 static int bond_dev_num = 0; 6278 6279 static void cmd_create_bonded_device_parsed(void *parsed_result, 6280 __rte_unused struct cmdline *cl, 6281 __rte_unused void *data) 6282 { 6283 struct cmd_create_bonded_device_result *res = parsed_result; 6284 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 6285 int port_id; 6286 int ret; 6287 6288 if (test_done == 0) { 6289 printf("Please stop forwarding first\n"); 6290 return; 6291 } 6292 6293 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 6294 bond_dev_num++); 6295 6296 /* Create a new bonded device. */ 6297 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 6298 if (port_id < 0) { 6299 printf("\t Failed to create bonded device.\n"); 6300 return; 6301 } else { 6302 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 6303 port_id); 6304 6305 /* Update number of ports */ 6306 nb_ports = rte_eth_dev_count_avail(); 6307 reconfig(port_id, res->socket); 6308 ret = rte_eth_promiscuous_enable(port_id); 6309 if (ret != 0) 6310 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n", 6311 port_id, rte_strerror(-ret)); 6312 6313 ports[port_id].need_setup = 0; 6314 ports[port_id].port_status = RTE_PORT_STOPPED; 6315 } 6316 6317 } 6318 6319 cmdline_parse_token_string_t cmd_createbonded_device_create = 6320 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6321 create, "create"); 6322 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 6323 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6324 bonded, "bonded"); 6325 cmdline_parse_token_string_t cmd_createbonded_device_device = 6326 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6327 device, "device"); 6328 cmdline_parse_token_num_t cmd_createbonded_device_mode = 6329 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6330 mode, RTE_UINT8); 6331 cmdline_parse_token_num_t cmd_createbonded_device_socket = 6332 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6333 socket, RTE_UINT8); 6334 6335 cmdline_parse_inst_t cmd_create_bonded_device = { 6336 .f = cmd_create_bonded_device_parsed, 6337 .help_str = "create bonded device <mode> <socket>: " 6338 "Create a new bonded device with specific bonding mode and socket", 6339 .data = NULL, 6340 .tokens = { 6341 (void *)&cmd_createbonded_device_create, 6342 (void *)&cmd_createbonded_device_bonded, 6343 (void *)&cmd_createbonded_device_device, 6344 (void *)&cmd_createbonded_device_mode, 6345 (void *)&cmd_createbonded_device_socket, 6346 NULL 6347 } 6348 }; 6349 6350 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 6351 struct cmd_set_bond_mac_addr_result { 6352 cmdline_fixed_string_t set; 6353 cmdline_fixed_string_t bonding; 6354 cmdline_fixed_string_t mac_addr; 6355 uint16_t port_num; 6356 struct rte_ether_addr address; 6357 }; 6358 6359 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 6360 __rte_unused struct cmdline *cl, 6361 __rte_unused void *data) 6362 { 6363 struct cmd_set_bond_mac_addr_result *res = parsed_result; 6364 int ret; 6365 6366 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 6367 return; 6368 6369 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 6370 6371 /* check the return value and print it if is < 0 */ 6372 if (ret < 0) 6373 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6374 } 6375 6376 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 6377 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 6378 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 6379 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 6380 "bonding"); 6381 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 6382 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 6383 "mac_addr"); 6384 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 6385 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 6386 port_num, RTE_UINT16); 6387 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 6388 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 6389 6390 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 6391 .f = cmd_set_bond_mac_addr_parsed, 6392 .data = (void *) 0, 6393 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 6394 .tokens = { 6395 (void *)&cmd_set_bond_mac_addr_set, 6396 (void *)&cmd_set_bond_mac_addr_bonding, 6397 (void *)&cmd_set_bond_mac_addr_mac, 6398 (void *)&cmd_set_bond_mac_addr_portnum, 6399 (void *)&cmd_set_bond_mac_addr_addr, 6400 NULL 6401 } 6402 }; 6403 6404 6405 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 6406 struct cmd_set_bond_mon_period_result { 6407 cmdline_fixed_string_t set; 6408 cmdline_fixed_string_t bonding; 6409 cmdline_fixed_string_t mon_period; 6410 uint16_t port_num; 6411 uint32_t period_ms; 6412 }; 6413 6414 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 6415 __rte_unused struct cmdline *cl, 6416 __rte_unused void *data) 6417 { 6418 struct cmd_set_bond_mon_period_result *res = parsed_result; 6419 int ret; 6420 6421 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 6422 6423 /* check the return value and print it if is < 0 */ 6424 if (ret < 0) 6425 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6426 } 6427 6428 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 6429 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6430 set, "set"); 6431 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 6432 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6433 bonding, "bonding"); 6434 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 6435 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6436 mon_period, "mon_period"); 6437 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 6438 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6439 port_num, RTE_UINT16); 6440 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 6441 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6442 period_ms, RTE_UINT32); 6443 6444 cmdline_parse_inst_t cmd_set_bond_mon_period = { 6445 .f = cmd_set_bond_mon_period_parsed, 6446 .data = (void *) 0, 6447 .help_str = "set bonding mon_period <port_id> <period_ms>", 6448 .tokens = { 6449 (void *)&cmd_set_bond_mon_period_set, 6450 (void *)&cmd_set_bond_mon_period_bonding, 6451 (void *)&cmd_set_bond_mon_period_mon_period, 6452 (void *)&cmd_set_bond_mon_period_portnum, 6453 (void *)&cmd_set_bond_mon_period_period_ms, 6454 NULL 6455 } 6456 }; 6457 6458 6459 6460 struct cmd_set_bonding_agg_mode_policy_result { 6461 cmdline_fixed_string_t set; 6462 cmdline_fixed_string_t bonding; 6463 cmdline_fixed_string_t agg_mode; 6464 uint16_t port_num; 6465 cmdline_fixed_string_t policy; 6466 }; 6467 6468 6469 static void 6470 cmd_set_bonding_agg_mode(void *parsed_result, 6471 __rte_unused struct cmdline *cl, 6472 __rte_unused void *data) 6473 { 6474 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 6475 uint8_t policy = AGG_BANDWIDTH; 6476 6477 if (!strcmp(res->policy, "bandwidth")) 6478 policy = AGG_BANDWIDTH; 6479 else if (!strcmp(res->policy, "stable")) 6480 policy = AGG_STABLE; 6481 else if (!strcmp(res->policy, "count")) 6482 policy = AGG_COUNT; 6483 6484 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 6485 } 6486 6487 6488 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 6489 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6490 set, "set"); 6491 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 6492 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6493 bonding, "bonding"); 6494 6495 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 6496 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6497 agg_mode, "agg_mode"); 6498 6499 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 6500 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6501 port_num, RTE_UINT16); 6502 6503 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 6504 TOKEN_STRING_INITIALIZER( 6505 struct cmd_set_bonding_balance_xmit_policy_result, 6506 policy, "stable#bandwidth#count"); 6507 6508 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 6509 .f = cmd_set_bonding_agg_mode, 6510 .data = (void *) 0, 6511 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 6512 .tokens = { 6513 (void *)&cmd_set_bonding_agg_mode_set, 6514 (void *)&cmd_set_bonding_agg_mode_bonding, 6515 (void *)&cmd_set_bonding_agg_mode_agg_mode, 6516 (void *)&cmd_set_bonding_agg_mode_portnum, 6517 (void *)&cmd_set_bonding_agg_mode_policy_string, 6518 NULL 6519 } 6520 }; 6521 6522 6523 #endif /* RTE_NET_BOND */ 6524 6525 /* *** SET FORWARDING MODE *** */ 6526 struct cmd_set_fwd_mode_result { 6527 cmdline_fixed_string_t set; 6528 cmdline_fixed_string_t fwd; 6529 cmdline_fixed_string_t mode; 6530 }; 6531 6532 static void cmd_set_fwd_mode_parsed(void *parsed_result, 6533 __rte_unused struct cmdline *cl, 6534 __rte_unused void *data) 6535 { 6536 struct cmd_set_fwd_mode_result *res = parsed_result; 6537 6538 retry_enabled = 0; 6539 set_pkt_forwarding_mode(res->mode); 6540 } 6541 6542 cmdline_parse_token_string_t cmd_setfwd_set = 6543 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 6544 cmdline_parse_token_string_t cmd_setfwd_fwd = 6545 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 6546 cmdline_parse_token_string_t cmd_setfwd_mode = 6547 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 6548 "" /* defined at init */); 6549 6550 cmdline_parse_inst_t cmd_set_fwd_mode = { 6551 .f = cmd_set_fwd_mode_parsed, 6552 .data = NULL, 6553 .help_str = NULL, /* defined at init */ 6554 .tokens = { 6555 (void *)&cmd_setfwd_set, 6556 (void *)&cmd_setfwd_fwd, 6557 (void *)&cmd_setfwd_mode, 6558 NULL, 6559 }, 6560 }; 6561 6562 static void cmd_set_fwd_mode_init(void) 6563 { 6564 char *modes, *c; 6565 static char token[128]; 6566 static char help[256]; 6567 cmdline_parse_token_string_t *token_struct; 6568 6569 modes = list_pkt_forwarding_modes(); 6570 snprintf(help, sizeof(help), "set fwd %s: " 6571 "Set packet forwarding mode", modes); 6572 cmd_set_fwd_mode.help_str = help; 6573 6574 /* string token separator is # */ 6575 for (c = token; *modes != '\0'; modes++) 6576 if (*modes == '|') 6577 *c++ = '#'; 6578 else 6579 *c++ = *modes; 6580 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 6581 token_struct->string_data.str = token; 6582 } 6583 6584 /* *** SET RETRY FORWARDING MODE *** */ 6585 struct cmd_set_fwd_retry_mode_result { 6586 cmdline_fixed_string_t set; 6587 cmdline_fixed_string_t fwd; 6588 cmdline_fixed_string_t mode; 6589 cmdline_fixed_string_t retry; 6590 }; 6591 6592 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 6593 __rte_unused struct cmdline *cl, 6594 __rte_unused void *data) 6595 { 6596 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 6597 6598 retry_enabled = 1; 6599 set_pkt_forwarding_mode(res->mode); 6600 } 6601 6602 cmdline_parse_token_string_t cmd_setfwd_retry_set = 6603 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6604 set, "set"); 6605 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 6606 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6607 fwd, "fwd"); 6608 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 6609 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6610 mode, 6611 "" /* defined at init */); 6612 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 6613 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6614 retry, "retry"); 6615 6616 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 6617 .f = cmd_set_fwd_retry_mode_parsed, 6618 .data = NULL, 6619 .help_str = NULL, /* defined at init */ 6620 .tokens = { 6621 (void *)&cmd_setfwd_retry_set, 6622 (void *)&cmd_setfwd_retry_fwd, 6623 (void *)&cmd_setfwd_retry_mode, 6624 (void *)&cmd_setfwd_retry_retry, 6625 NULL, 6626 }, 6627 }; 6628 6629 static void cmd_set_fwd_retry_mode_init(void) 6630 { 6631 char *modes, *c; 6632 static char token[128]; 6633 static char help[256]; 6634 cmdline_parse_token_string_t *token_struct; 6635 6636 modes = list_pkt_forwarding_retry_modes(); 6637 snprintf(help, sizeof(help), "set fwd %s retry: " 6638 "Set packet forwarding mode with retry", modes); 6639 cmd_set_fwd_retry_mode.help_str = help; 6640 6641 /* string token separator is # */ 6642 for (c = token; *modes != '\0'; modes++) 6643 if (*modes == '|') 6644 *c++ = '#'; 6645 else 6646 *c++ = *modes; 6647 token_struct = (cmdline_parse_token_string_t *) 6648 cmd_set_fwd_retry_mode.tokens[2]; 6649 token_struct->string_data.str = token; 6650 } 6651 6652 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 6653 struct cmd_set_burst_tx_retry_result { 6654 cmdline_fixed_string_t set; 6655 cmdline_fixed_string_t burst; 6656 cmdline_fixed_string_t tx; 6657 cmdline_fixed_string_t delay; 6658 uint32_t time; 6659 cmdline_fixed_string_t retry; 6660 uint32_t retry_num; 6661 }; 6662 6663 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 6664 __rte_unused struct cmdline *cl, 6665 __rte_unused void *data) 6666 { 6667 struct cmd_set_burst_tx_retry_result *res = parsed_result; 6668 6669 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 6670 && !strcmp(res->tx, "tx")) { 6671 if (!strcmp(res->delay, "delay")) 6672 burst_tx_delay_time = res->time; 6673 if (!strcmp(res->retry, "retry")) 6674 burst_tx_retry_num = res->retry_num; 6675 } 6676 6677 } 6678 6679 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 6680 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 6681 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 6682 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 6683 "burst"); 6684 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 6685 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 6686 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 6687 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 6688 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 6689 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, 6690 RTE_UINT32); 6691 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 6692 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 6693 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 6694 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, 6695 RTE_UINT32); 6696 6697 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 6698 .f = cmd_set_burst_tx_retry_parsed, 6699 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 6700 .tokens = { 6701 (void *)&cmd_set_burst_tx_retry_set, 6702 (void *)&cmd_set_burst_tx_retry_burst, 6703 (void *)&cmd_set_burst_tx_retry_tx, 6704 (void *)&cmd_set_burst_tx_retry_delay, 6705 (void *)&cmd_set_burst_tx_retry_time, 6706 (void *)&cmd_set_burst_tx_retry_retry, 6707 (void *)&cmd_set_burst_tx_retry_retry_num, 6708 NULL, 6709 }, 6710 }; 6711 6712 /* *** SET PROMISC MODE *** */ 6713 struct cmd_set_promisc_mode_result { 6714 cmdline_fixed_string_t set; 6715 cmdline_fixed_string_t promisc; 6716 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6717 uint16_t port_num; /* valid if "allports" argument == 0 */ 6718 cmdline_fixed_string_t mode; 6719 }; 6720 6721 static void cmd_set_promisc_mode_parsed(void *parsed_result, 6722 __rte_unused struct cmdline *cl, 6723 void *allports) 6724 { 6725 struct cmd_set_promisc_mode_result *res = parsed_result; 6726 int enable; 6727 portid_t i; 6728 6729 if (!strcmp(res->mode, "on")) 6730 enable = 1; 6731 else 6732 enable = 0; 6733 6734 /* all ports */ 6735 if (allports) { 6736 RTE_ETH_FOREACH_DEV(i) 6737 eth_set_promisc_mode(i, enable); 6738 } else { 6739 eth_set_promisc_mode(res->port_num, enable); 6740 } 6741 } 6742 6743 cmdline_parse_token_string_t cmd_setpromisc_set = 6744 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 6745 cmdline_parse_token_string_t cmd_setpromisc_promisc = 6746 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 6747 "promisc"); 6748 cmdline_parse_token_string_t cmd_setpromisc_portall = 6749 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 6750 "all"); 6751 cmdline_parse_token_num_t cmd_setpromisc_portnum = 6752 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 6753 RTE_UINT16); 6754 cmdline_parse_token_string_t cmd_setpromisc_mode = 6755 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 6756 "on#off"); 6757 6758 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 6759 .f = cmd_set_promisc_mode_parsed, 6760 .data = (void *)1, 6761 .help_str = "set promisc all on|off: Set promisc mode for all ports", 6762 .tokens = { 6763 (void *)&cmd_setpromisc_set, 6764 (void *)&cmd_setpromisc_promisc, 6765 (void *)&cmd_setpromisc_portall, 6766 (void *)&cmd_setpromisc_mode, 6767 NULL, 6768 }, 6769 }; 6770 6771 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 6772 .f = cmd_set_promisc_mode_parsed, 6773 .data = (void *)0, 6774 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 6775 .tokens = { 6776 (void *)&cmd_setpromisc_set, 6777 (void *)&cmd_setpromisc_promisc, 6778 (void *)&cmd_setpromisc_portnum, 6779 (void *)&cmd_setpromisc_mode, 6780 NULL, 6781 }, 6782 }; 6783 6784 /* *** SET ALLMULTI MODE *** */ 6785 struct cmd_set_allmulti_mode_result { 6786 cmdline_fixed_string_t set; 6787 cmdline_fixed_string_t allmulti; 6788 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6789 uint16_t port_num; /* valid if "allports" argument == 0 */ 6790 cmdline_fixed_string_t mode; 6791 }; 6792 6793 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 6794 __rte_unused struct cmdline *cl, 6795 void *allports) 6796 { 6797 struct cmd_set_allmulti_mode_result *res = parsed_result; 6798 int enable; 6799 portid_t i; 6800 6801 if (!strcmp(res->mode, "on")) 6802 enable = 1; 6803 else 6804 enable = 0; 6805 6806 /* all ports */ 6807 if (allports) { 6808 RTE_ETH_FOREACH_DEV(i) { 6809 eth_set_allmulticast_mode(i, enable); 6810 } 6811 } 6812 else { 6813 eth_set_allmulticast_mode(res->port_num, enable); 6814 } 6815 } 6816 6817 cmdline_parse_token_string_t cmd_setallmulti_set = 6818 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 6819 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 6820 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 6821 "allmulti"); 6822 cmdline_parse_token_string_t cmd_setallmulti_portall = 6823 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 6824 "all"); 6825 cmdline_parse_token_num_t cmd_setallmulti_portnum = 6826 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 6827 RTE_UINT16); 6828 cmdline_parse_token_string_t cmd_setallmulti_mode = 6829 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 6830 "on#off"); 6831 6832 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 6833 .f = cmd_set_allmulti_mode_parsed, 6834 .data = (void *)1, 6835 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 6836 .tokens = { 6837 (void *)&cmd_setallmulti_set, 6838 (void *)&cmd_setallmulti_allmulti, 6839 (void *)&cmd_setallmulti_portall, 6840 (void *)&cmd_setallmulti_mode, 6841 NULL, 6842 }, 6843 }; 6844 6845 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 6846 .f = cmd_set_allmulti_mode_parsed, 6847 .data = (void *)0, 6848 .help_str = "set allmulti <port_id> on|off: " 6849 "Set allmulti mode on port_id", 6850 .tokens = { 6851 (void *)&cmd_setallmulti_set, 6852 (void *)&cmd_setallmulti_allmulti, 6853 (void *)&cmd_setallmulti_portnum, 6854 (void *)&cmd_setallmulti_mode, 6855 NULL, 6856 }, 6857 }; 6858 6859 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 6860 struct cmd_link_flow_ctrl_set_result { 6861 cmdline_fixed_string_t set; 6862 cmdline_fixed_string_t flow_ctrl; 6863 cmdline_fixed_string_t rx; 6864 cmdline_fixed_string_t rx_lfc_mode; 6865 cmdline_fixed_string_t tx; 6866 cmdline_fixed_string_t tx_lfc_mode; 6867 cmdline_fixed_string_t mac_ctrl_frame_fwd; 6868 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 6869 cmdline_fixed_string_t autoneg_str; 6870 cmdline_fixed_string_t autoneg; 6871 cmdline_fixed_string_t hw_str; 6872 uint32_t high_water; 6873 cmdline_fixed_string_t lw_str; 6874 uint32_t low_water; 6875 cmdline_fixed_string_t pt_str; 6876 uint16_t pause_time; 6877 cmdline_fixed_string_t xon_str; 6878 uint16_t send_xon; 6879 portid_t port_id; 6880 }; 6881 6882 cmdline_parse_token_string_t cmd_lfc_set_set = 6883 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6884 set, "set"); 6885 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 6886 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6887 flow_ctrl, "flow_ctrl"); 6888 cmdline_parse_token_string_t cmd_lfc_set_rx = 6889 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6890 rx, "rx"); 6891 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 6892 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6893 rx_lfc_mode, "on#off"); 6894 cmdline_parse_token_string_t cmd_lfc_set_tx = 6895 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6896 tx, "tx"); 6897 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 6898 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6899 tx_lfc_mode, "on#off"); 6900 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 6901 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6902 hw_str, "high_water"); 6903 cmdline_parse_token_num_t cmd_lfc_set_high_water = 6904 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6905 high_water, RTE_UINT32); 6906 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 6907 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6908 lw_str, "low_water"); 6909 cmdline_parse_token_num_t cmd_lfc_set_low_water = 6910 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6911 low_water, RTE_UINT32); 6912 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 6913 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6914 pt_str, "pause_time"); 6915 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 6916 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6917 pause_time, RTE_UINT16); 6918 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 6919 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6920 xon_str, "send_xon"); 6921 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 6922 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6923 send_xon, RTE_UINT16); 6924 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 6925 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6926 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 6927 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 6928 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6929 mac_ctrl_frame_fwd_mode, "on#off"); 6930 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 6931 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6932 autoneg_str, "autoneg"); 6933 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 6934 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6935 autoneg, "on#off"); 6936 cmdline_parse_token_num_t cmd_lfc_set_portid = 6937 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6938 port_id, RTE_UINT16); 6939 6940 /* forward declaration */ 6941 static void 6942 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 6943 void *data); 6944 6945 cmdline_parse_inst_t cmd_link_flow_control_set = { 6946 .f = cmd_link_flow_ctrl_set_parsed, 6947 .data = NULL, 6948 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 6949 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 6950 "autoneg on|off <port_id>: Configure the Ethernet flow control", 6951 .tokens = { 6952 (void *)&cmd_lfc_set_set, 6953 (void *)&cmd_lfc_set_flow_ctrl, 6954 (void *)&cmd_lfc_set_rx, 6955 (void *)&cmd_lfc_set_rx_mode, 6956 (void *)&cmd_lfc_set_tx, 6957 (void *)&cmd_lfc_set_tx_mode, 6958 (void *)&cmd_lfc_set_high_water, 6959 (void *)&cmd_lfc_set_low_water, 6960 (void *)&cmd_lfc_set_pause_time, 6961 (void *)&cmd_lfc_set_send_xon, 6962 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6963 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6964 (void *)&cmd_lfc_set_autoneg_str, 6965 (void *)&cmd_lfc_set_autoneg, 6966 (void *)&cmd_lfc_set_portid, 6967 NULL, 6968 }, 6969 }; 6970 6971 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 6972 .f = cmd_link_flow_ctrl_set_parsed, 6973 .data = (void *)&cmd_link_flow_control_set_rx, 6974 .help_str = "set flow_ctrl rx on|off <port_id>: " 6975 "Change rx flow control parameter", 6976 .tokens = { 6977 (void *)&cmd_lfc_set_set, 6978 (void *)&cmd_lfc_set_flow_ctrl, 6979 (void *)&cmd_lfc_set_rx, 6980 (void *)&cmd_lfc_set_rx_mode, 6981 (void *)&cmd_lfc_set_portid, 6982 NULL, 6983 }, 6984 }; 6985 6986 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 6987 .f = cmd_link_flow_ctrl_set_parsed, 6988 .data = (void *)&cmd_link_flow_control_set_tx, 6989 .help_str = "set flow_ctrl tx on|off <port_id>: " 6990 "Change tx flow control parameter", 6991 .tokens = { 6992 (void *)&cmd_lfc_set_set, 6993 (void *)&cmd_lfc_set_flow_ctrl, 6994 (void *)&cmd_lfc_set_tx, 6995 (void *)&cmd_lfc_set_tx_mode, 6996 (void *)&cmd_lfc_set_portid, 6997 NULL, 6998 }, 6999 }; 7000 7001 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 7002 .f = cmd_link_flow_ctrl_set_parsed, 7003 .data = (void *)&cmd_link_flow_control_set_hw, 7004 .help_str = "set flow_ctrl high_water <value> <port_id>: " 7005 "Change high water flow control parameter", 7006 .tokens = { 7007 (void *)&cmd_lfc_set_set, 7008 (void *)&cmd_lfc_set_flow_ctrl, 7009 (void *)&cmd_lfc_set_high_water_str, 7010 (void *)&cmd_lfc_set_high_water, 7011 (void *)&cmd_lfc_set_portid, 7012 NULL, 7013 }, 7014 }; 7015 7016 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 7017 .f = cmd_link_flow_ctrl_set_parsed, 7018 .data = (void *)&cmd_link_flow_control_set_lw, 7019 .help_str = "set flow_ctrl low_water <value> <port_id>: " 7020 "Change low water flow control parameter", 7021 .tokens = { 7022 (void *)&cmd_lfc_set_set, 7023 (void *)&cmd_lfc_set_flow_ctrl, 7024 (void *)&cmd_lfc_set_low_water_str, 7025 (void *)&cmd_lfc_set_low_water, 7026 (void *)&cmd_lfc_set_portid, 7027 NULL, 7028 }, 7029 }; 7030 7031 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 7032 .f = cmd_link_flow_ctrl_set_parsed, 7033 .data = (void *)&cmd_link_flow_control_set_pt, 7034 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 7035 "Change pause time flow control parameter", 7036 .tokens = { 7037 (void *)&cmd_lfc_set_set, 7038 (void *)&cmd_lfc_set_flow_ctrl, 7039 (void *)&cmd_lfc_set_pause_time_str, 7040 (void *)&cmd_lfc_set_pause_time, 7041 (void *)&cmd_lfc_set_portid, 7042 NULL, 7043 }, 7044 }; 7045 7046 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 7047 .f = cmd_link_flow_ctrl_set_parsed, 7048 .data = (void *)&cmd_link_flow_control_set_xon, 7049 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 7050 "Change send_xon flow control parameter", 7051 .tokens = { 7052 (void *)&cmd_lfc_set_set, 7053 (void *)&cmd_lfc_set_flow_ctrl, 7054 (void *)&cmd_lfc_set_send_xon_str, 7055 (void *)&cmd_lfc_set_send_xon, 7056 (void *)&cmd_lfc_set_portid, 7057 NULL, 7058 }, 7059 }; 7060 7061 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 7062 .f = cmd_link_flow_ctrl_set_parsed, 7063 .data = (void *)&cmd_link_flow_control_set_macfwd, 7064 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 7065 "Change mac ctrl fwd flow control parameter", 7066 .tokens = { 7067 (void *)&cmd_lfc_set_set, 7068 (void *)&cmd_lfc_set_flow_ctrl, 7069 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 7070 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 7071 (void *)&cmd_lfc_set_portid, 7072 NULL, 7073 }, 7074 }; 7075 7076 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 7077 .f = cmd_link_flow_ctrl_set_parsed, 7078 .data = (void *)&cmd_link_flow_control_set_autoneg, 7079 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 7080 "Change autoneg flow control parameter", 7081 .tokens = { 7082 (void *)&cmd_lfc_set_set, 7083 (void *)&cmd_lfc_set_flow_ctrl, 7084 (void *)&cmd_lfc_set_autoneg_str, 7085 (void *)&cmd_lfc_set_autoneg, 7086 (void *)&cmd_lfc_set_portid, 7087 NULL, 7088 }, 7089 }; 7090 7091 static void 7092 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 7093 __rte_unused struct cmdline *cl, 7094 void *data) 7095 { 7096 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 7097 cmdline_parse_inst_t *cmd = data; 7098 struct rte_eth_fc_conf fc_conf; 7099 int rx_fc_en = 0; 7100 int tx_fc_en = 0; 7101 int ret; 7102 7103 /* 7104 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 7105 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 7106 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 7107 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 7108 */ 7109 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 7110 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 7111 }; 7112 7113 /* Partial command line, retrieve current configuration */ 7114 if (cmd) { 7115 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 7116 if (ret != 0) { 7117 printf("cannot get current flow ctrl parameters, return" 7118 "code = %d\n", ret); 7119 return; 7120 } 7121 7122 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 7123 (fc_conf.mode == RTE_FC_FULL)) 7124 rx_fc_en = 1; 7125 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 7126 (fc_conf.mode == RTE_FC_FULL)) 7127 tx_fc_en = 1; 7128 } 7129 7130 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 7131 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 7132 7133 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 7134 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 7135 7136 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 7137 7138 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 7139 fc_conf.high_water = res->high_water; 7140 7141 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 7142 fc_conf.low_water = res->low_water; 7143 7144 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 7145 fc_conf.pause_time = res->pause_time; 7146 7147 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 7148 fc_conf.send_xon = res->send_xon; 7149 7150 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 7151 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 7152 fc_conf.mac_ctrl_frame_fwd = 1; 7153 else 7154 fc_conf.mac_ctrl_frame_fwd = 0; 7155 } 7156 7157 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 7158 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 7159 7160 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 7161 if (ret != 0) 7162 printf("bad flow contrl parameter, return code = %d \n", ret); 7163 } 7164 7165 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 7166 struct cmd_priority_flow_ctrl_set_result { 7167 cmdline_fixed_string_t set; 7168 cmdline_fixed_string_t pfc_ctrl; 7169 cmdline_fixed_string_t rx; 7170 cmdline_fixed_string_t rx_pfc_mode; 7171 cmdline_fixed_string_t tx; 7172 cmdline_fixed_string_t tx_pfc_mode; 7173 uint32_t high_water; 7174 uint32_t low_water; 7175 uint16_t pause_time; 7176 uint8_t priority; 7177 portid_t port_id; 7178 }; 7179 7180 static void 7181 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 7182 __rte_unused struct cmdline *cl, 7183 __rte_unused void *data) 7184 { 7185 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 7186 struct rte_eth_pfc_conf pfc_conf; 7187 int rx_fc_enable, tx_fc_enable; 7188 int ret; 7189 7190 /* 7191 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 7192 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 7193 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 7194 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 7195 */ 7196 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 7197 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 7198 }; 7199 7200 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf)); 7201 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 7202 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 7203 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 7204 pfc_conf.fc.high_water = res->high_water; 7205 pfc_conf.fc.low_water = res->low_water; 7206 pfc_conf.fc.pause_time = res->pause_time; 7207 pfc_conf.priority = res->priority; 7208 7209 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 7210 if (ret != 0) 7211 printf("bad priority flow contrl parameter, return code = %d \n", ret); 7212 } 7213 7214 cmdline_parse_token_string_t cmd_pfc_set_set = 7215 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7216 set, "set"); 7217 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 7218 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7219 pfc_ctrl, "pfc_ctrl"); 7220 cmdline_parse_token_string_t cmd_pfc_set_rx = 7221 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7222 rx, "rx"); 7223 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 7224 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7225 rx_pfc_mode, "on#off"); 7226 cmdline_parse_token_string_t cmd_pfc_set_tx = 7227 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7228 tx, "tx"); 7229 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 7230 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7231 tx_pfc_mode, "on#off"); 7232 cmdline_parse_token_num_t cmd_pfc_set_high_water = 7233 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7234 high_water, RTE_UINT32); 7235 cmdline_parse_token_num_t cmd_pfc_set_low_water = 7236 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7237 low_water, RTE_UINT32); 7238 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 7239 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7240 pause_time, RTE_UINT16); 7241 cmdline_parse_token_num_t cmd_pfc_set_priority = 7242 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7243 priority, RTE_UINT8); 7244 cmdline_parse_token_num_t cmd_pfc_set_portid = 7245 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7246 port_id, RTE_UINT16); 7247 7248 cmdline_parse_inst_t cmd_priority_flow_control_set = { 7249 .f = cmd_priority_flow_ctrl_set_parsed, 7250 .data = NULL, 7251 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 7252 "<pause_time> <priority> <port_id>: " 7253 "Configure the Ethernet priority flow control", 7254 .tokens = { 7255 (void *)&cmd_pfc_set_set, 7256 (void *)&cmd_pfc_set_flow_ctrl, 7257 (void *)&cmd_pfc_set_rx, 7258 (void *)&cmd_pfc_set_rx_mode, 7259 (void *)&cmd_pfc_set_tx, 7260 (void *)&cmd_pfc_set_tx_mode, 7261 (void *)&cmd_pfc_set_high_water, 7262 (void *)&cmd_pfc_set_low_water, 7263 (void *)&cmd_pfc_set_pause_time, 7264 (void *)&cmd_pfc_set_priority, 7265 (void *)&cmd_pfc_set_portid, 7266 NULL, 7267 }, 7268 }; 7269 7270 /* *** RESET CONFIGURATION *** */ 7271 struct cmd_reset_result { 7272 cmdline_fixed_string_t reset; 7273 cmdline_fixed_string_t def; 7274 }; 7275 7276 static void cmd_reset_parsed(__rte_unused void *parsed_result, 7277 struct cmdline *cl, 7278 __rte_unused void *data) 7279 { 7280 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 7281 set_def_fwd_config(); 7282 } 7283 7284 cmdline_parse_token_string_t cmd_reset_set = 7285 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 7286 cmdline_parse_token_string_t cmd_reset_def = 7287 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 7288 "default"); 7289 7290 cmdline_parse_inst_t cmd_reset = { 7291 .f = cmd_reset_parsed, 7292 .data = NULL, 7293 .help_str = "set default: Reset default forwarding configuration", 7294 .tokens = { 7295 (void *)&cmd_reset_set, 7296 (void *)&cmd_reset_def, 7297 NULL, 7298 }, 7299 }; 7300 7301 /* *** START FORWARDING *** */ 7302 struct cmd_start_result { 7303 cmdline_fixed_string_t start; 7304 }; 7305 7306 cmdline_parse_token_string_t cmd_start_start = 7307 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 7308 7309 static void cmd_start_parsed(__rte_unused void *parsed_result, 7310 __rte_unused struct cmdline *cl, 7311 __rte_unused void *data) 7312 { 7313 start_packet_forwarding(0); 7314 } 7315 7316 cmdline_parse_inst_t cmd_start = { 7317 .f = cmd_start_parsed, 7318 .data = NULL, 7319 .help_str = "start: Start packet forwarding", 7320 .tokens = { 7321 (void *)&cmd_start_start, 7322 NULL, 7323 }, 7324 }; 7325 7326 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 7327 struct cmd_start_tx_first_result { 7328 cmdline_fixed_string_t start; 7329 cmdline_fixed_string_t tx_first; 7330 }; 7331 7332 static void 7333 cmd_start_tx_first_parsed(__rte_unused void *parsed_result, 7334 __rte_unused struct cmdline *cl, 7335 __rte_unused void *data) 7336 { 7337 start_packet_forwarding(1); 7338 } 7339 7340 cmdline_parse_token_string_t cmd_start_tx_first_start = 7341 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 7342 "start"); 7343 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 7344 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 7345 tx_first, "tx_first"); 7346 7347 cmdline_parse_inst_t cmd_start_tx_first = { 7348 .f = cmd_start_tx_first_parsed, 7349 .data = NULL, 7350 .help_str = "start tx_first: Start packet forwarding, " 7351 "after sending 1 burst of packets", 7352 .tokens = { 7353 (void *)&cmd_start_tx_first_start, 7354 (void *)&cmd_start_tx_first_tx_first, 7355 NULL, 7356 }, 7357 }; 7358 7359 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 7360 struct cmd_start_tx_first_n_result { 7361 cmdline_fixed_string_t start; 7362 cmdline_fixed_string_t tx_first; 7363 uint32_t tx_num; 7364 }; 7365 7366 static void 7367 cmd_start_tx_first_n_parsed(void *parsed_result, 7368 __rte_unused struct cmdline *cl, 7369 __rte_unused void *data) 7370 { 7371 struct cmd_start_tx_first_n_result *res = parsed_result; 7372 7373 start_packet_forwarding(res->tx_num); 7374 } 7375 7376 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 7377 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7378 start, "start"); 7379 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 7380 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7381 tx_first, "tx_first"); 7382 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 7383 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 7384 tx_num, RTE_UINT32); 7385 7386 cmdline_parse_inst_t cmd_start_tx_first_n = { 7387 .f = cmd_start_tx_first_n_parsed, 7388 .data = NULL, 7389 .help_str = "start tx_first <num>: " 7390 "packet forwarding, after sending <num> bursts of packets", 7391 .tokens = { 7392 (void *)&cmd_start_tx_first_n_start, 7393 (void *)&cmd_start_tx_first_n_tx_first, 7394 (void *)&cmd_start_tx_first_n_tx_num, 7395 NULL, 7396 }, 7397 }; 7398 7399 /* *** SET LINK UP *** */ 7400 struct cmd_set_link_up_result { 7401 cmdline_fixed_string_t set; 7402 cmdline_fixed_string_t link_up; 7403 cmdline_fixed_string_t port; 7404 portid_t port_id; 7405 }; 7406 7407 cmdline_parse_token_string_t cmd_set_link_up_set = 7408 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 7409 cmdline_parse_token_string_t cmd_set_link_up_link_up = 7410 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 7411 "link-up"); 7412 cmdline_parse_token_string_t cmd_set_link_up_port = 7413 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 7414 cmdline_parse_token_num_t cmd_set_link_up_port_id = 7415 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, 7416 RTE_UINT16); 7417 7418 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result, 7419 __rte_unused struct cmdline *cl, 7420 __rte_unused void *data) 7421 { 7422 struct cmd_set_link_up_result *res = parsed_result; 7423 dev_set_link_up(res->port_id); 7424 } 7425 7426 cmdline_parse_inst_t cmd_set_link_up = { 7427 .f = cmd_set_link_up_parsed, 7428 .data = NULL, 7429 .help_str = "set link-up port <port id>", 7430 .tokens = { 7431 (void *)&cmd_set_link_up_set, 7432 (void *)&cmd_set_link_up_link_up, 7433 (void *)&cmd_set_link_up_port, 7434 (void *)&cmd_set_link_up_port_id, 7435 NULL, 7436 }, 7437 }; 7438 7439 /* *** SET LINK DOWN *** */ 7440 struct cmd_set_link_down_result { 7441 cmdline_fixed_string_t set; 7442 cmdline_fixed_string_t link_down; 7443 cmdline_fixed_string_t port; 7444 portid_t port_id; 7445 }; 7446 7447 cmdline_parse_token_string_t cmd_set_link_down_set = 7448 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 7449 cmdline_parse_token_string_t cmd_set_link_down_link_down = 7450 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 7451 "link-down"); 7452 cmdline_parse_token_string_t cmd_set_link_down_port = 7453 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 7454 cmdline_parse_token_num_t cmd_set_link_down_port_id = 7455 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, 7456 RTE_UINT16); 7457 7458 static void cmd_set_link_down_parsed( 7459 __rte_unused void *parsed_result, 7460 __rte_unused struct cmdline *cl, 7461 __rte_unused void *data) 7462 { 7463 struct cmd_set_link_down_result *res = parsed_result; 7464 dev_set_link_down(res->port_id); 7465 } 7466 7467 cmdline_parse_inst_t cmd_set_link_down = { 7468 .f = cmd_set_link_down_parsed, 7469 .data = NULL, 7470 .help_str = "set link-down port <port id>", 7471 .tokens = { 7472 (void *)&cmd_set_link_down_set, 7473 (void *)&cmd_set_link_down_link_down, 7474 (void *)&cmd_set_link_down_port, 7475 (void *)&cmd_set_link_down_port_id, 7476 NULL, 7477 }, 7478 }; 7479 7480 /* *** SHOW CFG *** */ 7481 struct cmd_showcfg_result { 7482 cmdline_fixed_string_t show; 7483 cmdline_fixed_string_t cfg; 7484 cmdline_fixed_string_t what; 7485 }; 7486 7487 static void cmd_showcfg_parsed(void *parsed_result, 7488 __rte_unused struct cmdline *cl, 7489 __rte_unused void *data) 7490 { 7491 struct cmd_showcfg_result *res = parsed_result; 7492 if (!strcmp(res->what, "rxtx")) 7493 rxtx_config_display(); 7494 else if (!strcmp(res->what, "cores")) 7495 fwd_lcores_config_display(); 7496 else if (!strcmp(res->what, "fwd")) 7497 pkt_fwd_config_display(&cur_fwd_config); 7498 else if (!strcmp(res->what, "rxoffs")) 7499 show_rx_pkt_offsets(); 7500 else if (!strcmp(res->what, "rxpkts")) 7501 show_rx_pkt_segments(); 7502 else if (!strcmp(res->what, "txpkts")) 7503 show_tx_pkt_segments(); 7504 else if (!strcmp(res->what, "txtimes")) 7505 show_tx_pkt_times(); 7506 } 7507 7508 cmdline_parse_token_string_t cmd_showcfg_show = 7509 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 7510 cmdline_parse_token_string_t cmd_showcfg_port = 7511 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7512 cmdline_parse_token_string_t cmd_showcfg_what = 7513 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7514 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes"); 7515 7516 cmdline_parse_inst_t cmd_showcfg = { 7517 .f = cmd_showcfg_parsed, 7518 .data = NULL, 7519 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes", 7520 .tokens = { 7521 (void *)&cmd_showcfg_show, 7522 (void *)&cmd_showcfg_port, 7523 (void *)&cmd_showcfg_what, 7524 NULL, 7525 }, 7526 }; 7527 7528 /* *** SHOW ALL PORT INFO *** */ 7529 struct cmd_showportall_result { 7530 cmdline_fixed_string_t show; 7531 cmdline_fixed_string_t port; 7532 cmdline_fixed_string_t what; 7533 cmdline_fixed_string_t all; 7534 }; 7535 7536 static void cmd_showportall_parsed(void *parsed_result, 7537 __rte_unused struct cmdline *cl, 7538 __rte_unused void *data) 7539 { 7540 portid_t i; 7541 7542 struct cmd_showportall_result *res = parsed_result; 7543 if (!strcmp(res->show, "clear")) { 7544 if (!strcmp(res->what, "stats")) 7545 RTE_ETH_FOREACH_DEV(i) 7546 nic_stats_clear(i); 7547 else if (!strcmp(res->what, "xstats")) 7548 RTE_ETH_FOREACH_DEV(i) 7549 nic_xstats_clear(i); 7550 } else if (!strcmp(res->what, "info")) 7551 RTE_ETH_FOREACH_DEV(i) 7552 port_infos_display(i); 7553 else if (!strcmp(res->what, "summary")) { 7554 port_summary_header_display(); 7555 RTE_ETH_FOREACH_DEV(i) 7556 port_summary_display(i); 7557 } 7558 else if (!strcmp(res->what, "stats")) 7559 RTE_ETH_FOREACH_DEV(i) 7560 nic_stats_display(i); 7561 else if (!strcmp(res->what, "xstats")) 7562 RTE_ETH_FOREACH_DEV(i) 7563 nic_xstats_display(i); 7564 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) 7565 else if (!strcmp(res->what, "fdir")) 7566 RTE_ETH_FOREACH_DEV(i) 7567 fdir_get_infos(i); 7568 #endif 7569 else if (!strcmp(res->what, "dcb_tc")) 7570 RTE_ETH_FOREACH_DEV(i) 7571 port_dcb_info_display(i); 7572 else if (!strcmp(res->what, "cap")) 7573 RTE_ETH_FOREACH_DEV(i) 7574 port_offload_cap_display(i); 7575 } 7576 7577 cmdline_parse_token_string_t cmd_showportall_show = 7578 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7579 "show#clear"); 7580 cmdline_parse_token_string_t cmd_showportall_port = 7581 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7582 cmdline_parse_token_string_t cmd_showportall_what = 7583 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7584 "info#summary#stats#xstats#fdir#dcb_tc#cap"); 7585 cmdline_parse_token_string_t cmd_showportall_all = 7586 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 7587 cmdline_parse_inst_t cmd_showportall = { 7588 .f = cmd_showportall_parsed, 7589 .data = NULL, 7590 .help_str = "show|clear port " 7591 "info|summary|stats|xstats|fdir|dcb_tc|cap all", 7592 .tokens = { 7593 (void *)&cmd_showportall_show, 7594 (void *)&cmd_showportall_port, 7595 (void *)&cmd_showportall_what, 7596 (void *)&cmd_showportall_all, 7597 NULL, 7598 }, 7599 }; 7600 7601 /* *** SHOW PORT INFO *** */ 7602 struct cmd_showport_result { 7603 cmdline_fixed_string_t show; 7604 cmdline_fixed_string_t port; 7605 cmdline_fixed_string_t what; 7606 uint16_t portnum; 7607 }; 7608 7609 static void cmd_showport_parsed(void *parsed_result, 7610 __rte_unused struct cmdline *cl, 7611 __rte_unused void *data) 7612 { 7613 struct cmd_showport_result *res = parsed_result; 7614 if (!strcmp(res->show, "clear")) { 7615 if (!strcmp(res->what, "stats")) 7616 nic_stats_clear(res->portnum); 7617 else if (!strcmp(res->what, "xstats")) 7618 nic_xstats_clear(res->portnum); 7619 } else if (!strcmp(res->what, "info")) 7620 port_infos_display(res->portnum); 7621 else if (!strcmp(res->what, "summary")) { 7622 port_summary_header_display(); 7623 port_summary_display(res->portnum); 7624 } 7625 else if (!strcmp(res->what, "stats")) 7626 nic_stats_display(res->portnum); 7627 else if (!strcmp(res->what, "xstats")) 7628 nic_xstats_display(res->portnum); 7629 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) 7630 else if (!strcmp(res->what, "fdir")) 7631 fdir_get_infos(res->portnum); 7632 #endif 7633 else if (!strcmp(res->what, "dcb_tc")) 7634 port_dcb_info_display(res->portnum); 7635 else if (!strcmp(res->what, "cap")) 7636 port_offload_cap_display(res->portnum); 7637 } 7638 7639 cmdline_parse_token_string_t cmd_showport_show = 7640 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 7641 "show#clear"); 7642 cmdline_parse_token_string_t cmd_showport_port = 7643 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 7644 cmdline_parse_token_string_t cmd_showport_what = 7645 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 7646 "info#summary#stats#xstats#fdir#dcb_tc#cap"); 7647 cmdline_parse_token_num_t cmd_showport_portnum = 7648 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16); 7649 7650 cmdline_parse_inst_t cmd_showport = { 7651 .f = cmd_showport_parsed, 7652 .data = NULL, 7653 .help_str = "show|clear port " 7654 "info|summary|stats|xstats|fdir|dcb_tc|cap " 7655 "<port_id>", 7656 .tokens = { 7657 (void *)&cmd_showport_show, 7658 (void *)&cmd_showport_port, 7659 (void *)&cmd_showport_what, 7660 (void *)&cmd_showport_portnum, 7661 NULL, 7662 }, 7663 }; 7664 7665 /* *** SHOW DEVICE INFO *** */ 7666 struct cmd_showdevice_result { 7667 cmdline_fixed_string_t show; 7668 cmdline_fixed_string_t device; 7669 cmdline_fixed_string_t what; 7670 cmdline_fixed_string_t identifier; 7671 }; 7672 7673 static void cmd_showdevice_parsed(void *parsed_result, 7674 __rte_unused struct cmdline *cl, 7675 __rte_unused void *data) 7676 { 7677 struct cmd_showdevice_result *res = parsed_result; 7678 if (!strcmp(res->what, "info")) { 7679 if (!strcmp(res->identifier, "all")) 7680 device_infos_display(NULL); 7681 else 7682 device_infos_display(res->identifier); 7683 } 7684 } 7685 7686 cmdline_parse_token_string_t cmd_showdevice_show = 7687 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show, 7688 "show"); 7689 cmdline_parse_token_string_t cmd_showdevice_device = 7690 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device"); 7691 cmdline_parse_token_string_t cmd_showdevice_what = 7692 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what, 7693 "info"); 7694 cmdline_parse_token_string_t cmd_showdevice_identifier = 7695 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, 7696 identifier, NULL); 7697 7698 cmdline_parse_inst_t cmd_showdevice = { 7699 .f = cmd_showdevice_parsed, 7700 .data = NULL, 7701 .help_str = "show device info <identifier>|all", 7702 .tokens = { 7703 (void *)&cmd_showdevice_show, 7704 (void *)&cmd_showdevice_device, 7705 (void *)&cmd_showdevice_what, 7706 (void *)&cmd_showdevice_identifier, 7707 NULL, 7708 }, 7709 }; 7710 7711 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */ 7712 struct cmd_showeeprom_result { 7713 cmdline_fixed_string_t show; 7714 cmdline_fixed_string_t port; 7715 uint16_t portnum; 7716 cmdline_fixed_string_t type; 7717 }; 7718 7719 static void cmd_showeeprom_parsed(void *parsed_result, 7720 __rte_unused struct cmdline *cl, 7721 __rte_unused void *data) 7722 { 7723 struct cmd_showeeprom_result *res = parsed_result; 7724 7725 if (!strcmp(res->type, "eeprom")) 7726 port_eeprom_display(res->portnum); 7727 else if (!strcmp(res->type, "module_eeprom")) 7728 port_module_eeprom_display(res->portnum); 7729 else 7730 printf("Unknown argument\n"); 7731 } 7732 7733 cmdline_parse_token_string_t cmd_showeeprom_show = 7734 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show"); 7735 cmdline_parse_token_string_t cmd_showeeprom_port = 7736 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port"); 7737 cmdline_parse_token_num_t cmd_showeeprom_portnum = 7738 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, 7739 RTE_UINT16); 7740 cmdline_parse_token_string_t cmd_showeeprom_type = 7741 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom"); 7742 7743 cmdline_parse_inst_t cmd_showeeprom = { 7744 .f = cmd_showeeprom_parsed, 7745 .data = NULL, 7746 .help_str = "show port <port_id> module_eeprom|eeprom", 7747 .tokens = { 7748 (void *)&cmd_showeeprom_show, 7749 (void *)&cmd_showeeprom_port, 7750 (void *)&cmd_showeeprom_portnum, 7751 (void *)&cmd_showeeprom_type, 7752 NULL, 7753 }, 7754 }; 7755 7756 /* *** SHOW QUEUE INFO *** */ 7757 struct cmd_showqueue_result { 7758 cmdline_fixed_string_t show; 7759 cmdline_fixed_string_t type; 7760 cmdline_fixed_string_t what; 7761 uint16_t portnum; 7762 uint16_t queuenum; 7763 }; 7764 7765 static void 7766 cmd_showqueue_parsed(void *parsed_result, 7767 __rte_unused struct cmdline *cl, 7768 __rte_unused void *data) 7769 { 7770 struct cmd_showqueue_result *res = parsed_result; 7771 7772 if (!strcmp(res->type, "rxq")) 7773 rx_queue_infos_display(res->portnum, res->queuenum); 7774 else if (!strcmp(res->type, "txq")) 7775 tx_queue_infos_display(res->portnum, res->queuenum); 7776 } 7777 7778 cmdline_parse_token_string_t cmd_showqueue_show = 7779 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 7780 cmdline_parse_token_string_t cmd_showqueue_type = 7781 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 7782 cmdline_parse_token_string_t cmd_showqueue_what = 7783 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 7784 cmdline_parse_token_num_t cmd_showqueue_portnum = 7785 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, 7786 RTE_UINT16); 7787 cmdline_parse_token_num_t cmd_showqueue_queuenum = 7788 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, 7789 RTE_UINT16); 7790 7791 cmdline_parse_inst_t cmd_showqueue = { 7792 .f = cmd_showqueue_parsed, 7793 .data = NULL, 7794 .help_str = "show rxq|txq info <port_id> <queue_id>", 7795 .tokens = { 7796 (void *)&cmd_showqueue_show, 7797 (void *)&cmd_showqueue_type, 7798 (void *)&cmd_showqueue_what, 7799 (void *)&cmd_showqueue_portnum, 7800 (void *)&cmd_showqueue_queuenum, 7801 NULL, 7802 }, 7803 }; 7804 7805 /* show/clear fwd engine statistics */ 7806 struct fwd_result { 7807 cmdline_fixed_string_t action; 7808 cmdline_fixed_string_t fwd; 7809 cmdline_fixed_string_t stats; 7810 cmdline_fixed_string_t all; 7811 }; 7812 7813 cmdline_parse_token_string_t cmd_fwd_action = 7814 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear"); 7815 cmdline_parse_token_string_t cmd_fwd_fwd = 7816 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd"); 7817 cmdline_parse_token_string_t cmd_fwd_stats = 7818 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats"); 7819 cmdline_parse_token_string_t cmd_fwd_all = 7820 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all"); 7821 7822 static void 7823 cmd_showfwdall_parsed(void *parsed_result, 7824 __rte_unused struct cmdline *cl, 7825 __rte_unused void *data) 7826 { 7827 struct fwd_result *res = parsed_result; 7828 7829 if (!strcmp(res->action, "show")) 7830 fwd_stats_display(); 7831 else 7832 fwd_stats_reset(); 7833 } 7834 7835 static cmdline_parse_inst_t cmd_showfwdall = { 7836 .f = cmd_showfwdall_parsed, 7837 .data = NULL, 7838 .help_str = "show|clear fwd stats all", 7839 .tokens = { 7840 (void *)&cmd_fwd_action, 7841 (void *)&cmd_fwd_fwd, 7842 (void *)&cmd_fwd_stats, 7843 (void *)&cmd_fwd_all, 7844 NULL, 7845 }, 7846 }; 7847 7848 /* *** READ PORT REGISTER *** */ 7849 struct cmd_read_reg_result { 7850 cmdline_fixed_string_t read; 7851 cmdline_fixed_string_t reg; 7852 portid_t port_id; 7853 uint32_t reg_off; 7854 }; 7855 7856 static void 7857 cmd_read_reg_parsed(void *parsed_result, 7858 __rte_unused struct cmdline *cl, 7859 __rte_unused void *data) 7860 { 7861 struct cmd_read_reg_result *res = parsed_result; 7862 port_reg_display(res->port_id, res->reg_off); 7863 } 7864 7865 cmdline_parse_token_string_t cmd_read_reg_read = 7866 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 7867 cmdline_parse_token_string_t cmd_read_reg_reg = 7868 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 7869 cmdline_parse_token_num_t cmd_read_reg_port_id = 7870 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16); 7871 cmdline_parse_token_num_t cmd_read_reg_reg_off = 7872 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32); 7873 7874 cmdline_parse_inst_t cmd_read_reg = { 7875 .f = cmd_read_reg_parsed, 7876 .data = NULL, 7877 .help_str = "read reg <port_id> <reg_off>", 7878 .tokens = { 7879 (void *)&cmd_read_reg_read, 7880 (void *)&cmd_read_reg_reg, 7881 (void *)&cmd_read_reg_port_id, 7882 (void *)&cmd_read_reg_reg_off, 7883 NULL, 7884 }, 7885 }; 7886 7887 /* *** READ PORT REGISTER BIT FIELD *** */ 7888 struct cmd_read_reg_bit_field_result { 7889 cmdline_fixed_string_t read; 7890 cmdline_fixed_string_t regfield; 7891 portid_t port_id; 7892 uint32_t reg_off; 7893 uint8_t bit1_pos; 7894 uint8_t bit2_pos; 7895 }; 7896 7897 static void 7898 cmd_read_reg_bit_field_parsed(void *parsed_result, 7899 __rte_unused struct cmdline *cl, 7900 __rte_unused void *data) 7901 { 7902 struct cmd_read_reg_bit_field_result *res = parsed_result; 7903 port_reg_bit_field_display(res->port_id, res->reg_off, 7904 res->bit1_pos, res->bit2_pos); 7905 } 7906 7907 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 7908 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 7909 "read"); 7910 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 7911 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 7912 regfield, "regfield"); 7913 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 7914 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 7915 RTE_UINT16); 7916 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 7917 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 7918 RTE_UINT32); 7919 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 7920 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 7921 RTE_UINT8); 7922 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 7923 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 7924 RTE_UINT8); 7925 7926 cmdline_parse_inst_t cmd_read_reg_bit_field = { 7927 .f = cmd_read_reg_bit_field_parsed, 7928 .data = NULL, 7929 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 7930 "Read register bit field between bit_x and bit_y included", 7931 .tokens = { 7932 (void *)&cmd_read_reg_bit_field_read, 7933 (void *)&cmd_read_reg_bit_field_regfield, 7934 (void *)&cmd_read_reg_bit_field_port_id, 7935 (void *)&cmd_read_reg_bit_field_reg_off, 7936 (void *)&cmd_read_reg_bit_field_bit1_pos, 7937 (void *)&cmd_read_reg_bit_field_bit2_pos, 7938 NULL, 7939 }, 7940 }; 7941 7942 /* *** READ PORT REGISTER BIT *** */ 7943 struct cmd_read_reg_bit_result { 7944 cmdline_fixed_string_t read; 7945 cmdline_fixed_string_t regbit; 7946 portid_t port_id; 7947 uint32_t reg_off; 7948 uint8_t bit_pos; 7949 }; 7950 7951 static void 7952 cmd_read_reg_bit_parsed(void *parsed_result, 7953 __rte_unused struct cmdline *cl, 7954 __rte_unused void *data) 7955 { 7956 struct cmd_read_reg_bit_result *res = parsed_result; 7957 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 7958 } 7959 7960 cmdline_parse_token_string_t cmd_read_reg_bit_read = 7961 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 7962 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 7963 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 7964 regbit, "regbit"); 7965 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 7966 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, 7967 RTE_UINT16); 7968 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 7969 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, 7970 RTE_UINT32); 7971 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 7972 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, 7973 RTE_UINT8); 7974 7975 cmdline_parse_inst_t cmd_read_reg_bit = { 7976 .f = cmd_read_reg_bit_parsed, 7977 .data = NULL, 7978 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 7979 .tokens = { 7980 (void *)&cmd_read_reg_bit_read, 7981 (void *)&cmd_read_reg_bit_regbit, 7982 (void *)&cmd_read_reg_bit_port_id, 7983 (void *)&cmd_read_reg_bit_reg_off, 7984 (void *)&cmd_read_reg_bit_bit_pos, 7985 NULL, 7986 }, 7987 }; 7988 7989 /* *** WRITE PORT REGISTER *** */ 7990 struct cmd_write_reg_result { 7991 cmdline_fixed_string_t write; 7992 cmdline_fixed_string_t reg; 7993 portid_t port_id; 7994 uint32_t reg_off; 7995 uint32_t value; 7996 }; 7997 7998 static void 7999 cmd_write_reg_parsed(void *parsed_result, 8000 __rte_unused struct cmdline *cl, 8001 __rte_unused void *data) 8002 { 8003 struct cmd_write_reg_result *res = parsed_result; 8004 port_reg_set(res->port_id, res->reg_off, res->value); 8005 } 8006 8007 cmdline_parse_token_string_t cmd_write_reg_write = 8008 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 8009 cmdline_parse_token_string_t cmd_write_reg_reg = 8010 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 8011 cmdline_parse_token_num_t cmd_write_reg_port_id = 8012 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16); 8013 cmdline_parse_token_num_t cmd_write_reg_reg_off = 8014 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32); 8015 cmdline_parse_token_num_t cmd_write_reg_value = 8016 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32); 8017 8018 cmdline_parse_inst_t cmd_write_reg = { 8019 .f = cmd_write_reg_parsed, 8020 .data = NULL, 8021 .help_str = "write reg <port_id> <reg_off> <reg_value>", 8022 .tokens = { 8023 (void *)&cmd_write_reg_write, 8024 (void *)&cmd_write_reg_reg, 8025 (void *)&cmd_write_reg_port_id, 8026 (void *)&cmd_write_reg_reg_off, 8027 (void *)&cmd_write_reg_value, 8028 NULL, 8029 }, 8030 }; 8031 8032 /* *** WRITE PORT REGISTER BIT FIELD *** */ 8033 struct cmd_write_reg_bit_field_result { 8034 cmdline_fixed_string_t write; 8035 cmdline_fixed_string_t regfield; 8036 portid_t port_id; 8037 uint32_t reg_off; 8038 uint8_t bit1_pos; 8039 uint8_t bit2_pos; 8040 uint32_t value; 8041 }; 8042 8043 static void 8044 cmd_write_reg_bit_field_parsed(void *parsed_result, 8045 __rte_unused struct cmdline *cl, 8046 __rte_unused void *data) 8047 { 8048 struct cmd_write_reg_bit_field_result *res = parsed_result; 8049 port_reg_bit_field_set(res->port_id, res->reg_off, 8050 res->bit1_pos, res->bit2_pos, res->value); 8051 } 8052 8053 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 8054 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 8055 "write"); 8056 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 8057 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 8058 regfield, "regfield"); 8059 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 8060 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 8061 RTE_UINT16); 8062 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 8063 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 8064 RTE_UINT32); 8065 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 8066 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 8067 RTE_UINT8); 8068 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 8069 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 8070 RTE_UINT8); 8071 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 8072 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 8073 RTE_UINT32); 8074 8075 cmdline_parse_inst_t cmd_write_reg_bit_field = { 8076 .f = cmd_write_reg_bit_field_parsed, 8077 .data = NULL, 8078 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 8079 "<reg_value>: " 8080 "Set register bit field between bit_x and bit_y included", 8081 .tokens = { 8082 (void *)&cmd_write_reg_bit_field_write, 8083 (void *)&cmd_write_reg_bit_field_regfield, 8084 (void *)&cmd_write_reg_bit_field_port_id, 8085 (void *)&cmd_write_reg_bit_field_reg_off, 8086 (void *)&cmd_write_reg_bit_field_bit1_pos, 8087 (void *)&cmd_write_reg_bit_field_bit2_pos, 8088 (void *)&cmd_write_reg_bit_field_value, 8089 NULL, 8090 }, 8091 }; 8092 8093 /* *** WRITE PORT REGISTER BIT *** */ 8094 struct cmd_write_reg_bit_result { 8095 cmdline_fixed_string_t write; 8096 cmdline_fixed_string_t regbit; 8097 portid_t port_id; 8098 uint32_t reg_off; 8099 uint8_t bit_pos; 8100 uint8_t value; 8101 }; 8102 8103 static void 8104 cmd_write_reg_bit_parsed(void *parsed_result, 8105 __rte_unused struct cmdline *cl, 8106 __rte_unused void *data) 8107 { 8108 struct cmd_write_reg_bit_result *res = parsed_result; 8109 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 8110 } 8111 8112 cmdline_parse_token_string_t cmd_write_reg_bit_write = 8113 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 8114 "write"); 8115 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 8116 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 8117 regbit, "regbit"); 8118 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 8119 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, 8120 RTE_UINT16); 8121 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 8122 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, 8123 RTE_UINT32); 8124 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 8125 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, 8126 RTE_UINT8); 8127 cmdline_parse_token_num_t cmd_write_reg_bit_value = 8128 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, 8129 RTE_UINT8); 8130 8131 cmdline_parse_inst_t cmd_write_reg_bit = { 8132 .f = cmd_write_reg_bit_parsed, 8133 .data = NULL, 8134 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 8135 "0 <= bit_x <= 31", 8136 .tokens = { 8137 (void *)&cmd_write_reg_bit_write, 8138 (void *)&cmd_write_reg_bit_regbit, 8139 (void *)&cmd_write_reg_bit_port_id, 8140 (void *)&cmd_write_reg_bit_reg_off, 8141 (void *)&cmd_write_reg_bit_bit_pos, 8142 (void *)&cmd_write_reg_bit_value, 8143 NULL, 8144 }, 8145 }; 8146 8147 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 8148 struct cmd_read_rxd_txd_result { 8149 cmdline_fixed_string_t read; 8150 cmdline_fixed_string_t rxd_txd; 8151 portid_t port_id; 8152 uint16_t queue_id; 8153 uint16_t desc_id; 8154 }; 8155 8156 static void 8157 cmd_read_rxd_txd_parsed(void *parsed_result, 8158 __rte_unused struct cmdline *cl, 8159 __rte_unused void *data) 8160 { 8161 struct cmd_read_rxd_txd_result *res = parsed_result; 8162 8163 if (!strcmp(res->rxd_txd, "rxd")) 8164 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 8165 else if (!strcmp(res->rxd_txd, "txd")) 8166 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 8167 } 8168 8169 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 8170 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 8171 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 8172 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 8173 "rxd#txd"); 8174 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 8175 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, 8176 RTE_UINT16); 8177 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 8178 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, 8179 RTE_UINT16); 8180 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 8181 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, 8182 RTE_UINT16); 8183 8184 cmdline_parse_inst_t cmd_read_rxd_txd = { 8185 .f = cmd_read_rxd_txd_parsed, 8186 .data = NULL, 8187 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 8188 .tokens = { 8189 (void *)&cmd_read_rxd_txd_read, 8190 (void *)&cmd_read_rxd_txd_rxd_txd, 8191 (void *)&cmd_read_rxd_txd_port_id, 8192 (void *)&cmd_read_rxd_txd_queue_id, 8193 (void *)&cmd_read_rxd_txd_desc_id, 8194 NULL, 8195 }, 8196 }; 8197 8198 /* *** QUIT *** */ 8199 struct cmd_quit_result { 8200 cmdline_fixed_string_t quit; 8201 }; 8202 8203 static void cmd_quit_parsed(__rte_unused void *parsed_result, 8204 struct cmdline *cl, 8205 __rte_unused void *data) 8206 { 8207 cmdline_quit(cl); 8208 } 8209 8210 cmdline_parse_token_string_t cmd_quit_quit = 8211 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 8212 8213 cmdline_parse_inst_t cmd_quit = { 8214 .f = cmd_quit_parsed, 8215 .data = NULL, 8216 .help_str = "quit: Exit application", 8217 .tokens = { 8218 (void *)&cmd_quit_quit, 8219 NULL, 8220 }, 8221 }; 8222 8223 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 8224 struct cmd_mac_addr_result { 8225 cmdline_fixed_string_t mac_addr_cmd; 8226 cmdline_fixed_string_t what; 8227 uint16_t port_num; 8228 struct rte_ether_addr address; 8229 }; 8230 8231 static void cmd_mac_addr_parsed(void *parsed_result, 8232 __rte_unused struct cmdline *cl, 8233 __rte_unused void *data) 8234 { 8235 struct cmd_mac_addr_result *res = parsed_result; 8236 int ret; 8237 8238 if (strcmp(res->what, "add") == 0) 8239 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 8240 else if (strcmp(res->what, "set") == 0) 8241 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 8242 &res->address); 8243 else 8244 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 8245 8246 /* check the return value and print it if is < 0 */ 8247 if(ret < 0) 8248 printf("mac_addr_cmd error: (%s)\n", strerror(-ret)); 8249 8250 } 8251 8252 cmdline_parse_token_string_t cmd_mac_addr_cmd = 8253 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 8254 "mac_addr"); 8255 cmdline_parse_token_string_t cmd_mac_addr_what = 8256 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 8257 "add#remove#set"); 8258 cmdline_parse_token_num_t cmd_mac_addr_portnum = 8259 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 8260 RTE_UINT16); 8261 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 8262 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 8263 8264 cmdline_parse_inst_t cmd_mac_addr = { 8265 .f = cmd_mac_addr_parsed, 8266 .data = (void *)0, 8267 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 8268 "Add/Remove/Set MAC address on port_id", 8269 .tokens = { 8270 (void *)&cmd_mac_addr_cmd, 8271 (void *)&cmd_mac_addr_what, 8272 (void *)&cmd_mac_addr_portnum, 8273 (void *)&cmd_mac_addr_addr, 8274 NULL, 8275 }, 8276 }; 8277 8278 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 8279 struct cmd_eth_peer_result { 8280 cmdline_fixed_string_t set; 8281 cmdline_fixed_string_t eth_peer; 8282 portid_t port_id; 8283 cmdline_fixed_string_t peer_addr; 8284 }; 8285 8286 static void cmd_set_eth_peer_parsed(void *parsed_result, 8287 __rte_unused struct cmdline *cl, 8288 __rte_unused void *data) 8289 { 8290 struct cmd_eth_peer_result *res = parsed_result; 8291 8292 if (test_done == 0) { 8293 printf("Please stop forwarding first\n"); 8294 return; 8295 } 8296 if (!strcmp(res->eth_peer, "eth-peer")) { 8297 set_fwd_eth_peer(res->port_id, res->peer_addr); 8298 fwd_config_setup(); 8299 } 8300 } 8301 cmdline_parse_token_string_t cmd_eth_peer_set = 8302 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 8303 cmdline_parse_token_string_t cmd_eth_peer = 8304 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 8305 cmdline_parse_token_num_t cmd_eth_peer_port_id = 8306 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, 8307 RTE_UINT16); 8308 cmdline_parse_token_string_t cmd_eth_peer_addr = 8309 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 8310 8311 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 8312 .f = cmd_set_eth_peer_parsed, 8313 .data = NULL, 8314 .help_str = "set eth-peer <port_id> <peer_mac>", 8315 .tokens = { 8316 (void *)&cmd_eth_peer_set, 8317 (void *)&cmd_eth_peer, 8318 (void *)&cmd_eth_peer_port_id, 8319 (void *)&cmd_eth_peer_addr, 8320 NULL, 8321 }, 8322 }; 8323 8324 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 8325 struct cmd_set_qmap_result { 8326 cmdline_fixed_string_t set; 8327 cmdline_fixed_string_t qmap; 8328 cmdline_fixed_string_t what; 8329 portid_t port_id; 8330 uint16_t queue_id; 8331 uint8_t map_value; 8332 }; 8333 8334 static void 8335 cmd_set_qmap_parsed(void *parsed_result, 8336 __rte_unused struct cmdline *cl, 8337 __rte_unused void *data) 8338 { 8339 struct cmd_set_qmap_result *res = parsed_result; 8340 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 8341 8342 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 8343 } 8344 8345 cmdline_parse_token_string_t cmd_setqmap_set = 8346 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8347 set, "set"); 8348 cmdline_parse_token_string_t cmd_setqmap_qmap = 8349 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8350 qmap, "stat_qmap"); 8351 cmdline_parse_token_string_t cmd_setqmap_what = 8352 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8353 what, "tx#rx"); 8354 cmdline_parse_token_num_t cmd_setqmap_portid = 8355 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8356 port_id, RTE_UINT16); 8357 cmdline_parse_token_num_t cmd_setqmap_queueid = 8358 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8359 queue_id, RTE_UINT16); 8360 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 8361 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8362 map_value, RTE_UINT8); 8363 8364 cmdline_parse_inst_t cmd_set_qmap = { 8365 .f = cmd_set_qmap_parsed, 8366 .data = NULL, 8367 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 8368 "Set statistics mapping value on tx|rx queue_id of port_id", 8369 .tokens = { 8370 (void *)&cmd_setqmap_set, 8371 (void *)&cmd_setqmap_qmap, 8372 (void *)&cmd_setqmap_what, 8373 (void *)&cmd_setqmap_portid, 8374 (void *)&cmd_setqmap_queueid, 8375 (void *)&cmd_setqmap_mapvalue, 8376 NULL, 8377 }, 8378 }; 8379 8380 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 8381 struct cmd_set_xstats_hide_zero_result { 8382 cmdline_fixed_string_t keyword; 8383 cmdline_fixed_string_t name; 8384 cmdline_fixed_string_t on_off; 8385 }; 8386 8387 static void 8388 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 8389 __rte_unused struct cmdline *cl, 8390 __rte_unused void *data) 8391 { 8392 struct cmd_set_xstats_hide_zero_result *res; 8393 uint16_t on_off = 0; 8394 8395 res = parsed_result; 8396 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8397 set_xstats_hide_zero(on_off); 8398 } 8399 8400 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 8401 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8402 keyword, "set"); 8403 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 8404 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8405 name, "xstats-hide-zero"); 8406 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 8407 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8408 on_off, "on#off"); 8409 8410 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 8411 .f = cmd_set_xstats_hide_zero_parsed, 8412 .data = NULL, 8413 .help_str = "set xstats-hide-zero on|off", 8414 .tokens = { 8415 (void *)&cmd_set_xstats_hide_zero_keyword, 8416 (void *)&cmd_set_xstats_hide_zero_name, 8417 (void *)&cmd_set_xstats_hide_zero_on_off, 8418 NULL, 8419 }, 8420 }; 8421 8422 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */ 8423 struct cmd_set_record_core_cycles_result { 8424 cmdline_fixed_string_t keyword; 8425 cmdline_fixed_string_t name; 8426 cmdline_fixed_string_t on_off; 8427 }; 8428 8429 static void 8430 cmd_set_record_core_cycles_parsed(void *parsed_result, 8431 __rte_unused struct cmdline *cl, 8432 __rte_unused void *data) 8433 { 8434 struct cmd_set_record_core_cycles_result *res; 8435 uint16_t on_off = 0; 8436 8437 res = parsed_result; 8438 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8439 set_record_core_cycles(on_off); 8440 } 8441 8442 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword = 8443 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8444 keyword, "set"); 8445 cmdline_parse_token_string_t cmd_set_record_core_cycles_name = 8446 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8447 name, "record-core-cycles"); 8448 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off = 8449 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8450 on_off, "on#off"); 8451 8452 cmdline_parse_inst_t cmd_set_record_core_cycles = { 8453 .f = cmd_set_record_core_cycles_parsed, 8454 .data = NULL, 8455 .help_str = "set record-core-cycles on|off", 8456 .tokens = { 8457 (void *)&cmd_set_record_core_cycles_keyword, 8458 (void *)&cmd_set_record_core_cycles_name, 8459 (void *)&cmd_set_record_core_cycles_on_off, 8460 NULL, 8461 }, 8462 }; 8463 8464 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */ 8465 struct cmd_set_record_burst_stats_result { 8466 cmdline_fixed_string_t keyword; 8467 cmdline_fixed_string_t name; 8468 cmdline_fixed_string_t on_off; 8469 }; 8470 8471 static void 8472 cmd_set_record_burst_stats_parsed(void *parsed_result, 8473 __rte_unused struct cmdline *cl, 8474 __rte_unused void *data) 8475 { 8476 struct cmd_set_record_burst_stats_result *res; 8477 uint16_t on_off = 0; 8478 8479 res = parsed_result; 8480 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8481 set_record_burst_stats(on_off); 8482 } 8483 8484 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword = 8485 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8486 keyword, "set"); 8487 cmdline_parse_token_string_t cmd_set_record_burst_stats_name = 8488 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8489 name, "record-burst-stats"); 8490 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off = 8491 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8492 on_off, "on#off"); 8493 8494 cmdline_parse_inst_t cmd_set_record_burst_stats = { 8495 .f = cmd_set_record_burst_stats_parsed, 8496 .data = NULL, 8497 .help_str = "set record-burst-stats on|off", 8498 .tokens = { 8499 (void *)&cmd_set_record_burst_stats_keyword, 8500 (void *)&cmd_set_record_burst_stats_name, 8501 (void *)&cmd_set_record_burst_stats_on_off, 8502 NULL, 8503 }, 8504 }; 8505 8506 /* *** CONFIGURE UNICAST HASH TABLE *** */ 8507 struct cmd_set_uc_hash_table { 8508 cmdline_fixed_string_t set; 8509 cmdline_fixed_string_t port; 8510 portid_t port_id; 8511 cmdline_fixed_string_t what; 8512 struct rte_ether_addr address; 8513 cmdline_fixed_string_t mode; 8514 }; 8515 8516 static void 8517 cmd_set_uc_hash_parsed(void *parsed_result, 8518 __rte_unused struct cmdline *cl, 8519 __rte_unused void *data) 8520 { 8521 int ret=0; 8522 struct cmd_set_uc_hash_table *res = parsed_result; 8523 8524 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8525 8526 if (strcmp(res->what, "uta") == 0) 8527 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 8528 &res->address,(uint8_t)is_on); 8529 if (ret < 0) 8530 printf("bad unicast hash table parameter, return code = %d \n", ret); 8531 8532 } 8533 8534 cmdline_parse_token_string_t cmd_set_uc_hash_set = 8535 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8536 set, "set"); 8537 cmdline_parse_token_string_t cmd_set_uc_hash_port = 8538 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8539 port, "port"); 8540 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 8541 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 8542 port_id, RTE_UINT16); 8543 cmdline_parse_token_string_t cmd_set_uc_hash_what = 8544 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8545 what, "uta"); 8546 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 8547 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 8548 address); 8549 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 8550 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8551 mode, "on#off"); 8552 8553 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 8554 .f = cmd_set_uc_hash_parsed, 8555 .data = NULL, 8556 .help_str = "set port <port_id> uta <mac_addr> on|off)", 8557 .tokens = { 8558 (void *)&cmd_set_uc_hash_set, 8559 (void *)&cmd_set_uc_hash_port, 8560 (void *)&cmd_set_uc_hash_portid, 8561 (void *)&cmd_set_uc_hash_what, 8562 (void *)&cmd_set_uc_hash_mac, 8563 (void *)&cmd_set_uc_hash_mode, 8564 NULL, 8565 }, 8566 }; 8567 8568 struct cmd_set_uc_all_hash_table { 8569 cmdline_fixed_string_t set; 8570 cmdline_fixed_string_t port; 8571 portid_t port_id; 8572 cmdline_fixed_string_t what; 8573 cmdline_fixed_string_t value; 8574 cmdline_fixed_string_t mode; 8575 }; 8576 8577 static void 8578 cmd_set_uc_all_hash_parsed(void *parsed_result, 8579 __rte_unused struct cmdline *cl, 8580 __rte_unused void *data) 8581 { 8582 int ret=0; 8583 struct cmd_set_uc_all_hash_table *res = parsed_result; 8584 8585 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8586 8587 if ((strcmp(res->what, "uta") == 0) && 8588 (strcmp(res->value, "all") == 0)) 8589 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 8590 if (ret < 0) 8591 printf("bad unicast hash table parameter," 8592 "return code = %d \n", ret); 8593 } 8594 8595 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 8596 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8597 set, "set"); 8598 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 8599 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8600 port, "port"); 8601 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 8602 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 8603 port_id, RTE_UINT16); 8604 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 8605 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8606 what, "uta"); 8607 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 8608 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8609 value,"all"); 8610 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 8611 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8612 mode, "on#off"); 8613 8614 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 8615 .f = cmd_set_uc_all_hash_parsed, 8616 .data = NULL, 8617 .help_str = "set port <port_id> uta all on|off", 8618 .tokens = { 8619 (void *)&cmd_set_uc_all_hash_set, 8620 (void *)&cmd_set_uc_all_hash_port, 8621 (void *)&cmd_set_uc_all_hash_portid, 8622 (void *)&cmd_set_uc_all_hash_what, 8623 (void *)&cmd_set_uc_all_hash_value, 8624 (void *)&cmd_set_uc_all_hash_mode, 8625 NULL, 8626 }, 8627 }; 8628 8629 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 8630 struct cmd_set_vf_traffic { 8631 cmdline_fixed_string_t set; 8632 cmdline_fixed_string_t port; 8633 portid_t port_id; 8634 cmdline_fixed_string_t vf; 8635 uint8_t vf_id; 8636 cmdline_fixed_string_t what; 8637 cmdline_fixed_string_t mode; 8638 }; 8639 8640 static void 8641 cmd_set_vf_traffic_parsed(void *parsed_result, 8642 __rte_unused struct cmdline *cl, 8643 __rte_unused void *data) 8644 { 8645 struct cmd_set_vf_traffic *res = parsed_result; 8646 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 8647 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8648 8649 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 8650 } 8651 8652 cmdline_parse_token_string_t cmd_setvf_traffic_set = 8653 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8654 set, "set"); 8655 cmdline_parse_token_string_t cmd_setvf_traffic_port = 8656 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8657 port, "port"); 8658 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 8659 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8660 port_id, RTE_UINT16); 8661 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 8662 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8663 vf, "vf"); 8664 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 8665 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8666 vf_id, RTE_UINT8); 8667 cmdline_parse_token_string_t cmd_setvf_traffic_what = 8668 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8669 what, "tx#rx"); 8670 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 8671 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8672 mode, "on#off"); 8673 8674 cmdline_parse_inst_t cmd_set_vf_traffic = { 8675 .f = cmd_set_vf_traffic_parsed, 8676 .data = NULL, 8677 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 8678 .tokens = { 8679 (void *)&cmd_setvf_traffic_set, 8680 (void *)&cmd_setvf_traffic_port, 8681 (void *)&cmd_setvf_traffic_portid, 8682 (void *)&cmd_setvf_traffic_vf, 8683 (void *)&cmd_setvf_traffic_vfid, 8684 (void *)&cmd_setvf_traffic_what, 8685 (void *)&cmd_setvf_traffic_mode, 8686 NULL, 8687 }, 8688 }; 8689 8690 /* *** CONFIGURE VF RECEIVE MODE *** */ 8691 struct cmd_set_vf_rxmode { 8692 cmdline_fixed_string_t set; 8693 cmdline_fixed_string_t port; 8694 portid_t port_id; 8695 cmdline_fixed_string_t vf; 8696 uint8_t vf_id; 8697 cmdline_fixed_string_t what; 8698 cmdline_fixed_string_t mode; 8699 cmdline_fixed_string_t on; 8700 }; 8701 8702 static void 8703 cmd_set_vf_rxmode_parsed(void *parsed_result, 8704 __rte_unused struct cmdline *cl, 8705 __rte_unused void *data) 8706 { 8707 int ret = -ENOTSUP; 8708 uint16_t vf_rxmode = 0; 8709 struct cmd_set_vf_rxmode *res = parsed_result; 8710 8711 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 8712 if (!strcmp(res->what,"rxmode")) { 8713 if (!strcmp(res->mode, "AUPE")) 8714 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG; 8715 else if (!strcmp(res->mode, "ROPE")) 8716 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC; 8717 else if (!strcmp(res->mode, "BAM")) 8718 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST; 8719 else if (!strncmp(res->mode, "MPE",3)) 8720 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST; 8721 } 8722 8723 RTE_SET_USED(is_on); 8724 8725 #ifdef RTE_NET_IXGBE 8726 if (ret == -ENOTSUP) 8727 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 8728 vf_rxmode, (uint8_t)is_on); 8729 #endif 8730 #ifdef RTE_NET_BNXT 8731 if (ret == -ENOTSUP) 8732 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 8733 vf_rxmode, (uint8_t)is_on); 8734 #endif 8735 if (ret < 0) 8736 printf("bad VF receive mode parameter, return code = %d \n", 8737 ret); 8738 } 8739 8740 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 8741 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8742 set, "set"); 8743 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 8744 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8745 port, "port"); 8746 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 8747 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8748 port_id, RTE_UINT16); 8749 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 8750 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8751 vf, "vf"); 8752 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 8753 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8754 vf_id, RTE_UINT8); 8755 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 8756 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8757 what, "rxmode"); 8758 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 8759 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8760 mode, "AUPE#ROPE#BAM#MPE"); 8761 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 8762 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8763 on, "on#off"); 8764 8765 cmdline_parse_inst_t cmd_set_vf_rxmode = { 8766 .f = cmd_set_vf_rxmode_parsed, 8767 .data = NULL, 8768 .help_str = "set port <port_id> vf <vf_id> rxmode " 8769 "AUPE|ROPE|BAM|MPE on|off", 8770 .tokens = { 8771 (void *)&cmd_set_vf_rxmode_set, 8772 (void *)&cmd_set_vf_rxmode_port, 8773 (void *)&cmd_set_vf_rxmode_portid, 8774 (void *)&cmd_set_vf_rxmode_vf, 8775 (void *)&cmd_set_vf_rxmode_vfid, 8776 (void *)&cmd_set_vf_rxmode_what, 8777 (void *)&cmd_set_vf_rxmode_mode, 8778 (void *)&cmd_set_vf_rxmode_on, 8779 NULL, 8780 }, 8781 }; 8782 8783 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 8784 struct cmd_vf_mac_addr_result { 8785 cmdline_fixed_string_t mac_addr_cmd; 8786 cmdline_fixed_string_t what; 8787 cmdline_fixed_string_t port; 8788 uint16_t port_num; 8789 cmdline_fixed_string_t vf; 8790 uint8_t vf_num; 8791 struct rte_ether_addr address; 8792 }; 8793 8794 static void cmd_vf_mac_addr_parsed(void *parsed_result, 8795 __rte_unused struct cmdline *cl, 8796 __rte_unused void *data) 8797 { 8798 struct cmd_vf_mac_addr_result *res = parsed_result; 8799 int ret = -ENOTSUP; 8800 8801 if (strcmp(res->what, "add") != 0) 8802 return; 8803 8804 #ifdef RTE_NET_I40E 8805 if (ret == -ENOTSUP) 8806 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 8807 &res->address); 8808 #endif 8809 #ifdef RTE_NET_BNXT 8810 if (ret == -ENOTSUP) 8811 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 8812 res->vf_num); 8813 #endif 8814 8815 if(ret < 0) 8816 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 8817 8818 } 8819 8820 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 8821 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8822 mac_addr_cmd,"mac_addr"); 8823 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 8824 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8825 what,"add"); 8826 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 8827 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8828 port,"port"); 8829 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 8830 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8831 port_num, RTE_UINT16); 8832 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 8833 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8834 vf,"vf"); 8835 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 8836 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8837 vf_num, RTE_UINT8); 8838 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 8839 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 8840 address); 8841 8842 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 8843 .f = cmd_vf_mac_addr_parsed, 8844 .data = (void *)0, 8845 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 8846 "Add MAC address filtering for a VF on port_id", 8847 .tokens = { 8848 (void *)&cmd_vf_mac_addr_cmd, 8849 (void *)&cmd_vf_mac_addr_what, 8850 (void *)&cmd_vf_mac_addr_port, 8851 (void *)&cmd_vf_mac_addr_portnum, 8852 (void *)&cmd_vf_mac_addr_vf, 8853 (void *)&cmd_vf_mac_addr_vfnum, 8854 (void *)&cmd_vf_mac_addr_addr, 8855 NULL, 8856 }, 8857 }; 8858 8859 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 8860 struct cmd_vf_rx_vlan_filter { 8861 cmdline_fixed_string_t rx_vlan; 8862 cmdline_fixed_string_t what; 8863 uint16_t vlan_id; 8864 cmdline_fixed_string_t port; 8865 portid_t port_id; 8866 cmdline_fixed_string_t vf; 8867 uint64_t vf_mask; 8868 }; 8869 8870 static void 8871 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 8872 __rte_unused struct cmdline *cl, 8873 __rte_unused void *data) 8874 { 8875 struct cmd_vf_rx_vlan_filter *res = parsed_result; 8876 int ret = -ENOTSUP; 8877 8878 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 8879 8880 #ifdef RTE_NET_IXGBE 8881 if (ret == -ENOTSUP) 8882 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 8883 res->vlan_id, res->vf_mask, is_add); 8884 #endif 8885 #ifdef RTE_NET_I40E 8886 if (ret == -ENOTSUP) 8887 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 8888 res->vlan_id, res->vf_mask, is_add); 8889 #endif 8890 #ifdef RTE_NET_BNXT 8891 if (ret == -ENOTSUP) 8892 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 8893 res->vlan_id, res->vf_mask, is_add); 8894 #endif 8895 8896 switch (ret) { 8897 case 0: 8898 break; 8899 case -EINVAL: 8900 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n", 8901 res->vlan_id, res->vf_mask); 8902 break; 8903 case -ENODEV: 8904 printf("invalid port_id %d\n", res->port_id); 8905 break; 8906 case -ENOTSUP: 8907 printf("function not implemented or supported\n"); 8908 break; 8909 default: 8910 printf("programming error: (%s)\n", strerror(-ret)); 8911 } 8912 } 8913 8914 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 8915 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8916 rx_vlan, "rx_vlan"); 8917 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 8918 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8919 what, "add#rm"); 8920 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 8921 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8922 vlan_id, RTE_UINT16); 8923 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 8924 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8925 port, "port"); 8926 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 8927 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8928 port_id, RTE_UINT16); 8929 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 8930 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8931 vf, "vf"); 8932 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 8933 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8934 vf_mask, RTE_UINT64); 8935 8936 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 8937 .f = cmd_vf_rx_vlan_filter_parsed, 8938 .data = NULL, 8939 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 8940 "(vf_mask = hexadecimal VF mask)", 8941 .tokens = { 8942 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 8943 (void *)&cmd_vf_rx_vlan_filter_what, 8944 (void *)&cmd_vf_rx_vlan_filter_vlanid, 8945 (void *)&cmd_vf_rx_vlan_filter_port, 8946 (void *)&cmd_vf_rx_vlan_filter_portid, 8947 (void *)&cmd_vf_rx_vlan_filter_vf, 8948 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 8949 NULL, 8950 }, 8951 }; 8952 8953 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 8954 struct cmd_queue_rate_limit_result { 8955 cmdline_fixed_string_t set; 8956 cmdline_fixed_string_t port; 8957 uint16_t port_num; 8958 cmdline_fixed_string_t queue; 8959 uint8_t queue_num; 8960 cmdline_fixed_string_t rate; 8961 uint16_t rate_num; 8962 }; 8963 8964 static void cmd_queue_rate_limit_parsed(void *parsed_result, 8965 __rte_unused struct cmdline *cl, 8966 __rte_unused void *data) 8967 { 8968 struct cmd_queue_rate_limit_result *res = parsed_result; 8969 int ret = 0; 8970 8971 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8972 && (strcmp(res->queue, "queue") == 0) 8973 && (strcmp(res->rate, "rate") == 0)) 8974 ret = set_queue_rate_limit(res->port_num, res->queue_num, 8975 res->rate_num); 8976 if (ret < 0) 8977 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8978 8979 } 8980 8981 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 8982 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8983 set, "set"); 8984 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 8985 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8986 port, "port"); 8987 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 8988 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8989 port_num, RTE_UINT16); 8990 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 8991 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8992 queue, "queue"); 8993 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 8994 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8995 queue_num, RTE_UINT8); 8996 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 8997 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8998 rate, "rate"); 8999 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 9000 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9001 rate_num, RTE_UINT16); 9002 9003 cmdline_parse_inst_t cmd_queue_rate_limit = { 9004 .f = cmd_queue_rate_limit_parsed, 9005 .data = (void *)0, 9006 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 9007 "Set rate limit for a queue on port_id", 9008 .tokens = { 9009 (void *)&cmd_queue_rate_limit_set, 9010 (void *)&cmd_queue_rate_limit_port, 9011 (void *)&cmd_queue_rate_limit_portnum, 9012 (void *)&cmd_queue_rate_limit_queue, 9013 (void *)&cmd_queue_rate_limit_queuenum, 9014 (void *)&cmd_queue_rate_limit_rate, 9015 (void *)&cmd_queue_rate_limit_ratenum, 9016 NULL, 9017 }, 9018 }; 9019 9020 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 9021 struct cmd_vf_rate_limit_result { 9022 cmdline_fixed_string_t set; 9023 cmdline_fixed_string_t port; 9024 uint16_t port_num; 9025 cmdline_fixed_string_t vf; 9026 uint8_t vf_num; 9027 cmdline_fixed_string_t rate; 9028 uint16_t rate_num; 9029 cmdline_fixed_string_t q_msk; 9030 uint64_t q_msk_val; 9031 }; 9032 9033 static void cmd_vf_rate_limit_parsed(void *parsed_result, 9034 __rte_unused struct cmdline *cl, 9035 __rte_unused void *data) 9036 { 9037 struct cmd_vf_rate_limit_result *res = parsed_result; 9038 int ret = 0; 9039 9040 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 9041 && (strcmp(res->vf, "vf") == 0) 9042 && (strcmp(res->rate, "rate") == 0) 9043 && (strcmp(res->q_msk, "queue_mask") == 0)) 9044 ret = set_vf_rate_limit(res->port_num, res->vf_num, 9045 res->rate_num, res->q_msk_val); 9046 if (ret < 0) 9047 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret)); 9048 9049 } 9050 9051 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 9052 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9053 set, "set"); 9054 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 9055 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9056 port, "port"); 9057 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 9058 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9059 port_num, RTE_UINT16); 9060 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 9061 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9062 vf, "vf"); 9063 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 9064 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9065 vf_num, RTE_UINT8); 9066 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 9067 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9068 rate, "rate"); 9069 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 9070 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9071 rate_num, RTE_UINT16); 9072 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 9073 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9074 q_msk, "queue_mask"); 9075 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 9076 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9077 q_msk_val, RTE_UINT64); 9078 9079 cmdline_parse_inst_t cmd_vf_rate_limit = { 9080 .f = cmd_vf_rate_limit_parsed, 9081 .data = (void *)0, 9082 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 9083 "queue_mask <queue_mask_value>: " 9084 "Set rate limit for queues of VF on port_id", 9085 .tokens = { 9086 (void *)&cmd_vf_rate_limit_set, 9087 (void *)&cmd_vf_rate_limit_port, 9088 (void *)&cmd_vf_rate_limit_portnum, 9089 (void *)&cmd_vf_rate_limit_vf, 9090 (void *)&cmd_vf_rate_limit_vfnum, 9091 (void *)&cmd_vf_rate_limit_rate, 9092 (void *)&cmd_vf_rate_limit_ratenum, 9093 (void *)&cmd_vf_rate_limit_q_msk, 9094 (void *)&cmd_vf_rate_limit_q_msk_val, 9095 NULL, 9096 }, 9097 }; 9098 9099 /* *** CONFIGURE TUNNEL UDP PORT *** */ 9100 struct cmd_tunnel_udp_config { 9101 cmdline_fixed_string_t cmd; 9102 cmdline_fixed_string_t what; 9103 uint16_t udp_port; 9104 portid_t port_id; 9105 }; 9106 9107 static void 9108 cmd_tunnel_udp_config_parsed(void *parsed_result, 9109 __rte_unused struct cmdline *cl, 9110 __rte_unused void *data) 9111 { 9112 struct cmd_tunnel_udp_config *res = parsed_result; 9113 struct rte_eth_udp_tunnel tunnel_udp; 9114 int ret; 9115 9116 tunnel_udp.udp_port = res->udp_port; 9117 9118 if (!strcmp(res->cmd, "rx_vxlan_port")) 9119 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9120 9121 if (!strcmp(res->what, "add")) 9122 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9123 &tunnel_udp); 9124 else 9125 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9126 &tunnel_udp); 9127 9128 if (ret < 0) 9129 printf("udp tunneling add error: (%s)\n", strerror(-ret)); 9130 } 9131 9132 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd = 9133 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9134 cmd, "rx_vxlan_port"); 9135 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 9136 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9137 what, "add#rm"); 9138 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 9139 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9140 udp_port, RTE_UINT16); 9141 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 9142 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9143 port_id, RTE_UINT16); 9144 9145 cmdline_parse_inst_t cmd_tunnel_udp_config = { 9146 .f = cmd_tunnel_udp_config_parsed, 9147 .data = (void *)0, 9148 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 9149 "Add/Remove a tunneling UDP port filter", 9150 .tokens = { 9151 (void *)&cmd_tunnel_udp_config_cmd, 9152 (void *)&cmd_tunnel_udp_config_what, 9153 (void *)&cmd_tunnel_udp_config_udp_port, 9154 (void *)&cmd_tunnel_udp_config_port_id, 9155 NULL, 9156 }, 9157 }; 9158 9159 struct cmd_config_tunnel_udp_port { 9160 cmdline_fixed_string_t port; 9161 cmdline_fixed_string_t config; 9162 portid_t port_id; 9163 cmdline_fixed_string_t udp_tunnel_port; 9164 cmdline_fixed_string_t action; 9165 cmdline_fixed_string_t tunnel_type; 9166 uint16_t udp_port; 9167 }; 9168 9169 static void 9170 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 9171 __rte_unused struct cmdline *cl, 9172 __rte_unused void *data) 9173 { 9174 struct cmd_config_tunnel_udp_port *res = parsed_result; 9175 struct rte_eth_udp_tunnel tunnel_udp; 9176 int ret = 0; 9177 9178 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9179 return; 9180 9181 tunnel_udp.udp_port = res->udp_port; 9182 9183 if (!strcmp(res->tunnel_type, "vxlan")) { 9184 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9185 } else if (!strcmp(res->tunnel_type, "geneve")) { 9186 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 9187 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) { 9188 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 9189 } else if (!strcmp(res->tunnel_type, "ecpri")) { 9190 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI; 9191 } else { 9192 printf("Invalid tunnel type\n"); 9193 return; 9194 } 9195 9196 if (!strcmp(res->action, "add")) 9197 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9198 &tunnel_udp); 9199 else 9200 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9201 &tunnel_udp); 9202 9203 if (ret < 0) 9204 printf("udp tunneling port add error: (%s)\n", strerror(-ret)); 9205 } 9206 9207 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 9208 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 9209 "port"); 9210 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 9211 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 9212 "config"); 9213 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 9214 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 9215 RTE_UINT16); 9216 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 9217 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 9218 udp_tunnel_port, 9219 "udp_tunnel_port"); 9220 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 9221 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 9222 "add#rm"); 9223 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 9224 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 9225 "vxlan#geneve#vxlan-gpe#ecpri"); 9226 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 9227 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 9228 RTE_UINT16); 9229 9230 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 9231 .f = cmd_cfg_tunnel_udp_port_parsed, 9232 .data = NULL, 9233 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|" 9234 "geneve|vxlan-gpe|ecpri <udp_port>", 9235 .tokens = { 9236 (void *)&cmd_config_tunnel_udp_port_port, 9237 (void *)&cmd_config_tunnel_udp_port_config, 9238 (void *)&cmd_config_tunnel_udp_port_port_id, 9239 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 9240 (void *)&cmd_config_tunnel_udp_port_action, 9241 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 9242 (void *)&cmd_config_tunnel_udp_port_value, 9243 NULL, 9244 }, 9245 }; 9246 9247 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 9248 struct cmd_set_mirror_mask_result { 9249 cmdline_fixed_string_t set; 9250 cmdline_fixed_string_t port; 9251 portid_t port_id; 9252 cmdline_fixed_string_t mirror; 9253 uint8_t rule_id; 9254 cmdline_fixed_string_t what; 9255 cmdline_fixed_string_t value; 9256 cmdline_fixed_string_t dstpool; 9257 uint8_t dstpool_id; 9258 cmdline_fixed_string_t on; 9259 }; 9260 9261 cmdline_parse_token_string_t cmd_mirror_mask_set = 9262 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9263 set, "set"); 9264 cmdline_parse_token_string_t cmd_mirror_mask_port = 9265 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9266 port, "port"); 9267 cmdline_parse_token_num_t cmd_mirror_mask_portid = 9268 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9269 port_id, RTE_UINT16); 9270 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 9271 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9272 mirror, "mirror-rule"); 9273 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 9274 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9275 rule_id, RTE_UINT8); 9276 cmdline_parse_token_string_t cmd_mirror_mask_what = 9277 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9278 what, "pool-mirror-up#pool-mirror-down" 9279 "#vlan-mirror"); 9280 cmdline_parse_token_string_t cmd_mirror_mask_value = 9281 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9282 value, NULL); 9283 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 9284 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9285 dstpool, "dst-pool"); 9286 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 9287 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9288 dstpool_id, RTE_UINT8); 9289 cmdline_parse_token_string_t cmd_mirror_mask_on = 9290 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9291 on, "on#off"); 9292 9293 static void 9294 cmd_set_mirror_mask_parsed(void *parsed_result, 9295 __rte_unused struct cmdline *cl, 9296 __rte_unused void *data) 9297 { 9298 int ret,nb_item,i; 9299 struct cmd_set_mirror_mask_result *res = parsed_result; 9300 struct rte_eth_mirror_conf mr_conf; 9301 9302 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9303 9304 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 9305 9306 mr_conf.dst_pool = res->dstpool_id; 9307 9308 if (!strcmp(res->what, "pool-mirror-up")) { 9309 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9310 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 9311 } else if (!strcmp(res->what, "pool-mirror-down")) { 9312 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9313 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 9314 } else if (!strcmp(res->what, "vlan-mirror")) { 9315 mr_conf.rule_type = ETH_MIRROR_VLAN; 9316 nb_item = parse_item_list(res->value, "vlan", 9317 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 9318 if (nb_item <= 0) 9319 return; 9320 9321 for (i = 0; i < nb_item; i++) { 9322 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) { 9323 printf("Invalid vlan_id: must be < 4096\n"); 9324 return; 9325 } 9326 9327 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 9328 mr_conf.vlan.vlan_mask |= 1ULL << i; 9329 } 9330 } 9331 9332 if (!strcmp(res->on, "on")) 9333 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9334 res->rule_id, 1); 9335 else 9336 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9337 res->rule_id, 0); 9338 if (ret < 0) 9339 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9340 } 9341 9342 cmdline_parse_inst_t cmd_set_mirror_mask = { 9343 .f = cmd_set_mirror_mask_parsed, 9344 .data = NULL, 9345 .help_str = "set port <port_id> mirror-rule <rule_id> " 9346 "pool-mirror-up|pool-mirror-down|vlan-mirror " 9347 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 9348 .tokens = { 9349 (void *)&cmd_mirror_mask_set, 9350 (void *)&cmd_mirror_mask_port, 9351 (void *)&cmd_mirror_mask_portid, 9352 (void *)&cmd_mirror_mask_mirror, 9353 (void *)&cmd_mirror_mask_ruleid, 9354 (void *)&cmd_mirror_mask_what, 9355 (void *)&cmd_mirror_mask_value, 9356 (void *)&cmd_mirror_mask_dstpool, 9357 (void *)&cmd_mirror_mask_poolid, 9358 (void *)&cmd_mirror_mask_on, 9359 NULL, 9360 }, 9361 }; 9362 9363 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 9364 struct cmd_set_mirror_link_result { 9365 cmdline_fixed_string_t set; 9366 cmdline_fixed_string_t port; 9367 portid_t port_id; 9368 cmdline_fixed_string_t mirror; 9369 uint8_t rule_id; 9370 cmdline_fixed_string_t what; 9371 cmdline_fixed_string_t dstpool; 9372 uint8_t dstpool_id; 9373 cmdline_fixed_string_t on; 9374 }; 9375 9376 cmdline_parse_token_string_t cmd_mirror_link_set = 9377 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9378 set, "set"); 9379 cmdline_parse_token_string_t cmd_mirror_link_port = 9380 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9381 port, "port"); 9382 cmdline_parse_token_num_t cmd_mirror_link_portid = 9383 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9384 port_id, RTE_UINT16); 9385 cmdline_parse_token_string_t cmd_mirror_link_mirror = 9386 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9387 mirror, "mirror-rule"); 9388 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 9389 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9390 rule_id, RTE_UINT8); 9391 cmdline_parse_token_string_t cmd_mirror_link_what = 9392 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9393 what, "uplink-mirror#downlink-mirror"); 9394 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 9395 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9396 dstpool, "dst-pool"); 9397 cmdline_parse_token_num_t cmd_mirror_link_poolid = 9398 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9399 dstpool_id, RTE_UINT8); 9400 cmdline_parse_token_string_t cmd_mirror_link_on = 9401 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9402 on, "on#off"); 9403 9404 static void 9405 cmd_set_mirror_link_parsed(void *parsed_result, 9406 __rte_unused struct cmdline *cl, 9407 __rte_unused void *data) 9408 { 9409 int ret; 9410 struct cmd_set_mirror_link_result *res = parsed_result; 9411 struct rte_eth_mirror_conf mr_conf; 9412 9413 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9414 if (!strcmp(res->what, "uplink-mirror")) 9415 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 9416 else 9417 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 9418 9419 mr_conf.dst_pool = res->dstpool_id; 9420 9421 if (!strcmp(res->on, "on")) 9422 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9423 res->rule_id, 1); 9424 else 9425 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9426 res->rule_id, 0); 9427 9428 /* check the return value and print it if is < 0 */ 9429 if (ret < 0) 9430 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9431 9432 } 9433 9434 cmdline_parse_inst_t cmd_set_mirror_link = { 9435 .f = cmd_set_mirror_link_parsed, 9436 .data = NULL, 9437 .help_str = "set port <port_id> mirror-rule <rule_id> " 9438 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 9439 .tokens = { 9440 (void *)&cmd_mirror_link_set, 9441 (void *)&cmd_mirror_link_port, 9442 (void *)&cmd_mirror_link_portid, 9443 (void *)&cmd_mirror_link_mirror, 9444 (void *)&cmd_mirror_link_ruleid, 9445 (void *)&cmd_mirror_link_what, 9446 (void *)&cmd_mirror_link_dstpool, 9447 (void *)&cmd_mirror_link_poolid, 9448 (void *)&cmd_mirror_link_on, 9449 NULL, 9450 }, 9451 }; 9452 9453 /* *** RESET VM MIRROR RULE *** */ 9454 struct cmd_rm_mirror_rule_result { 9455 cmdline_fixed_string_t reset; 9456 cmdline_fixed_string_t port; 9457 portid_t port_id; 9458 cmdline_fixed_string_t mirror; 9459 uint8_t rule_id; 9460 }; 9461 9462 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 9463 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9464 reset, "reset"); 9465 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 9466 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9467 port, "port"); 9468 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 9469 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9470 port_id, RTE_UINT16); 9471 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 9472 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9473 mirror, "mirror-rule"); 9474 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 9475 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9476 rule_id, RTE_UINT8); 9477 9478 static void 9479 cmd_reset_mirror_rule_parsed(void *parsed_result, 9480 __rte_unused struct cmdline *cl, 9481 __rte_unused void *data) 9482 { 9483 int ret; 9484 struct cmd_set_mirror_link_result *res = parsed_result; 9485 /* check rule_id */ 9486 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 9487 if(ret < 0) 9488 printf("mirror rule remove error: (%s)\n", strerror(-ret)); 9489 } 9490 9491 cmdline_parse_inst_t cmd_reset_mirror_rule = { 9492 .f = cmd_reset_mirror_rule_parsed, 9493 .data = NULL, 9494 .help_str = "reset port <port_id> mirror-rule <rule_id>", 9495 .tokens = { 9496 (void *)&cmd_rm_mirror_rule_reset, 9497 (void *)&cmd_rm_mirror_rule_port, 9498 (void *)&cmd_rm_mirror_rule_portid, 9499 (void *)&cmd_rm_mirror_rule_mirror, 9500 (void *)&cmd_rm_mirror_rule_ruleid, 9501 NULL, 9502 }, 9503 }; 9504 9505 /* ******************************************************************************** */ 9506 9507 struct cmd_dump_result { 9508 cmdline_fixed_string_t dump; 9509 }; 9510 9511 static void 9512 dump_struct_sizes(void) 9513 { 9514 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9515 DUMP_SIZE(struct rte_mbuf); 9516 DUMP_SIZE(struct rte_mempool); 9517 DUMP_SIZE(struct rte_ring); 9518 #undef DUMP_SIZE 9519 } 9520 9521 9522 /* Dump the socket memory statistics on console */ 9523 static void 9524 dump_socket_mem(FILE *f) 9525 { 9526 struct rte_malloc_socket_stats socket_stats; 9527 unsigned int i; 9528 size_t total = 0; 9529 size_t alloc = 0; 9530 size_t free = 0; 9531 unsigned int n_alloc = 0; 9532 unsigned int n_free = 0; 9533 static size_t last_allocs; 9534 static size_t last_total; 9535 9536 9537 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) { 9538 if (rte_malloc_get_socket_stats(i, &socket_stats) || 9539 !socket_stats.heap_totalsz_bytes) 9540 continue; 9541 total += socket_stats.heap_totalsz_bytes; 9542 alloc += socket_stats.heap_allocsz_bytes; 9543 free += socket_stats.heap_freesz_bytes; 9544 n_alloc += socket_stats.alloc_count; 9545 n_free += socket_stats.free_count; 9546 fprintf(f, 9547 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 9548 i, 9549 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024), 9550 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024), 9551 (double)socket_stats.heap_allocsz_bytes * 100 / 9552 (double)socket_stats.heap_totalsz_bytes, 9553 (double)socket_stats.heap_freesz_bytes / (1024 * 1024), 9554 socket_stats.alloc_count, 9555 socket_stats.free_count); 9556 } 9557 fprintf(f, 9558 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 9559 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024), 9560 (double)alloc * 100 / (double)total, 9561 (double)free / (1024 * 1024), 9562 n_alloc, n_free); 9563 if (last_allocs) 9564 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n", 9565 ((double)total - (double)last_total) / (1024 * 1024), 9566 (double)(alloc - (double)last_allocs) / 1024 / 1024); 9567 last_allocs = alloc; 9568 last_total = total; 9569 } 9570 9571 static void cmd_dump_parsed(void *parsed_result, 9572 __rte_unused struct cmdline *cl, 9573 __rte_unused void *data) 9574 { 9575 struct cmd_dump_result *res = parsed_result; 9576 9577 if (!strcmp(res->dump, "dump_physmem")) 9578 rte_dump_physmem_layout(stdout); 9579 else if (!strcmp(res->dump, "dump_socket_mem")) 9580 dump_socket_mem(stdout); 9581 else if (!strcmp(res->dump, "dump_memzone")) 9582 rte_memzone_dump(stdout); 9583 else if (!strcmp(res->dump, "dump_struct_sizes")) 9584 dump_struct_sizes(); 9585 else if (!strcmp(res->dump, "dump_ring")) 9586 rte_ring_list_dump(stdout); 9587 else if (!strcmp(res->dump, "dump_mempool")) 9588 rte_mempool_list_dump(stdout); 9589 else if (!strcmp(res->dump, "dump_devargs")) 9590 rte_devargs_dump(stdout); 9591 else if (!strcmp(res->dump, "dump_log_types")) 9592 rte_log_dump(stdout); 9593 } 9594 9595 cmdline_parse_token_string_t cmd_dump_dump = 9596 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9597 "dump_physmem#" 9598 "dump_memzone#" 9599 "dump_socket_mem#" 9600 "dump_struct_sizes#" 9601 "dump_ring#" 9602 "dump_mempool#" 9603 "dump_devargs#" 9604 "dump_log_types"); 9605 9606 cmdline_parse_inst_t cmd_dump = { 9607 .f = cmd_dump_parsed, /* function to call */ 9608 .data = NULL, /* 2nd arg of func */ 9609 .help_str = "Dump status", 9610 .tokens = { /* token list, NULL terminated */ 9611 (void *)&cmd_dump_dump, 9612 NULL, 9613 }, 9614 }; 9615 9616 /* ******************************************************************************** */ 9617 9618 struct cmd_dump_one_result { 9619 cmdline_fixed_string_t dump; 9620 cmdline_fixed_string_t name; 9621 }; 9622 9623 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9624 __rte_unused void *data) 9625 { 9626 struct cmd_dump_one_result *res = parsed_result; 9627 9628 if (!strcmp(res->dump, "dump_ring")) { 9629 struct rte_ring *r; 9630 r = rte_ring_lookup(res->name); 9631 if (r == NULL) { 9632 cmdline_printf(cl, "Cannot find ring\n"); 9633 return; 9634 } 9635 rte_ring_dump(stdout, r); 9636 } else if (!strcmp(res->dump, "dump_mempool")) { 9637 struct rte_mempool *mp; 9638 mp = rte_mempool_lookup(res->name); 9639 if (mp == NULL) { 9640 cmdline_printf(cl, "Cannot find mempool\n"); 9641 return; 9642 } 9643 rte_mempool_dump(stdout, mp); 9644 } 9645 } 9646 9647 cmdline_parse_token_string_t cmd_dump_one_dump = 9648 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9649 "dump_ring#dump_mempool"); 9650 9651 cmdline_parse_token_string_t cmd_dump_one_name = 9652 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9653 9654 cmdline_parse_inst_t cmd_dump_one = { 9655 .f = cmd_dump_one_parsed, /* function to call */ 9656 .data = NULL, /* 2nd arg of func */ 9657 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9658 .tokens = { /* token list, NULL terminated */ 9659 (void *)&cmd_dump_one_dump, 9660 (void *)&cmd_dump_one_name, 9661 NULL, 9662 }, 9663 }; 9664 9665 /* *** queue region set *** */ 9666 struct cmd_queue_region_result { 9667 cmdline_fixed_string_t set; 9668 cmdline_fixed_string_t port; 9669 portid_t port_id; 9670 cmdline_fixed_string_t cmd; 9671 cmdline_fixed_string_t region; 9672 uint8_t region_id; 9673 cmdline_fixed_string_t queue_start_index; 9674 uint8_t queue_id; 9675 cmdline_fixed_string_t queue_num; 9676 uint8_t queue_num_value; 9677 }; 9678 9679 static void 9680 cmd_queue_region_parsed(void *parsed_result, 9681 __rte_unused struct cmdline *cl, 9682 __rte_unused void *data) 9683 { 9684 struct cmd_queue_region_result *res = parsed_result; 9685 int ret = -ENOTSUP; 9686 #ifdef RTE_NET_I40E 9687 struct rte_pmd_i40e_queue_region_conf region_conf; 9688 enum rte_pmd_i40e_queue_region_op op_type; 9689 #endif 9690 9691 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9692 return; 9693 9694 #ifdef RTE_NET_I40E 9695 memset(®ion_conf, 0, sizeof(region_conf)); 9696 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 9697 region_conf.region_id = res->region_id; 9698 region_conf.queue_num = res->queue_num_value; 9699 region_conf.queue_start_index = res->queue_id; 9700 9701 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9702 op_type, ®ion_conf); 9703 #endif 9704 9705 switch (ret) { 9706 case 0: 9707 break; 9708 case -ENOTSUP: 9709 printf("function not implemented or supported\n"); 9710 break; 9711 default: 9712 printf("queue region config error: (%s)\n", strerror(-ret)); 9713 } 9714 } 9715 9716 cmdline_parse_token_string_t cmd_queue_region_set = 9717 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9718 set, "set"); 9719 cmdline_parse_token_string_t cmd_queue_region_port = 9720 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 9721 cmdline_parse_token_num_t cmd_queue_region_port_id = 9722 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9723 port_id, RTE_UINT16); 9724 cmdline_parse_token_string_t cmd_queue_region_cmd = 9725 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9726 cmd, "queue-region"); 9727 cmdline_parse_token_string_t cmd_queue_region_id = 9728 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9729 region, "region_id"); 9730 cmdline_parse_token_num_t cmd_queue_region_index = 9731 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9732 region_id, RTE_UINT8); 9733 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 9734 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9735 queue_start_index, "queue_start_index"); 9736 cmdline_parse_token_num_t cmd_queue_region_queue_id = 9737 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9738 queue_id, RTE_UINT8); 9739 cmdline_parse_token_string_t cmd_queue_region_queue_num = 9740 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9741 queue_num, "queue_num"); 9742 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 9743 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9744 queue_num_value, RTE_UINT8); 9745 9746 cmdline_parse_inst_t cmd_queue_region = { 9747 .f = cmd_queue_region_parsed, 9748 .data = NULL, 9749 .help_str = "set port <port_id> queue-region region_id <value> " 9750 "queue_start_index <value> queue_num <value>: Set a queue region", 9751 .tokens = { 9752 (void *)&cmd_queue_region_set, 9753 (void *)&cmd_queue_region_port, 9754 (void *)&cmd_queue_region_port_id, 9755 (void *)&cmd_queue_region_cmd, 9756 (void *)&cmd_queue_region_id, 9757 (void *)&cmd_queue_region_index, 9758 (void *)&cmd_queue_region_queue_start_index, 9759 (void *)&cmd_queue_region_queue_id, 9760 (void *)&cmd_queue_region_queue_num, 9761 (void *)&cmd_queue_region_queue_num_value, 9762 NULL, 9763 }, 9764 }; 9765 9766 /* *** queue region and flowtype set *** */ 9767 struct cmd_region_flowtype_result { 9768 cmdline_fixed_string_t set; 9769 cmdline_fixed_string_t port; 9770 portid_t port_id; 9771 cmdline_fixed_string_t cmd; 9772 cmdline_fixed_string_t region; 9773 uint8_t region_id; 9774 cmdline_fixed_string_t flowtype; 9775 uint8_t flowtype_id; 9776 }; 9777 9778 static void 9779 cmd_region_flowtype_parsed(void *parsed_result, 9780 __rte_unused struct cmdline *cl, 9781 __rte_unused void *data) 9782 { 9783 struct cmd_region_flowtype_result *res = parsed_result; 9784 int ret = -ENOTSUP; 9785 #ifdef RTE_NET_I40E 9786 struct rte_pmd_i40e_queue_region_conf region_conf; 9787 enum rte_pmd_i40e_queue_region_op op_type; 9788 #endif 9789 9790 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9791 return; 9792 9793 #ifdef RTE_NET_I40E 9794 memset(®ion_conf, 0, sizeof(region_conf)); 9795 9796 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 9797 region_conf.region_id = res->region_id; 9798 region_conf.hw_flowtype = res->flowtype_id; 9799 9800 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9801 op_type, ®ion_conf); 9802 #endif 9803 9804 switch (ret) { 9805 case 0: 9806 break; 9807 case -ENOTSUP: 9808 printf("function not implemented or supported\n"); 9809 break; 9810 default: 9811 printf("region flowtype config error: (%s)\n", strerror(-ret)); 9812 } 9813 } 9814 9815 cmdline_parse_token_string_t cmd_region_flowtype_set = 9816 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9817 set, "set"); 9818 cmdline_parse_token_string_t cmd_region_flowtype_port = 9819 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9820 port, "port"); 9821 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 9822 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9823 port_id, RTE_UINT16); 9824 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 9825 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9826 cmd, "queue-region"); 9827 cmdline_parse_token_string_t cmd_region_flowtype_index = 9828 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9829 region, "region_id"); 9830 cmdline_parse_token_num_t cmd_region_flowtype_id = 9831 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9832 region_id, RTE_UINT8); 9833 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 9834 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9835 flowtype, "flowtype"); 9836 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 9837 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9838 flowtype_id, RTE_UINT8); 9839 cmdline_parse_inst_t cmd_region_flowtype = { 9840 .f = cmd_region_flowtype_parsed, 9841 .data = NULL, 9842 .help_str = "set port <port_id> queue-region region_id <value> " 9843 "flowtype <value>: Set a flowtype region index", 9844 .tokens = { 9845 (void *)&cmd_region_flowtype_set, 9846 (void *)&cmd_region_flowtype_port, 9847 (void *)&cmd_region_flowtype_port_index, 9848 (void *)&cmd_region_flowtype_cmd, 9849 (void *)&cmd_region_flowtype_index, 9850 (void *)&cmd_region_flowtype_id, 9851 (void *)&cmd_region_flowtype_flow_index, 9852 (void *)&cmd_region_flowtype_flow_id, 9853 NULL, 9854 }, 9855 }; 9856 9857 /* *** User Priority (UP) to queue region (region_id) set *** */ 9858 struct cmd_user_priority_region_result { 9859 cmdline_fixed_string_t set; 9860 cmdline_fixed_string_t port; 9861 portid_t port_id; 9862 cmdline_fixed_string_t cmd; 9863 cmdline_fixed_string_t user_priority; 9864 uint8_t user_priority_id; 9865 cmdline_fixed_string_t region; 9866 uint8_t region_id; 9867 }; 9868 9869 static void 9870 cmd_user_priority_region_parsed(void *parsed_result, 9871 __rte_unused struct cmdline *cl, 9872 __rte_unused void *data) 9873 { 9874 struct cmd_user_priority_region_result *res = parsed_result; 9875 int ret = -ENOTSUP; 9876 #ifdef RTE_NET_I40E 9877 struct rte_pmd_i40e_queue_region_conf region_conf; 9878 enum rte_pmd_i40e_queue_region_op op_type; 9879 #endif 9880 9881 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9882 return; 9883 9884 #ifdef RTE_NET_I40E 9885 memset(®ion_conf, 0, sizeof(region_conf)); 9886 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 9887 region_conf.user_priority = res->user_priority_id; 9888 region_conf.region_id = res->region_id; 9889 9890 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9891 op_type, ®ion_conf); 9892 #endif 9893 9894 switch (ret) { 9895 case 0: 9896 break; 9897 case -ENOTSUP: 9898 printf("function not implemented or supported\n"); 9899 break; 9900 default: 9901 printf("user_priority region config error: (%s)\n", 9902 strerror(-ret)); 9903 } 9904 } 9905 9906 cmdline_parse_token_string_t cmd_user_priority_region_set = 9907 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9908 set, "set"); 9909 cmdline_parse_token_string_t cmd_user_priority_region_port = 9910 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9911 port, "port"); 9912 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 9913 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9914 port_id, RTE_UINT16); 9915 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 9916 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9917 cmd, "queue-region"); 9918 cmdline_parse_token_string_t cmd_user_priority_region_UP = 9919 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9920 user_priority, "UP"); 9921 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 9922 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9923 user_priority_id, RTE_UINT8); 9924 cmdline_parse_token_string_t cmd_user_priority_region_region = 9925 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9926 region, "region_id"); 9927 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 9928 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9929 region_id, RTE_UINT8); 9930 9931 cmdline_parse_inst_t cmd_user_priority_region = { 9932 .f = cmd_user_priority_region_parsed, 9933 .data = NULL, 9934 .help_str = "set port <port_id> queue-region UP <value> " 9935 "region_id <value>: Set the mapping of User Priority (UP) " 9936 "to queue region (region_id) ", 9937 .tokens = { 9938 (void *)&cmd_user_priority_region_set, 9939 (void *)&cmd_user_priority_region_port, 9940 (void *)&cmd_user_priority_region_port_index, 9941 (void *)&cmd_user_priority_region_cmd, 9942 (void *)&cmd_user_priority_region_UP, 9943 (void *)&cmd_user_priority_region_UP_id, 9944 (void *)&cmd_user_priority_region_region, 9945 (void *)&cmd_user_priority_region_region_id, 9946 NULL, 9947 }, 9948 }; 9949 9950 /* *** flush all queue region related configuration *** */ 9951 struct cmd_flush_queue_region_result { 9952 cmdline_fixed_string_t set; 9953 cmdline_fixed_string_t port; 9954 portid_t port_id; 9955 cmdline_fixed_string_t cmd; 9956 cmdline_fixed_string_t flush; 9957 cmdline_fixed_string_t what; 9958 }; 9959 9960 static void 9961 cmd_flush_queue_region_parsed(void *parsed_result, 9962 __rte_unused struct cmdline *cl, 9963 __rte_unused void *data) 9964 { 9965 struct cmd_flush_queue_region_result *res = parsed_result; 9966 int ret = -ENOTSUP; 9967 #ifdef RTE_NET_I40E 9968 struct rte_pmd_i40e_queue_region_conf region_conf; 9969 enum rte_pmd_i40e_queue_region_op op_type; 9970 #endif 9971 9972 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9973 return; 9974 9975 #ifdef RTE_NET_I40E 9976 memset(®ion_conf, 0, sizeof(region_conf)); 9977 9978 if (strcmp(res->what, "on") == 0) 9979 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 9980 else 9981 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 9982 9983 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9984 op_type, ®ion_conf); 9985 #endif 9986 9987 switch (ret) { 9988 case 0: 9989 break; 9990 case -ENOTSUP: 9991 printf("function not implemented or supported\n"); 9992 break; 9993 default: 9994 printf("queue region config flush error: (%s)\n", 9995 strerror(-ret)); 9996 } 9997 } 9998 9999 cmdline_parse_token_string_t cmd_flush_queue_region_set = 10000 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10001 set, "set"); 10002 cmdline_parse_token_string_t cmd_flush_queue_region_port = 10003 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10004 port, "port"); 10005 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 10006 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 10007 port_id, RTE_UINT16); 10008 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 10009 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10010 cmd, "queue-region"); 10011 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 10012 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10013 flush, "flush"); 10014 cmdline_parse_token_string_t cmd_flush_queue_region_what = 10015 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10016 what, "on#off"); 10017 10018 cmdline_parse_inst_t cmd_flush_queue_region = { 10019 .f = cmd_flush_queue_region_parsed, 10020 .data = NULL, 10021 .help_str = "set port <port_id> queue-region flush on|off" 10022 ": flush all queue region related configuration", 10023 .tokens = { 10024 (void *)&cmd_flush_queue_region_set, 10025 (void *)&cmd_flush_queue_region_port, 10026 (void *)&cmd_flush_queue_region_port_index, 10027 (void *)&cmd_flush_queue_region_cmd, 10028 (void *)&cmd_flush_queue_region_flush, 10029 (void *)&cmd_flush_queue_region_what, 10030 NULL, 10031 }, 10032 }; 10033 10034 /* *** get all queue region related configuration info *** */ 10035 struct cmd_show_queue_region_info { 10036 cmdline_fixed_string_t show; 10037 cmdline_fixed_string_t port; 10038 portid_t port_id; 10039 cmdline_fixed_string_t cmd; 10040 }; 10041 10042 static void 10043 cmd_show_queue_region_info_parsed(void *parsed_result, 10044 __rte_unused struct cmdline *cl, 10045 __rte_unused void *data) 10046 { 10047 struct cmd_show_queue_region_info *res = parsed_result; 10048 int ret = -ENOTSUP; 10049 #ifdef RTE_NET_I40E 10050 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 10051 enum rte_pmd_i40e_queue_region_op op_type; 10052 #endif 10053 10054 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10055 return; 10056 10057 #ifdef RTE_NET_I40E 10058 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 10059 10060 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 10061 10062 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10063 op_type, &rte_pmd_regions); 10064 10065 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 10066 #endif 10067 10068 switch (ret) { 10069 case 0: 10070 break; 10071 case -ENOTSUP: 10072 printf("function not implemented or supported\n"); 10073 break; 10074 default: 10075 printf("queue region config info show error: (%s)\n", 10076 strerror(-ret)); 10077 } 10078 } 10079 10080 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 10081 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10082 show, "show"); 10083 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 10084 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10085 port, "port"); 10086 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 10087 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 10088 port_id, RTE_UINT16); 10089 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 10090 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10091 cmd, "queue-region"); 10092 10093 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 10094 .f = cmd_show_queue_region_info_parsed, 10095 .data = NULL, 10096 .help_str = "show port <port_id> queue-region" 10097 ": show all queue region related configuration info", 10098 .tokens = { 10099 (void *)&cmd_show_queue_region_info_get, 10100 (void *)&cmd_show_queue_region_info_port, 10101 (void *)&cmd_show_queue_region_info_port_index, 10102 (void *)&cmd_show_queue_region_info_cmd, 10103 NULL, 10104 }, 10105 }; 10106 10107 /* *** Filters Control *** */ 10108 10109 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10110 do { \ 10111 if ((ip_addr).family == AF_INET) \ 10112 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10113 else { \ 10114 printf("invalid parameter.\n"); \ 10115 return; \ 10116 } \ 10117 } while (0) 10118 10119 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10120 do { \ 10121 if ((ip_addr).family == AF_INET6) \ 10122 rte_memcpy(&(ip), \ 10123 &((ip_addr).addr.ipv6), \ 10124 sizeof(struct in6_addr)); \ 10125 else { \ 10126 printf("invalid parameter.\n"); \ 10127 return; \ 10128 } \ 10129 } while (0) 10130 10131 #ifdef RTE_NET_I40E 10132 10133 static uint16_t 10134 str2flowtype(char *string) 10135 { 10136 uint8_t i = 0; 10137 static const struct { 10138 char str[32]; 10139 uint16_t type; 10140 } flowtype_str[] = { 10141 {"raw", RTE_ETH_FLOW_RAW}, 10142 {"ipv4", RTE_ETH_FLOW_IPV4}, 10143 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10144 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10145 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10146 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10147 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10148 {"ipv6", RTE_ETH_FLOW_IPV6}, 10149 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10150 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10151 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10152 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10153 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10154 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10155 }; 10156 10157 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10158 if (!strcmp(flowtype_str[i].str, string)) 10159 return flowtype_str[i].type; 10160 } 10161 10162 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10163 return (uint16_t)atoi(string); 10164 10165 return RTE_ETH_FLOW_UNKNOWN; 10166 } 10167 10168 /* *** deal with flow director filter *** */ 10169 struct cmd_flow_director_result { 10170 cmdline_fixed_string_t flow_director_filter; 10171 portid_t port_id; 10172 cmdline_fixed_string_t mode; 10173 cmdline_fixed_string_t mode_value; 10174 cmdline_fixed_string_t ops; 10175 cmdline_fixed_string_t flow; 10176 cmdline_fixed_string_t flow_type; 10177 cmdline_fixed_string_t drop; 10178 cmdline_fixed_string_t queue; 10179 uint16_t queue_id; 10180 cmdline_fixed_string_t fd_id; 10181 uint32_t fd_id_value; 10182 cmdline_fixed_string_t packet; 10183 char filepath[]; 10184 }; 10185 10186 static void 10187 cmd_flow_director_filter_parsed(void *parsed_result, 10188 __rte_unused struct cmdline *cl, 10189 __rte_unused void *data) 10190 { 10191 struct cmd_flow_director_result *res = parsed_result; 10192 int ret = 0; 10193 struct rte_pmd_i40e_flow_type_mapping 10194 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 10195 struct rte_pmd_i40e_pkt_template_conf conf; 10196 uint16_t flow_type = str2flowtype(res->flow_type); 10197 uint16_t i, port = res->port_id; 10198 uint8_t add; 10199 10200 memset(&conf, 0, sizeof(conf)); 10201 10202 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 10203 printf("Invalid flow type specified.\n"); 10204 return; 10205 } 10206 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 10207 mapping); 10208 if (ret) 10209 return; 10210 if (mapping[flow_type].pctype == 0ULL) { 10211 printf("Invalid flow type specified.\n"); 10212 return; 10213 } 10214 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 10215 if (mapping[flow_type].pctype & (1ULL << i)) { 10216 conf.input.pctype = i; 10217 break; 10218 } 10219 } 10220 10221 conf.input.packet = open_file(res->filepath, 10222 &conf.input.length); 10223 if (!conf.input.packet) 10224 return; 10225 if (!strcmp(res->drop, "drop")) 10226 conf.action.behavior = 10227 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 10228 else 10229 conf.action.behavior = 10230 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 10231 conf.action.report_status = 10232 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 10233 conf.action.rx_queue = res->queue_id; 10234 conf.soft_id = res->fd_id_value; 10235 add = strcmp(res->ops, "del") ? 1 : 0; 10236 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 10237 &conf, 10238 add); 10239 if (ret < 0) 10240 printf("flow director config error: (%s)\n", 10241 strerror(-ret)); 10242 close_file(conf.input.packet); 10243 } 10244 10245 cmdline_parse_token_string_t cmd_flow_director_filter = 10246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10247 flow_director_filter, "flow_director_filter"); 10248 cmdline_parse_token_num_t cmd_flow_director_port_id = 10249 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10250 port_id, RTE_UINT16); 10251 cmdline_parse_token_string_t cmd_flow_director_ops = 10252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10253 ops, "add#del#update"); 10254 cmdline_parse_token_string_t cmd_flow_director_flow = 10255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10256 flow, "flow"); 10257 cmdline_parse_token_string_t cmd_flow_director_flow_type = 10258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10259 flow_type, NULL); 10260 cmdline_parse_token_string_t cmd_flow_director_drop = 10261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10262 drop, "drop#fwd"); 10263 cmdline_parse_token_string_t cmd_flow_director_queue = 10264 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10265 queue, "queue"); 10266 cmdline_parse_token_num_t cmd_flow_director_queue_id = 10267 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10268 queue_id, RTE_UINT16); 10269 cmdline_parse_token_string_t cmd_flow_director_fd_id = 10270 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10271 fd_id, "fd_id"); 10272 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 10273 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10274 fd_id_value, RTE_UINT32); 10275 10276 cmdline_parse_token_string_t cmd_flow_director_mode = 10277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10278 mode, "mode"); 10279 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 10280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10281 mode_value, "raw"); 10282 cmdline_parse_token_string_t cmd_flow_director_packet = 10283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10284 packet, "packet"); 10285 cmdline_parse_token_string_t cmd_flow_director_filepath = 10286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10287 filepath, NULL); 10288 10289 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 10290 .f = cmd_flow_director_filter_parsed, 10291 .data = NULL, 10292 .help_str = "flow_director_filter ... : Add or delete a raw flow " 10293 "director entry on NIC", 10294 .tokens = { 10295 (void *)&cmd_flow_director_filter, 10296 (void *)&cmd_flow_director_port_id, 10297 (void *)&cmd_flow_director_mode, 10298 (void *)&cmd_flow_director_mode_raw, 10299 (void *)&cmd_flow_director_ops, 10300 (void *)&cmd_flow_director_flow, 10301 (void *)&cmd_flow_director_flow_type, 10302 (void *)&cmd_flow_director_drop, 10303 (void *)&cmd_flow_director_queue, 10304 (void *)&cmd_flow_director_queue_id, 10305 (void *)&cmd_flow_director_fd_id, 10306 (void *)&cmd_flow_director_fd_id_value, 10307 (void *)&cmd_flow_director_packet, 10308 (void *)&cmd_flow_director_filepath, 10309 NULL, 10310 }, 10311 }; 10312 10313 #endif /* RTE_NET_I40E */ 10314 10315 /* *** deal with flow director mask *** */ 10316 struct cmd_flow_director_mask_result { 10317 cmdline_fixed_string_t flow_director_mask; 10318 portid_t port_id; 10319 cmdline_fixed_string_t mode; 10320 cmdline_fixed_string_t mode_value; 10321 cmdline_fixed_string_t vlan; 10322 uint16_t vlan_mask; 10323 cmdline_fixed_string_t src_mask; 10324 cmdline_ipaddr_t ipv4_src; 10325 cmdline_ipaddr_t ipv6_src; 10326 uint16_t port_src; 10327 cmdline_fixed_string_t dst_mask; 10328 cmdline_ipaddr_t ipv4_dst; 10329 cmdline_ipaddr_t ipv6_dst; 10330 uint16_t port_dst; 10331 cmdline_fixed_string_t mac; 10332 uint8_t mac_addr_byte_mask; 10333 cmdline_fixed_string_t tunnel_id; 10334 uint32_t tunnel_id_mask; 10335 cmdline_fixed_string_t tunnel_type; 10336 uint8_t tunnel_type_mask; 10337 }; 10338 10339 static void 10340 cmd_flow_director_mask_parsed(void *parsed_result, 10341 __rte_unused struct cmdline *cl, 10342 __rte_unused void *data) 10343 { 10344 struct cmd_flow_director_mask_result *res = parsed_result; 10345 struct rte_eth_fdir_masks *mask; 10346 struct rte_port *port; 10347 10348 port = &ports[res->port_id]; 10349 /** Check if the port is not started **/ 10350 if (port->port_status != RTE_PORT_STOPPED) { 10351 printf("Please stop port %d first\n", res->port_id); 10352 return; 10353 } 10354 10355 mask = &port->dev_conf.fdir_conf.mask; 10356 10357 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10358 if (strcmp(res->mode_value, "MAC-VLAN")) { 10359 printf("Please set mode to MAC-VLAN.\n"); 10360 return; 10361 } 10362 10363 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10364 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10365 if (strcmp(res->mode_value, "Tunnel")) { 10366 printf("Please set mode to Tunnel.\n"); 10367 return; 10368 } 10369 10370 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10371 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 10372 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 10373 mask->tunnel_type_mask = res->tunnel_type_mask; 10374 } else { 10375 if (strcmp(res->mode_value, "IP")) { 10376 printf("Please set mode to IP.\n"); 10377 return; 10378 } 10379 10380 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10381 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 10382 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 10383 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 10384 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 10385 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 10386 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 10387 } 10388 10389 cmd_reconfig_device_queue(res->port_id, 1, 1); 10390 } 10391 10392 cmdline_parse_token_string_t cmd_flow_director_mask = 10393 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10394 flow_director_mask, "flow_director_mask"); 10395 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 10396 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10397 port_id, RTE_UINT16); 10398 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 10399 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10400 vlan, "vlan"); 10401 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 10402 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10403 vlan_mask, RTE_UINT16); 10404 cmdline_parse_token_string_t cmd_flow_director_mask_src = 10405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10406 src_mask, "src_mask"); 10407 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 10408 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10409 ipv4_src); 10410 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 10411 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10412 ipv6_src); 10413 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 10414 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10415 port_src, RTE_UINT16); 10416 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 10417 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10418 dst_mask, "dst_mask"); 10419 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 10420 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10421 ipv4_dst); 10422 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 10423 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10424 ipv6_dst); 10425 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 10426 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10427 port_dst, RTE_UINT16); 10428 10429 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 10430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10431 mode, "mode"); 10432 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 10433 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10434 mode_value, "IP"); 10435 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 10436 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10437 mode_value, "MAC-VLAN"); 10438 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 10439 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10440 mode_value, "Tunnel"); 10441 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 10442 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10443 mac, "mac"); 10444 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 10445 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10446 mac_addr_byte_mask, RTE_UINT8); 10447 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 10448 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10449 tunnel_type, "tunnel-type"); 10450 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 10451 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10452 tunnel_type_mask, RTE_UINT8); 10453 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 10454 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10455 tunnel_id, "tunnel-id"); 10456 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 10457 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10458 tunnel_id_mask, RTE_UINT32); 10459 10460 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 10461 .f = cmd_flow_director_mask_parsed, 10462 .data = NULL, 10463 .help_str = "flow_director_mask ... : " 10464 "Set IP mode flow director's mask on NIC", 10465 .tokens = { 10466 (void *)&cmd_flow_director_mask, 10467 (void *)&cmd_flow_director_mask_port_id, 10468 (void *)&cmd_flow_director_mask_mode, 10469 (void *)&cmd_flow_director_mask_mode_ip, 10470 (void *)&cmd_flow_director_mask_vlan, 10471 (void *)&cmd_flow_director_mask_vlan_value, 10472 (void *)&cmd_flow_director_mask_src, 10473 (void *)&cmd_flow_director_mask_ipv4_src, 10474 (void *)&cmd_flow_director_mask_ipv6_src, 10475 (void *)&cmd_flow_director_mask_port_src, 10476 (void *)&cmd_flow_director_mask_dst, 10477 (void *)&cmd_flow_director_mask_ipv4_dst, 10478 (void *)&cmd_flow_director_mask_ipv6_dst, 10479 (void *)&cmd_flow_director_mask_port_dst, 10480 NULL, 10481 }, 10482 }; 10483 10484 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 10485 .f = cmd_flow_director_mask_parsed, 10486 .data = NULL, 10487 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 10488 "flow director's mask on NIC", 10489 .tokens = { 10490 (void *)&cmd_flow_director_mask, 10491 (void *)&cmd_flow_director_mask_port_id, 10492 (void *)&cmd_flow_director_mask_mode, 10493 (void *)&cmd_flow_director_mask_mode_mac_vlan, 10494 (void *)&cmd_flow_director_mask_vlan, 10495 (void *)&cmd_flow_director_mask_vlan_value, 10496 NULL, 10497 }, 10498 }; 10499 10500 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 10501 .f = cmd_flow_director_mask_parsed, 10502 .data = NULL, 10503 .help_str = "flow_director_mask ... : Set tunnel mode " 10504 "flow director's mask on NIC", 10505 .tokens = { 10506 (void *)&cmd_flow_director_mask, 10507 (void *)&cmd_flow_director_mask_port_id, 10508 (void *)&cmd_flow_director_mask_mode, 10509 (void *)&cmd_flow_director_mask_mode_tunnel, 10510 (void *)&cmd_flow_director_mask_vlan, 10511 (void *)&cmd_flow_director_mask_vlan_value, 10512 (void *)&cmd_flow_director_mask_mac, 10513 (void *)&cmd_flow_director_mask_mac_value, 10514 (void *)&cmd_flow_director_mask_tunnel_type, 10515 (void *)&cmd_flow_director_mask_tunnel_type_value, 10516 (void *)&cmd_flow_director_mask_tunnel_id, 10517 (void *)&cmd_flow_director_mask_tunnel_id_value, 10518 NULL, 10519 }, 10520 }; 10521 10522 /* *** deal with flow director flexible payload configuration *** */ 10523 struct cmd_flow_director_flexpayload_result { 10524 cmdline_fixed_string_t flow_director_flexpayload; 10525 portid_t port_id; 10526 cmdline_fixed_string_t payload_layer; 10527 cmdline_fixed_string_t payload_cfg; 10528 }; 10529 10530 static inline int 10531 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 10532 { 10533 char s[256]; 10534 const char *p, *p0 = q_arg; 10535 char *end; 10536 unsigned long int_fld; 10537 char *str_fld[max_num]; 10538 int i; 10539 unsigned size; 10540 int ret = -1; 10541 10542 p = strchr(p0, '('); 10543 if (p == NULL) 10544 return -1; 10545 ++p; 10546 p0 = strchr(p, ')'); 10547 if (p0 == NULL) 10548 return -1; 10549 10550 size = p0 - p; 10551 if (size >= sizeof(s)) 10552 return -1; 10553 10554 snprintf(s, sizeof(s), "%.*s", size, p); 10555 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10556 if (ret < 0 || ret > max_num) 10557 return -1; 10558 for (i = 0; i < ret; i++) { 10559 errno = 0; 10560 int_fld = strtoul(str_fld[i], &end, 0); 10561 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 10562 return -1; 10563 offsets[i] = (uint16_t)int_fld; 10564 } 10565 return ret; 10566 } 10567 10568 static void 10569 cmd_flow_director_flxpld_parsed(void *parsed_result, 10570 __rte_unused struct cmdline *cl, 10571 __rte_unused void *data) 10572 { 10573 struct cmd_flow_director_flexpayload_result *res = parsed_result; 10574 struct rte_eth_flex_payload_cfg flex_cfg; 10575 struct rte_port *port; 10576 int ret = 0; 10577 10578 port = &ports[res->port_id]; 10579 /** Check if the port is not started **/ 10580 if (port->port_status != RTE_PORT_STOPPED) { 10581 printf("Please stop port %d first\n", res->port_id); 10582 return; 10583 } 10584 10585 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 10586 10587 if (!strcmp(res->payload_layer, "raw")) 10588 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 10589 else if (!strcmp(res->payload_layer, "l2")) 10590 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 10591 else if (!strcmp(res->payload_layer, "l3")) 10592 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 10593 else if (!strcmp(res->payload_layer, "l4")) 10594 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 10595 10596 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 10597 RTE_ETH_FDIR_MAX_FLEXLEN); 10598 if (ret < 0) { 10599 printf("error: Cannot parse flex payload input.\n"); 10600 return; 10601 } 10602 10603 fdir_set_flex_payload(res->port_id, &flex_cfg); 10604 cmd_reconfig_device_queue(res->port_id, 1, 1); 10605 } 10606 10607 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 10608 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10609 flow_director_flexpayload, 10610 "flow_director_flex_payload"); 10611 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 10612 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10613 port_id, RTE_UINT16); 10614 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 10615 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10616 payload_layer, "raw#l2#l3#l4"); 10617 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 10618 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10619 payload_cfg, NULL); 10620 10621 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 10622 .f = cmd_flow_director_flxpld_parsed, 10623 .data = NULL, 10624 .help_str = "flow_director_flexpayload ... : " 10625 "Set flow director's flex payload on NIC", 10626 .tokens = { 10627 (void *)&cmd_flow_director_flexpayload, 10628 (void *)&cmd_flow_director_flexpayload_port_id, 10629 (void *)&cmd_flow_director_flexpayload_payload_layer, 10630 (void *)&cmd_flow_director_flexpayload_payload_cfg, 10631 NULL, 10632 }, 10633 }; 10634 10635 /* Generic flow interface command. */ 10636 extern cmdline_parse_inst_t cmd_flow; 10637 10638 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 10639 struct cmd_mcast_addr_result { 10640 cmdline_fixed_string_t mcast_addr_cmd; 10641 cmdline_fixed_string_t what; 10642 uint16_t port_num; 10643 struct rte_ether_addr mc_addr; 10644 }; 10645 10646 static void cmd_mcast_addr_parsed(void *parsed_result, 10647 __rte_unused struct cmdline *cl, 10648 __rte_unused void *data) 10649 { 10650 struct cmd_mcast_addr_result *res = parsed_result; 10651 10652 if (!rte_is_multicast_ether_addr(&res->mc_addr)) { 10653 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", 10654 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], 10655 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], 10656 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); 10657 return; 10658 } 10659 if (strcmp(res->what, "add") == 0) 10660 mcast_addr_add(res->port_num, &res->mc_addr); 10661 else 10662 mcast_addr_remove(res->port_num, &res->mc_addr); 10663 } 10664 10665 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 10666 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 10667 mcast_addr_cmd, "mcast_addr"); 10668 cmdline_parse_token_string_t cmd_mcast_addr_what = 10669 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 10670 "add#remove"); 10671 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 10672 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, 10673 RTE_UINT16); 10674 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 10675 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 10676 10677 cmdline_parse_inst_t cmd_mcast_addr = { 10678 .f = cmd_mcast_addr_parsed, 10679 .data = (void *)0, 10680 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 10681 "Add/Remove multicast MAC address on port_id", 10682 .tokens = { 10683 (void *)&cmd_mcast_addr_cmd, 10684 (void *)&cmd_mcast_addr_what, 10685 (void *)&cmd_mcast_addr_portnum, 10686 (void *)&cmd_mcast_addr_addr, 10687 NULL, 10688 }, 10689 }; 10690 10691 /* vf vlan anti spoof configuration */ 10692 10693 /* Common result structure for vf vlan anti spoof */ 10694 struct cmd_vf_vlan_anti_spoof_result { 10695 cmdline_fixed_string_t set; 10696 cmdline_fixed_string_t vf; 10697 cmdline_fixed_string_t vlan; 10698 cmdline_fixed_string_t antispoof; 10699 portid_t port_id; 10700 uint32_t vf_id; 10701 cmdline_fixed_string_t on_off; 10702 }; 10703 10704 /* Common CLI fields for vf vlan anti spoof enable disable */ 10705 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 10706 TOKEN_STRING_INITIALIZER 10707 (struct cmd_vf_vlan_anti_spoof_result, 10708 set, "set"); 10709 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 10710 TOKEN_STRING_INITIALIZER 10711 (struct cmd_vf_vlan_anti_spoof_result, 10712 vf, "vf"); 10713 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 10714 TOKEN_STRING_INITIALIZER 10715 (struct cmd_vf_vlan_anti_spoof_result, 10716 vlan, "vlan"); 10717 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 10718 TOKEN_STRING_INITIALIZER 10719 (struct cmd_vf_vlan_anti_spoof_result, 10720 antispoof, "antispoof"); 10721 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 10722 TOKEN_NUM_INITIALIZER 10723 (struct cmd_vf_vlan_anti_spoof_result, 10724 port_id, RTE_UINT16); 10725 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 10726 TOKEN_NUM_INITIALIZER 10727 (struct cmd_vf_vlan_anti_spoof_result, 10728 vf_id, RTE_UINT32); 10729 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 10730 TOKEN_STRING_INITIALIZER 10731 (struct cmd_vf_vlan_anti_spoof_result, 10732 on_off, "on#off"); 10733 10734 static void 10735 cmd_set_vf_vlan_anti_spoof_parsed( 10736 void *parsed_result, 10737 __rte_unused struct cmdline *cl, 10738 __rte_unused void *data) 10739 { 10740 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 10741 int ret = -ENOTSUP; 10742 10743 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 10744 10745 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10746 return; 10747 10748 #ifdef RTE_NET_IXGBE 10749 if (ret == -ENOTSUP) 10750 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 10751 res->vf_id, is_on); 10752 #endif 10753 #ifdef RTE_NET_I40E 10754 if (ret == -ENOTSUP) 10755 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 10756 res->vf_id, is_on); 10757 #endif 10758 #ifdef RTE_NET_BNXT 10759 if (ret == -ENOTSUP) 10760 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 10761 res->vf_id, is_on); 10762 #endif 10763 10764 switch (ret) { 10765 case 0: 10766 break; 10767 case -EINVAL: 10768 printf("invalid vf_id %d\n", res->vf_id); 10769 break; 10770 case -ENODEV: 10771 printf("invalid port_id %d\n", res->port_id); 10772 break; 10773 case -ENOTSUP: 10774 printf("function not implemented\n"); 10775 break; 10776 default: 10777 printf("programming error: (%s)\n", strerror(-ret)); 10778 } 10779 } 10780 10781 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 10782 .f = cmd_set_vf_vlan_anti_spoof_parsed, 10783 .data = NULL, 10784 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 10785 .tokens = { 10786 (void *)&cmd_vf_vlan_anti_spoof_set, 10787 (void *)&cmd_vf_vlan_anti_spoof_vf, 10788 (void *)&cmd_vf_vlan_anti_spoof_vlan, 10789 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 10790 (void *)&cmd_vf_vlan_anti_spoof_port_id, 10791 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 10792 (void *)&cmd_vf_vlan_anti_spoof_on_off, 10793 NULL, 10794 }, 10795 }; 10796 10797 /* vf mac anti spoof configuration */ 10798 10799 /* Common result structure for vf mac anti spoof */ 10800 struct cmd_vf_mac_anti_spoof_result { 10801 cmdline_fixed_string_t set; 10802 cmdline_fixed_string_t vf; 10803 cmdline_fixed_string_t mac; 10804 cmdline_fixed_string_t antispoof; 10805 portid_t port_id; 10806 uint32_t vf_id; 10807 cmdline_fixed_string_t on_off; 10808 }; 10809 10810 /* Common CLI fields for vf mac anti spoof enable disable */ 10811 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 10812 TOKEN_STRING_INITIALIZER 10813 (struct cmd_vf_mac_anti_spoof_result, 10814 set, "set"); 10815 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 10816 TOKEN_STRING_INITIALIZER 10817 (struct cmd_vf_mac_anti_spoof_result, 10818 vf, "vf"); 10819 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 10820 TOKEN_STRING_INITIALIZER 10821 (struct cmd_vf_mac_anti_spoof_result, 10822 mac, "mac"); 10823 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 10824 TOKEN_STRING_INITIALIZER 10825 (struct cmd_vf_mac_anti_spoof_result, 10826 antispoof, "antispoof"); 10827 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 10828 TOKEN_NUM_INITIALIZER 10829 (struct cmd_vf_mac_anti_spoof_result, 10830 port_id, RTE_UINT16); 10831 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 10832 TOKEN_NUM_INITIALIZER 10833 (struct cmd_vf_mac_anti_spoof_result, 10834 vf_id, RTE_UINT32); 10835 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 10836 TOKEN_STRING_INITIALIZER 10837 (struct cmd_vf_mac_anti_spoof_result, 10838 on_off, "on#off"); 10839 10840 static void 10841 cmd_set_vf_mac_anti_spoof_parsed( 10842 void *parsed_result, 10843 __rte_unused struct cmdline *cl, 10844 __rte_unused void *data) 10845 { 10846 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 10847 int ret = -ENOTSUP; 10848 10849 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 10850 10851 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10852 return; 10853 10854 #ifdef RTE_NET_IXGBE 10855 if (ret == -ENOTSUP) 10856 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 10857 res->vf_id, is_on); 10858 #endif 10859 #ifdef RTE_NET_I40E 10860 if (ret == -ENOTSUP) 10861 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 10862 res->vf_id, is_on); 10863 #endif 10864 #ifdef RTE_NET_BNXT 10865 if (ret == -ENOTSUP) 10866 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 10867 res->vf_id, is_on); 10868 #endif 10869 10870 switch (ret) { 10871 case 0: 10872 break; 10873 case -EINVAL: 10874 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 10875 break; 10876 case -ENODEV: 10877 printf("invalid port_id %d\n", res->port_id); 10878 break; 10879 case -ENOTSUP: 10880 printf("function not implemented\n"); 10881 break; 10882 default: 10883 printf("programming error: (%s)\n", strerror(-ret)); 10884 } 10885 } 10886 10887 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 10888 .f = cmd_set_vf_mac_anti_spoof_parsed, 10889 .data = NULL, 10890 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 10891 .tokens = { 10892 (void *)&cmd_vf_mac_anti_spoof_set, 10893 (void *)&cmd_vf_mac_anti_spoof_vf, 10894 (void *)&cmd_vf_mac_anti_spoof_mac, 10895 (void *)&cmd_vf_mac_anti_spoof_antispoof, 10896 (void *)&cmd_vf_mac_anti_spoof_port_id, 10897 (void *)&cmd_vf_mac_anti_spoof_vf_id, 10898 (void *)&cmd_vf_mac_anti_spoof_on_off, 10899 NULL, 10900 }, 10901 }; 10902 10903 /* vf vlan strip queue configuration */ 10904 10905 /* Common result structure for vf mac anti spoof */ 10906 struct cmd_vf_vlan_stripq_result { 10907 cmdline_fixed_string_t set; 10908 cmdline_fixed_string_t vf; 10909 cmdline_fixed_string_t vlan; 10910 cmdline_fixed_string_t stripq; 10911 portid_t port_id; 10912 uint16_t vf_id; 10913 cmdline_fixed_string_t on_off; 10914 }; 10915 10916 /* Common CLI fields for vf vlan strip enable disable */ 10917 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 10918 TOKEN_STRING_INITIALIZER 10919 (struct cmd_vf_vlan_stripq_result, 10920 set, "set"); 10921 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 10922 TOKEN_STRING_INITIALIZER 10923 (struct cmd_vf_vlan_stripq_result, 10924 vf, "vf"); 10925 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 10926 TOKEN_STRING_INITIALIZER 10927 (struct cmd_vf_vlan_stripq_result, 10928 vlan, "vlan"); 10929 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 10930 TOKEN_STRING_INITIALIZER 10931 (struct cmd_vf_vlan_stripq_result, 10932 stripq, "stripq"); 10933 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 10934 TOKEN_NUM_INITIALIZER 10935 (struct cmd_vf_vlan_stripq_result, 10936 port_id, RTE_UINT16); 10937 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 10938 TOKEN_NUM_INITIALIZER 10939 (struct cmd_vf_vlan_stripq_result, 10940 vf_id, RTE_UINT16); 10941 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 10942 TOKEN_STRING_INITIALIZER 10943 (struct cmd_vf_vlan_stripq_result, 10944 on_off, "on#off"); 10945 10946 static void 10947 cmd_set_vf_vlan_stripq_parsed( 10948 void *parsed_result, 10949 __rte_unused struct cmdline *cl, 10950 __rte_unused void *data) 10951 { 10952 struct cmd_vf_vlan_stripq_result *res = parsed_result; 10953 int ret = -ENOTSUP; 10954 10955 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 10956 10957 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10958 return; 10959 10960 #ifdef RTE_NET_IXGBE 10961 if (ret == -ENOTSUP) 10962 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 10963 res->vf_id, is_on); 10964 #endif 10965 #ifdef RTE_NET_I40E 10966 if (ret == -ENOTSUP) 10967 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 10968 res->vf_id, is_on); 10969 #endif 10970 #ifdef RTE_NET_BNXT 10971 if (ret == -ENOTSUP) 10972 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 10973 res->vf_id, is_on); 10974 #endif 10975 10976 switch (ret) { 10977 case 0: 10978 break; 10979 case -EINVAL: 10980 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 10981 break; 10982 case -ENODEV: 10983 printf("invalid port_id %d\n", res->port_id); 10984 break; 10985 case -ENOTSUP: 10986 printf("function not implemented\n"); 10987 break; 10988 default: 10989 printf("programming error: (%s)\n", strerror(-ret)); 10990 } 10991 } 10992 10993 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 10994 .f = cmd_set_vf_vlan_stripq_parsed, 10995 .data = NULL, 10996 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 10997 .tokens = { 10998 (void *)&cmd_vf_vlan_stripq_set, 10999 (void *)&cmd_vf_vlan_stripq_vf, 11000 (void *)&cmd_vf_vlan_stripq_vlan, 11001 (void *)&cmd_vf_vlan_stripq_stripq, 11002 (void *)&cmd_vf_vlan_stripq_port_id, 11003 (void *)&cmd_vf_vlan_stripq_vf_id, 11004 (void *)&cmd_vf_vlan_stripq_on_off, 11005 NULL, 11006 }, 11007 }; 11008 11009 /* vf vlan insert configuration */ 11010 11011 /* Common result structure for vf vlan insert */ 11012 struct cmd_vf_vlan_insert_result { 11013 cmdline_fixed_string_t set; 11014 cmdline_fixed_string_t vf; 11015 cmdline_fixed_string_t vlan; 11016 cmdline_fixed_string_t insert; 11017 portid_t port_id; 11018 uint16_t vf_id; 11019 uint16_t vlan_id; 11020 }; 11021 11022 /* Common CLI fields for vf vlan insert enable disable */ 11023 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 11024 TOKEN_STRING_INITIALIZER 11025 (struct cmd_vf_vlan_insert_result, 11026 set, "set"); 11027 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 11028 TOKEN_STRING_INITIALIZER 11029 (struct cmd_vf_vlan_insert_result, 11030 vf, "vf"); 11031 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 11032 TOKEN_STRING_INITIALIZER 11033 (struct cmd_vf_vlan_insert_result, 11034 vlan, "vlan"); 11035 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 11036 TOKEN_STRING_INITIALIZER 11037 (struct cmd_vf_vlan_insert_result, 11038 insert, "insert"); 11039 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 11040 TOKEN_NUM_INITIALIZER 11041 (struct cmd_vf_vlan_insert_result, 11042 port_id, RTE_UINT16); 11043 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 11044 TOKEN_NUM_INITIALIZER 11045 (struct cmd_vf_vlan_insert_result, 11046 vf_id, RTE_UINT16); 11047 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 11048 TOKEN_NUM_INITIALIZER 11049 (struct cmd_vf_vlan_insert_result, 11050 vlan_id, RTE_UINT16); 11051 11052 static void 11053 cmd_set_vf_vlan_insert_parsed( 11054 void *parsed_result, 11055 __rte_unused struct cmdline *cl, 11056 __rte_unused void *data) 11057 { 11058 struct cmd_vf_vlan_insert_result *res = parsed_result; 11059 int ret = -ENOTSUP; 11060 11061 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11062 return; 11063 11064 #ifdef RTE_NET_IXGBE 11065 if (ret == -ENOTSUP) 11066 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 11067 res->vlan_id); 11068 #endif 11069 #ifdef RTE_NET_I40E 11070 if (ret == -ENOTSUP) 11071 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 11072 res->vlan_id); 11073 #endif 11074 #ifdef RTE_NET_BNXT 11075 if (ret == -ENOTSUP) 11076 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 11077 res->vlan_id); 11078 #endif 11079 11080 switch (ret) { 11081 case 0: 11082 break; 11083 case -EINVAL: 11084 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); 11085 break; 11086 case -ENODEV: 11087 printf("invalid port_id %d\n", res->port_id); 11088 break; 11089 case -ENOTSUP: 11090 printf("function not implemented\n"); 11091 break; 11092 default: 11093 printf("programming error: (%s)\n", strerror(-ret)); 11094 } 11095 } 11096 11097 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 11098 .f = cmd_set_vf_vlan_insert_parsed, 11099 .data = NULL, 11100 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 11101 .tokens = { 11102 (void *)&cmd_vf_vlan_insert_set, 11103 (void *)&cmd_vf_vlan_insert_vf, 11104 (void *)&cmd_vf_vlan_insert_vlan, 11105 (void *)&cmd_vf_vlan_insert_insert, 11106 (void *)&cmd_vf_vlan_insert_port_id, 11107 (void *)&cmd_vf_vlan_insert_vf_id, 11108 (void *)&cmd_vf_vlan_insert_vlan_id, 11109 NULL, 11110 }, 11111 }; 11112 11113 /* tx loopback configuration */ 11114 11115 /* Common result structure for tx loopback */ 11116 struct cmd_tx_loopback_result { 11117 cmdline_fixed_string_t set; 11118 cmdline_fixed_string_t tx; 11119 cmdline_fixed_string_t loopback; 11120 portid_t port_id; 11121 cmdline_fixed_string_t on_off; 11122 }; 11123 11124 /* Common CLI fields for tx loopback enable disable */ 11125 cmdline_parse_token_string_t cmd_tx_loopback_set = 11126 TOKEN_STRING_INITIALIZER 11127 (struct cmd_tx_loopback_result, 11128 set, "set"); 11129 cmdline_parse_token_string_t cmd_tx_loopback_tx = 11130 TOKEN_STRING_INITIALIZER 11131 (struct cmd_tx_loopback_result, 11132 tx, "tx"); 11133 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 11134 TOKEN_STRING_INITIALIZER 11135 (struct cmd_tx_loopback_result, 11136 loopback, "loopback"); 11137 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 11138 TOKEN_NUM_INITIALIZER 11139 (struct cmd_tx_loopback_result, 11140 port_id, RTE_UINT16); 11141 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 11142 TOKEN_STRING_INITIALIZER 11143 (struct cmd_tx_loopback_result, 11144 on_off, "on#off"); 11145 11146 static void 11147 cmd_set_tx_loopback_parsed( 11148 void *parsed_result, 11149 __rte_unused struct cmdline *cl, 11150 __rte_unused void *data) 11151 { 11152 struct cmd_tx_loopback_result *res = parsed_result; 11153 int ret = -ENOTSUP; 11154 11155 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11156 11157 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11158 return; 11159 11160 #ifdef RTE_NET_IXGBE 11161 if (ret == -ENOTSUP) 11162 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 11163 #endif 11164 #ifdef RTE_NET_I40E 11165 if (ret == -ENOTSUP) 11166 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 11167 #endif 11168 #ifdef RTE_NET_BNXT 11169 if (ret == -ENOTSUP) 11170 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 11171 #endif 11172 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA 11173 if (ret == -ENOTSUP) 11174 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 11175 #endif 11176 11177 switch (ret) { 11178 case 0: 11179 break; 11180 case -EINVAL: 11181 printf("invalid is_on %d\n", is_on); 11182 break; 11183 case -ENODEV: 11184 printf("invalid port_id %d\n", res->port_id); 11185 break; 11186 case -ENOTSUP: 11187 printf("function not implemented\n"); 11188 break; 11189 default: 11190 printf("programming error: (%s)\n", strerror(-ret)); 11191 } 11192 } 11193 11194 cmdline_parse_inst_t cmd_set_tx_loopback = { 11195 .f = cmd_set_tx_loopback_parsed, 11196 .data = NULL, 11197 .help_str = "set tx loopback <port_id> on|off", 11198 .tokens = { 11199 (void *)&cmd_tx_loopback_set, 11200 (void *)&cmd_tx_loopback_tx, 11201 (void *)&cmd_tx_loopback_loopback, 11202 (void *)&cmd_tx_loopback_port_id, 11203 (void *)&cmd_tx_loopback_on_off, 11204 NULL, 11205 }, 11206 }; 11207 11208 /* all queues drop enable configuration */ 11209 11210 /* Common result structure for all queues drop enable */ 11211 struct cmd_all_queues_drop_en_result { 11212 cmdline_fixed_string_t set; 11213 cmdline_fixed_string_t all; 11214 cmdline_fixed_string_t queues; 11215 cmdline_fixed_string_t drop; 11216 portid_t port_id; 11217 cmdline_fixed_string_t on_off; 11218 }; 11219 11220 /* Common CLI fields for tx loopback enable disable */ 11221 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 11222 TOKEN_STRING_INITIALIZER 11223 (struct cmd_all_queues_drop_en_result, 11224 set, "set"); 11225 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 11226 TOKEN_STRING_INITIALIZER 11227 (struct cmd_all_queues_drop_en_result, 11228 all, "all"); 11229 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 11230 TOKEN_STRING_INITIALIZER 11231 (struct cmd_all_queues_drop_en_result, 11232 queues, "queues"); 11233 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 11234 TOKEN_STRING_INITIALIZER 11235 (struct cmd_all_queues_drop_en_result, 11236 drop, "drop"); 11237 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 11238 TOKEN_NUM_INITIALIZER 11239 (struct cmd_all_queues_drop_en_result, 11240 port_id, RTE_UINT16); 11241 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 11242 TOKEN_STRING_INITIALIZER 11243 (struct cmd_all_queues_drop_en_result, 11244 on_off, "on#off"); 11245 11246 static void 11247 cmd_set_all_queues_drop_en_parsed( 11248 void *parsed_result, 11249 __rte_unused struct cmdline *cl, 11250 __rte_unused void *data) 11251 { 11252 struct cmd_all_queues_drop_en_result *res = parsed_result; 11253 int ret = -ENOTSUP; 11254 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11255 11256 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11257 return; 11258 11259 #ifdef RTE_NET_IXGBE 11260 if (ret == -ENOTSUP) 11261 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 11262 #endif 11263 #ifdef RTE_NET_BNXT 11264 if (ret == -ENOTSUP) 11265 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 11266 #endif 11267 switch (ret) { 11268 case 0: 11269 break; 11270 case -EINVAL: 11271 printf("invalid is_on %d\n", is_on); 11272 break; 11273 case -ENODEV: 11274 printf("invalid port_id %d\n", res->port_id); 11275 break; 11276 case -ENOTSUP: 11277 printf("function not implemented\n"); 11278 break; 11279 default: 11280 printf("programming error: (%s)\n", strerror(-ret)); 11281 } 11282 } 11283 11284 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 11285 .f = cmd_set_all_queues_drop_en_parsed, 11286 .data = NULL, 11287 .help_str = "set all queues drop <port_id> on|off", 11288 .tokens = { 11289 (void *)&cmd_all_queues_drop_en_set, 11290 (void *)&cmd_all_queues_drop_en_all, 11291 (void *)&cmd_all_queues_drop_en_queues, 11292 (void *)&cmd_all_queues_drop_en_drop, 11293 (void *)&cmd_all_queues_drop_en_port_id, 11294 (void *)&cmd_all_queues_drop_en_on_off, 11295 NULL, 11296 }, 11297 }; 11298 11299 /* vf split drop enable configuration */ 11300 11301 /* Common result structure for vf split drop enable */ 11302 struct cmd_vf_split_drop_en_result { 11303 cmdline_fixed_string_t set; 11304 cmdline_fixed_string_t vf; 11305 cmdline_fixed_string_t split; 11306 cmdline_fixed_string_t drop; 11307 portid_t port_id; 11308 uint16_t vf_id; 11309 cmdline_fixed_string_t on_off; 11310 }; 11311 11312 /* Common CLI fields for vf split drop enable disable */ 11313 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 11314 TOKEN_STRING_INITIALIZER 11315 (struct cmd_vf_split_drop_en_result, 11316 set, "set"); 11317 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 11318 TOKEN_STRING_INITIALIZER 11319 (struct cmd_vf_split_drop_en_result, 11320 vf, "vf"); 11321 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 11322 TOKEN_STRING_INITIALIZER 11323 (struct cmd_vf_split_drop_en_result, 11324 split, "split"); 11325 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 11326 TOKEN_STRING_INITIALIZER 11327 (struct cmd_vf_split_drop_en_result, 11328 drop, "drop"); 11329 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 11330 TOKEN_NUM_INITIALIZER 11331 (struct cmd_vf_split_drop_en_result, 11332 port_id, RTE_UINT16); 11333 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 11334 TOKEN_NUM_INITIALIZER 11335 (struct cmd_vf_split_drop_en_result, 11336 vf_id, RTE_UINT16); 11337 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 11338 TOKEN_STRING_INITIALIZER 11339 (struct cmd_vf_split_drop_en_result, 11340 on_off, "on#off"); 11341 11342 static void 11343 cmd_set_vf_split_drop_en_parsed( 11344 void *parsed_result, 11345 __rte_unused struct cmdline *cl, 11346 __rte_unused void *data) 11347 { 11348 struct cmd_vf_split_drop_en_result *res = parsed_result; 11349 int ret = -ENOTSUP; 11350 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11351 11352 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11353 return; 11354 11355 #ifdef RTE_NET_IXGBE 11356 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 11357 is_on); 11358 #endif 11359 switch (ret) { 11360 case 0: 11361 break; 11362 case -EINVAL: 11363 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 11364 break; 11365 case -ENODEV: 11366 printf("invalid port_id %d\n", res->port_id); 11367 break; 11368 case -ENOTSUP: 11369 printf("not supported on port %d\n", res->port_id); 11370 break; 11371 default: 11372 printf("programming error: (%s)\n", strerror(-ret)); 11373 } 11374 } 11375 11376 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 11377 .f = cmd_set_vf_split_drop_en_parsed, 11378 .data = NULL, 11379 .help_str = "set vf split drop <port_id> <vf_id> on|off", 11380 .tokens = { 11381 (void *)&cmd_vf_split_drop_en_set, 11382 (void *)&cmd_vf_split_drop_en_vf, 11383 (void *)&cmd_vf_split_drop_en_split, 11384 (void *)&cmd_vf_split_drop_en_drop, 11385 (void *)&cmd_vf_split_drop_en_port_id, 11386 (void *)&cmd_vf_split_drop_en_vf_id, 11387 (void *)&cmd_vf_split_drop_en_on_off, 11388 NULL, 11389 }, 11390 }; 11391 11392 /* vf mac address configuration */ 11393 11394 /* Common result structure for vf mac address */ 11395 struct cmd_set_vf_mac_addr_result { 11396 cmdline_fixed_string_t set; 11397 cmdline_fixed_string_t vf; 11398 cmdline_fixed_string_t mac; 11399 cmdline_fixed_string_t addr; 11400 portid_t port_id; 11401 uint16_t vf_id; 11402 struct rte_ether_addr mac_addr; 11403 11404 }; 11405 11406 /* Common CLI fields for vf split drop enable disable */ 11407 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 11408 TOKEN_STRING_INITIALIZER 11409 (struct cmd_set_vf_mac_addr_result, 11410 set, "set"); 11411 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 11412 TOKEN_STRING_INITIALIZER 11413 (struct cmd_set_vf_mac_addr_result, 11414 vf, "vf"); 11415 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 11416 TOKEN_STRING_INITIALIZER 11417 (struct cmd_set_vf_mac_addr_result, 11418 mac, "mac"); 11419 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 11420 TOKEN_STRING_INITIALIZER 11421 (struct cmd_set_vf_mac_addr_result, 11422 addr, "addr"); 11423 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 11424 TOKEN_NUM_INITIALIZER 11425 (struct cmd_set_vf_mac_addr_result, 11426 port_id, RTE_UINT16); 11427 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 11428 TOKEN_NUM_INITIALIZER 11429 (struct cmd_set_vf_mac_addr_result, 11430 vf_id, RTE_UINT16); 11431 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 11432 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 11433 mac_addr); 11434 11435 static void 11436 cmd_set_vf_mac_addr_parsed( 11437 void *parsed_result, 11438 __rte_unused struct cmdline *cl, 11439 __rte_unused void *data) 11440 { 11441 struct cmd_set_vf_mac_addr_result *res = parsed_result; 11442 int ret = -ENOTSUP; 11443 11444 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11445 return; 11446 11447 #ifdef RTE_NET_IXGBE 11448 if (ret == -ENOTSUP) 11449 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 11450 &res->mac_addr); 11451 #endif 11452 #ifdef RTE_NET_I40E 11453 if (ret == -ENOTSUP) 11454 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 11455 &res->mac_addr); 11456 #endif 11457 #ifdef RTE_NET_BNXT 11458 if (ret == -ENOTSUP) 11459 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 11460 &res->mac_addr); 11461 #endif 11462 11463 switch (ret) { 11464 case 0: 11465 break; 11466 case -EINVAL: 11467 printf("invalid vf_id %d or mac_addr\n", res->vf_id); 11468 break; 11469 case -ENODEV: 11470 printf("invalid port_id %d\n", res->port_id); 11471 break; 11472 case -ENOTSUP: 11473 printf("function not implemented\n"); 11474 break; 11475 default: 11476 printf("programming error: (%s)\n", strerror(-ret)); 11477 } 11478 } 11479 11480 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 11481 .f = cmd_set_vf_mac_addr_parsed, 11482 .data = NULL, 11483 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 11484 .tokens = { 11485 (void *)&cmd_set_vf_mac_addr_set, 11486 (void *)&cmd_set_vf_mac_addr_vf, 11487 (void *)&cmd_set_vf_mac_addr_mac, 11488 (void *)&cmd_set_vf_mac_addr_addr, 11489 (void *)&cmd_set_vf_mac_addr_port_id, 11490 (void *)&cmd_set_vf_mac_addr_vf_id, 11491 (void *)&cmd_set_vf_mac_addr_mac_addr, 11492 NULL, 11493 }, 11494 }; 11495 11496 /* MACsec configuration */ 11497 11498 /* Common result structure for MACsec offload enable */ 11499 struct cmd_macsec_offload_on_result { 11500 cmdline_fixed_string_t set; 11501 cmdline_fixed_string_t macsec; 11502 cmdline_fixed_string_t offload; 11503 portid_t port_id; 11504 cmdline_fixed_string_t on; 11505 cmdline_fixed_string_t encrypt; 11506 cmdline_fixed_string_t en_on_off; 11507 cmdline_fixed_string_t replay_protect; 11508 cmdline_fixed_string_t rp_on_off; 11509 }; 11510 11511 /* Common CLI fields for MACsec offload disable */ 11512 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 11513 TOKEN_STRING_INITIALIZER 11514 (struct cmd_macsec_offload_on_result, 11515 set, "set"); 11516 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 11517 TOKEN_STRING_INITIALIZER 11518 (struct cmd_macsec_offload_on_result, 11519 macsec, "macsec"); 11520 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 11521 TOKEN_STRING_INITIALIZER 11522 (struct cmd_macsec_offload_on_result, 11523 offload, "offload"); 11524 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 11525 TOKEN_NUM_INITIALIZER 11526 (struct cmd_macsec_offload_on_result, 11527 port_id, RTE_UINT16); 11528 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 11529 TOKEN_STRING_INITIALIZER 11530 (struct cmd_macsec_offload_on_result, 11531 on, "on"); 11532 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 11533 TOKEN_STRING_INITIALIZER 11534 (struct cmd_macsec_offload_on_result, 11535 encrypt, "encrypt"); 11536 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 11537 TOKEN_STRING_INITIALIZER 11538 (struct cmd_macsec_offload_on_result, 11539 en_on_off, "on#off"); 11540 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 11541 TOKEN_STRING_INITIALIZER 11542 (struct cmd_macsec_offload_on_result, 11543 replay_protect, "replay-protect"); 11544 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 11545 TOKEN_STRING_INITIALIZER 11546 (struct cmd_macsec_offload_on_result, 11547 rp_on_off, "on#off"); 11548 11549 static void 11550 cmd_set_macsec_offload_on_parsed( 11551 void *parsed_result, 11552 __rte_unused struct cmdline *cl, 11553 __rte_unused void *data) 11554 { 11555 struct cmd_macsec_offload_on_result *res = parsed_result; 11556 int ret = -ENOTSUP; 11557 portid_t port_id = res->port_id; 11558 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 11559 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 11560 struct rte_eth_dev_info dev_info; 11561 11562 if (port_id_is_invalid(port_id, ENABLED_WARN)) 11563 return; 11564 if (!port_is_stopped(port_id)) { 11565 printf("Please stop port %d first\n", port_id); 11566 return; 11567 } 11568 11569 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11570 if (ret != 0) 11571 return; 11572 11573 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 11574 #ifdef RTE_NET_IXGBE 11575 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 11576 #endif 11577 } 11578 RTE_SET_USED(en); 11579 RTE_SET_USED(rp); 11580 11581 switch (ret) { 11582 case 0: 11583 ports[port_id].dev_conf.txmode.offloads |= 11584 DEV_TX_OFFLOAD_MACSEC_INSERT; 11585 cmd_reconfig_device_queue(port_id, 1, 1); 11586 break; 11587 case -ENODEV: 11588 printf("invalid port_id %d\n", port_id); 11589 break; 11590 case -ENOTSUP: 11591 printf("not supported on port %d\n", port_id); 11592 break; 11593 default: 11594 printf("programming error: (%s)\n", strerror(-ret)); 11595 } 11596 } 11597 11598 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 11599 .f = cmd_set_macsec_offload_on_parsed, 11600 .data = NULL, 11601 .help_str = "set macsec offload <port_id> on " 11602 "encrypt on|off replay-protect on|off", 11603 .tokens = { 11604 (void *)&cmd_macsec_offload_on_set, 11605 (void *)&cmd_macsec_offload_on_macsec, 11606 (void *)&cmd_macsec_offload_on_offload, 11607 (void *)&cmd_macsec_offload_on_port_id, 11608 (void *)&cmd_macsec_offload_on_on, 11609 (void *)&cmd_macsec_offload_on_encrypt, 11610 (void *)&cmd_macsec_offload_on_en_on_off, 11611 (void *)&cmd_macsec_offload_on_replay_protect, 11612 (void *)&cmd_macsec_offload_on_rp_on_off, 11613 NULL, 11614 }, 11615 }; 11616 11617 /* Common result structure for MACsec offload disable */ 11618 struct cmd_macsec_offload_off_result { 11619 cmdline_fixed_string_t set; 11620 cmdline_fixed_string_t macsec; 11621 cmdline_fixed_string_t offload; 11622 portid_t port_id; 11623 cmdline_fixed_string_t off; 11624 }; 11625 11626 /* Common CLI fields for MACsec offload disable */ 11627 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 11628 TOKEN_STRING_INITIALIZER 11629 (struct cmd_macsec_offload_off_result, 11630 set, "set"); 11631 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 11632 TOKEN_STRING_INITIALIZER 11633 (struct cmd_macsec_offload_off_result, 11634 macsec, "macsec"); 11635 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 11636 TOKEN_STRING_INITIALIZER 11637 (struct cmd_macsec_offload_off_result, 11638 offload, "offload"); 11639 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 11640 TOKEN_NUM_INITIALIZER 11641 (struct cmd_macsec_offload_off_result, 11642 port_id, RTE_UINT16); 11643 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 11644 TOKEN_STRING_INITIALIZER 11645 (struct cmd_macsec_offload_off_result, 11646 off, "off"); 11647 11648 static void 11649 cmd_set_macsec_offload_off_parsed( 11650 void *parsed_result, 11651 __rte_unused struct cmdline *cl, 11652 __rte_unused void *data) 11653 { 11654 struct cmd_macsec_offload_off_result *res = parsed_result; 11655 int ret = -ENOTSUP; 11656 struct rte_eth_dev_info dev_info; 11657 portid_t port_id = res->port_id; 11658 11659 if (port_id_is_invalid(port_id, ENABLED_WARN)) 11660 return; 11661 if (!port_is_stopped(port_id)) { 11662 printf("Please stop port %d first\n", port_id); 11663 return; 11664 } 11665 11666 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11667 if (ret != 0) 11668 return; 11669 11670 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 11671 #ifdef RTE_NET_IXGBE 11672 ret = rte_pmd_ixgbe_macsec_disable(port_id); 11673 #endif 11674 } 11675 switch (ret) { 11676 case 0: 11677 ports[port_id].dev_conf.txmode.offloads &= 11678 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 11679 cmd_reconfig_device_queue(port_id, 1, 1); 11680 break; 11681 case -ENODEV: 11682 printf("invalid port_id %d\n", port_id); 11683 break; 11684 case -ENOTSUP: 11685 printf("not supported on port %d\n", port_id); 11686 break; 11687 default: 11688 printf("programming error: (%s)\n", strerror(-ret)); 11689 } 11690 } 11691 11692 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 11693 .f = cmd_set_macsec_offload_off_parsed, 11694 .data = NULL, 11695 .help_str = "set macsec offload <port_id> off", 11696 .tokens = { 11697 (void *)&cmd_macsec_offload_off_set, 11698 (void *)&cmd_macsec_offload_off_macsec, 11699 (void *)&cmd_macsec_offload_off_offload, 11700 (void *)&cmd_macsec_offload_off_port_id, 11701 (void *)&cmd_macsec_offload_off_off, 11702 NULL, 11703 }, 11704 }; 11705 11706 /* Common result structure for MACsec secure connection configure */ 11707 struct cmd_macsec_sc_result { 11708 cmdline_fixed_string_t set; 11709 cmdline_fixed_string_t macsec; 11710 cmdline_fixed_string_t sc; 11711 cmdline_fixed_string_t tx_rx; 11712 portid_t port_id; 11713 struct rte_ether_addr mac; 11714 uint16_t pi; 11715 }; 11716 11717 /* Common CLI fields for MACsec secure connection configure */ 11718 cmdline_parse_token_string_t cmd_macsec_sc_set = 11719 TOKEN_STRING_INITIALIZER 11720 (struct cmd_macsec_sc_result, 11721 set, "set"); 11722 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 11723 TOKEN_STRING_INITIALIZER 11724 (struct cmd_macsec_sc_result, 11725 macsec, "macsec"); 11726 cmdline_parse_token_string_t cmd_macsec_sc_sc = 11727 TOKEN_STRING_INITIALIZER 11728 (struct cmd_macsec_sc_result, 11729 sc, "sc"); 11730 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 11731 TOKEN_STRING_INITIALIZER 11732 (struct cmd_macsec_sc_result, 11733 tx_rx, "tx#rx"); 11734 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 11735 TOKEN_NUM_INITIALIZER 11736 (struct cmd_macsec_sc_result, 11737 port_id, RTE_UINT16); 11738 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 11739 TOKEN_ETHERADDR_INITIALIZER 11740 (struct cmd_macsec_sc_result, 11741 mac); 11742 cmdline_parse_token_num_t cmd_macsec_sc_pi = 11743 TOKEN_NUM_INITIALIZER 11744 (struct cmd_macsec_sc_result, 11745 pi, RTE_UINT16); 11746 11747 static void 11748 cmd_set_macsec_sc_parsed( 11749 void *parsed_result, 11750 __rte_unused struct cmdline *cl, 11751 __rte_unused void *data) 11752 { 11753 struct cmd_macsec_sc_result *res = parsed_result; 11754 int ret = -ENOTSUP; 11755 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 11756 11757 #ifdef RTE_NET_IXGBE 11758 ret = is_tx ? 11759 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 11760 res->mac.addr_bytes) : 11761 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 11762 res->mac.addr_bytes, res->pi); 11763 #endif 11764 RTE_SET_USED(is_tx); 11765 11766 switch (ret) { 11767 case 0: 11768 break; 11769 case -ENODEV: 11770 printf("invalid port_id %d\n", res->port_id); 11771 break; 11772 case -ENOTSUP: 11773 printf("not supported on port %d\n", res->port_id); 11774 break; 11775 default: 11776 printf("programming error: (%s)\n", strerror(-ret)); 11777 } 11778 } 11779 11780 cmdline_parse_inst_t cmd_set_macsec_sc = { 11781 .f = cmd_set_macsec_sc_parsed, 11782 .data = NULL, 11783 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 11784 .tokens = { 11785 (void *)&cmd_macsec_sc_set, 11786 (void *)&cmd_macsec_sc_macsec, 11787 (void *)&cmd_macsec_sc_sc, 11788 (void *)&cmd_macsec_sc_tx_rx, 11789 (void *)&cmd_macsec_sc_port_id, 11790 (void *)&cmd_macsec_sc_mac, 11791 (void *)&cmd_macsec_sc_pi, 11792 NULL, 11793 }, 11794 }; 11795 11796 /* Common result structure for MACsec secure connection configure */ 11797 struct cmd_macsec_sa_result { 11798 cmdline_fixed_string_t set; 11799 cmdline_fixed_string_t macsec; 11800 cmdline_fixed_string_t sa; 11801 cmdline_fixed_string_t tx_rx; 11802 portid_t port_id; 11803 uint8_t idx; 11804 uint8_t an; 11805 uint32_t pn; 11806 cmdline_fixed_string_t key; 11807 }; 11808 11809 /* Common CLI fields for MACsec secure connection configure */ 11810 cmdline_parse_token_string_t cmd_macsec_sa_set = 11811 TOKEN_STRING_INITIALIZER 11812 (struct cmd_macsec_sa_result, 11813 set, "set"); 11814 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 11815 TOKEN_STRING_INITIALIZER 11816 (struct cmd_macsec_sa_result, 11817 macsec, "macsec"); 11818 cmdline_parse_token_string_t cmd_macsec_sa_sa = 11819 TOKEN_STRING_INITIALIZER 11820 (struct cmd_macsec_sa_result, 11821 sa, "sa"); 11822 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 11823 TOKEN_STRING_INITIALIZER 11824 (struct cmd_macsec_sa_result, 11825 tx_rx, "tx#rx"); 11826 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 11827 TOKEN_NUM_INITIALIZER 11828 (struct cmd_macsec_sa_result, 11829 port_id, RTE_UINT16); 11830 cmdline_parse_token_num_t cmd_macsec_sa_idx = 11831 TOKEN_NUM_INITIALIZER 11832 (struct cmd_macsec_sa_result, 11833 idx, RTE_UINT8); 11834 cmdline_parse_token_num_t cmd_macsec_sa_an = 11835 TOKEN_NUM_INITIALIZER 11836 (struct cmd_macsec_sa_result, 11837 an, RTE_UINT8); 11838 cmdline_parse_token_num_t cmd_macsec_sa_pn = 11839 TOKEN_NUM_INITIALIZER 11840 (struct cmd_macsec_sa_result, 11841 pn, RTE_UINT32); 11842 cmdline_parse_token_string_t cmd_macsec_sa_key = 11843 TOKEN_STRING_INITIALIZER 11844 (struct cmd_macsec_sa_result, 11845 key, NULL); 11846 11847 static void 11848 cmd_set_macsec_sa_parsed( 11849 void *parsed_result, 11850 __rte_unused struct cmdline *cl, 11851 __rte_unused void *data) 11852 { 11853 struct cmd_macsec_sa_result *res = parsed_result; 11854 int ret = -ENOTSUP; 11855 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 11856 uint8_t key[16] = { 0 }; 11857 uint8_t xdgt0; 11858 uint8_t xdgt1; 11859 int key_len; 11860 int i; 11861 11862 key_len = strlen(res->key) / 2; 11863 if (key_len > 16) 11864 key_len = 16; 11865 11866 for (i = 0; i < key_len; i++) { 11867 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 11868 if (xdgt0 == 0xFF) 11869 return; 11870 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 11871 if (xdgt1 == 0xFF) 11872 return; 11873 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 11874 } 11875 11876 #ifdef RTE_NET_IXGBE 11877 ret = is_tx ? 11878 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 11879 res->idx, res->an, res->pn, key) : 11880 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 11881 res->idx, res->an, res->pn, key); 11882 #endif 11883 RTE_SET_USED(is_tx); 11884 RTE_SET_USED(key); 11885 11886 switch (ret) { 11887 case 0: 11888 break; 11889 case -EINVAL: 11890 printf("invalid idx %d or an %d\n", res->idx, res->an); 11891 break; 11892 case -ENODEV: 11893 printf("invalid port_id %d\n", res->port_id); 11894 break; 11895 case -ENOTSUP: 11896 printf("not supported on port %d\n", res->port_id); 11897 break; 11898 default: 11899 printf("programming error: (%s)\n", strerror(-ret)); 11900 } 11901 } 11902 11903 cmdline_parse_inst_t cmd_set_macsec_sa = { 11904 .f = cmd_set_macsec_sa_parsed, 11905 .data = NULL, 11906 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 11907 .tokens = { 11908 (void *)&cmd_macsec_sa_set, 11909 (void *)&cmd_macsec_sa_macsec, 11910 (void *)&cmd_macsec_sa_sa, 11911 (void *)&cmd_macsec_sa_tx_rx, 11912 (void *)&cmd_macsec_sa_port_id, 11913 (void *)&cmd_macsec_sa_idx, 11914 (void *)&cmd_macsec_sa_an, 11915 (void *)&cmd_macsec_sa_pn, 11916 (void *)&cmd_macsec_sa_key, 11917 NULL, 11918 }, 11919 }; 11920 11921 /* VF unicast promiscuous mode configuration */ 11922 11923 /* Common result structure for VF unicast promiscuous mode */ 11924 struct cmd_vf_promisc_result { 11925 cmdline_fixed_string_t set; 11926 cmdline_fixed_string_t vf; 11927 cmdline_fixed_string_t promisc; 11928 portid_t port_id; 11929 uint32_t vf_id; 11930 cmdline_fixed_string_t on_off; 11931 }; 11932 11933 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 11934 cmdline_parse_token_string_t cmd_vf_promisc_set = 11935 TOKEN_STRING_INITIALIZER 11936 (struct cmd_vf_promisc_result, 11937 set, "set"); 11938 cmdline_parse_token_string_t cmd_vf_promisc_vf = 11939 TOKEN_STRING_INITIALIZER 11940 (struct cmd_vf_promisc_result, 11941 vf, "vf"); 11942 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 11943 TOKEN_STRING_INITIALIZER 11944 (struct cmd_vf_promisc_result, 11945 promisc, "promisc"); 11946 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 11947 TOKEN_NUM_INITIALIZER 11948 (struct cmd_vf_promisc_result, 11949 port_id, RTE_UINT16); 11950 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 11951 TOKEN_NUM_INITIALIZER 11952 (struct cmd_vf_promisc_result, 11953 vf_id, RTE_UINT32); 11954 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 11955 TOKEN_STRING_INITIALIZER 11956 (struct cmd_vf_promisc_result, 11957 on_off, "on#off"); 11958 11959 static void 11960 cmd_set_vf_promisc_parsed( 11961 void *parsed_result, 11962 __rte_unused struct cmdline *cl, 11963 __rte_unused void *data) 11964 { 11965 struct cmd_vf_promisc_result *res = parsed_result; 11966 int ret = -ENOTSUP; 11967 11968 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11969 11970 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11971 return; 11972 11973 #ifdef RTE_NET_I40E 11974 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 11975 res->vf_id, is_on); 11976 #endif 11977 11978 switch (ret) { 11979 case 0: 11980 break; 11981 case -EINVAL: 11982 printf("invalid vf_id %d\n", res->vf_id); 11983 break; 11984 case -ENODEV: 11985 printf("invalid port_id %d\n", res->port_id); 11986 break; 11987 case -ENOTSUP: 11988 printf("function not implemented\n"); 11989 break; 11990 default: 11991 printf("programming error: (%s)\n", strerror(-ret)); 11992 } 11993 } 11994 11995 cmdline_parse_inst_t cmd_set_vf_promisc = { 11996 .f = cmd_set_vf_promisc_parsed, 11997 .data = NULL, 11998 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 11999 "Set unicast promiscuous mode for a VF from the PF", 12000 .tokens = { 12001 (void *)&cmd_vf_promisc_set, 12002 (void *)&cmd_vf_promisc_vf, 12003 (void *)&cmd_vf_promisc_promisc, 12004 (void *)&cmd_vf_promisc_port_id, 12005 (void *)&cmd_vf_promisc_vf_id, 12006 (void *)&cmd_vf_promisc_on_off, 12007 NULL, 12008 }, 12009 }; 12010 12011 /* VF multicast promiscuous mode configuration */ 12012 12013 /* Common result structure for VF multicast promiscuous mode */ 12014 struct cmd_vf_allmulti_result { 12015 cmdline_fixed_string_t set; 12016 cmdline_fixed_string_t vf; 12017 cmdline_fixed_string_t allmulti; 12018 portid_t port_id; 12019 uint32_t vf_id; 12020 cmdline_fixed_string_t on_off; 12021 }; 12022 12023 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 12024 cmdline_parse_token_string_t cmd_vf_allmulti_set = 12025 TOKEN_STRING_INITIALIZER 12026 (struct cmd_vf_allmulti_result, 12027 set, "set"); 12028 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 12029 TOKEN_STRING_INITIALIZER 12030 (struct cmd_vf_allmulti_result, 12031 vf, "vf"); 12032 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 12033 TOKEN_STRING_INITIALIZER 12034 (struct cmd_vf_allmulti_result, 12035 allmulti, "allmulti"); 12036 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 12037 TOKEN_NUM_INITIALIZER 12038 (struct cmd_vf_allmulti_result, 12039 port_id, RTE_UINT16); 12040 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 12041 TOKEN_NUM_INITIALIZER 12042 (struct cmd_vf_allmulti_result, 12043 vf_id, RTE_UINT32); 12044 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 12045 TOKEN_STRING_INITIALIZER 12046 (struct cmd_vf_allmulti_result, 12047 on_off, "on#off"); 12048 12049 static void 12050 cmd_set_vf_allmulti_parsed( 12051 void *parsed_result, 12052 __rte_unused struct cmdline *cl, 12053 __rte_unused void *data) 12054 { 12055 struct cmd_vf_allmulti_result *res = parsed_result; 12056 int ret = -ENOTSUP; 12057 12058 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12059 12060 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12061 return; 12062 12063 #ifdef RTE_NET_I40E 12064 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 12065 res->vf_id, is_on); 12066 #endif 12067 12068 switch (ret) { 12069 case 0: 12070 break; 12071 case -EINVAL: 12072 printf("invalid vf_id %d\n", res->vf_id); 12073 break; 12074 case -ENODEV: 12075 printf("invalid port_id %d\n", res->port_id); 12076 break; 12077 case -ENOTSUP: 12078 printf("function not implemented\n"); 12079 break; 12080 default: 12081 printf("programming error: (%s)\n", strerror(-ret)); 12082 } 12083 } 12084 12085 cmdline_parse_inst_t cmd_set_vf_allmulti = { 12086 .f = cmd_set_vf_allmulti_parsed, 12087 .data = NULL, 12088 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 12089 "Set multicast promiscuous mode for a VF from the PF", 12090 .tokens = { 12091 (void *)&cmd_vf_allmulti_set, 12092 (void *)&cmd_vf_allmulti_vf, 12093 (void *)&cmd_vf_allmulti_allmulti, 12094 (void *)&cmd_vf_allmulti_port_id, 12095 (void *)&cmd_vf_allmulti_vf_id, 12096 (void *)&cmd_vf_allmulti_on_off, 12097 NULL, 12098 }, 12099 }; 12100 12101 /* vf broadcast mode configuration */ 12102 12103 /* Common result structure for vf broadcast */ 12104 struct cmd_set_vf_broadcast_result { 12105 cmdline_fixed_string_t set; 12106 cmdline_fixed_string_t vf; 12107 cmdline_fixed_string_t broadcast; 12108 portid_t port_id; 12109 uint16_t vf_id; 12110 cmdline_fixed_string_t on_off; 12111 }; 12112 12113 /* Common CLI fields for vf broadcast enable disable */ 12114 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 12115 TOKEN_STRING_INITIALIZER 12116 (struct cmd_set_vf_broadcast_result, 12117 set, "set"); 12118 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 12119 TOKEN_STRING_INITIALIZER 12120 (struct cmd_set_vf_broadcast_result, 12121 vf, "vf"); 12122 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 12123 TOKEN_STRING_INITIALIZER 12124 (struct cmd_set_vf_broadcast_result, 12125 broadcast, "broadcast"); 12126 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 12127 TOKEN_NUM_INITIALIZER 12128 (struct cmd_set_vf_broadcast_result, 12129 port_id, RTE_UINT16); 12130 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 12131 TOKEN_NUM_INITIALIZER 12132 (struct cmd_set_vf_broadcast_result, 12133 vf_id, RTE_UINT16); 12134 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 12135 TOKEN_STRING_INITIALIZER 12136 (struct cmd_set_vf_broadcast_result, 12137 on_off, "on#off"); 12138 12139 static void 12140 cmd_set_vf_broadcast_parsed( 12141 void *parsed_result, 12142 __rte_unused struct cmdline *cl, 12143 __rte_unused void *data) 12144 { 12145 struct cmd_set_vf_broadcast_result *res = parsed_result; 12146 int ret = -ENOTSUP; 12147 12148 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12149 12150 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12151 return; 12152 12153 #ifdef RTE_NET_I40E 12154 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 12155 res->vf_id, is_on); 12156 #endif 12157 12158 switch (ret) { 12159 case 0: 12160 break; 12161 case -EINVAL: 12162 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 12163 break; 12164 case -ENODEV: 12165 printf("invalid port_id %d\n", res->port_id); 12166 break; 12167 case -ENOTSUP: 12168 printf("function not implemented\n"); 12169 break; 12170 default: 12171 printf("programming error: (%s)\n", strerror(-ret)); 12172 } 12173 } 12174 12175 cmdline_parse_inst_t cmd_set_vf_broadcast = { 12176 .f = cmd_set_vf_broadcast_parsed, 12177 .data = NULL, 12178 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 12179 .tokens = { 12180 (void *)&cmd_set_vf_broadcast_set, 12181 (void *)&cmd_set_vf_broadcast_vf, 12182 (void *)&cmd_set_vf_broadcast_broadcast, 12183 (void *)&cmd_set_vf_broadcast_port_id, 12184 (void *)&cmd_set_vf_broadcast_vf_id, 12185 (void *)&cmd_set_vf_broadcast_on_off, 12186 NULL, 12187 }, 12188 }; 12189 12190 /* vf vlan tag configuration */ 12191 12192 /* Common result structure for vf vlan tag */ 12193 struct cmd_set_vf_vlan_tag_result { 12194 cmdline_fixed_string_t set; 12195 cmdline_fixed_string_t vf; 12196 cmdline_fixed_string_t vlan; 12197 cmdline_fixed_string_t tag; 12198 portid_t port_id; 12199 uint16_t vf_id; 12200 cmdline_fixed_string_t on_off; 12201 }; 12202 12203 /* Common CLI fields for vf vlan tag enable disable */ 12204 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 12205 TOKEN_STRING_INITIALIZER 12206 (struct cmd_set_vf_vlan_tag_result, 12207 set, "set"); 12208 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 12209 TOKEN_STRING_INITIALIZER 12210 (struct cmd_set_vf_vlan_tag_result, 12211 vf, "vf"); 12212 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 12213 TOKEN_STRING_INITIALIZER 12214 (struct cmd_set_vf_vlan_tag_result, 12215 vlan, "vlan"); 12216 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 12217 TOKEN_STRING_INITIALIZER 12218 (struct cmd_set_vf_vlan_tag_result, 12219 tag, "tag"); 12220 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 12221 TOKEN_NUM_INITIALIZER 12222 (struct cmd_set_vf_vlan_tag_result, 12223 port_id, RTE_UINT16); 12224 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 12225 TOKEN_NUM_INITIALIZER 12226 (struct cmd_set_vf_vlan_tag_result, 12227 vf_id, RTE_UINT16); 12228 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 12229 TOKEN_STRING_INITIALIZER 12230 (struct cmd_set_vf_vlan_tag_result, 12231 on_off, "on#off"); 12232 12233 static void 12234 cmd_set_vf_vlan_tag_parsed( 12235 void *parsed_result, 12236 __rte_unused struct cmdline *cl, 12237 __rte_unused void *data) 12238 { 12239 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 12240 int ret = -ENOTSUP; 12241 12242 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12243 12244 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12245 return; 12246 12247 #ifdef RTE_NET_I40E 12248 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 12249 res->vf_id, is_on); 12250 #endif 12251 12252 switch (ret) { 12253 case 0: 12254 break; 12255 case -EINVAL: 12256 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 12257 break; 12258 case -ENODEV: 12259 printf("invalid port_id %d\n", res->port_id); 12260 break; 12261 case -ENOTSUP: 12262 printf("function not implemented\n"); 12263 break; 12264 default: 12265 printf("programming error: (%s)\n", strerror(-ret)); 12266 } 12267 } 12268 12269 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 12270 .f = cmd_set_vf_vlan_tag_parsed, 12271 .data = NULL, 12272 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 12273 .tokens = { 12274 (void *)&cmd_set_vf_vlan_tag_set, 12275 (void *)&cmd_set_vf_vlan_tag_vf, 12276 (void *)&cmd_set_vf_vlan_tag_vlan, 12277 (void *)&cmd_set_vf_vlan_tag_tag, 12278 (void *)&cmd_set_vf_vlan_tag_port_id, 12279 (void *)&cmd_set_vf_vlan_tag_vf_id, 12280 (void *)&cmd_set_vf_vlan_tag_on_off, 12281 NULL, 12282 }, 12283 }; 12284 12285 /* Common definition of VF and TC TX bandwidth configuration */ 12286 struct cmd_vf_tc_bw_result { 12287 cmdline_fixed_string_t set; 12288 cmdline_fixed_string_t vf; 12289 cmdline_fixed_string_t tc; 12290 cmdline_fixed_string_t tx; 12291 cmdline_fixed_string_t min_bw; 12292 cmdline_fixed_string_t max_bw; 12293 cmdline_fixed_string_t strict_link_prio; 12294 portid_t port_id; 12295 uint16_t vf_id; 12296 uint8_t tc_no; 12297 uint32_t bw; 12298 cmdline_fixed_string_t bw_list; 12299 uint8_t tc_map; 12300 }; 12301 12302 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 12303 TOKEN_STRING_INITIALIZER 12304 (struct cmd_vf_tc_bw_result, 12305 set, "set"); 12306 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 12307 TOKEN_STRING_INITIALIZER 12308 (struct cmd_vf_tc_bw_result, 12309 vf, "vf"); 12310 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 12311 TOKEN_STRING_INITIALIZER 12312 (struct cmd_vf_tc_bw_result, 12313 tc, "tc"); 12314 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 12315 TOKEN_STRING_INITIALIZER 12316 (struct cmd_vf_tc_bw_result, 12317 tx, "tx"); 12318 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 12319 TOKEN_STRING_INITIALIZER 12320 (struct cmd_vf_tc_bw_result, 12321 strict_link_prio, "strict-link-priority"); 12322 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 12323 TOKEN_STRING_INITIALIZER 12324 (struct cmd_vf_tc_bw_result, 12325 min_bw, "min-bandwidth"); 12326 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 12327 TOKEN_STRING_INITIALIZER 12328 (struct cmd_vf_tc_bw_result, 12329 max_bw, "max-bandwidth"); 12330 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 12331 TOKEN_NUM_INITIALIZER 12332 (struct cmd_vf_tc_bw_result, 12333 port_id, RTE_UINT16); 12334 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 12335 TOKEN_NUM_INITIALIZER 12336 (struct cmd_vf_tc_bw_result, 12337 vf_id, RTE_UINT16); 12338 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 12339 TOKEN_NUM_INITIALIZER 12340 (struct cmd_vf_tc_bw_result, 12341 tc_no, RTE_UINT8); 12342 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 12343 TOKEN_NUM_INITIALIZER 12344 (struct cmd_vf_tc_bw_result, 12345 bw, RTE_UINT32); 12346 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 12347 TOKEN_STRING_INITIALIZER 12348 (struct cmd_vf_tc_bw_result, 12349 bw_list, NULL); 12350 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 12351 TOKEN_NUM_INITIALIZER 12352 (struct cmd_vf_tc_bw_result, 12353 tc_map, RTE_UINT8); 12354 12355 /* VF max bandwidth setting */ 12356 static void 12357 cmd_vf_max_bw_parsed( 12358 void *parsed_result, 12359 __rte_unused struct cmdline *cl, 12360 __rte_unused void *data) 12361 { 12362 struct cmd_vf_tc_bw_result *res = parsed_result; 12363 int ret = -ENOTSUP; 12364 12365 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12366 return; 12367 12368 #ifdef RTE_NET_I40E 12369 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 12370 res->vf_id, res->bw); 12371 #endif 12372 12373 switch (ret) { 12374 case 0: 12375 break; 12376 case -EINVAL: 12377 printf("invalid vf_id %d or bandwidth %d\n", 12378 res->vf_id, res->bw); 12379 break; 12380 case -ENODEV: 12381 printf("invalid port_id %d\n", res->port_id); 12382 break; 12383 case -ENOTSUP: 12384 printf("function not implemented\n"); 12385 break; 12386 default: 12387 printf("programming error: (%s)\n", strerror(-ret)); 12388 } 12389 } 12390 12391 cmdline_parse_inst_t cmd_vf_max_bw = { 12392 .f = cmd_vf_max_bw_parsed, 12393 .data = NULL, 12394 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 12395 .tokens = { 12396 (void *)&cmd_vf_tc_bw_set, 12397 (void *)&cmd_vf_tc_bw_vf, 12398 (void *)&cmd_vf_tc_bw_tx, 12399 (void *)&cmd_vf_tc_bw_max_bw, 12400 (void *)&cmd_vf_tc_bw_port_id, 12401 (void *)&cmd_vf_tc_bw_vf_id, 12402 (void *)&cmd_vf_tc_bw_bw, 12403 NULL, 12404 }, 12405 }; 12406 12407 static int 12408 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 12409 uint8_t *tc_num, 12410 char *str) 12411 { 12412 uint32_t size; 12413 const char *p, *p0 = str; 12414 char s[256]; 12415 char *end; 12416 char *str_fld[16]; 12417 uint16_t i; 12418 int ret; 12419 12420 p = strchr(p0, '('); 12421 if (p == NULL) { 12422 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 12423 return -1; 12424 } 12425 p++; 12426 p0 = strchr(p, ')'); 12427 if (p0 == NULL) { 12428 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 12429 return -1; 12430 } 12431 size = p0 - p; 12432 if (size >= sizeof(s)) { 12433 printf("The string size exceeds the internal buffer size\n"); 12434 return -1; 12435 } 12436 snprintf(s, sizeof(s), "%.*s", size, p); 12437 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 12438 if (ret <= 0) { 12439 printf("Failed to get the bandwidth list. "); 12440 return -1; 12441 } 12442 *tc_num = ret; 12443 for (i = 0; i < ret; i++) 12444 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 12445 12446 return 0; 12447 } 12448 12449 /* TC min bandwidth setting */ 12450 static void 12451 cmd_vf_tc_min_bw_parsed( 12452 void *parsed_result, 12453 __rte_unused struct cmdline *cl, 12454 __rte_unused void *data) 12455 { 12456 struct cmd_vf_tc_bw_result *res = parsed_result; 12457 uint8_t tc_num; 12458 uint8_t bw[16]; 12459 int ret = -ENOTSUP; 12460 12461 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12462 return; 12463 12464 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 12465 if (ret) 12466 return; 12467 12468 #ifdef RTE_NET_I40E 12469 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 12470 tc_num, bw); 12471 #endif 12472 12473 switch (ret) { 12474 case 0: 12475 break; 12476 case -EINVAL: 12477 printf("invalid vf_id %d or bandwidth\n", res->vf_id); 12478 break; 12479 case -ENODEV: 12480 printf("invalid port_id %d\n", res->port_id); 12481 break; 12482 case -ENOTSUP: 12483 printf("function not implemented\n"); 12484 break; 12485 default: 12486 printf("programming error: (%s)\n", strerror(-ret)); 12487 } 12488 } 12489 12490 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 12491 .f = cmd_vf_tc_min_bw_parsed, 12492 .data = NULL, 12493 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 12494 " <bw1, bw2, ...>", 12495 .tokens = { 12496 (void *)&cmd_vf_tc_bw_set, 12497 (void *)&cmd_vf_tc_bw_vf, 12498 (void *)&cmd_vf_tc_bw_tc, 12499 (void *)&cmd_vf_tc_bw_tx, 12500 (void *)&cmd_vf_tc_bw_min_bw, 12501 (void *)&cmd_vf_tc_bw_port_id, 12502 (void *)&cmd_vf_tc_bw_vf_id, 12503 (void *)&cmd_vf_tc_bw_bw_list, 12504 NULL, 12505 }, 12506 }; 12507 12508 static void 12509 cmd_tc_min_bw_parsed( 12510 void *parsed_result, 12511 __rte_unused struct cmdline *cl, 12512 __rte_unused void *data) 12513 { 12514 struct cmd_vf_tc_bw_result *res = parsed_result; 12515 struct rte_port *port; 12516 uint8_t tc_num; 12517 uint8_t bw[16]; 12518 int ret = -ENOTSUP; 12519 12520 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12521 return; 12522 12523 port = &ports[res->port_id]; 12524 /** Check if the port is not started **/ 12525 if (port->port_status != RTE_PORT_STOPPED) { 12526 printf("Please stop port %d first\n", res->port_id); 12527 return; 12528 } 12529 12530 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 12531 if (ret) 12532 return; 12533 12534 #ifdef RTE_NET_IXGBE 12535 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 12536 #endif 12537 12538 switch (ret) { 12539 case 0: 12540 break; 12541 case -EINVAL: 12542 printf("invalid bandwidth\n"); 12543 break; 12544 case -ENODEV: 12545 printf("invalid port_id %d\n", res->port_id); 12546 break; 12547 case -ENOTSUP: 12548 printf("function not implemented\n"); 12549 break; 12550 default: 12551 printf("programming error: (%s)\n", strerror(-ret)); 12552 } 12553 } 12554 12555 cmdline_parse_inst_t cmd_tc_min_bw = { 12556 .f = cmd_tc_min_bw_parsed, 12557 .data = NULL, 12558 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 12559 .tokens = { 12560 (void *)&cmd_vf_tc_bw_set, 12561 (void *)&cmd_vf_tc_bw_tc, 12562 (void *)&cmd_vf_tc_bw_tx, 12563 (void *)&cmd_vf_tc_bw_min_bw, 12564 (void *)&cmd_vf_tc_bw_port_id, 12565 (void *)&cmd_vf_tc_bw_bw_list, 12566 NULL, 12567 }, 12568 }; 12569 12570 /* TC max bandwidth setting */ 12571 static void 12572 cmd_vf_tc_max_bw_parsed( 12573 void *parsed_result, 12574 __rte_unused struct cmdline *cl, 12575 __rte_unused void *data) 12576 { 12577 struct cmd_vf_tc_bw_result *res = parsed_result; 12578 int ret = -ENOTSUP; 12579 12580 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12581 return; 12582 12583 #ifdef RTE_NET_I40E 12584 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 12585 res->tc_no, res->bw); 12586 #endif 12587 12588 switch (ret) { 12589 case 0: 12590 break; 12591 case -EINVAL: 12592 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n", 12593 res->vf_id, res->tc_no, res->bw); 12594 break; 12595 case -ENODEV: 12596 printf("invalid port_id %d\n", res->port_id); 12597 break; 12598 case -ENOTSUP: 12599 printf("function not implemented\n"); 12600 break; 12601 default: 12602 printf("programming error: (%s)\n", strerror(-ret)); 12603 } 12604 } 12605 12606 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 12607 .f = cmd_vf_tc_max_bw_parsed, 12608 .data = NULL, 12609 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 12610 " <bandwidth>", 12611 .tokens = { 12612 (void *)&cmd_vf_tc_bw_set, 12613 (void *)&cmd_vf_tc_bw_vf, 12614 (void *)&cmd_vf_tc_bw_tc, 12615 (void *)&cmd_vf_tc_bw_tx, 12616 (void *)&cmd_vf_tc_bw_max_bw, 12617 (void *)&cmd_vf_tc_bw_port_id, 12618 (void *)&cmd_vf_tc_bw_vf_id, 12619 (void *)&cmd_vf_tc_bw_tc_no, 12620 (void *)&cmd_vf_tc_bw_bw, 12621 NULL, 12622 }, 12623 }; 12624 12625 /** Set VXLAN encapsulation details */ 12626 struct cmd_set_vxlan_result { 12627 cmdline_fixed_string_t set; 12628 cmdline_fixed_string_t vxlan; 12629 cmdline_fixed_string_t pos_token; 12630 cmdline_fixed_string_t ip_version; 12631 uint32_t vlan_present:1; 12632 uint32_t vni; 12633 uint16_t udp_src; 12634 uint16_t udp_dst; 12635 cmdline_ipaddr_t ip_src; 12636 cmdline_ipaddr_t ip_dst; 12637 uint16_t tci; 12638 uint8_t tos; 12639 uint8_t ttl; 12640 struct rte_ether_addr eth_src; 12641 struct rte_ether_addr eth_dst; 12642 }; 12643 12644 cmdline_parse_token_string_t cmd_set_vxlan_set = 12645 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 12646 cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 12647 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 12648 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl = 12649 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 12650 "vxlan-tos-ttl"); 12651 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 12652 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 12653 "vxlan-with-vlan"); 12654 cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 12655 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12656 "ip-version"); 12657 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 12658 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 12659 "ipv4#ipv6"); 12660 cmdline_parse_token_string_t cmd_set_vxlan_vni = 12661 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12662 "vni"); 12663 cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 12664 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32); 12665 cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 12666 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12667 "udp-src"); 12668 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 12669 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16); 12670 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 12671 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12672 "udp-dst"); 12673 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 12674 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16); 12675 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos = 12676 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12677 "ip-tos"); 12678 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value = 12679 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8); 12680 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl = 12681 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12682 "ip-ttl"); 12683 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value = 12684 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8); 12685 cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 12686 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12687 "ip-src"); 12688 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 12689 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 12690 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 12691 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12692 "ip-dst"); 12693 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 12694 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 12695 cmdline_parse_token_string_t cmd_set_vxlan_vlan = 12696 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12697 "vlan-tci"); 12698 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 12699 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16); 12700 cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 12701 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12702 "eth-src"); 12703 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 12704 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 12705 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 12706 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12707 "eth-dst"); 12708 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 12709 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 12710 12711 static void cmd_set_vxlan_parsed(void *parsed_result, 12712 __rte_unused struct cmdline *cl, 12713 __rte_unused void *data) 12714 { 12715 struct cmd_set_vxlan_result *res = parsed_result; 12716 union { 12717 uint32_t vxlan_id; 12718 uint8_t vni[4]; 12719 } id = { 12720 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 12721 }; 12722 12723 vxlan_encap_conf.select_tos_ttl = 0; 12724 if (strcmp(res->vxlan, "vxlan") == 0) 12725 vxlan_encap_conf.select_vlan = 0; 12726 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 12727 vxlan_encap_conf.select_vlan = 1; 12728 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) { 12729 vxlan_encap_conf.select_vlan = 0; 12730 vxlan_encap_conf.select_tos_ttl = 1; 12731 } 12732 if (strcmp(res->ip_version, "ipv4") == 0) 12733 vxlan_encap_conf.select_ipv4 = 1; 12734 else if (strcmp(res->ip_version, "ipv6") == 0) 12735 vxlan_encap_conf.select_ipv4 = 0; 12736 else 12737 return; 12738 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 12739 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 12740 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 12741 vxlan_encap_conf.ip_tos = res->tos; 12742 vxlan_encap_conf.ip_ttl = res->ttl; 12743 if (vxlan_encap_conf.select_ipv4) { 12744 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 12745 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 12746 } else { 12747 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 12748 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 12749 } 12750 if (vxlan_encap_conf.select_vlan) 12751 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 12752 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 12753 RTE_ETHER_ADDR_LEN); 12754 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 12755 RTE_ETHER_ADDR_LEN); 12756 } 12757 12758 cmdline_parse_inst_t cmd_set_vxlan = { 12759 .f = cmd_set_vxlan_parsed, 12760 .data = NULL, 12761 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 12762 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 12763 " eth-src <eth-src> eth-dst <eth-dst>", 12764 .tokens = { 12765 (void *)&cmd_set_vxlan_set, 12766 (void *)&cmd_set_vxlan_vxlan, 12767 (void *)&cmd_set_vxlan_ip_version, 12768 (void *)&cmd_set_vxlan_ip_version_value, 12769 (void *)&cmd_set_vxlan_vni, 12770 (void *)&cmd_set_vxlan_vni_value, 12771 (void *)&cmd_set_vxlan_udp_src, 12772 (void *)&cmd_set_vxlan_udp_src_value, 12773 (void *)&cmd_set_vxlan_udp_dst, 12774 (void *)&cmd_set_vxlan_udp_dst_value, 12775 (void *)&cmd_set_vxlan_ip_src, 12776 (void *)&cmd_set_vxlan_ip_src_value, 12777 (void *)&cmd_set_vxlan_ip_dst, 12778 (void *)&cmd_set_vxlan_ip_dst_value, 12779 (void *)&cmd_set_vxlan_eth_src, 12780 (void *)&cmd_set_vxlan_eth_src_value, 12781 (void *)&cmd_set_vxlan_eth_dst, 12782 (void *)&cmd_set_vxlan_eth_dst_value, 12783 NULL, 12784 }, 12785 }; 12786 12787 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = { 12788 .f = cmd_set_vxlan_parsed, 12789 .data = NULL, 12790 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src" 12791 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>" 12792 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 12793 " eth-dst <eth-dst>", 12794 .tokens = { 12795 (void *)&cmd_set_vxlan_set, 12796 (void *)&cmd_set_vxlan_vxlan_tos_ttl, 12797 (void *)&cmd_set_vxlan_ip_version, 12798 (void *)&cmd_set_vxlan_ip_version_value, 12799 (void *)&cmd_set_vxlan_vni, 12800 (void *)&cmd_set_vxlan_vni_value, 12801 (void *)&cmd_set_vxlan_udp_src, 12802 (void *)&cmd_set_vxlan_udp_src_value, 12803 (void *)&cmd_set_vxlan_udp_dst, 12804 (void *)&cmd_set_vxlan_udp_dst_value, 12805 (void *)&cmd_set_vxlan_ip_tos, 12806 (void *)&cmd_set_vxlan_ip_tos_value, 12807 (void *)&cmd_set_vxlan_ip_ttl, 12808 (void *)&cmd_set_vxlan_ip_ttl_value, 12809 (void *)&cmd_set_vxlan_ip_src, 12810 (void *)&cmd_set_vxlan_ip_src_value, 12811 (void *)&cmd_set_vxlan_ip_dst, 12812 (void *)&cmd_set_vxlan_ip_dst_value, 12813 (void *)&cmd_set_vxlan_eth_src, 12814 (void *)&cmd_set_vxlan_eth_src_value, 12815 (void *)&cmd_set_vxlan_eth_dst, 12816 (void *)&cmd_set_vxlan_eth_dst_value, 12817 NULL, 12818 }, 12819 }; 12820 12821 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 12822 .f = cmd_set_vxlan_parsed, 12823 .data = NULL, 12824 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 12825 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 12826 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 12827 " <eth-dst>", 12828 .tokens = { 12829 (void *)&cmd_set_vxlan_set, 12830 (void *)&cmd_set_vxlan_vxlan_with_vlan, 12831 (void *)&cmd_set_vxlan_ip_version, 12832 (void *)&cmd_set_vxlan_ip_version_value, 12833 (void *)&cmd_set_vxlan_vni, 12834 (void *)&cmd_set_vxlan_vni_value, 12835 (void *)&cmd_set_vxlan_udp_src, 12836 (void *)&cmd_set_vxlan_udp_src_value, 12837 (void *)&cmd_set_vxlan_udp_dst, 12838 (void *)&cmd_set_vxlan_udp_dst_value, 12839 (void *)&cmd_set_vxlan_ip_src, 12840 (void *)&cmd_set_vxlan_ip_src_value, 12841 (void *)&cmd_set_vxlan_ip_dst, 12842 (void *)&cmd_set_vxlan_ip_dst_value, 12843 (void *)&cmd_set_vxlan_vlan, 12844 (void *)&cmd_set_vxlan_vlan_value, 12845 (void *)&cmd_set_vxlan_eth_src, 12846 (void *)&cmd_set_vxlan_eth_src_value, 12847 (void *)&cmd_set_vxlan_eth_dst, 12848 (void *)&cmd_set_vxlan_eth_dst_value, 12849 NULL, 12850 }, 12851 }; 12852 12853 /** Set NVGRE encapsulation details */ 12854 struct cmd_set_nvgre_result { 12855 cmdline_fixed_string_t set; 12856 cmdline_fixed_string_t nvgre; 12857 cmdline_fixed_string_t pos_token; 12858 cmdline_fixed_string_t ip_version; 12859 uint32_t tni; 12860 cmdline_ipaddr_t ip_src; 12861 cmdline_ipaddr_t ip_dst; 12862 uint16_t tci; 12863 struct rte_ether_addr eth_src; 12864 struct rte_ether_addr eth_dst; 12865 }; 12866 12867 cmdline_parse_token_string_t cmd_set_nvgre_set = 12868 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 12869 cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 12870 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 12871 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 12872 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 12873 "nvgre-with-vlan"); 12874 cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 12875 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12876 "ip-version"); 12877 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 12878 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 12879 "ipv4#ipv6"); 12880 cmdline_parse_token_string_t cmd_set_nvgre_tni = 12881 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12882 "tni"); 12883 cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 12884 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32); 12885 cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 12886 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12887 "ip-src"); 12888 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 12889 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 12890 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 12891 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12892 "ip-dst"); 12893 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 12894 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 12895 cmdline_parse_token_string_t cmd_set_nvgre_vlan = 12896 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12897 "vlan-tci"); 12898 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 12899 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16); 12900 cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 12901 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12902 "eth-src"); 12903 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 12904 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 12905 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 12906 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12907 "eth-dst"); 12908 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 12909 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 12910 12911 static void cmd_set_nvgre_parsed(void *parsed_result, 12912 __rte_unused struct cmdline *cl, 12913 __rte_unused void *data) 12914 { 12915 struct cmd_set_nvgre_result *res = parsed_result; 12916 union { 12917 uint32_t nvgre_tni; 12918 uint8_t tni[4]; 12919 } id = { 12920 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 12921 }; 12922 12923 if (strcmp(res->nvgre, "nvgre") == 0) 12924 nvgre_encap_conf.select_vlan = 0; 12925 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 12926 nvgre_encap_conf.select_vlan = 1; 12927 if (strcmp(res->ip_version, "ipv4") == 0) 12928 nvgre_encap_conf.select_ipv4 = 1; 12929 else if (strcmp(res->ip_version, "ipv6") == 0) 12930 nvgre_encap_conf.select_ipv4 = 0; 12931 else 12932 return; 12933 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 12934 if (nvgre_encap_conf.select_ipv4) { 12935 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 12936 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 12937 } else { 12938 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 12939 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 12940 } 12941 if (nvgre_encap_conf.select_vlan) 12942 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 12943 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 12944 RTE_ETHER_ADDR_LEN); 12945 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 12946 RTE_ETHER_ADDR_LEN); 12947 } 12948 12949 cmdline_parse_inst_t cmd_set_nvgre = { 12950 .f = cmd_set_nvgre_parsed, 12951 .data = NULL, 12952 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 12953 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 12954 " eth-dst <eth-dst>", 12955 .tokens = { 12956 (void *)&cmd_set_nvgre_set, 12957 (void *)&cmd_set_nvgre_nvgre, 12958 (void *)&cmd_set_nvgre_ip_version, 12959 (void *)&cmd_set_nvgre_ip_version_value, 12960 (void *)&cmd_set_nvgre_tni, 12961 (void *)&cmd_set_nvgre_tni_value, 12962 (void *)&cmd_set_nvgre_ip_src, 12963 (void *)&cmd_set_nvgre_ip_src_value, 12964 (void *)&cmd_set_nvgre_ip_dst, 12965 (void *)&cmd_set_nvgre_ip_dst_value, 12966 (void *)&cmd_set_nvgre_eth_src, 12967 (void *)&cmd_set_nvgre_eth_src_value, 12968 (void *)&cmd_set_nvgre_eth_dst, 12969 (void *)&cmd_set_nvgre_eth_dst_value, 12970 NULL, 12971 }, 12972 }; 12973 12974 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 12975 .f = cmd_set_nvgre_parsed, 12976 .data = NULL, 12977 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 12978 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 12979 " eth-src <eth-src> eth-dst <eth-dst>", 12980 .tokens = { 12981 (void *)&cmd_set_nvgre_set, 12982 (void *)&cmd_set_nvgre_nvgre_with_vlan, 12983 (void *)&cmd_set_nvgre_ip_version, 12984 (void *)&cmd_set_nvgre_ip_version_value, 12985 (void *)&cmd_set_nvgre_tni, 12986 (void *)&cmd_set_nvgre_tni_value, 12987 (void *)&cmd_set_nvgre_ip_src, 12988 (void *)&cmd_set_nvgre_ip_src_value, 12989 (void *)&cmd_set_nvgre_ip_dst, 12990 (void *)&cmd_set_nvgre_ip_dst_value, 12991 (void *)&cmd_set_nvgre_vlan, 12992 (void *)&cmd_set_nvgre_vlan_value, 12993 (void *)&cmd_set_nvgre_eth_src, 12994 (void *)&cmd_set_nvgre_eth_src_value, 12995 (void *)&cmd_set_nvgre_eth_dst, 12996 (void *)&cmd_set_nvgre_eth_dst_value, 12997 NULL, 12998 }, 12999 }; 13000 13001 /** Set L2 encapsulation details */ 13002 struct cmd_set_l2_encap_result { 13003 cmdline_fixed_string_t set; 13004 cmdline_fixed_string_t l2_encap; 13005 cmdline_fixed_string_t pos_token; 13006 cmdline_fixed_string_t ip_version; 13007 uint32_t vlan_present:1; 13008 uint16_t tci; 13009 struct rte_ether_addr eth_src; 13010 struct rte_ether_addr eth_dst; 13011 }; 13012 13013 cmdline_parse_token_string_t cmd_set_l2_encap_set = 13014 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); 13015 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = 13016 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); 13017 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = 13018 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, 13019 "l2_encap-with-vlan"); 13020 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = 13021 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13022 "ip-version"); 13023 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = 13024 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, 13025 "ipv4#ipv6"); 13026 cmdline_parse_token_string_t cmd_set_l2_encap_vlan = 13027 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13028 "vlan-tci"); 13029 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = 13030 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16); 13031 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = 13032 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13033 "eth-src"); 13034 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = 13035 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); 13036 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = 13037 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13038 "eth-dst"); 13039 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = 13040 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); 13041 13042 static void cmd_set_l2_encap_parsed(void *parsed_result, 13043 __rte_unused struct cmdline *cl, 13044 __rte_unused void *data) 13045 { 13046 struct cmd_set_l2_encap_result *res = parsed_result; 13047 13048 if (strcmp(res->l2_encap, "l2_encap") == 0) 13049 l2_encap_conf.select_vlan = 0; 13050 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) 13051 l2_encap_conf.select_vlan = 1; 13052 if (strcmp(res->ip_version, "ipv4") == 0) 13053 l2_encap_conf.select_ipv4 = 1; 13054 else if (strcmp(res->ip_version, "ipv6") == 0) 13055 l2_encap_conf.select_ipv4 = 0; 13056 else 13057 return; 13058 if (l2_encap_conf.select_vlan) 13059 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13060 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, 13061 RTE_ETHER_ADDR_LEN); 13062 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13063 RTE_ETHER_ADDR_LEN); 13064 } 13065 13066 cmdline_parse_inst_t cmd_set_l2_encap = { 13067 .f = cmd_set_l2_encap_parsed, 13068 .data = NULL, 13069 .help_str = "set l2_encap ip-version ipv4|ipv6" 13070 " eth-src <eth-src> eth-dst <eth-dst>", 13071 .tokens = { 13072 (void *)&cmd_set_l2_encap_set, 13073 (void *)&cmd_set_l2_encap_l2_encap, 13074 (void *)&cmd_set_l2_encap_ip_version, 13075 (void *)&cmd_set_l2_encap_ip_version_value, 13076 (void *)&cmd_set_l2_encap_eth_src, 13077 (void *)&cmd_set_l2_encap_eth_src_value, 13078 (void *)&cmd_set_l2_encap_eth_dst, 13079 (void *)&cmd_set_l2_encap_eth_dst_value, 13080 NULL, 13081 }, 13082 }; 13083 13084 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { 13085 .f = cmd_set_l2_encap_parsed, 13086 .data = NULL, 13087 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" 13088 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 13089 .tokens = { 13090 (void *)&cmd_set_l2_encap_set, 13091 (void *)&cmd_set_l2_encap_l2_encap_with_vlan, 13092 (void *)&cmd_set_l2_encap_ip_version, 13093 (void *)&cmd_set_l2_encap_ip_version_value, 13094 (void *)&cmd_set_l2_encap_vlan, 13095 (void *)&cmd_set_l2_encap_vlan_value, 13096 (void *)&cmd_set_l2_encap_eth_src, 13097 (void *)&cmd_set_l2_encap_eth_src_value, 13098 (void *)&cmd_set_l2_encap_eth_dst, 13099 (void *)&cmd_set_l2_encap_eth_dst_value, 13100 NULL, 13101 }, 13102 }; 13103 13104 /** Set L2 decapsulation details */ 13105 struct cmd_set_l2_decap_result { 13106 cmdline_fixed_string_t set; 13107 cmdline_fixed_string_t l2_decap; 13108 cmdline_fixed_string_t pos_token; 13109 uint32_t vlan_present:1; 13110 }; 13111 13112 cmdline_parse_token_string_t cmd_set_l2_decap_set = 13113 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); 13114 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = 13115 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 13116 "l2_decap"); 13117 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = 13118 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 13119 "l2_decap-with-vlan"); 13120 13121 static void cmd_set_l2_decap_parsed(void *parsed_result, 13122 __rte_unused struct cmdline *cl, 13123 __rte_unused void *data) 13124 { 13125 struct cmd_set_l2_decap_result *res = parsed_result; 13126 13127 if (strcmp(res->l2_decap, "l2_decap") == 0) 13128 l2_decap_conf.select_vlan = 0; 13129 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) 13130 l2_decap_conf.select_vlan = 1; 13131 } 13132 13133 cmdline_parse_inst_t cmd_set_l2_decap = { 13134 .f = cmd_set_l2_decap_parsed, 13135 .data = NULL, 13136 .help_str = "set l2_decap", 13137 .tokens = { 13138 (void *)&cmd_set_l2_decap_set, 13139 (void *)&cmd_set_l2_decap_l2_decap, 13140 NULL, 13141 }, 13142 }; 13143 13144 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { 13145 .f = cmd_set_l2_decap_parsed, 13146 .data = NULL, 13147 .help_str = "set l2_decap-with-vlan", 13148 .tokens = { 13149 (void *)&cmd_set_l2_decap_set, 13150 (void *)&cmd_set_l2_decap_l2_decap_with_vlan, 13151 NULL, 13152 }, 13153 }; 13154 13155 /** Set MPLSoGRE encapsulation details */ 13156 struct cmd_set_mplsogre_encap_result { 13157 cmdline_fixed_string_t set; 13158 cmdline_fixed_string_t mplsogre; 13159 cmdline_fixed_string_t pos_token; 13160 cmdline_fixed_string_t ip_version; 13161 uint32_t vlan_present:1; 13162 uint32_t label; 13163 cmdline_ipaddr_t ip_src; 13164 cmdline_ipaddr_t ip_dst; 13165 uint16_t tci; 13166 struct rte_ether_addr eth_src; 13167 struct rte_ether_addr eth_dst; 13168 }; 13169 13170 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = 13171 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, 13172 "set"); 13173 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = 13174 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, 13175 "mplsogre_encap"); 13176 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = 13177 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13178 mplsogre, "mplsogre_encap-with-vlan"); 13179 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = 13180 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13181 pos_token, "ip-version"); 13182 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = 13183 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13184 ip_version, "ipv4#ipv6"); 13185 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = 13186 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13187 pos_token, "label"); 13188 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = 13189 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, 13190 RTE_UINT32); 13191 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = 13192 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13193 pos_token, "ip-src"); 13194 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = 13195 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); 13196 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = 13197 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13198 pos_token, "ip-dst"); 13199 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = 13200 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); 13201 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = 13202 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13203 pos_token, "vlan-tci"); 13204 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = 13205 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, 13206 RTE_UINT16); 13207 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = 13208 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13209 pos_token, "eth-src"); 13210 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = 13211 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13212 eth_src); 13213 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = 13214 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13215 pos_token, "eth-dst"); 13216 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = 13217 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13218 eth_dst); 13219 13220 static void cmd_set_mplsogre_encap_parsed(void *parsed_result, 13221 __rte_unused struct cmdline *cl, 13222 __rte_unused void *data) 13223 { 13224 struct cmd_set_mplsogre_encap_result *res = parsed_result; 13225 union { 13226 uint32_t mplsogre_label; 13227 uint8_t label[4]; 13228 } id = { 13229 .mplsogre_label = rte_cpu_to_be_32(res->label<<12), 13230 }; 13231 13232 if (strcmp(res->mplsogre, "mplsogre_encap") == 0) 13233 mplsogre_encap_conf.select_vlan = 0; 13234 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) 13235 mplsogre_encap_conf.select_vlan = 1; 13236 if (strcmp(res->ip_version, "ipv4") == 0) 13237 mplsogre_encap_conf.select_ipv4 = 1; 13238 else if (strcmp(res->ip_version, "ipv6") == 0) 13239 mplsogre_encap_conf.select_ipv4 = 0; 13240 else 13241 return; 13242 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3); 13243 if (mplsogre_encap_conf.select_ipv4) { 13244 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); 13245 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); 13246 } else { 13247 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); 13248 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); 13249 } 13250 if (mplsogre_encap_conf.select_vlan) 13251 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13252 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, 13253 RTE_ETHER_ADDR_LEN); 13254 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13255 RTE_ETHER_ADDR_LEN); 13256 } 13257 13258 cmdline_parse_inst_t cmd_set_mplsogre_encap = { 13259 .f = cmd_set_mplsogre_encap_parsed, 13260 .data = NULL, 13261 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" 13262 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 13263 " eth-dst <eth-dst>", 13264 .tokens = { 13265 (void *)&cmd_set_mplsogre_encap_set, 13266 (void *)&cmd_set_mplsogre_encap_mplsogre_encap, 13267 (void *)&cmd_set_mplsogre_encap_ip_version, 13268 (void *)&cmd_set_mplsogre_encap_ip_version_value, 13269 (void *)&cmd_set_mplsogre_encap_label, 13270 (void *)&cmd_set_mplsogre_encap_label_value, 13271 (void *)&cmd_set_mplsogre_encap_ip_src, 13272 (void *)&cmd_set_mplsogre_encap_ip_src_value, 13273 (void *)&cmd_set_mplsogre_encap_ip_dst, 13274 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 13275 (void *)&cmd_set_mplsogre_encap_eth_src, 13276 (void *)&cmd_set_mplsogre_encap_eth_src_value, 13277 (void *)&cmd_set_mplsogre_encap_eth_dst, 13278 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 13279 NULL, 13280 }, 13281 }; 13282 13283 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { 13284 .f = cmd_set_mplsogre_encap_parsed, 13285 .data = NULL, 13286 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" 13287 " label <label> ip-src <ip-src> ip-dst <ip-dst>" 13288 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 13289 .tokens = { 13290 (void *)&cmd_set_mplsogre_encap_set, 13291 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, 13292 (void *)&cmd_set_mplsogre_encap_ip_version, 13293 (void *)&cmd_set_mplsogre_encap_ip_version_value, 13294 (void *)&cmd_set_mplsogre_encap_label, 13295 (void *)&cmd_set_mplsogre_encap_label_value, 13296 (void *)&cmd_set_mplsogre_encap_ip_src, 13297 (void *)&cmd_set_mplsogre_encap_ip_src_value, 13298 (void *)&cmd_set_mplsogre_encap_ip_dst, 13299 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 13300 (void *)&cmd_set_mplsogre_encap_vlan, 13301 (void *)&cmd_set_mplsogre_encap_vlan_value, 13302 (void *)&cmd_set_mplsogre_encap_eth_src, 13303 (void *)&cmd_set_mplsogre_encap_eth_src_value, 13304 (void *)&cmd_set_mplsogre_encap_eth_dst, 13305 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 13306 NULL, 13307 }, 13308 }; 13309 13310 /** Set MPLSoGRE decapsulation details */ 13311 struct cmd_set_mplsogre_decap_result { 13312 cmdline_fixed_string_t set; 13313 cmdline_fixed_string_t mplsogre; 13314 cmdline_fixed_string_t pos_token; 13315 cmdline_fixed_string_t ip_version; 13316 uint32_t vlan_present:1; 13317 }; 13318 13319 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = 13320 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, 13321 "set"); 13322 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = 13323 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, 13324 "mplsogre_decap"); 13325 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = 13326 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 13327 mplsogre, "mplsogre_decap-with-vlan"); 13328 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = 13329 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 13330 pos_token, "ip-version"); 13331 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = 13332 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 13333 ip_version, "ipv4#ipv6"); 13334 13335 static void cmd_set_mplsogre_decap_parsed(void *parsed_result, 13336 __rte_unused struct cmdline *cl, 13337 __rte_unused void *data) 13338 { 13339 struct cmd_set_mplsogre_decap_result *res = parsed_result; 13340 13341 if (strcmp(res->mplsogre, "mplsogre_decap") == 0) 13342 mplsogre_decap_conf.select_vlan = 0; 13343 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) 13344 mplsogre_decap_conf.select_vlan = 1; 13345 if (strcmp(res->ip_version, "ipv4") == 0) 13346 mplsogre_decap_conf.select_ipv4 = 1; 13347 else if (strcmp(res->ip_version, "ipv6") == 0) 13348 mplsogre_decap_conf.select_ipv4 = 0; 13349 } 13350 13351 cmdline_parse_inst_t cmd_set_mplsogre_decap = { 13352 .f = cmd_set_mplsogre_decap_parsed, 13353 .data = NULL, 13354 .help_str = "set mplsogre_decap ip-version ipv4|ipv6", 13355 .tokens = { 13356 (void *)&cmd_set_mplsogre_decap_set, 13357 (void *)&cmd_set_mplsogre_decap_mplsogre_decap, 13358 (void *)&cmd_set_mplsogre_decap_ip_version, 13359 (void *)&cmd_set_mplsogre_decap_ip_version_value, 13360 NULL, 13361 }, 13362 }; 13363 13364 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { 13365 .f = cmd_set_mplsogre_decap_parsed, 13366 .data = NULL, 13367 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", 13368 .tokens = { 13369 (void *)&cmd_set_mplsogre_decap_set, 13370 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, 13371 (void *)&cmd_set_mplsogre_decap_ip_version, 13372 (void *)&cmd_set_mplsogre_decap_ip_version_value, 13373 NULL, 13374 }, 13375 }; 13376 13377 /** Set MPLSoUDP encapsulation details */ 13378 struct cmd_set_mplsoudp_encap_result { 13379 cmdline_fixed_string_t set; 13380 cmdline_fixed_string_t mplsoudp; 13381 cmdline_fixed_string_t pos_token; 13382 cmdline_fixed_string_t ip_version; 13383 uint32_t vlan_present:1; 13384 uint32_t label; 13385 uint16_t udp_src; 13386 uint16_t udp_dst; 13387 cmdline_ipaddr_t ip_src; 13388 cmdline_ipaddr_t ip_dst; 13389 uint16_t tci; 13390 struct rte_ether_addr eth_src; 13391 struct rte_ether_addr eth_dst; 13392 }; 13393 13394 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = 13395 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, 13396 "set"); 13397 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = 13398 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, 13399 "mplsoudp_encap"); 13400 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = 13401 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13402 mplsoudp, "mplsoudp_encap-with-vlan"); 13403 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = 13404 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13405 pos_token, "ip-version"); 13406 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = 13407 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13408 ip_version, "ipv4#ipv6"); 13409 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = 13410 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13411 pos_token, "label"); 13412 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = 13413 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, 13414 RTE_UINT32); 13415 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = 13416 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13417 pos_token, "udp-src"); 13418 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = 13419 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, 13420 RTE_UINT16); 13421 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = 13422 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13423 pos_token, "udp-dst"); 13424 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = 13425 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, 13426 RTE_UINT16); 13427 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = 13428 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13429 pos_token, "ip-src"); 13430 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = 13431 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); 13432 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = 13433 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13434 pos_token, "ip-dst"); 13435 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = 13436 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); 13437 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = 13438 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13439 pos_token, "vlan-tci"); 13440 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = 13441 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, 13442 RTE_UINT16); 13443 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = 13444 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13445 pos_token, "eth-src"); 13446 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = 13447 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13448 eth_src); 13449 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = 13450 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13451 pos_token, "eth-dst"); 13452 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = 13453 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13454 eth_dst); 13455 13456 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, 13457 __rte_unused struct cmdline *cl, 13458 __rte_unused void *data) 13459 { 13460 struct cmd_set_mplsoudp_encap_result *res = parsed_result; 13461 union { 13462 uint32_t mplsoudp_label; 13463 uint8_t label[4]; 13464 } id = { 13465 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12), 13466 }; 13467 13468 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) 13469 mplsoudp_encap_conf.select_vlan = 0; 13470 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) 13471 mplsoudp_encap_conf.select_vlan = 1; 13472 if (strcmp(res->ip_version, "ipv4") == 0) 13473 mplsoudp_encap_conf.select_ipv4 = 1; 13474 else if (strcmp(res->ip_version, "ipv6") == 0) 13475 mplsoudp_encap_conf.select_ipv4 = 0; 13476 else 13477 return; 13478 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3); 13479 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 13480 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 13481 if (mplsoudp_encap_conf.select_ipv4) { 13482 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); 13483 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); 13484 } else { 13485 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); 13486 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); 13487 } 13488 if (mplsoudp_encap_conf.select_vlan) 13489 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13490 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, 13491 RTE_ETHER_ADDR_LEN); 13492 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13493 RTE_ETHER_ADDR_LEN); 13494 } 13495 13496 cmdline_parse_inst_t cmd_set_mplsoudp_encap = { 13497 .f = cmd_set_mplsoudp_encap_parsed, 13498 .data = NULL, 13499 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" 13500 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" 13501 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", 13502 .tokens = { 13503 (void *)&cmd_set_mplsoudp_encap_set, 13504 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, 13505 (void *)&cmd_set_mplsoudp_encap_ip_version, 13506 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 13507 (void *)&cmd_set_mplsoudp_encap_label, 13508 (void *)&cmd_set_mplsoudp_encap_label_value, 13509 (void *)&cmd_set_mplsoudp_encap_udp_src, 13510 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 13511 (void *)&cmd_set_mplsoudp_encap_udp_dst, 13512 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 13513 (void *)&cmd_set_mplsoudp_encap_ip_src, 13514 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 13515 (void *)&cmd_set_mplsoudp_encap_ip_dst, 13516 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 13517 (void *)&cmd_set_mplsoudp_encap_eth_src, 13518 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 13519 (void *)&cmd_set_mplsoudp_encap_eth_dst, 13520 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 13521 NULL, 13522 }, 13523 }; 13524 13525 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { 13526 .f = cmd_set_mplsoudp_encap_parsed, 13527 .data = NULL, 13528 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" 13529 " label <label> udp-src <udp-src> udp-dst <udp-dst>" 13530 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 13531 " eth-src <eth-src> eth-dst <eth-dst>", 13532 .tokens = { 13533 (void *)&cmd_set_mplsoudp_encap_set, 13534 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, 13535 (void *)&cmd_set_mplsoudp_encap_ip_version, 13536 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 13537 (void *)&cmd_set_mplsoudp_encap_label, 13538 (void *)&cmd_set_mplsoudp_encap_label_value, 13539 (void *)&cmd_set_mplsoudp_encap_udp_src, 13540 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 13541 (void *)&cmd_set_mplsoudp_encap_udp_dst, 13542 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 13543 (void *)&cmd_set_mplsoudp_encap_ip_src, 13544 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 13545 (void *)&cmd_set_mplsoudp_encap_ip_dst, 13546 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 13547 (void *)&cmd_set_mplsoudp_encap_vlan, 13548 (void *)&cmd_set_mplsoudp_encap_vlan_value, 13549 (void *)&cmd_set_mplsoudp_encap_eth_src, 13550 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 13551 (void *)&cmd_set_mplsoudp_encap_eth_dst, 13552 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 13553 NULL, 13554 }, 13555 }; 13556 13557 /** Set MPLSoUDP decapsulation details */ 13558 struct cmd_set_mplsoudp_decap_result { 13559 cmdline_fixed_string_t set; 13560 cmdline_fixed_string_t mplsoudp; 13561 cmdline_fixed_string_t pos_token; 13562 cmdline_fixed_string_t ip_version; 13563 uint32_t vlan_present:1; 13564 }; 13565 13566 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = 13567 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, 13568 "set"); 13569 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = 13570 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, 13571 "mplsoudp_decap"); 13572 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = 13573 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 13574 mplsoudp, "mplsoudp_decap-with-vlan"); 13575 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = 13576 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 13577 pos_token, "ip-version"); 13578 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = 13579 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 13580 ip_version, "ipv4#ipv6"); 13581 13582 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, 13583 __rte_unused struct cmdline *cl, 13584 __rte_unused void *data) 13585 { 13586 struct cmd_set_mplsoudp_decap_result *res = parsed_result; 13587 13588 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) 13589 mplsoudp_decap_conf.select_vlan = 0; 13590 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) 13591 mplsoudp_decap_conf.select_vlan = 1; 13592 if (strcmp(res->ip_version, "ipv4") == 0) 13593 mplsoudp_decap_conf.select_ipv4 = 1; 13594 else if (strcmp(res->ip_version, "ipv6") == 0) 13595 mplsoudp_decap_conf.select_ipv4 = 0; 13596 } 13597 13598 cmdline_parse_inst_t cmd_set_mplsoudp_decap = { 13599 .f = cmd_set_mplsoudp_decap_parsed, 13600 .data = NULL, 13601 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", 13602 .tokens = { 13603 (void *)&cmd_set_mplsoudp_decap_set, 13604 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, 13605 (void *)&cmd_set_mplsoudp_decap_ip_version, 13606 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 13607 NULL, 13608 }, 13609 }; 13610 13611 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { 13612 .f = cmd_set_mplsoudp_decap_parsed, 13613 .data = NULL, 13614 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", 13615 .tokens = { 13616 (void *)&cmd_set_mplsoudp_decap_set, 13617 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, 13618 (void *)&cmd_set_mplsoudp_decap_ip_version, 13619 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 13620 NULL, 13621 }, 13622 }; 13623 13624 /* Strict link priority scheduling mode setting */ 13625 static void 13626 cmd_strict_link_prio_parsed( 13627 void *parsed_result, 13628 __rte_unused struct cmdline *cl, 13629 __rte_unused void *data) 13630 { 13631 struct cmd_vf_tc_bw_result *res = parsed_result; 13632 int ret = -ENOTSUP; 13633 13634 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13635 return; 13636 13637 #ifdef RTE_NET_I40E 13638 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 13639 #endif 13640 13641 switch (ret) { 13642 case 0: 13643 break; 13644 case -EINVAL: 13645 printf("invalid tc_bitmap 0x%x\n", res->tc_map); 13646 break; 13647 case -ENODEV: 13648 printf("invalid port_id %d\n", res->port_id); 13649 break; 13650 case -ENOTSUP: 13651 printf("function not implemented\n"); 13652 break; 13653 default: 13654 printf("programming error: (%s)\n", strerror(-ret)); 13655 } 13656 } 13657 13658 cmdline_parse_inst_t cmd_strict_link_prio = { 13659 .f = cmd_strict_link_prio_parsed, 13660 .data = NULL, 13661 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 13662 .tokens = { 13663 (void *)&cmd_vf_tc_bw_set, 13664 (void *)&cmd_vf_tc_bw_tx, 13665 (void *)&cmd_vf_tc_bw_strict_link_prio, 13666 (void *)&cmd_vf_tc_bw_port_id, 13667 (void *)&cmd_vf_tc_bw_tc_map, 13668 NULL, 13669 }, 13670 }; 13671 13672 /* Load dynamic device personalization*/ 13673 struct cmd_ddp_add_result { 13674 cmdline_fixed_string_t ddp; 13675 cmdline_fixed_string_t add; 13676 portid_t port_id; 13677 char filepath[]; 13678 }; 13679 13680 cmdline_parse_token_string_t cmd_ddp_add_ddp = 13681 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 13682 cmdline_parse_token_string_t cmd_ddp_add_add = 13683 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 13684 cmdline_parse_token_num_t cmd_ddp_add_port_id = 13685 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, 13686 RTE_UINT16); 13687 cmdline_parse_token_string_t cmd_ddp_add_filepath = 13688 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 13689 13690 static void 13691 cmd_ddp_add_parsed( 13692 void *parsed_result, 13693 __rte_unused struct cmdline *cl, 13694 __rte_unused void *data) 13695 { 13696 struct cmd_ddp_add_result *res = parsed_result; 13697 uint8_t *buff; 13698 uint32_t size; 13699 char *filepath; 13700 char *file_fld[2]; 13701 int file_num; 13702 int ret = -ENOTSUP; 13703 13704 if (!all_ports_stopped()) { 13705 printf("Please stop all ports first\n"); 13706 return; 13707 } 13708 13709 filepath = strdup(res->filepath); 13710 if (filepath == NULL) { 13711 printf("Failed to allocate memory\n"); 13712 return; 13713 } 13714 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 13715 13716 buff = open_file(file_fld[0], &size); 13717 if (!buff) { 13718 free((void *)filepath); 13719 return; 13720 } 13721 13722 #ifdef RTE_NET_I40E 13723 if (ret == -ENOTSUP) 13724 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 13725 buff, size, 13726 RTE_PMD_I40E_PKG_OP_WR_ADD); 13727 #endif 13728 13729 if (ret == -EEXIST) 13730 printf("Profile has already existed.\n"); 13731 else if (ret < 0) 13732 printf("Failed to load profile.\n"); 13733 else if (file_num == 2) 13734 save_file(file_fld[1], buff, size); 13735 13736 close_file(buff); 13737 free((void *)filepath); 13738 } 13739 13740 cmdline_parse_inst_t cmd_ddp_add = { 13741 .f = cmd_ddp_add_parsed, 13742 .data = NULL, 13743 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 13744 .tokens = { 13745 (void *)&cmd_ddp_add_ddp, 13746 (void *)&cmd_ddp_add_add, 13747 (void *)&cmd_ddp_add_port_id, 13748 (void *)&cmd_ddp_add_filepath, 13749 NULL, 13750 }, 13751 }; 13752 13753 /* Delete dynamic device personalization*/ 13754 struct cmd_ddp_del_result { 13755 cmdline_fixed_string_t ddp; 13756 cmdline_fixed_string_t del; 13757 portid_t port_id; 13758 char filepath[]; 13759 }; 13760 13761 cmdline_parse_token_string_t cmd_ddp_del_ddp = 13762 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 13763 cmdline_parse_token_string_t cmd_ddp_del_del = 13764 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 13765 cmdline_parse_token_num_t cmd_ddp_del_port_id = 13766 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16); 13767 cmdline_parse_token_string_t cmd_ddp_del_filepath = 13768 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 13769 13770 static void 13771 cmd_ddp_del_parsed( 13772 void *parsed_result, 13773 __rte_unused struct cmdline *cl, 13774 __rte_unused void *data) 13775 { 13776 struct cmd_ddp_del_result *res = parsed_result; 13777 uint8_t *buff; 13778 uint32_t size; 13779 int ret = -ENOTSUP; 13780 13781 if (!all_ports_stopped()) { 13782 printf("Please stop all ports first\n"); 13783 return; 13784 } 13785 13786 buff = open_file(res->filepath, &size); 13787 if (!buff) 13788 return; 13789 13790 #ifdef RTE_NET_I40E 13791 if (ret == -ENOTSUP) 13792 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 13793 buff, size, 13794 RTE_PMD_I40E_PKG_OP_WR_DEL); 13795 #endif 13796 13797 if (ret == -EACCES) 13798 printf("Profile does not exist.\n"); 13799 else if (ret < 0) 13800 printf("Failed to delete profile.\n"); 13801 13802 close_file(buff); 13803 } 13804 13805 cmdline_parse_inst_t cmd_ddp_del = { 13806 .f = cmd_ddp_del_parsed, 13807 .data = NULL, 13808 .help_str = "ddp del <port_id> <backup_profile_path>", 13809 .tokens = { 13810 (void *)&cmd_ddp_del_ddp, 13811 (void *)&cmd_ddp_del_del, 13812 (void *)&cmd_ddp_del_port_id, 13813 (void *)&cmd_ddp_del_filepath, 13814 NULL, 13815 }, 13816 }; 13817 13818 /* Get dynamic device personalization profile info */ 13819 struct cmd_ddp_info_result { 13820 cmdline_fixed_string_t ddp; 13821 cmdline_fixed_string_t get; 13822 cmdline_fixed_string_t info; 13823 char filepath[]; 13824 }; 13825 13826 cmdline_parse_token_string_t cmd_ddp_info_ddp = 13827 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 13828 cmdline_parse_token_string_t cmd_ddp_info_get = 13829 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 13830 cmdline_parse_token_string_t cmd_ddp_info_info = 13831 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 13832 cmdline_parse_token_string_t cmd_ddp_info_filepath = 13833 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 13834 13835 static void 13836 cmd_ddp_info_parsed( 13837 void *parsed_result, 13838 __rte_unused struct cmdline *cl, 13839 __rte_unused void *data) 13840 { 13841 struct cmd_ddp_info_result *res = parsed_result; 13842 uint8_t *pkg; 13843 uint32_t pkg_size; 13844 int ret = -ENOTSUP; 13845 #ifdef RTE_NET_I40E 13846 uint32_t i, j, n; 13847 uint8_t *buff; 13848 uint32_t buff_size = 0; 13849 struct rte_pmd_i40e_profile_info info; 13850 uint32_t dev_num = 0; 13851 struct rte_pmd_i40e_ddp_device_id *devs; 13852 uint32_t proto_num = 0; 13853 struct rte_pmd_i40e_proto_info *proto = NULL; 13854 uint32_t pctype_num = 0; 13855 struct rte_pmd_i40e_ptype_info *pctype; 13856 uint32_t ptype_num = 0; 13857 struct rte_pmd_i40e_ptype_info *ptype; 13858 uint8_t proto_id; 13859 13860 #endif 13861 13862 pkg = open_file(res->filepath, &pkg_size); 13863 if (!pkg) 13864 return; 13865 13866 #ifdef RTE_NET_I40E 13867 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13868 (uint8_t *)&info, sizeof(info), 13869 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 13870 if (!ret) { 13871 printf("Global Track id: 0x%x\n", info.track_id); 13872 printf("Global Version: %d.%d.%d.%d\n", 13873 info.version.major, 13874 info.version.minor, 13875 info.version.update, 13876 info.version.draft); 13877 printf("Global Package name: %s\n\n", info.name); 13878 } 13879 13880 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13881 (uint8_t *)&info, sizeof(info), 13882 RTE_PMD_I40E_PKG_INFO_HEADER); 13883 if (!ret) { 13884 printf("i40e Profile Track id: 0x%x\n", info.track_id); 13885 printf("i40e Profile Version: %d.%d.%d.%d\n", 13886 info.version.major, 13887 info.version.minor, 13888 info.version.update, 13889 info.version.draft); 13890 printf("i40e Profile name: %s\n\n", info.name); 13891 } 13892 13893 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13894 (uint8_t *)&buff_size, sizeof(buff_size), 13895 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 13896 if (!ret && buff_size) { 13897 buff = (uint8_t *)malloc(buff_size); 13898 if (buff) { 13899 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13900 buff, buff_size, 13901 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 13902 if (!ret) 13903 printf("Package Notes:\n%s\n\n", buff); 13904 free(buff); 13905 } 13906 } 13907 13908 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13909 (uint8_t *)&dev_num, sizeof(dev_num), 13910 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 13911 if (!ret && dev_num) { 13912 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 13913 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 13914 if (devs) { 13915 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13916 (uint8_t *)devs, buff_size, 13917 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 13918 if (!ret) { 13919 printf("List of supported devices:\n"); 13920 for (i = 0; i < dev_num; i++) { 13921 printf(" %04X:%04X %04X:%04X\n", 13922 devs[i].vendor_dev_id >> 16, 13923 devs[i].vendor_dev_id & 0xFFFF, 13924 devs[i].sub_vendor_dev_id >> 16, 13925 devs[i].sub_vendor_dev_id & 0xFFFF); 13926 } 13927 printf("\n"); 13928 } 13929 free(devs); 13930 } 13931 } 13932 13933 /* get information about protocols and packet types */ 13934 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13935 (uint8_t *)&proto_num, sizeof(proto_num), 13936 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 13937 if (ret || !proto_num) 13938 goto no_print_return; 13939 13940 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 13941 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 13942 if (!proto) 13943 goto no_print_return; 13944 13945 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 13946 buff_size, 13947 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 13948 if (!ret) { 13949 printf("List of used protocols:\n"); 13950 for (i = 0; i < proto_num; i++) 13951 printf(" %2u: %s\n", proto[i].proto_id, 13952 proto[i].name); 13953 printf("\n"); 13954 } 13955 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13956 (uint8_t *)&pctype_num, sizeof(pctype_num), 13957 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 13958 if (ret || !pctype_num) 13959 goto no_print_pctypes; 13960 13961 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 13962 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 13963 if (!pctype) 13964 goto no_print_pctypes; 13965 13966 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 13967 buff_size, 13968 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 13969 if (ret) { 13970 free(pctype); 13971 goto no_print_pctypes; 13972 } 13973 13974 printf("List of defined packet classification types:\n"); 13975 for (i = 0; i < pctype_num; i++) { 13976 printf(" %2u:", pctype[i].ptype_id); 13977 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 13978 proto_id = pctype[i].protocols[j]; 13979 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 13980 for (n = 0; n < proto_num; n++) { 13981 if (proto[n].proto_id == proto_id) { 13982 printf(" %s", proto[n].name); 13983 break; 13984 } 13985 } 13986 } 13987 } 13988 printf("\n"); 13989 } 13990 printf("\n"); 13991 free(pctype); 13992 13993 no_print_pctypes: 13994 13995 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 13996 sizeof(ptype_num), 13997 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 13998 if (ret || !ptype_num) 13999 goto no_print_return; 14000 14001 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 14002 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 14003 if (!ptype) 14004 goto no_print_return; 14005 14006 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 14007 buff_size, 14008 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 14009 if (ret) { 14010 free(ptype); 14011 goto no_print_return; 14012 } 14013 printf("List of defined packet types:\n"); 14014 for (i = 0; i < ptype_num; i++) { 14015 printf(" %2u:", ptype[i].ptype_id); 14016 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 14017 proto_id = ptype[i].protocols[j]; 14018 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 14019 for (n = 0; n < proto_num; n++) { 14020 if (proto[n].proto_id == proto_id) { 14021 printf(" %s", proto[n].name); 14022 break; 14023 } 14024 } 14025 } 14026 } 14027 printf("\n"); 14028 } 14029 free(ptype); 14030 printf("\n"); 14031 14032 ret = 0; 14033 no_print_return: 14034 if (proto) 14035 free(proto); 14036 #endif 14037 if (ret == -ENOTSUP) 14038 printf("Function not supported in PMD driver\n"); 14039 close_file(pkg); 14040 } 14041 14042 cmdline_parse_inst_t cmd_ddp_get_info = { 14043 .f = cmd_ddp_info_parsed, 14044 .data = NULL, 14045 .help_str = "ddp get info <profile_path>", 14046 .tokens = { 14047 (void *)&cmd_ddp_info_ddp, 14048 (void *)&cmd_ddp_info_get, 14049 (void *)&cmd_ddp_info_info, 14050 (void *)&cmd_ddp_info_filepath, 14051 NULL, 14052 }, 14053 }; 14054 14055 /* Get dynamic device personalization profile info list*/ 14056 #define PROFILE_INFO_SIZE 48 14057 #define MAX_PROFILE_NUM 16 14058 14059 struct cmd_ddp_get_list_result { 14060 cmdline_fixed_string_t ddp; 14061 cmdline_fixed_string_t get; 14062 cmdline_fixed_string_t list; 14063 portid_t port_id; 14064 }; 14065 14066 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 14067 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 14068 cmdline_parse_token_string_t cmd_ddp_get_list_get = 14069 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 14070 cmdline_parse_token_string_t cmd_ddp_get_list_list = 14071 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 14072 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 14073 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, 14074 RTE_UINT16); 14075 14076 static void 14077 cmd_ddp_get_list_parsed( 14078 __rte_unused void *parsed_result, 14079 __rte_unused struct cmdline *cl, 14080 __rte_unused void *data) 14081 { 14082 #ifdef RTE_NET_I40E 14083 struct cmd_ddp_get_list_result *res = parsed_result; 14084 struct rte_pmd_i40e_profile_list *p_list; 14085 struct rte_pmd_i40e_profile_info *p_info; 14086 uint32_t p_num; 14087 uint32_t size; 14088 uint32_t i; 14089 #endif 14090 int ret = -ENOTSUP; 14091 14092 #ifdef RTE_NET_I40E 14093 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 14094 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 14095 if (!p_list) { 14096 printf("%s: Failed to malloc buffer\n", __func__); 14097 return; 14098 } 14099 14100 if (ret == -ENOTSUP) 14101 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 14102 (uint8_t *)p_list, size); 14103 14104 if (!ret) { 14105 p_num = p_list->p_count; 14106 printf("Profile number is: %d\n\n", p_num); 14107 14108 for (i = 0; i < p_num; i++) { 14109 p_info = &p_list->p_info[i]; 14110 printf("Profile %d:\n", i); 14111 printf("Track id: 0x%x\n", p_info->track_id); 14112 printf("Version: %d.%d.%d.%d\n", 14113 p_info->version.major, 14114 p_info->version.minor, 14115 p_info->version.update, 14116 p_info->version.draft); 14117 printf("Profile name: %s\n\n", p_info->name); 14118 } 14119 } 14120 14121 free(p_list); 14122 #endif 14123 14124 if (ret < 0) 14125 printf("Failed to get ddp list\n"); 14126 } 14127 14128 cmdline_parse_inst_t cmd_ddp_get_list = { 14129 .f = cmd_ddp_get_list_parsed, 14130 .data = NULL, 14131 .help_str = "ddp get list <port_id>", 14132 .tokens = { 14133 (void *)&cmd_ddp_get_list_ddp, 14134 (void *)&cmd_ddp_get_list_get, 14135 (void *)&cmd_ddp_get_list_list, 14136 (void *)&cmd_ddp_get_list_port_id, 14137 NULL, 14138 }, 14139 }; 14140 14141 /* Configure input set */ 14142 struct cmd_cfg_input_set_result { 14143 cmdline_fixed_string_t port; 14144 cmdline_fixed_string_t cfg; 14145 portid_t port_id; 14146 cmdline_fixed_string_t pctype; 14147 uint8_t pctype_id; 14148 cmdline_fixed_string_t inset_type; 14149 cmdline_fixed_string_t opt; 14150 cmdline_fixed_string_t field; 14151 uint8_t field_idx; 14152 }; 14153 14154 static void 14155 cmd_cfg_input_set_parsed( 14156 __rte_unused void *parsed_result, 14157 __rte_unused struct cmdline *cl, 14158 __rte_unused void *data) 14159 { 14160 #ifdef RTE_NET_I40E 14161 struct cmd_cfg_input_set_result *res = parsed_result; 14162 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 14163 struct rte_pmd_i40e_inset inset; 14164 #endif 14165 int ret = -ENOTSUP; 14166 14167 if (!all_ports_stopped()) { 14168 printf("Please stop all ports first\n"); 14169 return; 14170 } 14171 14172 #ifdef RTE_NET_I40E 14173 if (!strcmp(res->inset_type, "hash_inset")) 14174 inset_type = INSET_HASH; 14175 else if (!strcmp(res->inset_type, "fdir_inset")) 14176 inset_type = INSET_FDIR; 14177 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 14178 inset_type = INSET_FDIR_FLX; 14179 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 14180 &inset, inset_type); 14181 if (ret) { 14182 printf("Failed to get input set.\n"); 14183 return; 14184 } 14185 14186 if (!strcmp(res->opt, "get")) { 14187 ret = rte_pmd_i40e_inset_field_get(inset.inset, 14188 res->field_idx); 14189 if (ret) 14190 printf("Field index %d is enabled.\n", res->field_idx); 14191 else 14192 printf("Field index %d is disabled.\n", res->field_idx); 14193 return; 14194 } else if (!strcmp(res->opt, "set")) 14195 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 14196 res->field_idx); 14197 else if (!strcmp(res->opt, "clear")) 14198 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 14199 res->field_idx); 14200 if (ret) { 14201 printf("Failed to configure input set field.\n"); 14202 return; 14203 } 14204 14205 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 14206 &inset, inset_type); 14207 if (ret) { 14208 printf("Failed to set input set.\n"); 14209 return; 14210 } 14211 #endif 14212 14213 if (ret == -ENOTSUP) 14214 printf("Function not supported\n"); 14215 } 14216 14217 cmdline_parse_token_string_t cmd_cfg_input_set_port = 14218 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14219 port, "port"); 14220 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 14221 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14222 cfg, "config"); 14223 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 14224 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 14225 port_id, RTE_UINT16); 14226 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 14227 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14228 pctype, "pctype"); 14229 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 14230 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 14231 pctype_id, RTE_UINT8); 14232 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 14233 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14234 inset_type, 14235 "hash_inset#fdir_inset#fdir_flx_inset"); 14236 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 14237 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14238 opt, "get#set#clear"); 14239 cmdline_parse_token_string_t cmd_cfg_input_set_field = 14240 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14241 field, "field"); 14242 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 14243 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 14244 field_idx, RTE_UINT8); 14245 14246 cmdline_parse_inst_t cmd_cfg_input_set = { 14247 .f = cmd_cfg_input_set_parsed, 14248 .data = NULL, 14249 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 14250 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 14251 .tokens = { 14252 (void *)&cmd_cfg_input_set_port, 14253 (void *)&cmd_cfg_input_set_cfg, 14254 (void *)&cmd_cfg_input_set_port_id, 14255 (void *)&cmd_cfg_input_set_pctype, 14256 (void *)&cmd_cfg_input_set_pctype_id, 14257 (void *)&cmd_cfg_input_set_inset_type, 14258 (void *)&cmd_cfg_input_set_opt, 14259 (void *)&cmd_cfg_input_set_field, 14260 (void *)&cmd_cfg_input_set_field_idx, 14261 NULL, 14262 }, 14263 }; 14264 14265 /* Clear input set */ 14266 struct cmd_clear_input_set_result { 14267 cmdline_fixed_string_t port; 14268 cmdline_fixed_string_t cfg; 14269 portid_t port_id; 14270 cmdline_fixed_string_t pctype; 14271 uint8_t pctype_id; 14272 cmdline_fixed_string_t inset_type; 14273 cmdline_fixed_string_t clear; 14274 cmdline_fixed_string_t all; 14275 }; 14276 14277 static void 14278 cmd_clear_input_set_parsed( 14279 __rte_unused void *parsed_result, 14280 __rte_unused struct cmdline *cl, 14281 __rte_unused void *data) 14282 { 14283 #ifdef RTE_NET_I40E 14284 struct cmd_clear_input_set_result *res = parsed_result; 14285 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 14286 struct rte_pmd_i40e_inset inset; 14287 #endif 14288 int ret = -ENOTSUP; 14289 14290 if (!all_ports_stopped()) { 14291 printf("Please stop all ports first\n"); 14292 return; 14293 } 14294 14295 #ifdef RTE_NET_I40E 14296 if (!strcmp(res->inset_type, "hash_inset")) 14297 inset_type = INSET_HASH; 14298 else if (!strcmp(res->inset_type, "fdir_inset")) 14299 inset_type = INSET_FDIR; 14300 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 14301 inset_type = INSET_FDIR_FLX; 14302 14303 memset(&inset, 0, sizeof(inset)); 14304 14305 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 14306 &inset, inset_type); 14307 if (ret) { 14308 printf("Failed to clear input set.\n"); 14309 return; 14310 } 14311 14312 #endif 14313 14314 if (ret == -ENOTSUP) 14315 printf("Function not supported\n"); 14316 } 14317 14318 cmdline_parse_token_string_t cmd_clear_input_set_port = 14319 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14320 port, "port"); 14321 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 14322 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14323 cfg, "config"); 14324 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 14325 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 14326 port_id, RTE_UINT16); 14327 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 14328 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14329 pctype, "pctype"); 14330 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 14331 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 14332 pctype_id, RTE_UINT8); 14333 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 14334 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14335 inset_type, 14336 "hash_inset#fdir_inset#fdir_flx_inset"); 14337 cmdline_parse_token_string_t cmd_clear_input_set_clear = 14338 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14339 clear, "clear"); 14340 cmdline_parse_token_string_t cmd_clear_input_set_all = 14341 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14342 all, "all"); 14343 14344 cmdline_parse_inst_t cmd_clear_input_set = { 14345 .f = cmd_clear_input_set_parsed, 14346 .data = NULL, 14347 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 14348 "fdir_inset|fdir_flx_inset clear all", 14349 .tokens = { 14350 (void *)&cmd_clear_input_set_port, 14351 (void *)&cmd_clear_input_set_cfg, 14352 (void *)&cmd_clear_input_set_port_id, 14353 (void *)&cmd_clear_input_set_pctype, 14354 (void *)&cmd_clear_input_set_pctype_id, 14355 (void *)&cmd_clear_input_set_inset_type, 14356 (void *)&cmd_clear_input_set_clear, 14357 (void *)&cmd_clear_input_set_all, 14358 NULL, 14359 }, 14360 }; 14361 14362 /* show vf stats */ 14363 14364 /* Common result structure for show vf stats */ 14365 struct cmd_show_vf_stats_result { 14366 cmdline_fixed_string_t show; 14367 cmdline_fixed_string_t vf; 14368 cmdline_fixed_string_t stats; 14369 portid_t port_id; 14370 uint16_t vf_id; 14371 }; 14372 14373 /* Common CLI fields show vf stats*/ 14374 cmdline_parse_token_string_t cmd_show_vf_stats_show = 14375 TOKEN_STRING_INITIALIZER 14376 (struct cmd_show_vf_stats_result, 14377 show, "show"); 14378 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 14379 TOKEN_STRING_INITIALIZER 14380 (struct cmd_show_vf_stats_result, 14381 vf, "vf"); 14382 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 14383 TOKEN_STRING_INITIALIZER 14384 (struct cmd_show_vf_stats_result, 14385 stats, "stats"); 14386 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 14387 TOKEN_NUM_INITIALIZER 14388 (struct cmd_show_vf_stats_result, 14389 port_id, RTE_UINT16); 14390 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 14391 TOKEN_NUM_INITIALIZER 14392 (struct cmd_show_vf_stats_result, 14393 vf_id, RTE_UINT16); 14394 14395 static void 14396 cmd_show_vf_stats_parsed( 14397 void *parsed_result, 14398 __rte_unused struct cmdline *cl, 14399 __rte_unused void *data) 14400 { 14401 struct cmd_show_vf_stats_result *res = parsed_result; 14402 struct rte_eth_stats stats; 14403 int ret = -ENOTSUP; 14404 static const char *nic_stats_border = "########################"; 14405 14406 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14407 return; 14408 14409 memset(&stats, 0, sizeof(stats)); 14410 14411 #ifdef RTE_NET_I40E 14412 if (ret == -ENOTSUP) 14413 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 14414 res->vf_id, 14415 &stats); 14416 #endif 14417 #ifdef RTE_NET_BNXT 14418 if (ret == -ENOTSUP) 14419 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 14420 res->vf_id, 14421 &stats); 14422 #endif 14423 14424 switch (ret) { 14425 case 0: 14426 break; 14427 case -EINVAL: 14428 printf("invalid vf_id %d\n", res->vf_id); 14429 break; 14430 case -ENODEV: 14431 printf("invalid port_id %d\n", res->port_id); 14432 break; 14433 case -ENOTSUP: 14434 printf("function not implemented\n"); 14435 break; 14436 default: 14437 printf("programming error: (%s)\n", strerror(-ret)); 14438 } 14439 14440 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 14441 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 14442 14443 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 14444 "%-"PRIu64"\n", 14445 stats.ipackets, stats.imissed, stats.ibytes); 14446 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 14447 printf(" RX-nombuf: %-10"PRIu64"\n", 14448 stats.rx_nombuf); 14449 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 14450 "%-"PRIu64"\n", 14451 stats.opackets, stats.oerrors, stats.obytes); 14452 14453 printf(" %s############################%s\n", 14454 nic_stats_border, nic_stats_border); 14455 } 14456 14457 cmdline_parse_inst_t cmd_show_vf_stats = { 14458 .f = cmd_show_vf_stats_parsed, 14459 .data = NULL, 14460 .help_str = "show vf stats <port_id> <vf_id>", 14461 .tokens = { 14462 (void *)&cmd_show_vf_stats_show, 14463 (void *)&cmd_show_vf_stats_vf, 14464 (void *)&cmd_show_vf_stats_stats, 14465 (void *)&cmd_show_vf_stats_port_id, 14466 (void *)&cmd_show_vf_stats_vf_id, 14467 NULL, 14468 }, 14469 }; 14470 14471 /* clear vf stats */ 14472 14473 /* Common result structure for clear vf stats */ 14474 struct cmd_clear_vf_stats_result { 14475 cmdline_fixed_string_t clear; 14476 cmdline_fixed_string_t vf; 14477 cmdline_fixed_string_t stats; 14478 portid_t port_id; 14479 uint16_t vf_id; 14480 }; 14481 14482 /* Common CLI fields clear vf stats*/ 14483 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 14484 TOKEN_STRING_INITIALIZER 14485 (struct cmd_clear_vf_stats_result, 14486 clear, "clear"); 14487 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 14488 TOKEN_STRING_INITIALIZER 14489 (struct cmd_clear_vf_stats_result, 14490 vf, "vf"); 14491 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 14492 TOKEN_STRING_INITIALIZER 14493 (struct cmd_clear_vf_stats_result, 14494 stats, "stats"); 14495 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 14496 TOKEN_NUM_INITIALIZER 14497 (struct cmd_clear_vf_stats_result, 14498 port_id, RTE_UINT16); 14499 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 14500 TOKEN_NUM_INITIALIZER 14501 (struct cmd_clear_vf_stats_result, 14502 vf_id, RTE_UINT16); 14503 14504 static void 14505 cmd_clear_vf_stats_parsed( 14506 void *parsed_result, 14507 __rte_unused struct cmdline *cl, 14508 __rte_unused void *data) 14509 { 14510 struct cmd_clear_vf_stats_result *res = parsed_result; 14511 int ret = -ENOTSUP; 14512 14513 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14514 return; 14515 14516 #ifdef RTE_NET_I40E 14517 if (ret == -ENOTSUP) 14518 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 14519 res->vf_id); 14520 #endif 14521 #ifdef RTE_NET_BNXT 14522 if (ret == -ENOTSUP) 14523 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 14524 res->vf_id); 14525 #endif 14526 14527 switch (ret) { 14528 case 0: 14529 break; 14530 case -EINVAL: 14531 printf("invalid vf_id %d\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_clear_vf_stats = { 14545 .f = cmd_clear_vf_stats_parsed, 14546 .data = NULL, 14547 .help_str = "clear vf stats <port_id> <vf_id>", 14548 .tokens = { 14549 (void *)&cmd_clear_vf_stats_clear, 14550 (void *)&cmd_clear_vf_stats_vf, 14551 (void *)&cmd_clear_vf_stats_stats, 14552 (void *)&cmd_clear_vf_stats_port_id, 14553 (void *)&cmd_clear_vf_stats_vf_id, 14554 NULL, 14555 }, 14556 }; 14557 14558 /* port config pctype mapping reset */ 14559 14560 /* Common result structure for port config pctype mapping reset */ 14561 struct cmd_pctype_mapping_reset_result { 14562 cmdline_fixed_string_t port; 14563 cmdline_fixed_string_t config; 14564 portid_t port_id; 14565 cmdline_fixed_string_t pctype; 14566 cmdline_fixed_string_t mapping; 14567 cmdline_fixed_string_t reset; 14568 }; 14569 14570 /* Common CLI fields for port config pctype mapping reset*/ 14571 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 14572 TOKEN_STRING_INITIALIZER 14573 (struct cmd_pctype_mapping_reset_result, 14574 port, "port"); 14575 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 14576 TOKEN_STRING_INITIALIZER 14577 (struct cmd_pctype_mapping_reset_result, 14578 config, "config"); 14579 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 14580 TOKEN_NUM_INITIALIZER 14581 (struct cmd_pctype_mapping_reset_result, 14582 port_id, RTE_UINT16); 14583 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 14584 TOKEN_STRING_INITIALIZER 14585 (struct cmd_pctype_mapping_reset_result, 14586 pctype, "pctype"); 14587 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 14588 TOKEN_STRING_INITIALIZER 14589 (struct cmd_pctype_mapping_reset_result, 14590 mapping, "mapping"); 14591 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 14592 TOKEN_STRING_INITIALIZER 14593 (struct cmd_pctype_mapping_reset_result, 14594 reset, "reset"); 14595 14596 static void 14597 cmd_pctype_mapping_reset_parsed( 14598 void *parsed_result, 14599 __rte_unused struct cmdline *cl, 14600 __rte_unused void *data) 14601 { 14602 struct cmd_pctype_mapping_reset_result *res = parsed_result; 14603 int ret = -ENOTSUP; 14604 14605 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14606 return; 14607 14608 #ifdef RTE_NET_I40E 14609 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 14610 #endif 14611 14612 switch (ret) { 14613 case 0: 14614 break; 14615 case -ENODEV: 14616 printf("invalid port_id %d\n", res->port_id); 14617 break; 14618 case -ENOTSUP: 14619 printf("function not implemented\n"); 14620 break; 14621 default: 14622 printf("programming error: (%s)\n", strerror(-ret)); 14623 } 14624 } 14625 14626 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 14627 .f = cmd_pctype_mapping_reset_parsed, 14628 .data = NULL, 14629 .help_str = "port config <port_id> pctype mapping reset", 14630 .tokens = { 14631 (void *)&cmd_pctype_mapping_reset_port, 14632 (void *)&cmd_pctype_mapping_reset_config, 14633 (void *)&cmd_pctype_mapping_reset_port_id, 14634 (void *)&cmd_pctype_mapping_reset_pctype, 14635 (void *)&cmd_pctype_mapping_reset_mapping, 14636 (void *)&cmd_pctype_mapping_reset_reset, 14637 NULL, 14638 }, 14639 }; 14640 14641 /* show port pctype mapping */ 14642 14643 /* Common result structure for show port pctype mapping */ 14644 struct cmd_pctype_mapping_get_result { 14645 cmdline_fixed_string_t show; 14646 cmdline_fixed_string_t port; 14647 portid_t port_id; 14648 cmdline_fixed_string_t pctype; 14649 cmdline_fixed_string_t mapping; 14650 }; 14651 14652 /* Common CLI fields for pctype mapping get */ 14653 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 14654 TOKEN_STRING_INITIALIZER 14655 (struct cmd_pctype_mapping_get_result, 14656 show, "show"); 14657 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 14658 TOKEN_STRING_INITIALIZER 14659 (struct cmd_pctype_mapping_get_result, 14660 port, "port"); 14661 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 14662 TOKEN_NUM_INITIALIZER 14663 (struct cmd_pctype_mapping_get_result, 14664 port_id, RTE_UINT16); 14665 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 14666 TOKEN_STRING_INITIALIZER 14667 (struct cmd_pctype_mapping_get_result, 14668 pctype, "pctype"); 14669 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 14670 TOKEN_STRING_INITIALIZER 14671 (struct cmd_pctype_mapping_get_result, 14672 mapping, "mapping"); 14673 14674 static void 14675 cmd_pctype_mapping_get_parsed( 14676 void *parsed_result, 14677 __rte_unused struct cmdline *cl, 14678 __rte_unused void *data) 14679 { 14680 struct cmd_pctype_mapping_get_result *res = parsed_result; 14681 int ret = -ENOTSUP; 14682 #ifdef RTE_NET_I40E 14683 struct rte_pmd_i40e_flow_type_mapping 14684 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 14685 int i, j, first_pctype; 14686 #endif 14687 14688 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14689 return; 14690 14691 #ifdef RTE_NET_I40E 14692 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 14693 #endif 14694 14695 switch (ret) { 14696 case 0: 14697 break; 14698 case -ENODEV: 14699 printf("invalid port_id %d\n", res->port_id); 14700 return; 14701 case -ENOTSUP: 14702 printf("function not implemented\n"); 14703 return; 14704 default: 14705 printf("programming error: (%s)\n", strerror(-ret)); 14706 return; 14707 } 14708 14709 #ifdef RTE_NET_I40E 14710 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 14711 if (mapping[i].pctype != 0ULL) { 14712 first_pctype = 1; 14713 14714 printf("pctype: "); 14715 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 14716 if (mapping[i].pctype & (1ULL << j)) { 14717 printf(first_pctype ? 14718 "%02d" : ",%02d", j); 14719 first_pctype = 0; 14720 } 14721 } 14722 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 14723 } 14724 } 14725 #endif 14726 } 14727 14728 cmdline_parse_inst_t cmd_pctype_mapping_get = { 14729 .f = cmd_pctype_mapping_get_parsed, 14730 .data = NULL, 14731 .help_str = "show port <port_id> pctype mapping", 14732 .tokens = { 14733 (void *)&cmd_pctype_mapping_get_show, 14734 (void *)&cmd_pctype_mapping_get_port, 14735 (void *)&cmd_pctype_mapping_get_port_id, 14736 (void *)&cmd_pctype_mapping_get_pctype, 14737 (void *)&cmd_pctype_mapping_get_mapping, 14738 NULL, 14739 }, 14740 }; 14741 14742 /* port config pctype mapping update */ 14743 14744 /* Common result structure for port config pctype mapping update */ 14745 struct cmd_pctype_mapping_update_result { 14746 cmdline_fixed_string_t port; 14747 cmdline_fixed_string_t config; 14748 portid_t port_id; 14749 cmdline_fixed_string_t pctype; 14750 cmdline_fixed_string_t mapping; 14751 cmdline_fixed_string_t update; 14752 cmdline_fixed_string_t pctype_list; 14753 uint16_t flow_type; 14754 }; 14755 14756 /* Common CLI fields for pctype mapping update*/ 14757 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 14758 TOKEN_STRING_INITIALIZER 14759 (struct cmd_pctype_mapping_update_result, 14760 port, "port"); 14761 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 14762 TOKEN_STRING_INITIALIZER 14763 (struct cmd_pctype_mapping_update_result, 14764 config, "config"); 14765 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 14766 TOKEN_NUM_INITIALIZER 14767 (struct cmd_pctype_mapping_update_result, 14768 port_id, RTE_UINT16); 14769 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 14770 TOKEN_STRING_INITIALIZER 14771 (struct cmd_pctype_mapping_update_result, 14772 pctype, "pctype"); 14773 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 14774 TOKEN_STRING_INITIALIZER 14775 (struct cmd_pctype_mapping_update_result, 14776 mapping, "mapping"); 14777 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 14778 TOKEN_STRING_INITIALIZER 14779 (struct cmd_pctype_mapping_update_result, 14780 update, "update"); 14781 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 14782 TOKEN_STRING_INITIALIZER 14783 (struct cmd_pctype_mapping_update_result, 14784 pctype_list, NULL); 14785 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 14786 TOKEN_NUM_INITIALIZER 14787 (struct cmd_pctype_mapping_update_result, 14788 flow_type, RTE_UINT16); 14789 14790 static void 14791 cmd_pctype_mapping_update_parsed( 14792 void *parsed_result, 14793 __rte_unused struct cmdline *cl, 14794 __rte_unused void *data) 14795 { 14796 struct cmd_pctype_mapping_update_result *res = parsed_result; 14797 int ret = -ENOTSUP; 14798 #ifdef RTE_NET_I40E 14799 struct rte_pmd_i40e_flow_type_mapping mapping; 14800 unsigned int i; 14801 unsigned int nb_item; 14802 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 14803 #endif 14804 14805 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14806 return; 14807 14808 #ifdef RTE_NET_I40E 14809 nb_item = parse_item_list(res->pctype_list, "pctypes", 14810 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 14811 mapping.flow_type = res->flow_type; 14812 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 14813 mapping.pctype |= (1ULL << pctype_list[i]); 14814 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 14815 &mapping, 14816 1, 14817 0); 14818 #endif 14819 14820 switch (ret) { 14821 case 0: 14822 break; 14823 case -EINVAL: 14824 printf("invalid pctype or flow type\n"); 14825 break; 14826 case -ENODEV: 14827 printf("invalid port_id %d\n", res->port_id); 14828 break; 14829 case -ENOTSUP: 14830 printf("function not implemented\n"); 14831 break; 14832 default: 14833 printf("programming error: (%s)\n", strerror(-ret)); 14834 } 14835 } 14836 14837 cmdline_parse_inst_t cmd_pctype_mapping_update = { 14838 .f = cmd_pctype_mapping_update_parsed, 14839 .data = NULL, 14840 .help_str = "port config <port_id> pctype mapping update" 14841 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 14842 .tokens = { 14843 (void *)&cmd_pctype_mapping_update_port, 14844 (void *)&cmd_pctype_mapping_update_config, 14845 (void *)&cmd_pctype_mapping_update_port_id, 14846 (void *)&cmd_pctype_mapping_update_pctype, 14847 (void *)&cmd_pctype_mapping_update_mapping, 14848 (void *)&cmd_pctype_mapping_update_update, 14849 (void *)&cmd_pctype_mapping_update_pc_type, 14850 (void *)&cmd_pctype_mapping_update_flow_type, 14851 NULL, 14852 }, 14853 }; 14854 14855 /* ptype mapping get */ 14856 14857 /* Common result structure for ptype mapping get */ 14858 struct cmd_ptype_mapping_get_result { 14859 cmdline_fixed_string_t ptype; 14860 cmdline_fixed_string_t mapping; 14861 cmdline_fixed_string_t get; 14862 portid_t port_id; 14863 uint8_t valid_only; 14864 }; 14865 14866 /* Common CLI fields for ptype mapping get */ 14867 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 14868 TOKEN_STRING_INITIALIZER 14869 (struct cmd_ptype_mapping_get_result, 14870 ptype, "ptype"); 14871 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 14872 TOKEN_STRING_INITIALIZER 14873 (struct cmd_ptype_mapping_get_result, 14874 mapping, "mapping"); 14875 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 14876 TOKEN_STRING_INITIALIZER 14877 (struct cmd_ptype_mapping_get_result, 14878 get, "get"); 14879 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 14880 TOKEN_NUM_INITIALIZER 14881 (struct cmd_ptype_mapping_get_result, 14882 port_id, RTE_UINT16); 14883 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 14884 TOKEN_NUM_INITIALIZER 14885 (struct cmd_ptype_mapping_get_result, 14886 valid_only, RTE_UINT8); 14887 14888 static void 14889 cmd_ptype_mapping_get_parsed( 14890 void *parsed_result, 14891 __rte_unused struct cmdline *cl, 14892 __rte_unused void *data) 14893 { 14894 struct cmd_ptype_mapping_get_result *res = parsed_result; 14895 int ret = -ENOTSUP; 14896 #ifdef RTE_NET_I40E 14897 int max_ptype_num = 256; 14898 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 14899 uint16_t count; 14900 int i; 14901 #endif 14902 14903 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14904 return; 14905 14906 #ifdef RTE_NET_I40E 14907 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 14908 mapping, 14909 max_ptype_num, 14910 &count, 14911 res->valid_only); 14912 #endif 14913 14914 switch (ret) { 14915 case 0: 14916 break; 14917 case -ENODEV: 14918 printf("invalid port_id %d\n", res->port_id); 14919 break; 14920 case -ENOTSUP: 14921 printf("function not implemented\n"); 14922 break; 14923 default: 14924 printf("programming error: (%s)\n", strerror(-ret)); 14925 } 14926 14927 #ifdef RTE_NET_I40E 14928 if (!ret) { 14929 for (i = 0; i < count; i++) 14930 printf("%3d\t0x%08x\n", 14931 mapping[i].hw_ptype, mapping[i].sw_ptype); 14932 } 14933 #endif 14934 } 14935 14936 cmdline_parse_inst_t cmd_ptype_mapping_get = { 14937 .f = cmd_ptype_mapping_get_parsed, 14938 .data = NULL, 14939 .help_str = "ptype mapping get <port_id> <valid_only>", 14940 .tokens = { 14941 (void *)&cmd_ptype_mapping_get_ptype, 14942 (void *)&cmd_ptype_mapping_get_mapping, 14943 (void *)&cmd_ptype_mapping_get_get, 14944 (void *)&cmd_ptype_mapping_get_port_id, 14945 (void *)&cmd_ptype_mapping_get_valid_only, 14946 NULL, 14947 }, 14948 }; 14949 14950 /* ptype mapping replace */ 14951 14952 /* Common result structure for ptype mapping replace */ 14953 struct cmd_ptype_mapping_replace_result { 14954 cmdline_fixed_string_t ptype; 14955 cmdline_fixed_string_t mapping; 14956 cmdline_fixed_string_t replace; 14957 portid_t port_id; 14958 uint32_t target; 14959 uint8_t mask; 14960 uint32_t pkt_type; 14961 }; 14962 14963 /* Common CLI fields for ptype mapping replace */ 14964 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 14965 TOKEN_STRING_INITIALIZER 14966 (struct cmd_ptype_mapping_replace_result, 14967 ptype, "ptype"); 14968 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 14969 TOKEN_STRING_INITIALIZER 14970 (struct cmd_ptype_mapping_replace_result, 14971 mapping, "mapping"); 14972 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 14973 TOKEN_STRING_INITIALIZER 14974 (struct cmd_ptype_mapping_replace_result, 14975 replace, "replace"); 14976 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 14977 TOKEN_NUM_INITIALIZER 14978 (struct cmd_ptype_mapping_replace_result, 14979 port_id, RTE_UINT16); 14980 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 14981 TOKEN_NUM_INITIALIZER 14982 (struct cmd_ptype_mapping_replace_result, 14983 target, RTE_UINT32); 14984 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 14985 TOKEN_NUM_INITIALIZER 14986 (struct cmd_ptype_mapping_replace_result, 14987 mask, RTE_UINT8); 14988 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 14989 TOKEN_NUM_INITIALIZER 14990 (struct cmd_ptype_mapping_replace_result, 14991 pkt_type, RTE_UINT32); 14992 14993 static void 14994 cmd_ptype_mapping_replace_parsed( 14995 void *parsed_result, 14996 __rte_unused struct cmdline *cl, 14997 __rte_unused void *data) 14998 { 14999 struct cmd_ptype_mapping_replace_result *res = parsed_result; 15000 int ret = -ENOTSUP; 15001 15002 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15003 return; 15004 15005 #ifdef RTE_NET_I40E 15006 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 15007 res->target, 15008 res->mask, 15009 res->pkt_type); 15010 #endif 15011 15012 switch (ret) { 15013 case 0: 15014 break; 15015 case -EINVAL: 15016 printf("invalid ptype 0x%8x or 0x%8x\n", 15017 res->target, res->pkt_type); 15018 break; 15019 case -ENODEV: 15020 printf("invalid port_id %d\n", res->port_id); 15021 break; 15022 case -ENOTSUP: 15023 printf("function not implemented\n"); 15024 break; 15025 default: 15026 printf("programming error: (%s)\n", strerror(-ret)); 15027 } 15028 } 15029 15030 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 15031 .f = cmd_ptype_mapping_replace_parsed, 15032 .data = NULL, 15033 .help_str = 15034 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 15035 .tokens = { 15036 (void *)&cmd_ptype_mapping_replace_ptype, 15037 (void *)&cmd_ptype_mapping_replace_mapping, 15038 (void *)&cmd_ptype_mapping_replace_replace, 15039 (void *)&cmd_ptype_mapping_replace_port_id, 15040 (void *)&cmd_ptype_mapping_replace_target, 15041 (void *)&cmd_ptype_mapping_replace_mask, 15042 (void *)&cmd_ptype_mapping_replace_pkt_type, 15043 NULL, 15044 }, 15045 }; 15046 15047 /* ptype mapping reset */ 15048 15049 /* Common result structure for ptype mapping reset */ 15050 struct cmd_ptype_mapping_reset_result { 15051 cmdline_fixed_string_t ptype; 15052 cmdline_fixed_string_t mapping; 15053 cmdline_fixed_string_t reset; 15054 portid_t port_id; 15055 }; 15056 15057 /* Common CLI fields for ptype mapping reset*/ 15058 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 15059 TOKEN_STRING_INITIALIZER 15060 (struct cmd_ptype_mapping_reset_result, 15061 ptype, "ptype"); 15062 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 15063 TOKEN_STRING_INITIALIZER 15064 (struct cmd_ptype_mapping_reset_result, 15065 mapping, "mapping"); 15066 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 15067 TOKEN_STRING_INITIALIZER 15068 (struct cmd_ptype_mapping_reset_result, 15069 reset, "reset"); 15070 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 15071 TOKEN_NUM_INITIALIZER 15072 (struct cmd_ptype_mapping_reset_result, 15073 port_id, RTE_UINT16); 15074 15075 static void 15076 cmd_ptype_mapping_reset_parsed( 15077 void *parsed_result, 15078 __rte_unused struct cmdline *cl, 15079 __rte_unused void *data) 15080 { 15081 struct cmd_ptype_mapping_reset_result *res = parsed_result; 15082 int ret = -ENOTSUP; 15083 15084 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15085 return; 15086 15087 #ifdef RTE_NET_I40E 15088 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 15089 #endif 15090 15091 switch (ret) { 15092 case 0: 15093 break; 15094 case -ENODEV: 15095 printf("invalid port_id %d\n", res->port_id); 15096 break; 15097 case -ENOTSUP: 15098 printf("function not implemented\n"); 15099 break; 15100 default: 15101 printf("programming error: (%s)\n", strerror(-ret)); 15102 } 15103 } 15104 15105 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 15106 .f = cmd_ptype_mapping_reset_parsed, 15107 .data = NULL, 15108 .help_str = "ptype mapping reset <port_id>", 15109 .tokens = { 15110 (void *)&cmd_ptype_mapping_reset_ptype, 15111 (void *)&cmd_ptype_mapping_reset_mapping, 15112 (void *)&cmd_ptype_mapping_reset_reset, 15113 (void *)&cmd_ptype_mapping_reset_port_id, 15114 NULL, 15115 }, 15116 }; 15117 15118 /* ptype mapping update */ 15119 15120 /* Common result structure for ptype mapping update */ 15121 struct cmd_ptype_mapping_update_result { 15122 cmdline_fixed_string_t ptype; 15123 cmdline_fixed_string_t mapping; 15124 cmdline_fixed_string_t reset; 15125 portid_t port_id; 15126 uint8_t hw_ptype; 15127 uint32_t sw_ptype; 15128 }; 15129 15130 /* Common CLI fields for ptype mapping update*/ 15131 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 15132 TOKEN_STRING_INITIALIZER 15133 (struct cmd_ptype_mapping_update_result, 15134 ptype, "ptype"); 15135 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 15136 TOKEN_STRING_INITIALIZER 15137 (struct cmd_ptype_mapping_update_result, 15138 mapping, "mapping"); 15139 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 15140 TOKEN_STRING_INITIALIZER 15141 (struct cmd_ptype_mapping_update_result, 15142 reset, "update"); 15143 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 15144 TOKEN_NUM_INITIALIZER 15145 (struct cmd_ptype_mapping_update_result, 15146 port_id, RTE_UINT16); 15147 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 15148 TOKEN_NUM_INITIALIZER 15149 (struct cmd_ptype_mapping_update_result, 15150 hw_ptype, RTE_UINT8); 15151 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 15152 TOKEN_NUM_INITIALIZER 15153 (struct cmd_ptype_mapping_update_result, 15154 sw_ptype, RTE_UINT32); 15155 15156 static void 15157 cmd_ptype_mapping_update_parsed( 15158 void *parsed_result, 15159 __rte_unused struct cmdline *cl, 15160 __rte_unused void *data) 15161 { 15162 struct cmd_ptype_mapping_update_result *res = parsed_result; 15163 int ret = -ENOTSUP; 15164 #ifdef RTE_NET_I40E 15165 struct rte_pmd_i40e_ptype_mapping mapping; 15166 #endif 15167 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15168 return; 15169 15170 #ifdef RTE_NET_I40E 15171 mapping.hw_ptype = res->hw_ptype; 15172 mapping.sw_ptype = res->sw_ptype; 15173 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 15174 &mapping, 15175 1, 15176 0); 15177 #endif 15178 15179 switch (ret) { 15180 case 0: 15181 break; 15182 case -EINVAL: 15183 printf("invalid ptype 0x%8x\n", res->sw_ptype); 15184 break; 15185 case -ENODEV: 15186 printf("invalid port_id %d\n", res->port_id); 15187 break; 15188 case -ENOTSUP: 15189 printf("function not implemented\n"); 15190 break; 15191 default: 15192 printf("programming error: (%s)\n", strerror(-ret)); 15193 } 15194 } 15195 15196 cmdline_parse_inst_t cmd_ptype_mapping_update = { 15197 .f = cmd_ptype_mapping_update_parsed, 15198 .data = NULL, 15199 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 15200 .tokens = { 15201 (void *)&cmd_ptype_mapping_update_ptype, 15202 (void *)&cmd_ptype_mapping_update_mapping, 15203 (void *)&cmd_ptype_mapping_update_update, 15204 (void *)&cmd_ptype_mapping_update_port_id, 15205 (void *)&cmd_ptype_mapping_update_hw_ptype, 15206 (void *)&cmd_ptype_mapping_update_sw_ptype, 15207 NULL, 15208 }, 15209 }; 15210 15211 /* Common result structure for file commands */ 15212 struct cmd_cmdfile_result { 15213 cmdline_fixed_string_t load; 15214 cmdline_fixed_string_t filename; 15215 }; 15216 15217 /* Common CLI fields for file commands */ 15218 cmdline_parse_token_string_t cmd_load_cmdfile = 15219 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 15220 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 15221 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 15222 15223 static void 15224 cmd_load_from_file_parsed( 15225 void *parsed_result, 15226 __rte_unused struct cmdline *cl, 15227 __rte_unused void *data) 15228 { 15229 struct cmd_cmdfile_result *res = parsed_result; 15230 15231 cmdline_read_from_file(res->filename); 15232 } 15233 15234 cmdline_parse_inst_t cmd_load_from_file = { 15235 .f = cmd_load_from_file_parsed, 15236 .data = NULL, 15237 .help_str = "load <filename>", 15238 .tokens = { 15239 (void *)&cmd_load_cmdfile, 15240 (void *)&cmd_load_cmdfile_filename, 15241 NULL, 15242 }, 15243 }; 15244 15245 /* Get Rx offloads capabilities */ 15246 struct cmd_rx_offload_get_capa_result { 15247 cmdline_fixed_string_t show; 15248 cmdline_fixed_string_t port; 15249 portid_t port_id; 15250 cmdline_fixed_string_t rx_offload; 15251 cmdline_fixed_string_t capabilities; 15252 }; 15253 15254 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 15255 TOKEN_STRING_INITIALIZER 15256 (struct cmd_rx_offload_get_capa_result, 15257 show, "show"); 15258 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 15259 TOKEN_STRING_INITIALIZER 15260 (struct cmd_rx_offload_get_capa_result, 15261 port, "port"); 15262 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 15263 TOKEN_NUM_INITIALIZER 15264 (struct cmd_rx_offload_get_capa_result, 15265 port_id, RTE_UINT16); 15266 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 15267 TOKEN_STRING_INITIALIZER 15268 (struct cmd_rx_offload_get_capa_result, 15269 rx_offload, "rx_offload"); 15270 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 15271 TOKEN_STRING_INITIALIZER 15272 (struct cmd_rx_offload_get_capa_result, 15273 capabilities, "capabilities"); 15274 15275 static void 15276 print_rx_offloads(uint64_t offloads) 15277 { 15278 uint64_t single_offload; 15279 int begin; 15280 int end; 15281 int bit; 15282 15283 if (offloads == 0) 15284 return; 15285 15286 begin = __builtin_ctzll(offloads); 15287 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 15288 15289 single_offload = 1ULL << begin; 15290 for (bit = begin; bit < end; bit++) { 15291 if (offloads & single_offload) 15292 printf(" %s", 15293 rte_eth_dev_rx_offload_name(single_offload)); 15294 single_offload <<= 1; 15295 } 15296 } 15297 15298 static void 15299 cmd_rx_offload_get_capa_parsed( 15300 void *parsed_result, 15301 __rte_unused struct cmdline *cl, 15302 __rte_unused void *data) 15303 { 15304 struct cmd_rx_offload_get_capa_result *res = parsed_result; 15305 struct rte_eth_dev_info dev_info; 15306 portid_t port_id = res->port_id; 15307 uint64_t queue_offloads; 15308 uint64_t port_offloads; 15309 int ret; 15310 15311 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15312 if (ret != 0) 15313 return; 15314 15315 queue_offloads = dev_info.rx_queue_offload_capa; 15316 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 15317 15318 printf("Rx Offloading Capabilities of port %d :\n", port_id); 15319 printf(" Per Queue :"); 15320 print_rx_offloads(queue_offloads); 15321 15322 printf("\n"); 15323 printf(" Per Port :"); 15324 print_rx_offloads(port_offloads); 15325 printf("\n\n"); 15326 } 15327 15328 cmdline_parse_inst_t cmd_rx_offload_get_capa = { 15329 .f = cmd_rx_offload_get_capa_parsed, 15330 .data = NULL, 15331 .help_str = "show port <port_id> rx_offload capabilities", 15332 .tokens = { 15333 (void *)&cmd_rx_offload_get_capa_show, 15334 (void *)&cmd_rx_offload_get_capa_port, 15335 (void *)&cmd_rx_offload_get_capa_port_id, 15336 (void *)&cmd_rx_offload_get_capa_rx_offload, 15337 (void *)&cmd_rx_offload_get_capa_capabilities, 15338 NULL, 15339 } 15340 }; 15341 15342 /* Get Rx offloads configuration */ 15343 struct cmd_rx_offload_get_configuration_result { 15344 cmdline_fixed_string_t show; 15345 cmdline_fixed_string_t port; 15346 portid_t port_id; 15347 cmdline_fixed_string_t rx_offload; 15348 cmdline_fixed_string_t configuration; 15349 }; 15350 15351 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 15352 TOKEN_STRING_INITIALIZER 15353 (struct cmd_rx_offload_get_configuration_result, 15354 show, "show"); 15355 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 15356 TOKEN_STRING_INITIALIZER 15357 (struct cmd_rx_offload_get_configuration_result, 15358 port, "port"); 15359 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 15360 TOKEN_NUM_INITIALIZER 15361 (struct cmd_rx_offload_get_configuration_result, 15362 port_id, RTE_UINT16); 15363 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 15364 TOKEN_STRING_INITIALIZER 15365 (struct cmd_rx_offload_get_configuration_result, 15366 rx_offload, "rx_offload"); 15367 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 15368 TOKEN_STRING_INITIALIZER 15369 (struct cmd_rx_offload_get_configuration_result, 15370 configuration, "configuration"); 15371 15372 static void 15373 cmd_rx_offload_get_configuration_parsed( 15374 void *parsed_result, 15375 __rte_unused struct cmdline *cl, 15376 __rte_unused void *data) 15377 { 15378 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 15379 struct rte_eth_dev_info dev_info; 15380 portid_t port_id = res->port_id; 15381 struct rte_port *port = &ports[port_id]; 15382 uint64_t port_offloads; 15383 uint64_t queue_offloads; 15384 uint16_t nb_rx_queues; 15385 int q; 15386 int ret; 15387 15388 printf("Rx Offloading Configuration of port %d :\n", port_id); 15389 15390 port_offloads = port->dev_conf.rxmode.offloads; 15391 printf(" Port :"); 15392 print_rx_offloads(port_offloads); 15393 printf("\n"); 15394 15395 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15396 if (ret != 0) 15397 return; 15398 15399 nb_rx_queues = dev_info.nb_rx_queues; 15400 for (q = 0; q < nb_rx_queues; q++) { 15401 queue_offloads = port->rx_conf[q].offloads; 15402 printf(" Queue[%2d] :", q); 15403 print_rx_offloads(queue_offloads); 15404 printf("\n"); 15405 } 15406 printf("\n"); 15407 } 15408 15409 cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 15410 .f = cmd_rx_offload_get_configuration_parsed, 15411 .data = NULL, 15412 .help_str = "show port <port_id> rx_offload configuration", 15413 .tokens = { 15414 (void *)&cmd_rx_offload_get_configuration_show, 15415 (void *)&cmd_rx_offload_get_configuration_port, 15416 (void *)&cmd_rx_offload_get_configuration_port_id, 15417 (void *)&cmd_rx_offload_get_configuration_rx_offload, 15418 (void *)&cmd_rx_offload_get_configuration_configuration, 15419 NULL, 15420 } 15421 }; 15422 15423 /* Enable/Disable a per port offloading */ 15424 struct cmd_config_per_port_rx_offload_result { 15425 cmdline_fixed_string_t port; 15426 cmdline_fixed_string_t config; 15427 portid_t port_id; 15428 cmdline_fixed_string_t rx_offload; 15429 cmdline_fixed_string_t offload; 15430 cmdline_fixed_string_t on_off; 15431 }; 15432 15433 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 15434 TOKEN_STRING_INITIALIZER 15435 (struct cmd_config_per_port_rx_offload_result, 15436 port, "port"); 15437 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 15438 TOKEN_STRING_INITIALIZER 15439 (struct cmd_config_per_port_rx_offload_result, 15440 config, "config"); 15441 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 15442 TOKEN_NUM_INITIALIZER 15443 (struct cmd_config_per_port_rx_offload_result, 15444 port_id, RTE_UINT16); 15445 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 15446 TOKEN_STRING_INITIALIZER 15447 (struct cmd_config_per_port_rx_offload_result, 15448 rx_offload, "rx_offload"); 15449 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 15450 TOKEN_STRING_INITIALIZER 15451 (struct cmd_config_per_port_rx_offload_result, 15452 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 15453 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 15454 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 15455 "scatter#buffer_split#timestamp#security#" 15456 "keep_crc#rss_hash"); 15457 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 15458 TOKEN_STRING_INITIALIZER 15459 (struct cmd_config_per_port_rx_offload_result, 15460 on_off, "on#off"); 15461 15462 static uint64_t 15463 search_rx_offload(const char *name) 15464 { 15465 uint64_t single_offload; 15466 const char *single_name; 15467 int found = 0; 15468 unsigned int bit; 15469 15470 single_offload = 1; 15471 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 15472 single_name = rte_eth_dev_rx_offload_name(single_offload); 15473 if (!strcasecmp(single_name, name)) { 15474 found = 1; 15475 break; 15476 } 15477 single_offload <<= 1; 15478 } 15479 15480 if (found) 15481 return single_offload; 15482 15483 return 0; 15484 } 15485 15486 static void 15487 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 15488 __rte_unused struct cmdline *cl, 15489 __rte_unused void *data) 15490 { 15491 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 15492 portid_t port_id = res->port_id; 15493 struct rte_eth_dev_info dev_info; 15494 struct rte_port *port = &ports[port_id]; 15495 uint64_t single_offload; 15496 uint16_t nb_rx_queues; 15497 int q; 15498 int ret; 15499 15500 if (port->port_status != RTE_PORT_STOPPED) { 15501 printf("Error: Can't config offload when Port %d " 15502 "is not stopped\n", port_id); 15503 return; 15504 } 15505 15506 single_offload = search_rx_offload(res->offload); 15507 if (single_offload == 0) { 15508 printf("Unknown offload name: %s\n", res->offload); 15509 return; 15510 } 15511 15512 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15513 if (ret != 0) 15514 return; 15515 15516 nb_rx_queues = dev_info.nb_rx_queues; 15517 if (!strcmp(res->on_off, "on")) { 15518 port->dev_conf.rxmode.offloads |= single_offload; 15519 for (q = 0; q < nb_rx_queues; q++) 15520 port->rx_conf[q].offloads |= single_offload; 15521 } else { 15522 port->dev_conf.rxmode.offloads &= ~single_offload; 15523 for (q = 0; q < nb_rx_queues; q++) 15524 port->rx_conf[q].offloads &= ~single_offload; 15525 } 15526 15527 cmd_reconfig_device_queue(port_id, 1, 1); 15528 } 15529 15530 cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 15531 .f = cmd_config_per_port_rx_offload_parsed, 15532 .data = NULL, 15533 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 15534 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 15535 "macsec_strip|header_split|vlan_filter|vlan_extend|" 15536 "jumbo_frame|scatter|buffer_split|timestamp|security|" 15537 "keep_crc|rss_hash on|off", 15538 .tokens = { 15539 (void *)&cmd_config_per_port_rx_offload_result_port, 15540 (void *)&cmd_config_per_port_rx_offload_result_config, 15541 (void *)&cmd_config_per_port_rx_offload_result_port_id, 15542 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 15543 (void *)&cmd_config_per_port_rx_offload_result_offload, 15544 (void *)&cmd_config_per_port_rx_offload_result_on_off, 15545 NULL, 15546 } 15547 }; 15548 15549 /* Enable/Disable a per queue offloading */ 15550 struct cmd_config_per_queue_rx_offload_result { 15551 cmdline_fixed_string_t port; 15552 portid_t port_id; 15553 cmdline_fixed_string_t rxq; 15554 uint16_t queue_id; 15555 cmdline_fixed_string_t rx_offload; 15556 cmdline_fixed_string_t offload; 15557 cmdline_fixed_string_t on_off; 15558 }; 15559 15560 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 15561 TOKEN_STRING_INITIALIZER 15562 (struct cmd_config_per_queue_rx_offload_result, 15563 port, "port"); 15564 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 15565 TOKEN_NUM_INITIALIZER 15566 (struct cmd_config_per_queue_rx_offload_result, 15567 port_id, RTE_UINT16); 15568 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 15569 TOKEN_STRING_INITIALIZER 15570 (struct cmd_config_per_queue_rx_offload_result, 15571 rxq, "rxq"); 15572 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 15573 TOKEN_NUM_INITIALIZER 15574 (struct cmd_config_per_queue_rx_offload_result, 15575 queue_id, RTE_UINT16); 15576 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 15577 TOKEN_STRING_INITIALIZER 15578 (struct cmd_config_per_queue_rx_offload_result, 15579 rx_offload, "rx_offload"); 15580 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 15581 TOKEN_STRING_INITIALIZER 15582 (struct cmd_config_per_queue_rx_offload_result, 15583 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 15584 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 15585 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 15586 "scatter#buffer_split#timestamp#security#keep_crc"); 15587 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 15588 TOKEN_STRING_INITIALIZER 15589 (struct cmd_config_per_queue_rx_offload_result, 15590 on_off, "on#off"); 15591 15592 static void 15593 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 15594 __rte_unused struct cmdline *cl, 15595 __rte_unused void *data) 15596 { 15597 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 15598 struct rte_eth_dev_info dev_info; 15599 portid_t port_id = res->port_id; 15600 uint16_t queue_id = res->queue_id; 15601 struct rte_port *port = &ports[port_id]; 15602 uint64_t single_offload; 15603 int ret; 15604 15605 if (port->port_status != RTE_PORT_STOPPED) { 15606 printf("Error: Can't config offload when Port %d " 15607 "is not stopped\n", port_id); 15608 return; 15609 } 15610 15611 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15612 if (ret != 0) 15613 return; 15614 15615 if (queue_id >= dev_info.nb_rx_queues) { 15616 printf("Error: input queue_id should be 0 ... " 15617 "%d\n", dev_info.nb_rx_queues - 1); 15618 return; 15619 } 15620 15621 single_offload = search_rx_offload(res->offload); 15622 if (single_offload == 0) { 15623 printf("Unknown offload name: %s\n", res->offload); 15624 return; 15625 } 15626 15627 if (!strcmp(res->on_off, "on")) 15628 port->rx_conf[queue_id].offloads |= single_offload; 15629 else 15630 port->rx_conf[queue_id].offloads &= ~single_offload; 15631 15632 cmd_reconfig_device_queue(port_id, 1, 1); 15633 } 15634 15635 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 15636 .f = cmd_config_per_queue_rx_offload_parsed, 15637 .data = NULL, 15638 .help_str = "port <port_id> rxq <queue_id> rx_offload " 15639 "vlan_strip|ipv4_cksum|" 15640 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 15641 "macsec_strip|header_split|vlan_filter|vlan_extend|" 15642 "jumbo_frame|scatter|buffer_split|timestamp|security|" 15643 "keep_crc on|off", 15644 .tokens = { 15645 (void *)&cmd_config_per_queue_rx_offload_result_port, 15646 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 15647 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 15648 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 15649 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 15650 (void *)&cmd_config_per_queue_rx_offload_result_offload, 15651 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 15652 NULL, 15653 } 15654 }; 15655 15656 /* Get Tx offloads capabilities */ 15657 struct cmd_tx_offload_get_capa_result { 15658 cmdline_fixed_string_t show; 15659 cmdline_fixed_string_t port; 15660 portid_t port_id; 15661 cmdline_fixed_string_t tx_offload; 15662 cmdline_fixed_string_t capabilities; 15663 }; 15664 15665 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 15666 TOKEN_STRING_INITIALIZER 15667 (struct cmd_tx_offload_get_capa_result, 15668 show, "show"); 15669 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 15670 TOKEN_STRING_INITIALIZER 15671 (struct cmd_tx_offload_get_capa_result, 15672 port, "port"); 15673 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 15674 TOKEN_NUM_INITIALIZER 15675 (struct cmd_tx_offload_get_capa_result, 15676 port_id, RTE_UINT16); 15677 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 15678 TOKEN_STRING_INITIALIZER 15679 (struct cmd_tx_offload_get_capa_result, 15680 tx_offload, "tx_offload"); 15681 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 15682 TOKEN_STRING_INITIALIZER 15683 (struct cmd_tx_offload_get_capa_result, 15684 capabilities, "capabilities"); 15685 15686 static void 15687 print_tx_offloads(uint64_t offloads) 15688 { 15689 uint64_t single_offload; 15690 int begin; 15691 int end; 15692 int bit; 15693 15694 if (offloads == 0) 15695 return; 15696 15697 begin = __builtin_ctzll(offloads); 15698 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 15699 15700 single_offload = 1ULL << begin; 15701 for (bit = begin; bit < end; bit++) { 15702 if (offloads & single_offload) 15703 printf(" %s", 15704 rte_eth_dev_tx_offload_name(single_offload)); 15705 single_offload <<= 1; 15706 } 15707 } 15708 15709 static void 15710 cmd_tx_offload_get_capa_parsed( 15711 void *parsed_result, 15712 __rte_unused struct cmdline *cl, 15713 __rte_unused void *data) 15714 { 15715 struct cmd_tx_offload_get_capa_result *res = parsed_result; 15716 struct rte_eth_dev_info dev_info; 15717 portid_t port_id = res->port_id; 15718 uint64_t queue_offloads; 15719 uint64_t port_offloads; 15720 int ret; 15721 15722 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15723 if (ret != 0) 15724 return; 15725 15726 queue_offloads = dev_info.tx_queue_offload_capa; 15727 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 15728 15729 printf("Tx Offloading Capabilities of port %d :\n", port_id); 15730 printf(" Per Queue :"); 15731 print_tx_offloads(queue_offloads); 15732 15733 printf("\n"); 15734 printf(" Per Port :"); 15735 print_tx_offloads(port_offloads); 15736 printf("\n\n"); 15737 } 15738 15739 cmdline_parse_inst_t cmd_tx_offload_get_capa = { 15740 .f = cmd_tx_offload_get_capa_parsed, 15741 .data = NULL, 15742 .help_str = "show port <port_id> tx_offload capabilities", 15743 .tokens = { 15744 (void *)&cmd_tx_offload_get_capa_show, 15745 (void *)&cmd_tx_offload_get_capa_port, 15746 (void *)&cmd_tx_offload_get_capa_port_id, 15747 (void *)&cmd_tx_offload_get_capa_tx_offload, 15748 (void *)&cmd_tx_offload_get_capa_capabilities, 15749 NULL, 15750 } 15751 }; 15752 15753 /* Get Tx offloads configuration */ 15754 struct cmd_tx_offload_get_configuration_result { 15755 cmdline_fixed_string_t show; 15756 cmdline_fixed_string_t port; 15757 portid_t port_id; 15758 cmdline_fixed_string_t tx_offload; 15759 cmdline_fixed_string_t configuration; 15760 }; 15761 15762 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 15763 TOKEN_STRING_INITIALIZER 15764 (struct cmd_tx_offload_get_configuration_result, 15765 show, "show"); 15766 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 15767 TOKEN_STRING_INITIALIZER 15768 (struct cmd_tx_offload_get_configuration_result, 15769 port, "port"); 15770 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 15771 TOKEN_NUM_INITIALIZER 15772 (struct cmd_tx_offload_get_configuration_result, 15773 port_id, RTE_UINT16); 15774 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 15775 TOKEN_STRING_INITIALIZER 15776 (struct cmd_tx_offload_get_configuration_result, 15777 tx_offload, "tx_offload"); 15778 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 15779 TOKEN_STRING_INITIALIZER 15780 (struct cmd_tx_offload_get_configuration_result, 15781 configuration, "configuration"); 15782 15783 static void 15784 cmd_tx_offload_get_configuration_parsed( 15785 void *parsed_result, 15786 __rte_unused struct cmdline *cl, 15787 __rte_unused void *data) 15788 { 15789 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 15790 struct rte_eth_dev_info dev_info; 15791 portid_t port_id = res->port_id; 15792 struct rte_port *port = &ports[port_id]; 15793 uint64_t port_offloads; 15794 uint64_t queue_offloads; 15795 uint16_t nb_tx_queues; 15796 int q; 15797 int ret; 15798 15799 printf("Tx Offloading Configuration of port %d :\n", port_id); 15800 15801 port_offloads = port->dev_conf.txmode.offloads; 15802 printf(" Port :"); 15803 print_tx_offloads(port_offloads); 15804 printf("\n"); 15805 15806 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15807 if (ret != 0) 15808 return; 15809 15810 nb_tx_queues = dev_info.nb_tx_queues; 15811 for (q = 0; q < nb_tx_queues; q++) { 15812 queue_offloads = port->tx_conf[q].offloads; 15813 printf(" Queue[%2d] :", q); 15814 print_tx_offloads(queue_offloads); 15815 printf("\n"); 15816 } 15817 printf("\n"); 15818 } 15819 15820 cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 15821 .f = cmd_tx_offload_get_configuration_parsed, 15822 .data = NULL, 15823 .help_str = "show port <port_id> tx_offload configuration", 15824 .tokens = { 15825 (void *)&cmd_tx_offload_get_configuration_show, 15826 (void *)&cmd_tx_offload_get_configuration_port, 15827 (void *)&cmd_tx_offload_get_configuration_port_id, 15828 (void *)&cmd_tx_offload_get_configuration_tx_offload, 15829 (void *)&cmd_tx_offload_get_configuration_configuration, 15830 NULL, 15831 } 15832 }; 15833 15834 /* Enable/Disable a per port offloading */ 15835 struct cmd_config_per_port_tx_offload_result { 15836 cmdline_fixed_string_t port; 15837 cmdline_fixed_string_t config; 15838 portid_t port_id; 15839 cmdline_fixed_string_t tx_offload; 15840 cmdline_fixed_string_t offload; 15841 cmdline_fixed_string_t on_off; 15842 }; 15843 15844 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 15845 TOKEN_STRING_INITIALIZER 15846 (struct cmd_config_per_port_tx_offload_result, 15847 port, "port"); 15848 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 15849 TOKEN_STRING_INITIALIZER 15850 (struct cmd_config_per_port_tx_offload_result, 15851 config, "config"); 15852 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 15853 TOKEN_NUM_INITIALIZER 15854 (struct cmd_config_per_port_tx_offload_result, 15855 port_id, RTE_UINT16); 15856 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 15857 TOKEN_STRING_INITIALIZER 15858 (struct cmd_config_per_port_tx_offload_result, 15859 tx_offload, "tx_offload"); 15860 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 15861 TOKEN_STRING_INITIALIZER 15862 (struct cmd_config_per_port_tx_offload_result, 15863 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 15864 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 15865 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 15866 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 15867 "mt_lockfree#multi_segs#mbuf_fast_free#security#" 15868 "send_on_timestamp"); 15869 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = 15870 TOKEN_STRING_INITIALIZER 15871 (struct cmd_config_per_port_tx_offload_result, 15872 on_off, "on#off"); 15873 15874 static uint64_t 15875 search_tx_offload(const char *name) 15876 { 15877 uint64_t single_offload; 15878 const char *single_name; 15879 int found = 0; 15880 unsigned int bit; 15881 15882 single_offload = 1; 15883 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 15884 single_name = rte_eth_dev_tx_offload_name(single_offload); 15885 if (single_name == NULL) 15886 break; 15887 if (!strcasecmp(single_name, name)) { 15888 found = 1; 15889 break; 15890 } else if (!strcasecmp(single_name, "UNKNOWN")) 15891 break; 15892 single_offload <<= 1; 15893 } 15894 15895 if (found) 15896 return single_offload; 15897 15898 return 0; 15899 } 15900 15901 static void 15902 cmd_config_per_port_tx_offload_parsed(void *parsed_result, 15903 __rte_unused struct cmdline *cl, 15904 __rte_unused void *data) 15905 { 15906 struct cmd_config_per_port_tx_offload_result *res = parsed_result; 15907 portid_t port_id = res->port_id; 15908 struct rte_eth_dev_info dev_info; 15909 struct rte_port *port = &ports[port_id]; 15910 uint64_t single_offload; 15911 uint16_t nb_tx_queues; 15912 int q; 15913 int ret; 15914 15915 if (port->port_status != RTE_PORT_STOPPED) { 15916 printf("Error: Can't config offload when Port %d " 15917 "is not stopped\n", port_id); 15918 return; 15919 } 15920 15921 single_offload = search_tx_offload(res->offload); 15922 if (single_offload == 0) { 15923 printf("Unknown offload name: %s\n", res->offload); 15924 return; 15925 } 15926 15927 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15928 if (ret != 0) 15929 return; 15930 15931 nb_tx_queues = dev_info.nb_tx_queues; 15932 if (!strcmp(res->on_off, "on")) { 15933 port->dev_conf.txmode.offloads |= single_offload; 15934 for (q = 0; q < nb_tx_queues; q++) 15935 port->tx_conf[q].offloads |= single_offload; 15936 } else { 15937 port->dev_conf.txmode.offloads &= ~single_offload; 15938 for (q = 0; q < nb_tx_queues; q++) 15939 port->tx_conf[q].offloads &= ~single_offload; 15940 } 15941 15942 cmd_reconfig_device_queue(port_id, 1, 1); 15943 } 15944 15945 cmdline_parse_inst_t cmd_config_per_port_tx_offload = { 15946 .f = cmd_config_per_port_tx_offload_parsed, 15947 .data = NULL, 15948 .help_str = "port config <port_id> tx_offload " 15949 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 15950 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 15951 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 15952 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 15953 "mt_lockfree|multi_segs|mbuf_fast_free|security|" 15954 "send_on_timestamp on|off", 15955 .tokens = { 15956 (void *)&cmd_config_per_port_tx_offload_result_port, 15957 (void *)&cmd_config_per_port_tx_offload_result_config, 15958 (void *)&cmd_config_per_port_tx_offload_result_port_id, 15959 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 15960 (void *)&cmd_config_per_port_tx_offload_result_offload, 15961 (void *)&cmd_config_per_port_tx_offload_result_on_off, 15962 NULL, 15963 } 15964 }; 15965 15966 /* Enable/Disable a per queue offloading */ 15967 struct cmd_config_per_queue_tx_offload_result { 15968 cmdline_fixed_string_t port; 15969 portid_t port_id; 15970 cmdline_fixed_string_t txq; 15971 uint16_t queue_id; 15972 cmdline_fixed_string_t tx_offload; 15973 cmdline_fixed_string_t offload; 15974 cmdline_fixed_string_t on_off; 15975 }; 15976 15977 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 15978 TOKEN_STRING_INITIALIZER 15979 (struct cmd_config_per_queue_tx_offload_result, 15980 port, "port"); 15981 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 15982 TOKEN_NUM_INITIALIZER 15983 (struct cmd_config_per_queue_tx_offload_result, 15984 port_id, RTE_UINT16); 15985 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 15986 TOKEN_STRING_INITIALIZER 15987 (struct cmd_config_per_queue_tx_offload_result, 15988 txq, "txq"); 15989 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 15990 TOKEN_NUM_INITIALIZER 15991 (struct cmd_config_per_queue_tx_offload_result, 15992 queue_id, RTE_UINT16); 15993 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 15994 TOKEN_STRING_INITIALIZER 15995 (struct cmd_config_per_queue_tx_offload_result, 15996 tx_offload, "tx_offload"); 15997 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 15998 TOKEN_STRING_INITIALIZER 15999 (struct cmd_config_per_queue_tx_offload_result, 16000 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 16001 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 16002 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 16003 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 16004 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 16005 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 16006 TOKEN_STRING_INITIALIZER 16007 (struct cmd_config_per_queue_tx_offload_result, 16008 on_off, "on#off"); 16009 16010 static void 16011 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 16012 __rte_unused struct cmdline *cl, 16013 __rte_unused void *data) 16014 { 16015 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 16016 struct rte_eth_dev_info dev_info; 16017 portid_t port_id = res->port_id; 16018 uint16_t queue_id = res->queue_id; 16019 struct rte_port *port = &ports[port_id]; 16020 uint64_t single_offload; 16021 int ret; 16022 16023 if (port->port_status != RTE_PORT_STOPPED) { 16024 printf("Error: Can't config offload when Port %d " 16025 "is not stopped\n", port_id); 16026 return; 16027 } 16028 16029 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16030 if (ret != 0) 16031 return; 16032 16033 if (queue_id >= dev_info.nb_tx_queues) { 16034 printf("Error: input queue_id should be 0 ... " 16035 "%d\n", dev_info.nb_tx_queues - 1); 16036 return; 16037 } 16038 16039 single_offload = search_tx_offload(res->offload); 16040 if (single_offload == 0) { 16041 printf("Unknown offload name: %s\n", res->offload); 16042 return; 16043 } 16044 16045 if (!strcmp(res->on_off, "on")) 16046 port->tx_conf[queue_id].offloads |= single_offload; 16047 else 16048 port->tx_conf[queue_id].offloads &= ~single_offload; 16049 16050 cmd_reconfig_device_queue(port_id, 1, 1); 16051 } 16052 16053 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 16054 .f = cmd_config_per_queue_tx_offload_parsed, 16055 .data = NULL, 16056 .help_str = "port <port_id> txq <queue_id> tx_offload " 16057 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 16058 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 16059 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 16060 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 16061 "mt_lockfree|multi_segs|mbuf_fast_free|security " 16062 "on|off", 16063 .tokens = { 16064 (void *)&cmd_config_per_queue_tx_offload_result_port, 16065 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 16066 (void *)&cmd_config_per_queue_tx_offload_result_txq, 16067 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 16068 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 16069 (void *)&cmd_config_per_queue_tx_offload_result_offload, 16070 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 16071 NULL, 16072 } 16073 }; 16074 16075 /* *** configure tx_metadata for specific port *** */ 16076 struct cmd_config_tx_metadata_specific_result { 16077 cmdline_fixed_string_t port; 16078 cmdline_fixed_string_t keyword; 16079 uint16_t port_id; 16080 cmdline_fixed_string_t item; 16081 uint32_t value; 16082 }; 16083 16084 static void 16085 cmd_config_tx_metadata_specific_parsed(void *parsed_result, 16086 __rte_unused struct cmdline *cl, 16087 __rte_unused void *data) 16088 { 16089 struct cmd_config_tx_metadata_specific_result *res = parsed_result; 16090 16091 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16092 return; 16093 ports[res->port_id].tx_metadata = res->value; 16094 /* Add/remove callback to insert valid metadata in every Tx packet. */ 16095 if (ports[res->port_id].tx_metadata) 16096 add_tx_md_callback(res->port_id); 16097 else 16098 remove_tx_md_callback(res->port_id); 16099 rte_flow_dynf_metadata_register(); 16100 } 16101 16102 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = 16103 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16104 port, "port"); 16105 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = 16106 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16107 keyword, "config"); 16108 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = 16109 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16110 port_id, RTE_UINT16); 16111 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = 16112 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16113 item, "tx_metadata"); 16114 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = 16115 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16116 value, RTE_UINT32); 16117 16118 cmdline_parse_inst_t cmd_config_tx_metadata_specific = { 16119 .f = cmd_config_tx_metadata_specific_parsed, 16120 .data = NULL, 16121 .help_str = "port config <port_id> tx_metadata <value>", 16122 .tokens = { 16123 (void *)&cmd_config_tx_metadata_specific_port, 16124 (void *)&cmd_config_tx_metadata_specific_keyword, 16125 (void *)&cmd_config_tx_metadata_specific_id, 16126 (void *)&cmd_config_tx_metadata_specific_item, 16127 (void *)&cmd_config_tx_metadata_specific_value, 16128 NULL, 16129 }, 16130 }; 16131 16132 /* *** set dynf *** */ 16133 struct cmd_config_tx_dynf_specific_result { 16134 cmdline_fixed_string_t port; 16135 cmdline_fixed_string_t keyword; 16136 uint16_t port_id; 16137 cmdline_fixed_string_t item; 16138 cmdline_fixed_string_t name; 16139 cmdline_fixed_string_t value; 16140 }; 16141 16142 static void 16143 cmd_config_dynf_specific_parsed(void *parsed_result, 16144 __rte_unused struct cmdline *cl, 16145 __rte_unused void *data) 16146 { 16147 struct cmd_config_tx_dynf_specific_result *res = parsed_result; 16148 struct rte_mbuf_dynflag desc_flag; 16149 int flag; 16150 uint64_t old_port_flags; 16151 16152 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16153 return; 16154 flag = rte_mbuf_dynflag_lookup(res->name, NULL); 16155 if (flag <= 0) { 16156 if (strlcpy(desc_flag.name, res->name, 16157 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) { 16158 printf("Flag name too long\n"); 16159 return; 16160 } 16161 desc_flag.flags = 0; 16162 flag = rte_mbuf_dynflag_register(&desc_flag); 16163 if (flag < 0) { 16164 printf("Can't register flag\n"); 16165 return; 16166 } 16167 strcpy(dynf_names[flag], desc_flag.name); 16168 } 16169 old_port_flags = ports[res->port_id].mbuf_dynf; 16170 if (!strcmp(res->value, "set")) { 16171 ports[res->port_id].mbuf_dynf |= 1UL << flag; 16172 if (old_port_flags == 0) 16173 add_tx_dynf_callback(res->port_id); 16174 } else { 16175 ports[res->port_id].mbuf_dynf &= ~(1UL << flag); 16176 if (ports[res->port_id].mbuf_dynf == 0) 16177 remove_tx_dynf_callback(res->port_id); 16178 } 16179 } 16180 16181 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port = 16182 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16183 keyword, "port"); 16184 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword = 16185 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16186 keyword, "config"); 16187 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id = 16188 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16189 port_id, RTE_UINT16); 16190 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item = 16191 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16192 item, "dynf"); 16193 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name = 16194 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16195 name, NULL); 16196 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value = 16197 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16198 value, "set#clear"); 16199 16200 cmdline_parse_inst_t cmd_config_tx_dynf_specific = { 16201 .f = cmd_config_dynf_specific_parsed, 16202 .data = NULL, 16203 .help_str = "port config <port id> dynf <name> set|clear", 16204 .tokens = { 16205 (void *)&cmd_config_tx_dynf_specific_port, 16206 (void *)&cmd_config_tx_dynf_specific_keyword, 16207 (void *)&cmd_config_tx_dynf_specific_port_id, 16208 (void *)&cmd_config_tx_dynf_specific_item, 16209 (void *)&cmd_config_tx_dynf_specific_name, 16210 (void *)&cmd_config_tx_dynf_specific_value, 16211 NULL, 16212 }, 16213 }; 16214 16215 /* *** display tx_metadata per port configuration *** */ 16216 struct cmd_show_tx_metadata_result { 16217 cmdline_fixed_string_t cmd_show; 16218 cmdline_fixed_string_t cmd_port; 16219 cmdline_fixed_string_t cmd_keyword; 16220 portid_t cmd_pid; 16221 }; 16222 16223 static void 16224 cmd_show_tx_metadata_parsed(void *parsed_result, 16225 __rte_unused struct cmdline *cl, 16226 __rte_unused void *data) 16227 { 16228 struct cmd_show_tx_metadata_result *res = parsed_result; 16229 16230 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16231 printf("invalid port id %u\n", res->cmd_pid); 16232 return; 16233 } 16234 if (!strcmp(res->cmd_keyword, "tx_metadata")) { 16235 printf("Port %u tx_metadata: %u\n", res->cmd_pid, 16236 ports[res->cmd_pid].tx_metadata); 16237 } 16238 } 16239 16240 cmdline_parse_token_string_t cmd_show_tx_metadata_show = 16241 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 16242 cmd_show, "show"); 16243 cmdline_parse_token_string_t cmd_show_tx_metadata_port = 16244 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 16245 cmd_port, "port"); 16246 cmdline_parse_token_num_t cmd_show_tx_metadata_pid = 16247 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, 16248 cmd_pid, RTE_UINT16); 16249 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = 16250 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 16251 cmd_keyword, "tx_metadata"); 16252 16253 cmdline_parse_inst_t cmd_show_tx_metadata = { 16254 .f = cmd_show_tx_metadata_parsed, 16255 .data = NULL, 16256 .help_str = "show port <port_id> tx_metadata", 16257 .tokens = { 16258 (void *)&cmd_show_tx_metadata_show, 16259 (void *)&cmd_show_tx_metadata_port, 16260 (void *)&cmd_show_tx_metadata_pid, 16261 (void *)&cmd_show_tx_metadata_keyword, 16262 NULL, 16263 }, 16264 }; 16265 16266 /* *** show fec capability per port configuration *** */ 16267 struct cmd_show_fec_capability_result { 16268 cmdline_fixed_string_t cmd_show; 16269 cmdline_fixed_string_t cmd_port; 16270 cmdline_fixed_string_t cmd_fec; 16271 cmdline_fixed_string_t cmd_keyword; 16272 portid_t cmd_pid; 16273 }; 16274 16275 static void 16276 cmd_show_fec_capability_parsed(void *parsed_result, 16277 __rte_unused struct cmdline *cl, 16278 __rte_unused void *data) 16279 { 16280 struct cmd_show_fec_capability_result *res = parsed_result; 16281 struct rte_eth_fec_capa *speed_fec_capa; 16282 unsigned int num; 16283 int ret; 16284 16285 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16286 printf("Invalid port id %u\n", res->cmd_pid); 16287 return; 16288 } 16289 16290 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0); 16291 if (ret == -ENOTSUP) { 16292 printf("Function not implemented\n"); 16293 return; 16294 } else if (ret < 0) { 16295 printf("Get FEC capability failed: %d\n", ret); 16296 return; 16297 } 16298 16299 num = (unsigned int)ret; 16300 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa)); 16301 if (speed_fec_capa == NULL) { 16302 printf("Failed to alloc FEC capability buffer\n"); 16303 return; 16304 } 16305 16306 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num); 16307 if (ret < 0) { 16308 printf("Error getting FEC capability: %d\n", ret); 16309 goto out; 16310 } 16311 16312 show_fec_capability(num, speed_fec_capa); 16313 out: 16314 free(speed_fec_capa); 16315 } 16316 16317 cmdline_parse_token_string_t cmd_show_fec_capability_show = 16318 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16319 cmd_show, "show"); 16320 cmdline_parse_token_string_t cmd_show_fec_capability_port = 16321 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16322 cmd_port, "port"); 16323 cmdline_parse_token_num_t cmd_show_fec_capability_pid = 16324 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result, 16325 cmd_pid, RTE_UINT16); 16326 cmdline_parse_token_string_t cmd_show_fec_capability_fec = 16327 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16328 cmd_fec, "fec"); 16329 cmdline_parse_token_string_t cmd_show_fec_capability_keyword = 16330 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16331 cmd_keyword, "capabilities"); 16332 16333 cmdline_parse_inst_t cmd_show_capability = { 16334 .f = cmd_show_fec_capability_parsed, 16335 .data = NULL, 16336 .help_str = "show port <port_id> fec capabilities", 16337 .tokens = { 16338 (void *)&cmd_show_fec_capability_show, 16339 (void *)&cmd_show_fec_capability_port, 16340 (void *)&cmd_show_fec_capability_pid, 16341 (void *)&cmd_show_fec_capability_fec, 16342 (void *)&cmd_show_fec_capability_keyword, 16343 NULL, 16344 }, 16345 }; 16346 16347 /* *** show fec mode per port configuration *** */ 16348 struct cmd_show_fec_metadata_result { 16349 cmdline_fixed_string_t cmd_show; 16350 cmdline_fixed_string_t cmd_port; 16351 cmdline_fixed_string_t cmd_keyword; 16352 portid_t cmd_pid; 16353 }; 16354 16355 static void 16356 cmd_show_fec_mode_parsed(void *parsed_result, 16357 __rte_unused struct cmdline *cl, 16358 __rte_unused void *data) 16359 { 16360 #define FEC_NAME_SIZE 16 16361 struct cmd_show_fec_metadata_result *res = parsed_result; 16362 uint32_t mode; 16363 char buf[FEC_NAME_SIZE]; 16364 int ret; 16365 16366 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16367 printf("Invalid port id %u\n", res->cmd_pid); 16368 return; 16369 } 16370 ret = rte_eth_fec_get(res->cmd_pid, &mode); 16371 if (ret == -ENOTSUP) { 16372 printf("Function not implemented\n"); 16373 return; 16374 } else if (ret < 0) { 16375 printf("Get FEC mode failed\n"); 16376 return; 16377 } 16378 16379 switch (mode) { 16380 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC): 16381 strlcpy(buf, "off", sizeof(buf)); 16382 break; 16383 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO): 16384 strlcpy(buf, "auto", sizeof(buf)); 16385 break; 16386 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER): 16387 strlcpy(buf, "baser", sizeof(buf)); 16388 break; 16389 case RTE_ETH_FEC_MODE_CAPA_MASK(RS): 16390 strlcpy(buf, "rs", sizeof(buf)); 16391 break; 16392 default: 16393 return; 16394 } 16395 16396 printf("%s\n", buf); 16397 } 16398 16399 cmdline_parse_token_string_t cmd_show_fec_mode_show = 16400 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 16401 cmd_show, "show"); 16402 cmdline_parse_token_string_t cmd_show_fec_mode_port = 16403 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 16404 cmd_port, "port"); 16405 cmdline_parse_token_num_t cmd_show_fec_mode_pid = 16406 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result, 16407 cmd_pid, RTE_UINT16); 16408 cmdline_parse_token_string_t cmd_show_fec_mode_keyword = 16409 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 16410 cmd_keyword, "fec_mode"); 16411 16412 cmdline_parse_inst_t cmd_show_fec_mode = { 16413 .f = cmd_show_fec_mode_parsed, 16414 .data = NULL, 16415 .help_str = "show port <port_id> fec_mode", 16416 .tokens = { 16417 (void *)&cmd_show_fec_mode_show, 16418 (void *)&cmd_show_fec_mode_port, 16419 (void *)&cmd_show_fec_mode_pid, 16420 (void *)&cmd_show_fec_mode_keyword, 16421 NULL, 16422 }, 16423 }; 16424 16425 /* *** set fec mode per port configuration *** */ 16426 struct cmd_set_port_fec_mode { 16427 cmdline_fixed_string_t set; 16428 cmdline_fixed_string_t port; 16429 portid_t port_id; 16430 cmdline_fixed_string_t fec_mode; 16431 cmdline_fixed_string_t fec_value; 16432 }; 16433 16434 /* Common CLI fields for set fec mode */ 16435 cmdline_parse_token_string_t cmd_set_port_fec_mode_set = 16436 TOKEN_STRING_INITIALIZER 16437 (struct cmd_set_port_fec_mode, 16438 set, "set"); 16439 cmdline_parse_token_string_t cmd_set_port_fec_mode_port = 16440 TOKEN_STRING_INITIALIZER 16441 (struct cmd_set_port_fec_mode, 16442 port, "port"); 16443 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id = 16444 TOKEN_NUM_INITIALIZER 16445 (struct cmd_set_port_fec_mode, 16446 port_id, RTE_UINT16); 16447 cmdline_parse_token_string_t cmd_set_port_fec_mode_str = 16448 TOKEN_STRING_INITIALIZER 16449 (struct cmd_set_port_fec_mode, 16450 fec_mode, "fec_mode"); 16451 cmdline_parse_token_string_t cmd_set_port_fec_mode_value = 16452 TOKEN_STRING_INITIALIZER 16453 (struct cmd_set_port_fec_mode, 16454 fec_value, NULL); 16455 16456 static void 16457 cmd_set_port_fec_mode_parsed( 16458 void *parsed_result, 16459 __rte_unused struct cmdline *cl, 16460 __rte_unused void *data) 16461 { 16462 struct cmd_set_port_fec_mode *res = parsed_result; 16463 uint16_t port_id = res->port_id; 16464 uint32_t mode; 16465 int ret; 16466 16467 ret = parse_fec_mode(res->fec_value, &mode); 16468 if (ret < 0) { 16469 printf("Unknown fec mode: %s for Port %d\n", res->fec_value, 16470 port_id); 16471 return; 16472 } 16473 16474 ret = rte_eth_fec_set(port_id, mode); 16475 if (ret == -ENOTSUP) { 16476 printf("Function not implemented\n"); 16477 return; 16478 } else if (ret < 0) { 16479 printf("Set FEC mode failed\n"); 16480 return; 16481 } 16482 } 16483 16484 cmdline_parse_inst_t cmd_set_fec_mode = { 16485 .f = cmd_set_port_fec_mode_parsed, 16486 .data = NULL, 16487 .help_str = "set port <port_id> fec_mode auto|off|rs|baser", 16488 .tokens = { 16489 (void *)&cmd_set_port_fec_mode_set, 16490 (void *)&cmd_set_port_fec_mode_port, 16491 (void *)&cmd_set_port_fec_mode_port_id, 16492 (void *)&cmd_set_port_fec_mode_str, 16493 (void *)&cmd_set_port_fec_mode_value, 16494 NULL, 16495 }, 16496 }; 16497 16498 /* show port supported ptypes */ 16499 16500 /* Common result structure for show port ptypes */ 16501 struct cmd_show_port_supported_ptypes_result { 16502 cmdline_fixed_string_t show; 16503 cmdline_fixed_string_t port; 16504 portid_t port_id; 16505 cmdline_fixed_string_t ptypes; 16506 }; 16507 16508 /* Common CLI fields for show port ptypes */ 16509 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show = 16510 TOKEN_STRING_INITIALIZER 16511 (struct cmd_show_port_supported_ptypes_result, 16512 show, "show"); 16513 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port = 16514 TOKEN_STRING_INITIALIZER 16515 (struct cmd_show_port_supported_ptypes_result, 16516 port, "port"); 16517 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id = 16518 TOKEN_NUM_INITIALIZER 16519 (struct cmd_show_port_supported_ptypes_result, 16520 port_id, RTE_UINT16); 16521 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes = 16522 TOKEN_STRING_INITIALIZER 16523 (struct cmd_show_port_supported_ptypes_result, 16524 ptypes, "ptypes"); 16525 16526 static void 16527 cmd_show_port_supported_ptypes_parsed( 16528 void *parsed_result, 16529 __rte_unused struct cmdline *cl, 16530 __rte_unused void *data) 16531 { 16532 #define RSVD_PTYPE_MASK 0xf0000000 16533 #define MAX_PTYPES_PER_LAYER 16 16534 #define LTYPE_NAMESIZE 32 16535 #define PTYPE_NAMESIZE 256 16536 struct cmd_show_port_supported_ptypes_result *res = parsed_result; 16537 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE]; 16538 uint32_t ptype_mask = RTE_PTYPE_L2_MASK; 16539 uint32_t ptypes[MAX_PTYPES_PER_LAYER]; 16540 uint16_t port_id = res->port_id; 16541 int ret, i; 16542 16543 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0); 16544 if (ret < 0) 16545 return; 16546 16547 while (ptype_mask != RSVD_PTYPE_MASK) { 16548 16549 switch (ptype_mask) { 16550 case RTE_PTYPE_L2_MASK: 16551 strlcpy(ltype, "L2", sizeof(ltype)); 16552 break; 16553 case RTE_PTYPE_L3_MASK: 16554 strlcpy(ltype, "L3", sizeof(ltype)); 16555 break; 16556 case RTE_PTYPE_L4_MASK: 16557 strlcpy(ltype, "L4", sizeof(ltype)); 16558 break; 16559 case RTE_PTYPE_TUNNEL_MASK: 16560 strlcpy(ltype, "Tunnel", sizeof(ltype)); 16561 break; 16562 case RTE_PTYPE_INNER_L2_MASK: 16563 strlcpy(ltype, "Inner L2", sizeof(ltype)); 16564 break; 16565 case RTE_PTYPE_INNER_L3_MASK: 16566 strlcpy(ltype, "Inner L3", sizeof(ltype)); 16567 break; 16568 case RTE_PTYPE_INNER_L4_MASK: 16569 strlcpy(ltype, "Inner L4", sizeof(ltype)); 16570 break; 16571 default: 16572 return; 16573 } 16574 16575 ret = rte_eth_dev_get_supported_ptypes(res->port_id, 16576 ptype_mask, ptypes, 16577 MAX_PTYPES_PER_LAYER); 16578 16579 if (ret > 0) 16580 printf("Supported %s ptypes:\n", ltype); 16581 else 16582 printf("%s ptypes unsupported\n", ltype); 16583 16584 for (i = 0; i < ret; ++i) { 16585 rte_get_ptype_name(ptypes[i], buf, sizeof(buf)); 16586 printf("%s\n", buf); 16587 } 16588 16589 ptype_mask <<= 4; 16590 } 16591 } 16592 16593 cmdline_parse_inst_t cmd_show_port_supported_ptypes = { 16594 .f = cmd_show_port_supported_ptypes_parsed, 16595 .data = NULL, 16596 .help_str = "show port <port_id> ptypes", 16597 .tokens = { 16598 (void *)&cmd_show_port_supported_ptypes_show, 16599 (void *)&cmd_show_port_supported_ptypes_port, 16600 (void *)&cmd_show_port_supported_ptypes_port_id, 16601 (void *)&cmd_show_port_supported_ptypes_ptypes, 16602 NULL, 16603 }, 16604 }; 16605 16606 /* *** display rx/tx descriptor status *** */ 16607 struct cmd_show_rx_tx_desc_status_result { 16608 cmdline_fixed_string_t cmd_show; 16609 cmdline_fixed_string_t cmd_port; 16610 cmdline_fixed_string_t cmd_keyword; 16611 cmdline_fixed_string_t cmd_desc; 16612 cmdline_fixed_string_t cmd_status; 16613 portid_t cmd_pid; 16614 portid_t cmd_qid; 16615 portid_t cmd_did; 16616 }; 16617 16618 static void 16619 cmd_show_rx_tx_desc_status_parsed(void *parsed_result, 16620 __rte_unused struct cmdline *cl, 16621 __rte_unused void *data) 16622 { 16623 struct cmd_show_rx_tx_desc_status_result *res = parsed_result; 16624 int rc; 16625 16626 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16627 printf("invalid port id %u\n", res->cmd_pid); 16628 return; 16629 } 16630 16631 if (!strcmp(res->cmd_keyword, "rxq")) { 16632 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid, 16633 res->cmd_did); 16634 if (rc < 0) { 16635 printf("Invalid queueid = %d\n", res->cmd_qid); 16636 return; 16637 } 16638 if (rc == RTE_ETH_RX_DESC_AVAIL) 16639 printf("Desc status = AVAILABLE\n"); 16640 else if (rc == RTE_ETH_RX_DESC_DONE) 16641 printf("Desc status = DONE\n"); 16642 else 16643 printf("Desc status = UNAVAILABLE\n"); 16644 } else if (!strcmp(res->cmd_keyword, "txq")) { 16645 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid, 16646 res->cmd_did); 16647 if (rc < 0) { 16648 printf("Invalid queueid = %d\n", res->cmd_qid); 16649 return; 16650 } 16651 if (rc == RTE_ETH_TX_DESC_FULL) 16652 printf("Desc status = FULL\n"); 16653 else if (rc == RTE_ETH_TX_DESC_DONE) 16654 printf("Desc status = DONE\n"); 16655 else 16656 printf("Desc status = UNAVAILABLE\n"); 16657 } 16658 } 16659 16660 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show = 16661 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16662 cmd_show, "show"); 16663 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port = 16664 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16665 cmd_port, "port"); 16666 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid = 16667 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16668 cmd_pid, RTE_UINT16); 16669 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword = 16670 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16671 cmd_keyword, "rxq#txq"); 16672 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid = 16673 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16674 cmd_qid, RTE_UINT16); 16675 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc = 16676 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16677 cmd_desc, "desc"); 16678 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did = 16679 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16680 cmd_did, RTE_UINT16); 16681 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status = 16682 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16683 cmd_status, "status"); 16684 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = { 16685 .f = cmd_show_rx_tx_desc_status_parsed, 16686 .data = NULL, 16687 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> " 16688 "status", 16689 .tokens = { 16690 (void *)&cmd_show_rx_tx_desc_status_show, 16691 (void *)&cmd_show_rx_tx_desc_status_port, 16692 (void *)&cmd_show_rx_tx_desc_status_pid, 16693 (void *)&cmd_show_rx_tx_desc_status_keyword, 16694 (void *)&cmd_show_rx_tx_desc_status_qid, 16695 (void *)&cmd_show_rx_tx_desc_status_desc, 16696 (void *)&cmd_show_rx_tx_desc_status_did, 16697 (void *)&cmd_show_rx_tx_desc_status_status, 16698 NULL, 16699 }, 16700 }; 16701 16702 /* Common result structure for set port ptypes */ 16703 struct cmd_set_port_ptypes_result { 16704 cmdline_fixed_string_t set; 16705 cmdline_fixed_string_t port; 16706 portid_t port_id; 16707 cmdline_fixed_string_t ptype_mask; 16708 uint32_t mask; 16709 }; 16710 16711 /* Common CLI fields for set port ptypes */ 16712 cmdline_parse_token_string_t cmd_set_port_ptypes_set = 16713 TOKEN_STRING_INITIALIZER 16714 (struct cmd_set_port_ptypes_result, 16715 set, "set"); 16716 cmdline_parse_token_string_t cmd_set_port_ptypes_port = 16717 TOKEN_STRING_INITIALIZER 16718 (struct cmd_set_port_ptypes_result, 16719 port, "port"); 16720 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id = 16721 TOKEN_NUM_INITIALIZER 16722 (struct cmd_set_port_ptypes_result, 16723 port_id, RTE_UINT16); 16724 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str = 16725 TOKEN_STRING_INITIALIZER 16726 (struct cmd_set_port_ptypes_result, 16727 ptype_mask, "ptype_mask"); 16728 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 = 16729 TOKEN_NUM_INITIALIZER 16730 (struct cmd_set_port_ptypes_result, 16731 mask, RTE_UINT32); 16732 16733 static void 16734 cmd_set_port_ptypes_parsed( 16735 void *parsed_result, 16736 __rte_unused struct cmdline *cl, 16737 __rte_unused void *data) 16738 { 16739 struct cmd_set_port_ptypes_result *res = parsed_result; 16740 #define PTYPE_NAMESIZE 256 16741 char ptype_name[PTYPE_NAMESIZE]; 16742 uint16_t port_id = res->port_id; 16743 uint32_t ptype_mask = res->mask; 16744 int ret, i; 16745 16746 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK, 16747 NULL, 0); 16748 if (ret <= 0) { 16749 printf("Port %d doesn't support any ptypes.\n", port_id); 16750 return; 16751 } 16752 16753 uint32_t ptypes[ret]; 16754 16755 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); 16756 if (ret < 0) { 16757 printf("Unable to set requested ptypes for Port %d\n", port_id); 16758 return; 16759 } 16760 16761 printf("Successfully set following ptypes for Port %d\n", port_id); 16762 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) { 16763 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name)); 16764 printf("%s\n", ptype_name); 16765 } 16766 16767 clear_ptypes = false; 16768 } 16769 16770 cmdline_parse_inst_t cmd_set_port_ptypes = { 16771 .f = cmd_set_port_ptypes_parsed, 16772 .data = NULL, 16773 .help_str = "set port <port_id> ptype_mask <mask>", 16774 .tokens = { 16775 (void *)&cmd_set_port_ptypes_set, 16776 (void *)&cmd_set_port_ptypes_port, 16777 (void *)&cmd_set_port_ptypes_port_id, 16778 (void *)&cmd_set_port_ptypes_mask_str, 16779 (void *)&cmd_set_port_ptypes_mask_u32, 16780 NULL, 16781 }, 16782 }; 16783 16784 /* *** display mac addresses added to a port *** */ 16785 struct cmd_showport_macs_result { 16786 cmdline_fixed_string_t cmd_show; 16787 cmdline_fixed_string_t cmd_port; 16788 cmdline_fixed_string_t cmd_keyword; 16789 portid_t cmd_pid; 16790 }; 16791 16792 static void 16793 cmd_showport_macs_parsed(void *parsed_result, 16794 __rte_unused struct cmdline *cl, 16795 __rte_unused void *data) 16796 { 16797 struct cmd_showport_macs_result *res = parsed_result; 16798 16799 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN)) 16800 return; 16801 16802 if (!strcmp(res->cmd_keyword, "macs")) 16803 show_macs(res->cmd_pid); 16804 else if (!strcmp(res->cmd_keyword, "mcast_macs")) 16805 show_mcast_macs(res->cmd_pid); 16806 } 16807 16808 cmdline_parse_token_string_t cmd_showport_macs_show = 16809 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 16810 cmd_show, "show"); 16811 cmdline_parse_token_string_t cmd_showport_macs_port = 16812 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 16813 cmd_port, "port"); 16814 cmdline_parse_token_num_t cmd_showport_macs_pid = 16815 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result, 16816 cmd_pid, RTE_UINT16); 16817 cmdline_parse_token_string_t cmd_showport_macs_keyword = 16818 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 16819 cmd_keyword, "macs#mcast_macs"); 16820 16821 cmdline_parse_inst_t cmd_showport_macs = { 16822 .f = cmd_showport_macs_parsed, 16823 .data = NULL, 16824 .help_str = "show port <port_id> macs|mcast_macs", 16825 .tokens = { 16826 (void *)&cmd_showport_macs_show, 16827 (void *)&cmd_showport_macs_port, 16828 (void *)&cmd_showport_macs_pid, 16829 (void *)&cmd_showport_macs_keyword, 16830 NULL, 16831 }, 16832 }; 16833 16834 /* ******************************************************************************** */ 16835 16836 /* list of instructions */ 16837 cmdline_parse_ctx_t main_ctx[] = { 16838 (cmdline_parse_inst_t *)&cmd_help_brief, 16839 (cmdline_parse_inst_t *)&cmd_help_long, 16840 (cmdline_parse_inst_t *)&cmd_quit, 16841 (cmdline_parse_inst_t *)&cmd_load_from_file, 16842 (cmdline_parse_inst_t *)&cmd_showport, 16843 (cmdline_parse_inst_t *)&cmd_showqueue, 16844 (cmdline_parse_inst_t *)&cmd_showeeprom, 16845 (cmdline_parse_inst_t *)&cmd_showportall, 16846 (cmdline_parse_inst_t *)&cmd_showdevice, 16847 (cmdline_parse_inst_t *)&cmd_showcfg, 16848 (cmdline_parse_inst_t *)&cmd_showfwdall, 16849 (cmdline_parse_inst_t *)&cmd_start, 16850 (cmdline_parse_inst_t *)&cmd_start_tx_first, 16851 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 16852 (cmdline_parse_inst_t *)&cmd_set_link_up, 16853 (cmdline_parse_inst_t *)&cmd_set_link_down, 16854 (cmdline_parse_inst_t *)&cmd_reset, 16855 (cmdline_parse_inst_t *)&cmd_set_numbers, 16856 (cmdline_parse_inst_t *)&cmd_set_log, 16857 (cmdline_parse_inst_t *)&cmd_set_rxoffs, 16858 (cmdline_parse_inst_t *)&cmd_set_rxpkts, 16859 (cmdline_parse_inst_t *)&cmd_set_txpkts, 16860 (cmdline_parse_inst_t *)&cmd_set_txsplit, 16861 (cmdline_parse_inst_t *)&cmd_set_txtimes, 16862 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 16863 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 16864 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 16865 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 16866 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 16867 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 16868 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 16869 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 16870 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 16871 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 16872 (cmdline_parse_inst_t *)&cmd_set_link_check, 16873 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 16874 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 16875 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 16876 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 16877 #ifdef RTE_NET_BOND 16878 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 16879 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 16880 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 16881 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 16882 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 16883 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 16884 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 16885 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 16886 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 16887 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 16888 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 16889 #endif 16890 (cmdline_parse_inst_t *)&cmd_vlan_offload, 16891 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 16892 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 16893 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 16894 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 16895 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 16896 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 16897 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 16898 (cmdline_parse_inst_t *)&cmd_csum_set, 16899 (cmdline_parse_inst_t *)&cmd_csum_show, 16900 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 16901 (cmdline_parse_inst_t *)&cmd_tso_set, 16902 (cmdline_parse_inst_t *)&cmd_tso_show, 16903 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 16904 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 16905 (cmdline_parse_inst_t *)&cmd_gro_enable, 16906 (cmdline_parse_inst_t *)&cmd_gro_flush, 16907 (cmdline_parse_inst_t *)&cmd_gro_show, 16908 (cmdline_parse_inst_t *)&cmd_gso_enable, 16909 (cmdline_parse_inst_t *)&cmd_gso_size, 16910 (cmdline_parse_inst_t *)&cmd_gso_show, 16911 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 16912 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 16913 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 16914 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 16915 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 16916 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 16917 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 16918 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 16919 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 16920 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 16921 (cmdline_parse_inst_t *)&cmd_config_dcb, 16922 (cmdline_parse_inst_t *)&cmd_read_reg, 16923 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 16924 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 16925 (cmdline_parse_inst_t *)&cmd_write_reg, 16926 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 16927 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 16928 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 16929 (cmdline_parse_inst_t *)&cmd_stop, 16930 (cmdline_parse_inst_t *)&cmd_mac_addr, 16931 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 16932 (cmdline_parse_inst_t *)&cmd_set_qmap, 16933 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 16934 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles, 16935 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats, 16936 (cmdline_parse_inst_t *)&cmd_operate_port, 16937 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 16938 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 16939 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 16940 (cmdline_parse_inst_t *)&cmd_operate_detach_device, 16941 (cmdline_parse_inst_t *)&cmd_set_port_setup_on, 16942 (cmdline_parse_inst_t *)&cmd_config_speed_all, 16943 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 16944 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 16945 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 16946 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 16947 (cmdline_parse_inst_t *)&cmd_config_mtu, 16948 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 16949 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size, 16950 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 16951 (cmdline_parse_inst_t *)&cmd_config_rss, 16952 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 16953 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 16954 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 16955 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 16956 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 16957 (cmdline_parse_inst_t *)&cmd_showport_reta, 16958 (cmdline_parse_inst_t *)&cmd_showport_macs, 16959 (cmdline_parse_inst_t *)&cmd_config_burst, 16960 (cmdline_parse_inst_t *)&cmd_config_thresh, 16961 (cmdline_parse_inst_t *)&cmd_config_threshold, 16962 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 16963 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 16964 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 16965 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 16966 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 16967 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 16968 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 16969 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 16970 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 16971 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 16972 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 16973 (cmdline_parse_inst_t *)&cmd_dump, 16974 (cmdline_parse_inst_t *)&cmd_dump_one, 16975 #ifdef RTE_NET_I40E 16976 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 16977 #endif 16978 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 16979 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 16980 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 16981 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 16982 (cmdline_parse_inst_t *)&cmd_flow, 16983 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 16984 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 16985 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 16986 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 16987 (cmdline_parse_inst_t *)&cmd_create_port_meter, 16988 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 16989 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 16990 (cmdline_parse_inst_t *)&cmd_del_port_meter, 16991 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 16992 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 16993 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, 16994 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 16995 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 16996 (cmdline_parse_inst_t *)&cmd_mcast_addr, 16997 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 16998 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 16999 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 17000 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 17001 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 17002 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 17003 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 17004 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 17005 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 17006 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 17007 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 17008 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 17009 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 17010 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 17011 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 17012 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 17013 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 17014 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 17015 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 17016 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 17017 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 17018 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 17019 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 17020 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 17021 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 17022 (cmdline_parse_inst_t *)&cmd_set_vxlan, 17023 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl, 17024 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 17025 (cmdline_parse_inst_t *)&cmd_set_nvgre, 17026 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 17027 (cmdline_parse_inst_t *)&cmd_set_l2_encap, 17028 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, 17029 (cmdline_parse_inst_t *)&cmd_set_l2_decap, 17030 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, 17031 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, 17032 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, 17033 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, 17034 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, 17035 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, 17036 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, 17037 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, 17038 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, 17039 (cmdline_parse_inst_t *)&cmd_ddp_add, 17040 (cmdline_parse_inst_t *)&cmd_ddp_del, 17041 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 17042 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 17043 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 17044 (cmdline_parse_inst_t *)&cmd_clear_input_set, 17045 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 17046 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 17047 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes, 17048 (cmdline_parse_inst_t *)&cmd_set_port_ptypes, 17049 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 17050 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 17051 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 17052 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 17053 17054 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 17055 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 17056 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 17057 (cmdline_parse_inst_t *)&cmd_queue_region, 17058 (cmdline_parse_inst_t *)&cmd_region_flowtype, 17059 (cmdline_parse_inst_t *)&cmd_user_priority_region, 17060 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 17061 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 17062 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 17063 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 17064 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 17065 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 17066 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 17067 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 17068 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 17069 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 17070 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 17071 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 17072 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 17073 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 17074 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 17075 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode, 17076 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 17077 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 17078 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 17079 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 17080 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 17081 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 17082 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, 17083 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, 17084 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, 17085 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 17086 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 17087 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 17088 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 17089 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 17090 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 17091 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 17092 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 17093 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 17094 #ifdef RTE_LIB_BPF 17095 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 17096 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 17097 #endif 17098 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, 17099 (cmdline_parse_inst_t *)&cmd_show_tx_metadata, 17100 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status, 17101 (cmdline_parse_inst_t *)&cmd_set_raw, 17102 (cmdline_parse_inst_t *)&cmd_show_set_raw, 17103 (cmdline_parse_inst_t *)&cmd_show_set_raw_all, 17104 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific, 17105 (cmdline_parse_inst_t *)&cmd_show_fec_mode, 17106 (cmdline_parse_inst_t *)&cmd_set_fec_mode, 17107 (cmdline_parse_inst_t *)&cmd_show_capability, 17108 NULL, 17109 }; 17110 17111 /* read cmdline commands from file */ 17112 void 17113 cmdline_read_from_file(const char *filename) 17114 { 17115 struct cmdline *cl; 17116 17117 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 17118 if (cl == NULL) { 17119 printf("Failed to create file based cmdline context: %s\n", 17120 filename); 17121 return; 17122 } 17123 17124 cmdline_interact(cl); 17125 cmdline_quit(cl); 17126 17127 cmdline_free(cl); 17128 17129 printf("Read CLI commands from %s\n", filename); 17130 } 17131 17132 /* prompt function, called from main on MAIN lcore */ 17133 void 17134 prompt(void) 17135 { 17136 int ret; 17137 /* initialize non-constant commands */ 17138 cmd_set_fwd_mode_init(); 17139 cmd_set_fwd_retry_mode_init(); 17140 17141 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 17142 if (testpmd_cl == NULL) 17143 return; 17144 17145 ret = atexit(prompt_exit); 17146 if (ret != 0) 17147 printf("Cannot set exit function for cmdline\n"); 17148 17149 cmdline_interact(testpmd_cl); 17150 if (ret != 0) 17151 cmdline_stdin_exit(testpmd_cl); 17152 } 17153 17154 void 17155 prompt_exit(void) 17156 { 17157 if (testpmd_cl != NULL) { 17158 cmdline_quit(testpmd_cl); 17159 cmdline_stdin_exit(testpmd_cl); 17160 } 17161 } 17162 17163 static void 17164 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 17165 { 17166 if (id == (portid_t)RTE_PORT_ALL) { 17167 portid_t pid; 17168 17169 RTE_ETH_FOREACH_DEV(pid) { 17170 /* check if need_reconfig has been set to 1 */ 17171 if (ports[pid].need_reconfig == 0) 17172 ports[pid].need_reconfig = dev; 17173 /* check if need_reconfig_queues has been set to 1 */ 17174 if (ports[pid].need_reconfig_queues == 0) 17175 ports[pid].need_reconfig_queues = queue; 17176 } 17177 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 17178 /* check if need_reconfig has been set to 1 */ 17179 if (ports[id].need_reconfig == 0) 17180 ports[id].need_reconfig = dev; 17181 /* check if need_reconfig_queues has been set to 1 */ 17182 if (ports[id].need_reconfig_queues == 0) 17183 ports[id].need_reconfig_queues = queue; 17184 } 17185 } 17186